diff --git a/c-api/allocation.po b/c-api/allocation.po index 28435d6916..e8713614a1 100644 --- a/c-api/allocation.po +++ b/c-api/allocation.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-18 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -112,8 +112,8 @@ msgstr "" "取,該巨集的拿到指向該物件的指標。" #: ../../c-api/allocation.rst:79 -msgid ":c:func:`PyModule_Create`" -msgstr ":c:func:`PyModule_Create`" +msgid ":ref:`moduleobjects`" +msgstr ":ref:`moduleobjects`" #: ../../c-api/allocation.rst:80 msgid "To allocate and create extension modules." diff --git a/c-api/code.po b/c-api/code.po index 19d27d2885..3ce283f533 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-10-09 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -213,7 +213,7 @@ msgstr "" #: ../../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 " +"*co* has been fully initialized. Otherwise, the callback is invoked before " "the destruction of *co* takes place, so the prior state of *co* can be " "inspected." msgstr "" diff --git a/c-api/exceptions.po b/c-api/exceptions.po index a2e93cc598..177603071c 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-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -799,24 +799,34 @@ msgid "" "as the docstring for the exception class." msgstr "" -#: ../../c-api/exceptions.rst:753 +#: ../../c-api/exceptions.rst:754 +msgid "" +"Return non-zero if *ob* is an exception class, zero otherwise. This function " +"always succeeds." +msgstr "" + +#: ../../c-api/exceptions.rst:759 +msgid "Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*." +msgstr "" + +#: ../../c-api/exceptions.rst:763 msgid "Exception Objects" msgstr "例外物件" -#: ../../c-api/exceptions.rst:757 +#: ../../c-api/exceptions.rst:767 msgid "" "Return the traceback associated with the exception as a new reference, as " "accessible from Python through the :attr:`~BaseException.__traceback__` " "attribute. If there is no traceback associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:765 +#: ../../c-api/exceptions.rst:775 msgid "" "Set the traceback associated with the exception to *tb*. Use ``Py_None`` to " "clear it." msgstr "" -#: ../../c-api/exceptions.rst:771 +#: ../../c-api/exceptions.rst:781 msgid "" "Return the context (another exception instance during whose handling *ex* " "was raised) associated with the exception as a new reference, as accessible " @@ -824,14 +834,14 @@ msgid "" "there is no context associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:779 +#: ../../c-api/exceptions.rst:789 msgid "" "Set the context associated with the exception to *ctx*. Use ``NULL`` to " "clear it. There is no type check to make sure that *ctx* is an exception " "instance. This steals a reference to *ctx*." msgstr "" -#: ../../c-api/exceptions.rst:786 +#: ../../c-api/exceptions.rst:796 msgid "" "Return the cause (either an exception instance, or ``None``, set by " "``raise ... from ...``) associated with the exception as a new reference, as " @@ -839,28 +849,28 @@ msgid "" "attribute." msgstr "" -#: ../../c-api/exceptions.rst:794 +#: ../../c-api/exceptions.rst:804 msgid "" "Set the cause associated with the exception to *cause*. Use ``NULL`` to " "clear it. There is no type check to make sure that *cause* is either an " "exception instance or ``None``. This steals a reference to *cause*." msgstr "" -#: ../../c-api/exceptions.rst:798 +#: ../../c-api/exceptions.rst:808 msgid "" "The :attr:`~BaseException.__suppress_context__` attribute is implicitly set " "to ``True`` by this function." msgstr "" -#: ../../c-api/exceptions.rst:804 +#: ../../c-api/exceptions.rst:814 msgid "Return :attr:`~BaseException.args` of exception *ex*." msgstr "" -#: ../../c-api/exceptions.rst:809 +#: ../../c-api/exceptions.rst:819 msgid "Set :attr:`~BaseException.args` of exception *ex* to *args*." msgstr "" -#: ../../c-api/exceptions.rst:813 +#: ../../c-api/exceptions.rst:823 msgid "" "Implement part of the interpreter's implementation of :keyword:`!except*`. " "*orig* is the original exception that was caught, and *excs* is the list of " @@ -872,72 +882,72 @@ msgid "" "if there is nothing to reraise." msgstr "" -#: ../../c-api/exceptions.rst:827 +#: ../../c-api/exceptions.rst:837 msgid "Unicode Exception Objects" msgstr "" -#: ../../c-api/exceptions.rst:829 +#: ../../c-api/exceptions.rst:839 msgid "" "The following functions are used to create and modify Unicode exceptions " "from C." msgstr "" -#: ../../c-api/exceptions.rst:833 +#: ../../c-api/exceptions.rst:843 msgid "" "Create a :class:`UnicodeDecodeError` object with the attributes *encoding*, " "*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are " "UTF-8 encoded strings." msgstr "" -#: ../../c-api/exceptions.rst:840 +#: ../../c-api/exceptions.rst:850 msgid "Return the *encoding* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:846 +#: ../../c-api/exceptions.rst:856 msgid "Return the *object* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:852 +#: ../../c-api/exceptions.rst:862 msgid "" "Get the *start* attribute of the given exception object and place it into " "*\\*start*. *start* must not be ``NULL``. Return ``0`` on success, ``-1`` " "on failure." msgstr "" -#: ../../c-api/exceptions.rst:860 +#: ../../c-api/exceptions.rst:870 msgid "" "Set the *start* attribute of the given exception object to *start*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:867 +#: ../../c-api/exceptions.rst:877 msgid "" "Get the *end* attribute of the given exception object and place it into " "*\\*end*. *end* must not be ``NULL``. Return ``0`` on success, ``-1`` on " "failure." msgstr "" -#: ../../c-api/exceptions.rst:875 +#: ../../c-api/exceptions.rst:885 msgid "" "Set the *end* attribute of the given exception object to *end*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:882 +#: ../../c-api/exceptions.rst:892 msgid "Return the *reason* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:888 +#: ../../c-api/exceptions.rst:898 msgid "" "Set the *reason* attribute of the given exception object to *reason*. " "Return ``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:895 +#: ../../c-api/exceptions.rst:905 msgid "Recursion Control" msgstr "" -#: ../../c-api/exceptions.rst:897 +#: ../../c-api/exceptions.rst:907 msgid "" "These two functions provide a way to perform safe recursive calls at the C " "level, both in the core and in extension modules. They are needed if the " @@ -947,44 +957,44 @@ msgid "" "recursion handling." msgstr "" -#: ../../c-api/exceptions.rst:906 +#: ../../c-api/exceptions.rst:916 msgid "Marks a point where a recursive C-level call is about to be performed." msgstr "" -#: ../../c-api/exceptions.rst:908 +#: ../../c-api/exceptions.rst:918 msgid "" "If :c:macro:`!USE_STACKCHECK` is defined, this function checks if the OS " "stack overflowed using :c:func:`PyOS_CheckStack`. If this is the case, it " "sets a :exc:`MemoryError` and returns a nonzero value." msgstr "" -#: ../../c-api/exceptions.rst:912 +#: ../../c-api/exceptions.rst:922 msgid "" "The function then checks if the recursion limit is reached. If this is the " "case, a :exc:`RecursionError` is set and a nonzero value is returned. " "Otherwise, zero is returned." msgstr "" -#: ../../c-api/exceptions.rst:916 +#: ../../c-api/exceptions.rst:926 msgid "" "*where* should be a UTF-8 encoded string such as ``\" in instance check\"`` " "to be concatenated to the :exc:`RecursionError` message caused by the " "recursion depth limit." msgstr "" -#: ../../c-api/exceptions.rst:920 ../../c-api/exceptions.rst:928 +#: ../../c-api/exceptions.rst:930 ../../c-api/exceptions.rst:938 msgid "" "This function is now also available in the :ref:`limited API `." msgstr "" -#: ../../c-api/exceptions.rst:925 +#: ../../c-api/exceptions.rst:935 msgid "" "Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each " "*successful* invocation of :c:func:`Py_EnterRecursiveCall`." msgstr "" -#: ../../c-api/exceptions.rst:931 +#: ../../c-api/exceptions.rst:941 msgid "" "Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types " "requires special recursion handling. In addition to protecting the stack, :" @@ -993,13 +1003,13 @@ msgid "" "Effectively, these are the C equivalent to :func:`reprlib.recursive_repr`." msgstr "" -#: ../../c-api/exceptions.rst:939 +#: ../../c-api/exceptions.rst:949 msgid "" "Called at the beginning of the :c:member:`~PyTypeObject.tp_repr` " "implementation to detect cycles." msgstr "" -#: ../../c-api/exceptions.rst:942 +#: ../../c-api/exceptions.rst:952 msgid "" "If the object has already been processed, the function returns a positive " "integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " @@ -1007,30 +1017,30 @@ msgid "" "`dict` objects return ``{...}`` and :class:`list` objects return ``[...]``." msgstr "" -#: ../../c-api/exceptions.rst:948 +#: ../../c-api/exceptions.rst:958 msgid "" "The function will return a negative integer if the recursion limit is " "reached. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " "should typically return ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:952 +#: ../../c-api/exceptions.rst:962 msgid "" "Otherwise, the function returns zero and the :c:member:`~PyTypeObject." "tp_repr` implementation can continue normally." msgstr "" -#: ../../c-api/exceptions.rst:957 +#: ../../c-api/exceptions.rst:967 msgid "" "Ends a :c:func:`Py_ReprEnter`. Must be called once for each invocation of :" "c:func:`Py_ReprEnter` that returns zero." msgstr "" -#: ../../c-api/exceptions.rst:964 +#: ../../c-api/exceptions.rst:974 msgid "Standard Exceptions" msgstr "" -#: ../../c-api/exceptions.rst:966 +#: ../../c-api/exceptions.rst:976 msgid "" "All standard Python exceptions are available as global variables whose names " "are ``PyExc_`` followed by the Python exception name. These have the type :" @@ -1038,459 +1048,467 @@ msgid "" "all the variables:" msgstr "" -#: ../../c-api/exceptions.rst:1028 ../../c-api/exceptions.rst:1163 -#: ../../c-api/exceptions.rst:1208 +#: ../../c-api/exceptions.rst:1039 ../../c-api/exceptions.rst:1179 +#: ../../c-api/exceptions.rst:1225 msgid "C Name" msgstr "C 名稱" -#: ../../c-api/exceptions.rst:1028 ../../c-api/exceptions.rst:1208 +#: ../../c-api/exceptions.rst:1039 ../../c-api/exceptions.rst:1225 msgid "Python Name" msgstr "Python 名稱" -#: ../../c-api/exceptions.rst:1028 ../../c-api/exceptions.rst:1163 -#: ../../c-api/exceptions.rst:1208 +#: ../../c-api/exceptions.rst:1039 ../../c-api/exceptions.rst:1179 +#: ../../c-api/exceptions.rst:1225 msgid "Notes" msgstr "註解" -#: ../../c-api/exceptions.rst:1030 +#: ../../c-api/exceptions.rst:1041 msgid ":c:data:`PyExc_BaseException`" msgstr ":c:data:`PyExc_BaseException`" -#: ../../c-api/exceptions.rst:1030 +#: ../../c-api/exceptions.rst:1041 msgid ":exc:`BaseException`" msgstr ":exc:`BaseException`" -#: ../../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 +#: ../../c-api/exceptions.rst:1041 ../../c-api/exceptions.rst:1043 +#: ../../c-api/exceptions.rst:1045 ../../c-api/exceptions.rst:1047 +#: ../../c-api/exceptions.rst:1093 ../../c-api/exceptions.rst:1105 msgid "[1]_" msgstr "[1]_" -#: ../../c-api/exceptions.rst:1032 +#: ../../c-api/exceptions.rst:1043 +msgid ":c:data:`PyExc_BaseExceptionGroup`" +msgstr ":c:data:`PyExc_BaseExceptionGroup`" + +#: ../../c-api/exceptions.rst:1043 +msgid ":exc:`BaseExceptionGroup`" +msgstr ":exc:`BaseExceptionGroup`" + +#: ../../c-api/exceptions.rst:1045 msgid ":c:data:`PyExc_Exception`" msgstr ":c:data:`PyExc_Exception`" -#: ../../c-api/exceptions.rst:1032 +#: ../../c-api/exceptions.rst:1045 msgid ":exc:`Exception`" msgstr ":exc:`Exception`" -#: ../../c-api/exceptions.rst:1034 +#: ../../c-api/exceptions.rst:1047 msgid ":c:data:`PyExc_ArithmeticError`" msgstr ":c:data:`PyExc_ArithmeticError`" -#: ../../c-api/exceptions.rst:1034 +#: ../../c-api/exceptions.rst:1047 msgid ":exc:`ArithmeticError`" msgstr ":exc:`ArithmeticError`" -#: ../../c-api/exceptions.rst:1036 +#: ../../c-api/exceptions.rst:1049 msgid ":c:data:`PyExc_AssertionError`" msgstr ":c:data:`PyExc_AssertionError`" -#: ../../c-api/exceptions.rst:1036 +#: ../../c-api/exceptions.rst:1049 msgid ":exc:`AssertionError`" msgstr ":exc:`AssertionError`" -#: ../../c-api/exceptions.rst:1038 +#: ../../c-api/exceptions.rst:1051 msgid ":c:data:`PyExc_AttributeError`" msgstr ":c:data:`PyExc_AttributeError`" -#: ../../c-api/exceptions.rst:1038 +#: ../../c-api/exceptions.rst:1051 msgid ":exc:`AttributeError`" msgstr ":exc:`AttributeError`" -#: ../../c-api/exceptions.rst:1040 +#: ../../c-api/exceptions.rst:1053 msgid ":c:data:`PyExc_BlockingIOError`" msgstr ":c:data:`PyExc_BlockingIOError`" -#: ../../c-api/exceptions.rst:1040 +#: ../../c-api/exceptions.rst:1053 msgid ":exc:`BlockingIOError`" msgstr ":exc:`BlockingIOError`" -#: ../../c-api/exceptions.rst:1042 +#: ../../c-api/exceptions.rst:1055 msgid ":c:data:`PyExc_BrokenPipeError`" msgstr ":c:data:`PyExc_BrokenPipeError`" -#: ../../c-api/exceptions.rst:1042 +#: ../../c-api/exceptions.rst:1055 msgid ":exc:`BrokenPipeError`" msgstr ":exc:`BrokenPipeError`" -#: ../../c-api/exceptions.rst:1044 +#: ../../c-api/exceptions.rst:1057 msgid ":c:data:`PyExc_BufferError`" msgstr ":c:data:`PyExc_BufferError`" -#: ../../c-api/exceptions.rst:1044 +#: ../../c-api/exceptions.rst:1057 msgid ":exc:`BufferError`" msgstr ":exc:`BufferError`" -#: ../../c-api/exceptions.rst:1046 +#: ../../c-api/exceptions.rst:1059 msgid ":c:data:`PyExc_ChildProcessError`" msgstr ":c:data:`PyExc_ChildProcessError`" -#: ../../c-api/exceptions.rst:1046 +#: ../../c-api/exceptions.rst:1059 msgid ":exc:`ChildProcessError`" msgstr ":exc:`ChildProcessError`" -#: ../../c-api/exceptions.rst:1048 +#: ../../c-api/exceptions.rst:1061 msgid ":c:data:`PyExc_ConnectionAbortedError`" msgstr ":c:data:`PyExc_ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1048 +#: ../../c-api/exceptions.rst:1061 msgid ":exc:`ConnectionAbortedError`" msgstr ":exc:`ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1050 +#: ../../c-api/exceptions.rst:1063 msgid ":c:data:`PyExc_ConnectionError`" msgstr ":c:data:`PyExc_ConnectionError`" -#: ../../c-api/exceptions.rst:1050 +#: ../../c-api/exceptions.rst:1063 msgid ":exc:`ConnectionError`" msgstr ":exc:`ConnectionError`" -#: ../../c-api/exceptions.rst:1052 +#: ../../c-api/exceptions.rst:1065 msgid ":c:data:`PyExc_ConnectionRefusedError`" msgstr ":c:data:`PyExc_ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1052 +#: ../../c-api/exceptions.rst:1065 msgid ":exc:`ConnectionRefusedError`" msgstr ":exc:`ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1054 +#: ../../c-api/exceptions.rst:1067 msgid ":c:data:`PyExc_ConnectionResetError`" msgstr ":c:data:`PyExc_ConnectionResetError`" -#: ../../c-api/exceptions.rst:1054 +#: ../../c-api/exceptions.rst:1067 msgid ":exc:`ConnectionResetError`" msgstr ":exc:`ConnectionResetError`" -#: ../../c-api/exceptions.rst:1056 +#: ../../c-api/exceptions.rst:1069 msgid ":c:data:`PyExc_EOFError`" msgstr ":c:data:`PyExc_EOFError`" -#: ../../c-api/exceptions.rst:1056 +#: ../../c-api/exceptions.rst:1069 msgid ":exc:`EOFError`" msgstr ":exc:`EOFError`" -#: ../../c-api/exceptions.rst:1058 +#: ../../c-api/exceptions.rst:1071 msgid ":c:data:`PyExc_FileExistsError`" msgstr ":c:data:`PyExc_FileExistsError`" -#: ../../c-api/exceptions.rst:1058 +#: ../../c-api/exceptions.rst:1071 msgid ":exc:`FileExistsError`" msgstr ":exc:`FileExistsError`" -#: ../../c-api/exceptions.rst:1060 +#: ../../c-api/exceptions.rst:1073 msgid ":c:data:`PyExc_FileNotFoundError`" msgstr ":c:data:`PyExc_FileNotFoundError`" -#: ../../c-api/exceptions.rst:1060 +#: ../../c-api/exceptions.rst:1073 msgid ":exc:`FileNotFoundError`" msgstr ":exc:`FileNotFoundError`" -#: ../../c-api/exceptions.rst:1062 +#: ../../c-api/exceptions.rst:1075 msgid ":c:data:`PyExc_FloatingPointError`" msgstr ":c:data:`PyExc_FloatingPointError`" -#: ../../c-api/exceptions.rst:1062 +#: ../../c-api/exceptions.rst:1075 msgid ":exc:`FloatingPointError`" msgstr ":exc:`FloatingPointError`" -#: ../../c-api/exceptions.rst:1064 +#: ../../c-api/exceptions.rst:1077 msgid ":c:data:`PyExc_GeneratorExit`" msgstr ":c:data:`PyExc_GeneratorExit`" -#: ../../c-api/exceptions.rst:1064 +#: ../../c-api/exceptions.rst:1077 msgid ":exc:`GeneratorExit`" msgstr ":exc:`GeneratorExit`" -#: ../../c-api/exceptions.rst:1066 +#: ../../c-api/exceptions.rst:1079 msgid ":c:data:`PyExc_ImportError`" msgstr ":c:data:`PyExc_ImportError`" -#: ../../c-api/exceptions.rst:1066 +#: ../../c-api/exceptions.rst:1079 msgid ":exc:`ImportError`" msgstr ":exc:`ImportError`" -#: ../../c-api/exceptions.rst:1068 +#: ../../c-api/exceptions.rst:1081 msgid ":c:data:`PyExc_IndentationError`" msgstr ":c:data:`PyExc_IndentationError`" -#: ../../c-api/exceptions.rst:1068 +#: ../../c-api/exceptions.rst:1081 msgid ":exc:`IndentationError`" msgstr ":exc:`IndentationError`" -#: ../../c-api/exceptions.rst:1070 +#: ../../c-api/exceptions.rst:1083 msgid ":c:data:`PyExc_IndexError`" msgstr ":c:data:`PyExc_IndexError`" -#: ../../c-api/exceptions.rst:1070 +#: ../../c-api/exceptions.rst:1083 msgid ":exc:`IndexError`" msgstr ":exc:`IndexError`" -#: ../../c-api/exceptions.rst:1072 +#: ../../c-api/exceptions.rst:1085 msgid ":c:data:`PyExc_InterruptedError`" msgstr ":c:data:`PyExc_InterruptedError`" -#: ../../c-api/exceptions.rst:1072 +#: ../../c-api/exceptions.rst:1085 msgid ":exc:`InterruptedError`" msgstr ":exc:`InterruptedError`" -#: ../../c-api/exceptions.rst:1074 +#: ../../c-api/exceptions.rst:1087 msgid ":c:data:`PyExc_IsADirectoryError`" msgstr ":c:data:`PyExc_IsADirectoryError`" -#: ../../c-api/exceptions.rst:1074 +#: ../../c-api/exceptions.rst:1087 msgid ":exc:`IsADirectoryError`" msgstr ":exc:`IsADirectoryError`" -#: ../../c-api/exceptions.rst:1076 +#: ../../c-api/exceptions.rst:1089 msgid ":c:data:`PyExc_KeyError`" msgstr ":c:data:`PyExc_KeyError`" -#: ../../c-api/exceptions.rst:1076 +#: ../../c-api/exceptions.rst:1089 msgid ":exc:`KeyError`" msgstr ":exc:`KeyError`" -#: ../../c-api/exceptions.rst:1078 +#: ../../c-api/exceptions.rst:1091 msgid ":c:data:`PyExc_KeyboardInterrupt`" msgstr ":c:data:`PyExc_KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1078 +#: ../../c-api/exceptions.rst:1091 msgid ":exc:`KeyboardInterrupt`" msgstr ":exc:`KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1080 +#: ../../c-api/exceptions.rst:1093 msgid ":c:data:`PyExc_LookupError`" msgstr ":c:data:`PyExc_LookupError`" -#: ../../c-api/exceptions.rst:1080 +#: ../../c-api/exceptions.rst:1093 msgid ":exc:`LookupError`" msgstr ":exc:`LookupError`" -#: ../../c-api/exceptions.rst:1082 +#: ../../c-api/exceptions.rst:1095 msgid ":c:data:`PyExc_MemoryError`" msgstr ":c:data:`PyExc_MemoryError`" -#: ../../c-api/exceptions.rst:1082 +#: ../../c-api/exceptions.rst:1095 msgid ":exc:`MemoryError`" msgstr ":exc:`MemoryError`" -#: ../../c-api/exceptions.rst:1084 +#: ../../c-api/exceptions.rst:1097 msgid ":c:data:`PyExc_ModuleNotFoundError`" msgstr ":c:data:`PyExc_ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1084 +#: ../../c-api/exceptions.rst:1097 msgid ":exc:`ModuleNotFoundError`" msgstr ":exc:`ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1086 +#: ../../c-api/exceptions.rst:1099 msgid ":c:data:`PyExc_NameError`" msgstr ":c:data:`PyExc_NameError`" -#: ../../c-api/exceptions.rst:1086 +#: ../../c-api/exceptions.rst:1099 msgid ":exc:`NameError`" msgstr ":exc:`NameError`" -#: ../../c-api/exceptions.rst:1088 +#: ../../c-api/exceptions.rst:1101 msgid ":c:data:`PyExc_NotADirectoryError`" msgstr ":c:data:`PyExc_NotADirectoryError`" -#: ../../c-api/exceptions.rst:1088 +#: ../../c-api/exceptions.rst:1101 msgid ":exc:`NotADirectoryError`" msgstr ":exc:`NotADirectoryError`" -#: ../../c-api/exceptions.rst:1090 +#: ../../c-api/exceptions.rst:1103 msgid ":c:data:`PyExc_NotImplementedError`" msgstr ":c:data:`PyExc_NotImplementedError`" -#: ../../c-api/exceptions.rst:1090 +#: ../../c-api/exceptions.rst:1103 msgid ":exc:`NotImplementedError`" msgstr ":exc:`NotImplementedError`" -#: ../../c-api/exceptions.rst:1092 +#: ../../c-api/exceptions.rst:1105 msgid ":c:data:`PyExc_OSError`" msgstr ":c:data:`PyExc_OSError`" -#: ../../c-api/exceptions.rst:1092 +#: ../../c-api/exceptions.rst:1105 msgid ":exc:`OSError`" msgstr ":exc:`OSError`" -#: ../../c-api/exceptions.rst:1094 +#: ../../c-api/exceptions.rst:1107 msgid ":c:data:`PyExc_OverflowError`" msgstr ":c:data:`PyExc_OverflowError`" -#: ../../c-api/exceptions.rst:1094 +#: ../../c-api/exceptions.rst:1107 msgid ":exc:`OverflowError`" msgstr ":exc:`OverflowError`" -#: ../../c-api/exceptions.rst:1096 +#: ../../c-api/exceptions.rst:1109 msgid ":c:data:`PyExc_PermissionError`" msgstr ":c:data:`PyExc_PermissionError`" -#: ../../c-api/exceptions.rst:1096 +#: ../../c-api/exceptions.rst:1109 msgid ":exc:`PermissionError`" msgstr ":exc:`PermissionError`" -#: ../../c-api/exceptions.rst:1098 +#: ../../c-api/exceptions.rst:1111 msgid ":c:data:`PyExc_ProcessLookupError`" msgstr ":c:data:`PyExc_ProcessLookupError`" -#: ../../c-api/exceptions.rst:1098 +#: ../../c-api/exceptions.rst:1111 msgid ":exc:`ProcessLookupError`" msgstr ":exc:`ProcessLookupError`" -#: ../../c-api/exceptions.rst:1100 +#: ../../c-api/exceptions.rst:1113 msgid ":c:data:`PyExc_PythonFinalizationError`" msgstr ":c:data:`PyExc_PythonFinalizationError`" -#: ../../c-api/exceptions.rst:1100 +#: ../../c-api/exceptions.rst:1113 msgid ":exc:`PythonFinalizationError`" msgstr ":exc:`PythonFinalizationError`" -#: ../../c-api/exceptions.rst:1102 +#: ../../c-api/exceptions.rst:1115 msgid ":c:data:`PyExc_RecursionError`" msgstr ":c:data:`PyExc_RecursionError`" -#: ../../c-api/exceptions.rst:1102 +#: ../../c-api/exceptions.rst:1115 msgid ":exc:`RecursionError`" msgstr ":exc:`RecursionError`" -#: ../../c-api/exceptions.rst:1104 +#: ../../c-api/exceptions.rst:1117 msgid ":c:data:`PyExc_ReferenceError`" msgstr ":c:data:`PyExc_ReferenceError`" -#: ../../c-api/exceptions.rst:1104 +#: ../../c-api/exceptions.rst:1117 msgid ":exc:`ReferenceError`" msgstr ":exc:`ReferenceError`" -#: ../../c-api/exceptions.rst:1106 +#: ../../c-api/exceptions.rst:1119 msgid ":c:data:`PyExc_RuntimeError`" msgstr ":c:data:`PyExc_RuntimeError`" -#: ../../c-api/exceptions.rst:1106 +#: ../../c-api/exceptions.rst:1119 msgid ":exc:`RuntimeError`" msgstr ":exc:`RuntimeError`" -#: ../../c-api/exceptions.rst:1108 +#: ../../c-api/exceptions.rst:1121 msgid ":c:data:`PyExc_StopAsyncIteration`" msgstr ":c:data:`PyExc_StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1108 +#: ../../c-api/exceptions.rst:1121 msgid ":exc:`StopAsyncIteration`" msgstr ":exc:`StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1110 +#: ../../c-api/exceptions.rst:1123 msgid ":c:data:`PyExc_StopIteration`" msgstr ":c:data:`PyExc_StopIteration`" -#: ../../c-api/exceptions.rst:1110 +#: ../../c-api/exceptions.rst:1123 msgid ":exc:`StopIteration`" msgstr ":exc:`StopIteration`" -#: ../../c-api/exceptions.rst:1112 +#: ../../c-api/exceptions.rst:1125 msgid ":c:data:`PyExc_SyntaxError`" msgstr ":c:data:`PyExc_SyntaxError`" -#: ../../c-api/exceptions.rst:1112 +#: ../../c-api/exceptions.rst:1125 msgid ":exc:`SyntaxError`" msgstr ":exc:`SyntaxError`" -#: ../../c-api/exceptions.rst:1114 +#: ../../c-api/exceptions.rst:1127 msgid ":c:data:`PyExc_SystemError`" msgstr ":c:data:`PyExc_SystemError`" -#: ../../c-api/exceptions.rst:1114 +#: ../../c-api/exceptions.rst:1127 msgid ":exc:`SystemError`" msgstr ":exc:`SystemError`" -#: ../../c-api/exceptions.rst:1116 +#: ../../c-api/exceptions.rst:1129 msgid ":c:data:`PyExc_SystemExit`" msgstr ":c:data:`PyExc_SystemExit`" -#: ../../c-api/exceptions.rst:1116 +#: ../../c-api/exceptions.rst:1129 msgid ":exc:`SystemExit`" msgstr ":exc:`SystemExit`" -#: ../../c-api/exceptions.rst:1118 +#: ../../c-api/exceptions.rst:1131 msgid ":c:data:`PyExc_TabError`" msgstr ":c:data:`PyExc_TabError`" -#: ../../c-api/exceptions.rst:1118 +#: ../../c-api/exceptions.rst:1131 msgid ":exc:`TabError`" msgstr ":exc:`TabError`" -#: ../../c-api/exceptions.rst:1120 +#: ../../c-api/exceptions.rst:1133 msgid ":c:data:`PyExc_TimeoutError`" msgstr ":c:data:`PyExc_TimeoutError`" -#: ../../c-api/exceptions.rst:1120 +#: ../../c-api/exceptions.rst:1133 msgid ":exc:`TimeoutError`" msgstr ":exc:`TimeoutError`" -#: ../../c-api/exceptions.rst:1122 +#: ../../c-api/exceptions.rst:1135 msgid ":c:data:`PyExc_TypeError`" msgstr ":c:data:`PyExc_TypeError`" -#: ../../c-api/exceptions.rst:1122 +#: ../../c-api/exceptions.rst:1135 msgid ":exc:`TypeError`" msgstr ":exc:`TypeError`" -#: ../../c-api/exceptions.rst:1124 +#: ../../c-api/exceptions.rst:1137 msgid ":c:data:`PyExc_UnboundLocalError`" msgstr ":c:data:`PyExc_UnboundLocalError`" -#: ../../c-api/exceptions.rst:1124 +#: ../../c-api/exceptions.rst:1137 msgid ":exc:`UnboundLocalError`" msgstr ":exc:`UnboundLocalError`" -#: ../../c-api/exceptions.rst:1126 +#: ../../c-api/exceptions.rst:1139 msgid ":c:data:`PyExc_UnicodeDecodeError`" msgstr ":c:data:`PyExc_UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1126 +#: ../../c-api/exceptions.rst:1139 msgid ":exc:`UnicodeDecodeError`" msgstr ":exc:`UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1128 +#: ../../c-api/exceptions.rst:1141 msgid ":c:data:`PyExc_UnicodeEncodeError`" msgstr ":c:data:`PyExc_UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1128 +#: ../../c-api/exceptions.rst:1141 msgid ":exc:`UnicodeEncodeError`" msgstr ":exc:`UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1130 +#: ../../c-api/exceptions.rst:1143 msgid ":c:data:`PyExc_UnicodeError`" msgstr ":c:data:`PyExc_UnicodeError`" -#: ../../c-api/exceptions.rst:1130 +#: ../../c-api/exceptions.rst:1143 msgid ":exc:`UnicodeError`" msgstr ":exc:`UnicodeError`" -#: ../../c-api/exceptions.rst:1132 +#: ../../c-api/exceptions.rst:1145 msgid ":c:data:`PyExc_UnicodeTranslateError`" msgstr ":c:data:`PyExc_UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1132 +#: ../../c-api/exceptions.rst:1145 msgid ":exc:`UnicodeTranslateError`" msgstr ":exc:`UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1134 +#: ../../c-api/exceptions.rst:1147 msgid ":c:data:`PyExc_ValueError`" msgstr ":c:data:`PyExc_ValueError`" -#: ../../c-api/exceptions.rst:1134 +#: ../../c-api/exceptions.rst:1147 msgid ":exc:`ValueError`" msgstr ":exc:`ValueError`" -#: ../../c-api/exceptions.rst:1136 +#: ../../c-api/exceptions.rst:1149 msgid ":c:data:`PyExc_ZeroDivisionError`" msgstr ":c:data:`PyExc_ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1136 +#: ../../c-api/exceptions.rst:1149 msgid ":exc:`ZeroDivisionError`" msgstr ":exc:`ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1139 +#: ../../c-api/exceptions.rst:1152 msgid "" ":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:" "`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:" @@ -1510,57 +1528,61 @@ msgstr "" "`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` 和 :c:data:" "`PyExc_TimeoutError` 是在 :pep:`3151` 被引入。" -#: ../../c-api/exceptions.rst:1149 +#: ../../c-api/exceptions.rst:1162 msgid ":c:data:`PyExc_StopAsyncIteration` and :c:data:`PyExc_RecursionError`." msgstr ":c:data:`PyExc_StopAsyncIteration` 和 :c:data:`PyExc_RecursionError`。" -#: ../../c-api/exceptions.rst:1152 +#: ../../c-api/exceptions.rst:1165 msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr ":c:data:`PyExc_ModuleNotFoundError`。" -#: ../../c-api/exceptions.rst:1155 +#: ../../c-api/exceptions.rst:1168 +msgid ":c:data:`PyExc_BaseExceptionGroup`." +msgstr ":c:data:`PyExc_BaseExceptionGroup`" + +#: ../../c-api/exceptions.rst:1171 msgid "These are compatibility aliases to :c:data:`PyExc_OSError`:" msgstr "" -#: ../../c-api/exceptions.rst:1165 +#: ../../c-api/exceptions.rst:1181 msgid ":c:data:`!PyExc_EnvironmentError`" msgstr ":c:data:`!PyExc_EnvironmentError`" -#: ../../c-api/exceptions.rst:1167 +#: ../../c-api/exceptions.rst:1183 msgid ":c:data:`!PyExc_IOError`" msgstr ":c:data:`!PyExc_IOError`" -#: ../../c-api/exceptions.rst:1169 +#: ../../c-api/exceptions.rst:1185 msgid ":c:data:`!PyExc_WindowsError`" msgstr ":c:data:`!PyExc_WindowsError`" -#: ../../c-api/exceptions.rst:1169 +#: ../../c-api/exceptions.rst:1185 msgid "[2]_" msgstr "[2]_" -#: ../../c-api/exceptions.rst:1172 +#: ../../c-api/exceptions.rst:1188 msgid "These aliases used to be separate exception types." msgstr "" -#: ../../c-api/exceptions.rst:1175 ../../c-api/exceptions.rst:1236 +#: ../../c-api/exceptions.rst:1191 ../../c-api/exceptions.rst:1258 msgid "Notes:" msgstr "註解:" -#: ../../c-api/exceptions.rst:1178 +#: ../../c-api/exceptions.rst:1194 msgid "This is a base class for other standard exceptions." msgstr "" -#: ../../c-api/exceptions.rst:1181 +#: ../../c-api/exceptions.rst:1197 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:1187 +#: ../../c-api/exceptions.rst:1203 msgid "Standard Warning Categories" msgstr "" -#: ../../c-api/exceptions.rst:1189 +#: ../../c-api/exceptions.rst:1205 msgid "" "All standard Python warning categories are available as global variables " "whose names are ``PyExc_`` followed by the Python exception name. These have " @@ -1568,103 +1590,115 @@ msgid "" "here are all the variables:" msgstr "" -#: ../../c-api/exceptions.rst:1210 +#: ../../c-api/exceptions.rst:1227 msgid ":c:data:`PyExc_Warning`" msgstr ":c:data:`PyExc_Warning`" -#: ../../c-api/exceptions.rst:1210 +#: ../../c-api/exceptions.rst:1227 msgid ":exc:`Warning`" msgstr ":exc:`Warning`" -#: ../../c-api/exceptions.rst:1210 +#: ../../c-api/exceptions.rst:1227 msgid "[3]_" msgstr "[3]_" -#: ../../c-api/exceptions.rst:1212 +#: ../../c-api/exceptions.rst:1229 msgid ":c:data:`PyExc_BytesWarning`" msgstr ":c:data:`PyExc_BytesWarning`" -#: ../../c-api/exceptions.rst:1212 +#: ../../c-api/exceptions.rst:1229 msgid ":exc:`BytesWarning`" msgstr ":exc:`BytesWarning`" -#: ../../c-api/exceptions.rst:1214 +#: ../../c-api/exceptions.rst:1231 msgid ":c:data:`PyExc_DeprecationWarning`" msgstr ":c:data:`PyExc_DeprecationWarning`" -#: ../../c-api/exceptions.rst:1214 +#: ../../c-api/exceptions.rst:1231 msgid ":exc:`DeprecationWarning`" msgstr ":exc:`DeprecationWarning`" -#: ../../c-api/exceptions.rst:1216 +#: ../../c-api/exceptions.rst:1233 +msgid ":c:data:`PyExc_EncodingWarning`" +msgstr ":c:data:`PyExc_EncodingWarning`" + +#: ../../c-api/exceptions.rst:1233 +msgid ":exc:`EncodingWarning`" +msgstr ":exc:`EncodingWarning`" + +#: ../../c-api/exceptions.rst:1235 msgid ":c:data:`PyExc_FutureWarning`" msgstr ":c:data:`PyExc_FutureWarning`" -#: ../../c-api/exceptions.rst:1216 +#: ../../c-api/exceptions.rst:1235 msgid ":exc:`FutureWarning`" msgstr ":exc:`FutureWarning`" -#: ../../c-api/exceptions.rst:1218 +#: ../../c-api/exceptions.rst:1237 msgid ":c:data:`PyExc_ImportWarning`" msgstr ":c:data:`PyExc_ImportWarning`" -#: ../../c-api/exceptions.rst:1218 +#: ../../c-api/exceptions.rst:1237 msgid ":exc:`ImportWarning`" msgstr ":exc:`ImportWarning`" -#: ../../c-api/exceptions.rst:1220 +#: ../../c-api/exceptions.rst:1239 msgid ":c:data:`PyExc_PendingDeprecationWarning`" msgstr ":c:data:`PyExc_PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1220 +#: ../../c-api/exceptions.rst:1239 msgid ":exc:`PendingDeprecationWarning`" msgstr ":exc:`PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1222 +#: ../../c-api/exceptions.rst:1241 msgid ":c:data:`PyExc_ResourceWarning`" msgstr ":c:data:`PyExc_ResourceWarning`" -#: ../../c-api/exceptions.rst:1222 +#: ../../c-api/exceptions.rst:1241 msgid ":exc:`ResourceWarning`" msgstr ":exc:`ResourceWarning`" -#: ../../c-api/exceptions.rst:1224 +#: ../../c-api/exceptions.rst:1243 msgid ":c:data:`PyExc_RuntimeWarning`" msgstr ":c:data:`PyExc_RuntimeWarning`" -#: ../../c-api/exceptions.rst:1224 +#: ../../c-api/exceptions.rst:1243 msgid ":exc:`RuntimeWarning`" msgstr ":exc:`RuntimeWarning`" -#: ../../c-api/exceptions.rst:1226 +#: ../../c-api/exceptions.rst:1245 msgid ":c:data:`PyExc_SyntaxWarning`" msgstr ":c:data:`PyExc_SyntaxWarning`" -#: ../../c-api/exceptions.rst:1226 +#: ../../c-api/exceptions.rst:1245 msgid ":exc:`SyntaxWarning`" msgstr ":exc:`SyntaxWarning`" -#: ../../c-api/exceptions.rst:1228 +#: ../../c-api/exceptions.rst:1247 msgid ":c:data:`PyExc_UnicodeWarning`" msgstr ":c:data:`PyExc_UnicodeWarning`" -#: ../../c-api/exceptions.rst:1228 +#: ../../c-api/exceptions.rst:1247 msgid ":exc:`UnicodeWarning`" msgstr ":exc:`UnicodeWarning`" -#: ../../c-api/exceptions.rst:1230 +#: ../../c-api/exceptions.rst:1249 msgid ":c:data:`PyExc_UserWarning`" msgstr ":c:data:`PyExc_UserWarning`" -#: ../../c-api/exceptions.rst:1230 +#: ../../c-api/exceptions.rst:1249 msgid ":exc:`UserWarning`" msgstr ":exc:`UserWarning`" -#: ../../c-api/exceptions.rst:1233 +#: ../../c-api/exceptions.rst:1252 msgid ":c:data:`PyExc_ResourceWarning`." msgstr ":c:data:`PyExc_ResourceWarning`." -#: ../../c-api/exceptions.rst:1239 +#: ../../c-api/exceptions.rst:1255 +msgid ":c:data:`PyExc_EncodingWarning`." +msgstr ":c:data:`PyExc_EncodingWarning`" + +#: ../../c-api/exceptions.rst:1261 msgid "This is a base class for other standard warning categories." msgstr "" @@ -1691,274 +1725,282 @@ msgstr "SIGINT(C 巨集)" msgid "KeyboardInterrupt (built-in exception)" msgstr "KeyboardInterrupt(內建例外)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_BaseException (C var)" msgstr "PyExc_BaseException(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 +msgid "PyExc_BaseExceptionGroup (C var)" +msgstr "PyExc_BaseExceptionGroup(C 變數)" + +#: ../../c-api/exceptions.rst:981 msgid "PyExc_Exception (C var)" msgstr "PyExc_Exception(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ArithmeticError (C var)" msgstr "PyExc_ArithmeticError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_AssertionError (C var)" msgstr "PyExc_AssertionError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_AttributeError (C var)" msgstr "PyExc_AttributeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_BlockingIOError (C var)" msgstr "PyExc_BlockingIOError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_BrokenPipeError (C var)" msgstr "PyExc_BrokenPipeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_BufferError (C var)" msgstr "PyExc_BufferError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ChildProcessError (C var)" msgstr "PyExc_ChildProcessError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ConnectionAbortedError (C var)" msgstr "PyExc_ConnectionAbortedError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ConnectionError (C var)" msgstr "PyExc_ConnectionError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ConnectionRefusedError (C var)" msgstr "PyExc_ConnectionRefusedError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ConnectionResetError (C var)" msgstr "PyExc_ConnectionResetError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_EOFError (C var)" msgstr "PyExc_EOFError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_FileExistsError (C var)" msgstr "PyExc_FileExistsError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_FileNotFoundError (C var)" msgstr "PyExc_FileNotFoundError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_FloatingPointError (C var)" msgstr "PyExc_FloatingPointError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_GeneratorExit (C var)" msgstr "PyExc_GeneratorExit(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ImportError (C var)" msgstr "PyExc_ImportError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_IndentationError (C var)" msgstr "PyExc_IndentationError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_IndexError (C var)" msgstr "PyExc_IndexError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_InterruptedError (C var)" msgstr "PyExc_InterruptedError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_IsADirectoryError (C var)" msgstr "PyExc_IsADirectoryError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_KeyError (C var)" msgstr "PyExc_KeyError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_KeyboardInterrupt (C var)" msgstr "PyExc_KeyboardInterrupt(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_LookupError (C var)" msgstr "PyExc_LookupError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_MemoryError (C var)" msgstr "PyExc_MemoryError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ModuleNotFoundError (C var)" msgstr "PyExc_ModuleNotFoundError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_NameError (C var)" msgstr "PyExc_NameError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_NotADirectoryError (C var)" msgstr "PyExc_NotADirectoryError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_NotImplementedError (C var)" msgstr "PyExc_NotImplementedError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_OSError (C var)" msgstr "PyExc_OSError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_OverflowError (C var)" msgstr "PyExc_OverflowError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_PermissionError (C var)" msgstr "PyExc_PermissionError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ProcessLookupError (C var)" msgstr "PyExc_ProcessLookupError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_PythonFinalizationError (C var)" msgstr "PyExc_PythonFinalizationError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_RecursionError (C var)" msgstr "PyExc_RecursionError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ReferenceError (C var)" msgstr "PyExc_ReferenceError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_RuntimeError (C var)" msgstr "PyExc_RuntimeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_StopAsyncIteration (C var)" msgstr "PyExc_StopAsyncIteration(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_StopIteration (C var)" msgstr "PyExc_StopIteration(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_SyntaxError (C var)" msgstr "PyExc_SyntaxError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_SystemError (C var)" msgstr "PyExc_SystemError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_SystemExit (C var)" msgstr "PyExc_SystemExit(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_TabError (C var)" msgstr "PyExc_TabError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_TimeoutError (C var)" msgstr "PyExc_TimeoutError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_TypeError (C var)" msgstr "PyExc_TypeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_UnboundLocalError (C var)" msgstr "PyExc_UnboundLocalError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_UnicodeDecodeError (C var)" msgstr "PyExc_UnicodeDecodeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_UnicodeEncodeError (C var)" msgstr "PyExc_UnicodeEncodeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_UnicodeError (C var)" msgstr "PyExc_UnicodeError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_UnicodeTranslateError (C var)" msgstr "PyExc_UnicodeTranslateError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ValueError (C var)" msgstr "PyExc_ValueError(C 變數)" -#: ../../c-api/exceptions.rst:971 +#: ../../c-api/exceptions.rst:981 msgid "PyExc_ZeroDivisionError (C var)" msgstr "PyExc_ZeroDivisionError(C 變數)" -#: ../../c-api/exceptions.rst:1157 +#: ../../c-api/exceptions.rst:1173 msgid "PyExc_EnvironmentError (C var)" msgstr "PyExc_EnvironmentError(C 變數)" -#: ../../c-api/exceptions.rst:1157 +#: ../../c-api/exceptions.rst:1173 msgid "PyExc_IOError (C var)" msgstr "PyExc_IOError(C 變數)" -#: ../../c-api/exceptions.rst:1157 +#: ../../c-api/exceptions.rst:1173 msgid "PyExc_WindowsError (C var)" msgstr "PyExc_WindowsError(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_Warning (C var)" msgstr "PyExc_Warning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_BytesWarning (C var)" msgstr "PyExc_BytesWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_DeprecationWarning (C var)" msgstr "PyExc_DeprecationWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 +msgid "PyExc_EncodingWarning (C var)" +msgstr "PyExc_EncodingWarning(C 變數)" + +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_FutureWarning (C var)" msgstr "PyExc_FutureWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_ImportWarning (C var)" msgstr "PyExc_ImportWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_PendingDeprecationWarning (C var)" msgstr "PyExc_PendingDeprecationWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_ResourceWarning (C var)" msgstr "PyExc_ResourceWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_RuntimeWarning (C var)" msgstr "PyExc_RuntimeWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_SyntaxWarning (C var)" msgstr "PyExc_SyntaxWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_UnicodeWarning (C var)" msgstr "PyExc_UnicodeWarning(C 變數)" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1210 msgid "PyExc_UserWarning (C var)" msgstr "PyExc_UserWarning(C 變數)" diff --git a/c-api/function.po b/c-api/function.po index 299c34cd6c..9328805cc2 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: 2025-02-17 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -37,17 +37,17 @@ msgstr "用於函式的 C 結構。" #: ../../c-api/function.rst:22 msgid "" "This is an instance of :c:type:`PyTypeObject` and represents the Python " -"function type. It is exposed to Python programmers as " -"``types.FunctionType``." +"function type. It is exposed to Python programmers as ``types." +"FunctionType``." msgstr "" "這是個 :c:type:`PyTypeObject` 的實例,且代表了 Python 函式型別,Python 程式設" "計者可透過 ``types.FunctionType`` 使用它。" #: ../../c-api/function.rst:28 msgid "" -"Return true if *o* is a function object (has " -"type :c:data:`PyFunction_Type`). The parameter must not be ``NULL``. This " -"function always succeeds." +"Return true if *o* is a function object (has type :c:data:" +"`PyFunction_Type`). The parameter must not be ``NULL``. This function " +"always succeeds." msgstr "" "如果 *o* 是個函式物件(擁有 :c:data:`PyFunction_Type` 的型別)則回傳 true。參" "數必須不為 ``NULL``。此函式必能成功執行。" @@ -63,30 +63,28 @@ msgstr "" #: ../../c-api/function.rst:37 msgid "" -"The function's docstring and name are retrieved from the code " -"object. :attr:`~function.__module__` is retrieved from *globals*. The " -"argument defaults, annotations and closure are set to " -"``NULL``. :attr:`~function.__qualname__` is set to the same value as the " -"code object's :attr:`~codeobject.co_qualname` field." +"The function's docstring and name are retrieved from the code object. :attr:" +"`~function.__module__` is retrieved from *globals*. The argument defaults, " +"annotations and closure are set to ``NULL``. :attr:`~function.__qualname__` " +"is set to the same value as the code object's :attr:`~codeobject." +"co_qualname` field." msgstr "" -"函式的文件字串 (docstring) 和名稱是從程式碼物件所取" -"得,:attr:`~function.__module__` 是自 *globals* 所取得。引數預設值、標註 " -"(annotation) 和閉包 (closure) 被設為 " -"``NULL``,:attr:`~function.__qualname__` 被設為和程式碼物" +"函式的文件字串 (docstring) 和名稱是從程式碼物件所取得,:attr:`~function." +"__module__` 是自 *globals* 所取得。引數預設值、標註 (annotation) 和閉包 " +"(closure) 被設為 ``NULL``,:attr:`~function.__qualname__` 被設為和程式碼物" "件 :attr:`~codeobject.co_qualname` 欄位相同的值。" #: ../../c-api/function.rst:46 msgid "" -"As :c:func:`PyFunction_New`, but also allows setting the function " -"object's :attr:`~function.__qualname__` attribute. *qualname* should be a " -"unicode object or ``NULL``; if ``NULL``, the :attr:`!__qualname__` attribute " -"is set to the same value as the code " -"object's :attr:`~codeobject.co_qualname` field." +"As :c:func:`PyFunction_New`, but also allows setting the function object's :" +"attr:`~function.__qualname__` attribute. *qualname* should be a unicode " +"object or ``NULL``; if ``NULL``, the :attr:`!__qualname__` attribute is set " +"to the same value as the code object's :attr:`~codeobject.co_qualname` field." msgstr "" -"和 :c:func:`PyFunction_New` 相似,但也允許函式物" -"件 :attr:`~function.__qualname__` 屬性的設定,*qualname* 應為一個 unicode 物" -"件或是 ``NULL``;如為 ``NULL``,:attr:`!__qualname__` 屬性會被設為與程式碼物" -"件 :attr:`~codeobject.co_qualname` 欄位相同的值。" +"和 :c:func:`PyFunction_New` 相似,但也允許函式物件 :attr:`~function." +"__qualname__` 屬性的設定,*qualname* 應為一個 unicode 物件或是 ``NULL``;如" +"為 ``NULL``,:attr:`!__qualname__` 屬性會被設為與程式碼物件 :attr:" +"`~codeobject.co_qualname` 欄位相同的值。" #: ../../c-api/function.rst:57 msgid "Return the code object associated with the function object *op*." @@ -102,9 +100,8 @@ msgid "" "attribute of the :ref:`function object ` *op*. It can be " "*NULL*." msgstr "" -"回傳一個\\ :ref:`函式物件 ` *op* " -"之 :attr:`~function.__module__` 屬性的 :term:`borrowed reference`,它可以是 " -"*NULL*。" +"回傳一個\\ :ref:`函式物件 ` *op* 之 :attr:`~function." +"__module__` 屬性的 :term:`borrowed reference`,它可以是 *NULL*。" #: ../../c-api/function.rst:71 msgid "" @@ -129,8 +126,8 @@ msgid "" msgstr "" "設定函式物件 *op* 的引數預設值。*defaults* 必須是 ``Py_None`` 或一個 tuple。" -#: ../../c-api/function.rst:86 ../../c-api/function.rst:109 -#: ../../c-api/function.rst:123 +#: ../../c-api/function.rst:86 ../../c-api/function.rst:116 +#: ../../c-api/function.rst:130 msgid "Raises :exc:`SystemError` and returns ``-1`` on failure." msgstr "引發 :exc:`SystemError` 且在失敗時回傳 ``-1``。" @@ -142,9 +139,17 @@ msgstr "為一個給定的函式物件 *func* 設定 vectorcall 欄位。" msgid "" "Warning: extensions using this API must preserve the behavior of the " "unaltered (default) vectorcall function!" +msgstr "警告:使用此 API 的擴充套件必須保留未更改(預設)vectorcall 函式的行為!" + +#: ../../c-api/function.rst:101 +msgid "" +"Return the keyword-only argument default values of the function object *op*. " +"This can be a dictionary of arguments or ``NULL``." msgstr "" +"回傳函式物件 *op* 的僅限關鍵字引數預設值,這可以是一個含有多個引數的字典或 " +"``NULL``。" -#: ../../c-api/function.rst:100 +#: ../../c-api/function.rst:107 msgid "" "Return the closure associated with the function object *op*. This can be " "``NULL`` or a tuple of cell objects." @@ -152,7 +157,7 @@ msgstr "" "回傳與函式物件 *op* 相關聯的閉包,這可以是個 ``NULL`` 或是一個包含 cell 物件" "的 tuple。" -#: ../../c-api/function.rst:106 +#: ../../c-api/function.rst:113 msgid "" "Set the closure associated with the function object *op*. *closure* must be " "``Py_None`` or a tuple of cell objects." @@ -160,20 +165,27 @@ msgstr "" "設定與函式物件 *op* 相關聯的閉包,*closure* 必須是 ``Py_None`` 或是一個包含 " "cell 物件的 tuple。" -#: ../../c-api/function.rst:114 +#: ../../c-api/function.rst:121 msgid "" "Return the annotations of the function object *op*. This can be a mutable " "dictionary or ``NULL``." msgstr "" "回傳函式物件 *op* 的標註,這可以是一個可變動的 (mutable) 字典或 ``NULL``。" -#: ../../c-api/function.rst:120 +#: ../../c-api/function.rst:127 msgid "" "Set the annotations for the function object *op*. *annotations* must be a " "dictionary or ``Py_None``." msgstr "設定函式物件 *op* 的標註,*annotations* 必須是一個字典或 ``Py_None``。" -#: ../../c-api/function.rst:128 +#: ../../c-api/function.rst:141 +msgid "" +"These functions are similar to their ``PyFunction_Get*`` counterparts, but " +"do not do type checking. Passing anything other than an instance of :c:data:" +"`PyFunction_Type` is undefined behavior." +msgstr "" + +#: ../../c-api/function.rst:148 msgid "" "Register *callback* as a function watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyFunction_ClearWatcher`. In " @@ -181,60 +193,60 @@ msgid "" "exception." msgstr "" -#: ../../c-api/function.rst:138 +#: ../../c-api/function.rst:158 msgid "" -"Clear watcher identified by *watcher_id* previously returned " -"from :c:func:`PyFunction_AddWatcher` for the current interpreter. Return " -"``0`` on success, or ``-1`` and set an exception on error (e.g. if the " -"given *watcher_id* was never registered.)" +"Clear watcher identified by *watcher_id* previously returned from :c:func:" +"`PyFunction_AddWatcher` for the current interpreter. Return ``0`` on " +"success, or ``-1`` and set an exception on error (e.g. if the given " +"*watcher_id* was never registered.)" msgstr "" -#: ../../c-api/function.rst:148 +#: ../../c-api/function.rst:168 msgid "Enumeration of possible function watcher events:" msgstr "" -#: ../../c-api/function.rst:150 +#: ../../c-api/function.rst:170 msgid "``PyFunction_EVENT_CREATE``" msgstr "``PyFunction_EVENT_CREATE``" -#: ../../c-api/function.rst:151 +#: ../../c-api/function.rst:171 msgid "``PyFunction_EVENT_DESTROY``" msgstr "``PyFunction_EVENT_DESTROY``" -#: ../../c-api/function.rst:152 +#: ../../c-api/function.rst:172 msgid "``PyFunction_EVENT_MODIFY_CODE``" msgstr "``PyFunction_EVENT_MODIFY_CODE``" -#: ../../c-api/function.rst:153 +#: ../../c-api/function.rst:173 msgid "``PyFunction_EVENT_MODIFY_DEFAULTS``" msgstr "``PyFunction_EVENT_MODIFY_DEFAULTS``" -#: ../../c-api/function.rst:154 +#: ../../c-api/function.rst:174 msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" msgstr "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" -#: ../../c-api/function.rst:161 +#: ../../c-api/function.rst:181 msgid "Type of a function watcher callback function." msgstr "" -#: ../../c-api/function.rst:163 +#: ../../c-api/function.rst:183 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " -"then *new_value* will be ``NULL``. Otherwise, *new_value* will hold " -"a :term:`borrowed reference` to the new value that is about to be stored in " -"*func* for the attribute that is being modified." +"then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" +"`borrowed reference` to the new value that is about to be stored in *func* " +"for the attribute that is being modified." msgstr "" -#: ../../c-api/function.rst:168 +#: ../../c-api/function.rst:188 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" -#: ../../c-api/function.rst:171 +#: ../../c-api/function.rst:191 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " -"after `func` has been fully initialized. Otherwise, the callback is invoked " +"after *func* has been fully initialized. Otherwise, the callback is invoked " "before the modification to *func* takes place, so the prior state of *func* " "can be inspected. The runtime is permitted to optimize away the creation of " "function objects when possible. In such cases no event will be emitted. " @@ -243,7 +255,7 @@ msgid "" "semantics of the Python code being executed." msgstr "" -#: ../../c-api/function.rst:180 +#: ../../c-api/function.rst:200 msgid "" "If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " @@ -251,14 +263,14 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/function.rst:185 +#: ../../c-api/function.rst:205 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " -"will be printed as an unraisable exception " -"using :c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``." +"will be printed as an unraisable exception using :c:func:" +"`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/function.rst:189 +#: ../../c-api/function.rst:209 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 5fd35ae6f8..8ad9b1c6a1 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: 2025-04-13 00:40+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -255,9 +255,10 @@ msgstr "" #: ../../c-api/gcsupport.rst:185 msgid "" -"If *o* is not ``NULL``, call the *visit* callback, with arguments *o* and " -"*arg*. If *visit* returns a non-zero value, then return it. Using this " -"macro, :c:member:`~PyTypeObject.tp_traverse` handlers look like::" +"If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, " +"with arguments *o* and *arg*. If *visit* returns a non-zero value, then " +"return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse` handlers " +"look like::" msgstr "" #: ../../c-api/gcsupport.rst:190 diff --git a/c-api/init.po b/c-api/init.po index 0ce89e728e..eaedaa945b 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-12 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -205,8 +205,10 @@ msgstr ":c:func:`PyMutex_Unlock`" msgid "" "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`, :c:func:`PyEval_InitThreads`, " -"and :c:func:`Py_RunMain`." +"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`, :c:func:`PyEval_InitThreads`, and :c:func:`Py_RunMain`." msgstr "" #: ../../c-api/init.rst:90 @@ -216,30 +218,30 @@ msgstr "" #: ../../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 `." +"features and options. By default, these flags are controlled by :ref:" +"`command line options `." msgstr "" #: ../../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:`Py_BytesWarningFlag` to 1 and ``-bb`` " -"sets :c:data:`Py_BytesWarningFlag` to 2." +"times that the option was set. For example, ``-b`` sets :c:data:" +"`Py_BytesWarningFlag` to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to " +"2." msgstr "" #: ../../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 `." +"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: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``." +"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:110 @@ -248,9 +250,9 @@ msgstr "由 :option:`-b` 選項設定。" #: ../../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 `." +"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:120 @@ -267,9 +269,9 @@ msgstr "由 :option:`-d` 選項與 :envvar:`PYTHONDEBUG` 環境變數設定。" #: ../../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 `." +"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:134 @@ -287,15 +289,15 @@ msgstr "" #: ../../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 `." +"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:148 msgid "" -"Suppress error messages when calculating the module search path " -"in :c:func:`Py_GetPath`." +"Suppress error messages when calculating the module search path in :c:func:" +"`Py_GetPath`." msgstr "" #: ../../c-api/init.rst:151 @@ -304,9 +306,8 @@ msgstr "" #: ../../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, " +"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 "" @@ -325,15 +326,15 @@ msgstr "" #: ../../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 `." +"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:176 msgid "" -"Ignore all :envvar:`!PYTHON*` environment variables, " -"e.g. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." +"Ignore all :envvar:`!PYTHON*` environment variables, e.g. :envvar:" +"`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." msgstr "" "忽略所有可能被設定的 :envvar:`!PYTHON*` 環境變數,例如 :envvar:`PYTHONPATH` " "與 :envvar:`PYTHONHOME`。" @@ -344,9 +345,9 @@ msgstr "由 :option:`-E` 與 :option:`-I` 選項設定。" #: ../../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 `." +"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:189 @@ -364,9 +365,9 @@ msgstr "由 :option:`-i` 選項與 :envvar:`PYTHONINSPECT` 環境變數設定。 #: ../../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 `." +"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:204 @@ -375,9 +376,9 @@ msgstr "由 :option:`-i` 選項設定。" #: ../../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 `." +"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:214 @@ -392,9 +393,9 @@ msgstr "由 :option:`-i` 選項設定。" #: ../../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 `." +"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:229 @@ -422,15 +423,15 @@ msgstr "" #: ../../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 `." +"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:248 msgid "" -"If the flag is non-zero, use :class:`io.FileIO` instead of :class:`!" -"io._WindowsConsoleIO` for :mod:`sys` standard streams." +"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:251 @@ -445,17 +446,17 @@ msgstr "更多詳情請見 :pep:`528`。" #: ../../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 `." +"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: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 " -"manipulations if :mod:`site` is explicitly imported later " -"(call :func:`site.main` if you want them to be triggered)." +"manipulations if :mod:`site` is explicitly imported later (call :func:`site." +"main` if you want them to be triggered)." msgstr "" #: ../../c-api/init.rst:271 @@ -464,30 +465,30 @@ msgstr "由 :option:`-S` 選項設定。" #: ../../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 `." +"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:281 msgid "" -"Don't add the :data:`user site-packages directory ` " -"to :data:`sys.path`." +"Don't add the :data:`user site-packages directory ` to :data:" +"`sys.path`." msgstr "" #: ../../c-api/init.rst:284 msgid "" -"Set by the :option:`-s` and :option:`-I` options, and " -"the :envvar:`PYTHONNOUSERSITE` environment variable." +"Set by the :option:`-s` and :option:`-I` options, and the :envvar:" +"`PYTHONNOUSERSITE` environment variable." msgstr "" "由 :option:`-s` 選項、:option:`-I` 選項與 :envvar:`PYTHONNOUSERSITE` 環境變數" "設定。" #: ../../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 `." +"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:295 @@ -498,9 +499,9 @@ msgstr "由 :option:`-O` 選項與 :envvar:`PYTHONOPTIMIZE` 環境變數設定 #: ../../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 `." +"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:306 @@ -514,9 +515,9 @@ msgstr "由 :option:`-q` 選項設定。" #: ../../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 `." +"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:320 @@ -531,9 +532,9 @@ msgstr "由 :option:`-u` 選項與 :envvar:`PYTHONUNBUFFERED` 環境變數設定 #: ../../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 `." +"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:333 @@ -557,9 +558,8 @@ msgstr "" #: ../../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." +"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:364 @@ -622,20 +622,19 @@ msgstr "" #: ../../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:`Py_NewInterpreter` below) that were created and not yet " -"destroyed since the last call to :c:func:`Py_Initialize`. Ideally, this " -"frees all memory allocated by the Python interpreter. This is a no-op when " -"called for a second time (without calling :c:func:`Py_Initialize` again " -"first)." +"of Python/C API functions, and destroy all sub-interpreters (see :c:func:" +"`Py_NewInterpreter` below) that were created and not yet destroyed since the " +"last call to :c:func:`Py_Initialize`. Ideally, this frees all memory " +"allocated by the Python interpreter. This is a no-op when called for a " +"second time (without calling :c:func:`Py_Initialize` again first)." msgstr "" #: ../../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 " -"thread and the main interpreter. This should never be called " -"while :c:func:`Py_RunMain` is running." +"thread and the main interpreter. This should never be called while :c:func:" +"`Py_RunMain` is running." msgstr "" #: ../../c-api/init.rst:429 @@ -672,11 +671,11 @@ msgstr "" #: ../../c-api/init.rst:452 msgid "" -"Raises an :ref:`auditing event ` " -"``cpython._PySys_ClearAuditHooks`` with no arguments." +"Raises an :ref:`auditing event ` ``cpython." +"_PySys_ClearAuditHooks`` with no arguments." msgstr "" -"引發一個不附帶引數的\\ :ref:`稽核事件 ` " -"``cpython._PySys_ClearAuditHooks``。" +"引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." +"_PySys_ClearAuditHooks``。" #: ../../c-api/init.rst:459 msgid "" @@ -719,29 +718,18 @@ 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." +"The return value is ``2`` if the argument list does not represent a valid " +"Python command line, and otherwise the same as :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:496 +#: ../../c-api/init.rst:494 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." +"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: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 +#: ../../c-api/init.rst:498 msgid "" "PyConfig config;\n" "PyConfig_InitPythonConfig(&config);\n" @@ -752,91 +740,86 @@ msgid "" "Py_RunMain();" msgstr "" -#: ../../c-api/init.rst:515 +#: ../../c-api/init.rst:506 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)." +"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 +#: ../../c-api/init.rst:519 msgid "Executes the main module in a fully configured CPython runtime." msgstr "" -#: ../../c-api/init.rst:530 +#: ../../c-api/init.rst:521 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." +"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 +#: ../../c-api/init.rst:527 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``." +"exception), the exit status of an unhandled :exc:`SystemExit`, or ``1`` for " +"any other unhandled exception." msgstr "" -#: ../../c-api/init.rst:542 +#: ../../c-api/init.rst:532 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." +"determined by the way the *REPL session* terminates: ``0``, ``1``, or the " +"status of a :exc:`SystemExit`, as specified above." msgstr "" -#: ../../c-api/init.rst:552 +#: ../../c-api/init.rst:540 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." +"This function always finalizes the Python interpreter before it returns." msgstr "" -#: ../../c-api/init.rst:556 +#: ../../c-api/init.rst:542 msgid "" "See :ref:`Python Configuration ` for an example of a " -"customized Python that always runs in isolated mode " -"using :c:func:`Py_RunMain`." +"customized Python that always runs in isolated mode using :c:func:" +"`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:562 +#: ../../c-api/init.rst:548 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 +#: ../../c-api/init.rst:552 msgid "The :term:`GIL` must be held for *interp*." msgstr "" -#: ../../c-api/init.rst:571 +#: ../../c-api/init.rst:557 msgid "Process-wide parameters" msgstr "" -#: ../../c-api/init.rst:581 +#: ../../c-api/init.rst:567 msgid "" -"This API is kept for backward compatibility: " -"setting :c:member:`PyConfig.program_name` should be used instead, " -"see :ref:`Python Initialization Configuration `." +"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:585 +#: ../../c-api/init.rst:571 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 " @@ -850,37 +833,37 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:596 ../../c-api/init.rst:838 ../../c-api/init.rst:874 -#: ../../c-api/init.rst:900 +#: ../../c-api/init.rst:582 ../../c-api/init.rst:824 ../../c-api/init.rst:860 +#: ../../c-api/init.rst:886 msgid "" -"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get " -"a :c:expr:`wchar_t*` string." +"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" +"`wchar_t*` string." msgstr "" -#: ../../c-api/init.rst:604 +#: ../../c-api/init.rst:590 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: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 +#: ../../c-api/init.rst:594 ../../c-api/init.rst:616 ../../c-api/init.rst:662 +#: ../../c-api/init.rst:684 ../../c-api/init.rst:710 ../../c-api/init.rst:898 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: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 +#: ../../c-api/init.rst:597 ../../c-api/init.rst:619 ../../c-api/init.rst:665 +#: ../../c-api/init.rst:687 ../../c-api/init.rst:715 ../../c-api/init.rst:901 msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" -#: ../../c-api/init.rst:614 ../../c-api/init.rst:704 +#: ../../c-api/init.rst:600 ../../c-api/init.rst:690 msgid "Get :data:`sys.executable` instead." msgstr "" -#: ../../c-api/init.rst:620 +#: ../../c-api/init.rst:606 msgid "" "Return the *prefix* for installed platform-independent files. This is " "derived through a number of complicated rules from the program name set " @@ -894,27 +877,27 @@ msgid "" "See also the next function." msgstr "" -#: ../../c-api/init.rst:636 +#: ../../c-api/init.rst:622 msgid "" "Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if :ref:`virtual " "environments ` need to be handled." msgstr "" -#: ../../c-api/init.rst:643 +#: ../../c-api/init.rst:629 msgid "" "Return the *exec-prefix* for installed platform-*dependent* files. This is " "derived through a number of complicated rules from the program name set " "with :c:member:`PyConfig.program_name` and some environment variables; for " "example, if the program name is ``'/usr/local/bin/python'``, the exec-prefix " "is ``'/usr/local'``. The returned string points into static storage; the " -"caller should not modify its value. This corresponds to " -"the :makevar:`exec_prefix` variable in the top-level :file:`Makefile` and " -"the ``--exec-prefix`` argument to the :program:`configure` script at build " -"time. The value is available to Python code as ``sys.base_exec_prefix``. " -"It is only useful on Unix." +"caller should not modify its value. This corresponds to the :makevar:" +"`exec_prefix` variable in the top-level :file:`Makefile` and the ``--exec-" +"prefix`` argument to the :program:`configure` script at build time. The " +"value is available to Python code as ``sys.base_exec_prefix``. It is only " +"useful on Unix." msgstr "" -#: ../../c-api/init.rst:654 +#: ../../c-api/init.rst:640 msgid "" "Background: The exec-prefix differs from the prefix when platform dependent " "files (such as executables and shared libraries) are installed in a " @@ -923,7 +906,7 @@ msgid "" "independent may be installed in :file:`/usr/local`." msgstr "" -#: ../../c-api/init.rst:660 +#: ../../c-api/init.rst:646 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 " @@ -937,21 +920,21 @@ msgid "" "independent from the Python version by which they were compiled!)." msgstr "" -#: ../../c-api/init.rst:671 +#: ../../c-api/init.rst:657 msgid "" -"System administrators will know how to configure the :program:`mount` " -"or :program:`automount` programs to share :file:`/usr/local` between " -"platforms while having :file:`/usr/local/plat` be a different filesystem for " -"each platform." +"System administrators will know how to configure the :program:`mount` or :" +"program:`automount` programs to share :file:`/usr/local` between platforms " +"while having :file:`/usr/local/plat` be a different filesystem for each " +"platform." msgstr "" -#: ../../c-api/init.rst:682 +#: ../../c-api/init.rst:668 msgid "" -"Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` " -"if :ref:`virtual environments ` need to be handled." +"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:692 +#: ../../c-api/init.rst:678 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 " @@ -960,7 +943,7 @@ msgid "" "available to Python code as ``sys.executable``." msgstr "" -#: ../../c-api/init.rst:714 +#: ../../c-api/init.rst:700 msgid "" "Return the default module search path; this is computed from the program " "name (set by :c:member:`PyConfig.program_name`) and some environment " @@ -973,34 +956,34 @@ msgid "" "for loading modules." msgstr "" -#: ../../c-api/init.rst:732 +#: ../../c-api/init.rst:718 msgid "Get :data:`sys.path` instead." msgstr "" -#: ../../c-api/init.rst:738 +#: ../../c-api/init.rst:724 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: ../../c-api/init.rst:741 +#: ../../c-api/init.rst:727 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:745 +#: ../../c-api/init.rst:731 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 " "period. The returned string points into static storage; the caller should " -"not modify its value. The value is available to Python code " -"as :data:`sys.version`." +"not modify its value. The value is available to Python code as :data:`sys." +"version`." msgstr "" -#: ../../c-api/init.rst:750 +#: ../../c-api/init.rst:736 msgid "See also the :c:var:`Py_Version` constant." msgstr "" -#: ../../c-api/init.rst:757 +#: ../../c-api/init.rst:743 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -1011,58 +994,58 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: ../../c-api/init.rst:768 +#: ../../c-api/init.rst:754 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: ../../c-api/init.rst:770 +#: ../../c-api/init.rst:756 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" -#: ../../c-api/init.rst:774 +#: ../../c-api/init.rst:760 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:780 +#: ../../c-api/init.rst:766 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: ../../c-api/init.rst:783 +#: ../../c-api/init.rst:769 msgid "\"[GCC 2.7.2.2]\"" msgstr "\"[GCC 2.7.2.2]\"" -#: ../../c-api/init.rst:787 ../../c-api/init.rst:801 +#: ../../c-api/init.rst:773 ../../c-api/init.rst:787 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:794 +#: ../../c-api/init.rst:780 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:797 +#: ../../c-api/init.rst:783 msgid "\"#67, Aug 1 1997, 22:34:28\"" msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/init.rst:813 +#: ../../c-api/init.rst:799 msgid "" -"This API is kept for backward compatibility: " -"setting :c:member:`PyConfig.argv`, :c:member:`PyConfig.parse_argv` " -"and :c:member:`PyConfig.safe_path` should be used instead, see :ref:`Python " -"Initialization Configuration `." +"This API is kept for backward compatibility: setting :c:member:`PyConfig." +"argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " +"should be used instead, see :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:818 +#: ../../c-api/init.rst:804 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 " @@ -1073,85 +1056,84 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/init.rst:826 +#: ../../c-api/init.rst:812 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:830 +#: ../../c-api/init.rst:816 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`." +"path of the directory where the script is located is prepended to :data:`sys." +"path`." msgstr "" -#: ../../c-api/init.rst:833 +#: ../../c-api/init.rst:819 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:841 ../../c-api/init.rst:877 +#: ../../c-api/init.rst:827 ../../c-api/init.rst:863 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:845 +#: ../../c-api/init.rst:831 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:850 +#: ../../c-api/init.rst:836 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::" +"popping the first :data:`sys.path` element after having called :c:func:" +"`PySys_SetArgv`, for example using::" msgstr "" -#: ../../c-api/init.rst:854 +#: ../../c-api/init.rst:840 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/init.rst:866 +#: ../../c-api/init.rst:852 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 `." +"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:870 +#: ../../c-api/init.rst:856 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`." +"``1`` unless the :program:`python` interpreter was started with the :option:" +"`-I`." msgstr "" -#: ../../c-api/init.rst:880 +#: ../../c-api/init.rst:866 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: ../../c-api/init.rst:887 +#: ../../c-api/init.rst:873 msgid "" -"This API is kept for backward compatibility: " -"setting :c:member:`PyConfig.home` should be used instead, see :ref:`Python " -"Initialization Configuration `." +"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:891 +#: ../../c-api/init.rst:877 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:895 +#: ../../c-api/init.rst:881 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 " @@ -1159,24 +1141,24 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:908 +#: ../../c-api/init.rst:894 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." +"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:918 +#: ../../c-api/init.rst:904 msgid "" "Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment variable " "instead." msgstr "改為取得 :c:member:`PyConfig.home` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../c-api/init.rst:926 +#: ../../c-api/init.rst:912 msgid "Thread State and the Global Interpreter Lock" msgstr "" -#: ../../c-api/init.rst:933 +#: ../../c-api/init.rst:919 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 " @@ -1188,18 +1170,17 @@ msgid "" "once instead of twice." msgstr "" -#: ../../c-api/init.rst:943 +#: ../../c-api/init.rst:929 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 to emulate concurrency of execution, the interpreter " -"regularly tries to switch threads (see :func:`sys.setswitchinterval`). The " -"lock is also released around potentially blocking I/O operations like " -"reading or writing a file, so that other Python threads can run in the " -"meantime." +"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 " +"to emulate concurrency of execution, the interpreter regularly tries to " +"switch threads (see :func:`sys.setswitchinterval`). The lock is also " +"released around potentially blocking I/O operations like reading or writing " +"a file, so that other Python threads can run in the meantime." msgstr "" -#: ../../c-api/init.rst:953 +#: ../../c-api/init.rst:939 msgid "" "The Python interpreter keeps some thread-specific bookkeeping information " "inside a data structure called :c:type:`PyThreadState`. There's also one " @@ -1207,17 +1188,17 @@ msgid "" "retrieved using :c:func:`PyThreadState_Get`." msgstr "" -#: ../../c-api/init.rst:959 +#: ../../c-api/init.rst:945 msgid "Releasing the GIL from extension code" msgstr "" -#: ../../c-api/init.rst:961 +#: ../../c-api/init.rst:947 msgid "" "Most extension code manipulating the :term:`GIL` has the following simple " "structure::" msgstr "" -#: ../../c-api/init.rst:964 +#: ../../c-api/init.rst:950 msgid "" "Save the thread state in a local variable.\n" "Release the global interpreter lock.\n" @@ -1226,29 +1207,29 @@ msgid "" "Restore the thread state from the local variable." msgstr "" -#: ../../c-api/init.rst:970 +#: ../../c-api/init.rst:956 msgid "This is so common that a pair of macros exists to simplify it::" msgstr "" -#: ../../c-api/init.rst:972 +#: ../../c-api/init.rst:958 msgid "" "Py_BEGIN_ALLOW_THREADS\n" "... Do some blocking I/O operation ...\n" "Py_END_ALLOW_THREADS" msgstr "" -#: ../../c-api/init.rst:980 +#: ../../c-api/init.rst:966 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:984 +#: ../../c-api/init.rst:970 msgid "The block above expands to the following code::" msgstr "" -#: ../../c-api/init.rst:986 +#: ../../c-api/init.rst:972 msgid "" "PyThreadState *_save;\n" "\n" @@ -1257,7 +1238,7 @@ msgid "" "PyEval_RestoreThread(_save);" msgstr "" -#: ../../c-api/init.rst:996 +#: ../../c-api/init.rst:982 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 " @@ -1268,7 +1249,7 @@ msgid "" "state, the lock must be acquired before storing the thread state pointer." msgstr "" -#: ../../c-api/init.rst:1005 +#: ../../c-api/init.rst:991 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 " @@ -1278,21 +1259,21 @@ msgid "" "compressing or hashing data." msgstr "" -#: ../../c-api/init.rst:1016 +#: ../../c-api/init.rst:1002 msgid "Non-Python created threads" msgstr "" -#: ../../c-api/init.rst:1018 +#: ../../c-api/init.rst:1004 msgid "" -"When threads are created using the dedicated Python APIs (such as " -"the :mod:`threading` module), a thread state is automatically associated to " -"them and the code showed above is therefore correct. However, when threads " -"are created from C (for example by a third-party library with its own thread " +"When threads are created using the dedicated Python APIs (such as the :mod:" +"`threading` module), a thread state is automatically associated to them and " +"the code showed above is therefore correct. However, when threads are " +"created from C (for example by a third-party library with its own thread " "management), they don't hold the GIL, nor is there a thread state structure " "for them." msgstr "" -#: ../../c-api/init.rst:1025 +#: ../../c-api/init.rst:1011 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 " @@ -1303,14 +1284,14 @@ msgid "" "finally free the thread state data structure." msgstr "" -#: ../../c-api/init.rst:1033 +#: ../../c-api/init.rst:1019 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:1037 +#: ../../c-api/init.rst:1023 msgid "" "PyGILState_STATE gstate;\n" "gstate = PyGILState_Ensure();\n" @@ -1323,20 +1304,20 @@ msgid "" "PyGILState_Release(gstate);" msgstr "" -#: ../../c-api/init.rst:1047 +#: ../../c-api/init.rst:1033 msgid "" "Note that the ``PyGILState_*`` functions assume there is only one global " "interpreter (created automatically by :c:func:`Py_Initialize`). Python " -"supports the creation of additional interpreters " -"(using :c:func:`Py_NewInterpreter`), but mixing multiple interpreters and " -"the ``PyGILState_*`` API is unsupported." +"supports the creation of additional interpreters (using :c:func:" +"`Py_NewInterpreter`), but mixing multiple interpreters and the " +"``PyGILState_*`` API is unsupported." msgstr "" -#: ../../c-api/init.rst:1057 +#: ../../c-api/init.rst:1043 msgid "Cautions about fork()" msgstr "" -#: ../../c-api/init.rst:1059 +#: ../../c-api/init.rst:1045 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 " @@ -1345,7 +1326,7 @@ msgid "" "CPython's runtime." msgstr "" -#: ../../c-api/init.rst:1065 +#: ../../c-api/init.rst:1051 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` " @@ -1355,14 +1336,14 @@ msgid "" "of additional (non-Python) locks that need to be acquired before or reset " "after a fork. OS facilities such as :c:func:`!pthread_atfork` would need to " "be used to accomplish the same thing. Additionally, when extending or " -"embedding Python, calling :c:func:`fork` directly rather than " -"through :func:`os.fork` (and returning to or calling into Python) may result " -"in a deadlock by one of Python's internal locks being held by a thread that " -"is defunct after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the " -"necessary locks, but is not always able to." +"embedding Python, calling :c:func:`fork` directly rather than through :func:" +"`os.fork` (and returning to or calling into Python) may result in a deadlock " +"by one of Python's internal locks being held by a thread that is defunct " +"after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the necessary " +"locks, but is not always able to." msgstr "" -#: ../../c-api/init.rst:1080 +#: ../../c-api/init.rst:1066 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 " @@ -1375,17 +1356,17 @@ msgid "" "called immediately after." msgstr "" -#: ../../c-api/init.rst:1093 +#: ../../c-api/init.rst:1079 msgid "High-level API" msgstr "高階 API" -#: ../../c-api/init.rst:1095 +#: ../../c-api/init.rst:1081 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:1100 +#: ../../c-api/init.rst:1086 msgid "" "This data structure represents the state shared by a number of cooperating " "threads. Threads belonging to the same interpreter share their module " @@ -1393,7 +1374,7 @@ msgid "" "in this structure." msgstr "" -#: ../../c-api/init.rst:1105 +#: ../../c-api/init.rst:1091 msgid "" "Threads belonging to different interpreters initially share nothing, except " "process state like available memory, open file descriptors and such. The " @@ -1401,41 +1382,41 @@ msgid "" "which interpreter they belong." msgstr "" -#: ../../c-api/init.rst:1113 +#: ../../c-api/init.rst:1099 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" -#: ../../c-api/init.rst:1118 +#: ../../c-api/init.rst:1104 msgid "This thread's interpreter state." msgstr "" -#: ../../c-api/init.rst:1129 +#: ../../c-api/init.rst:1115 msgid "Deprecated function which does nothing." msgstr "" -#: ../../c-api/init.rst:1131 +#: ../../c-api/init.rst:1117 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." msgstr "" -#: ../../c-api/init.rst:1133 +#: ../../c-api/init.rst:1119 msgid "The function now does nothing." msgstr "此函式現在不會做任何事情。" -#: ../../c-api/init.rst:1136 +#: ../../c-api/init.rst:1122 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:1140 +#: ../../c-api/init.rst:1126 msgid "" "This function cannot be called before :c:func:`Py_Initialize()` anymore." msgstr "" -#: ../../c-api/init.rst:1150 +#: ../../c-api/init.rst:1136 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 " @@ -1443,7 +1424,7 @@ msgid "" "acquired it." msgstr "" -#: ../../c-api/init.rst:1158 +#: ../../c-api/init.rst:1144 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 " @@ -1451,8 +1432,8 @@ msgid "" "ensues." msgstr "" -#: ../../c-api/init.rst:1164 ../../c-api/init.rst:1223 -#: ../../c-api/init.rst:1519 +#: ../../c-api/init.rst:1150 ../../c-api/init.rst:1210 +#: ../../c-api/init.rst:1506 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 " @@ -1461,87 +1442,92 @@ msgid "" "avoid unwanted termination." msgstr "" -#: ../../c-api/init.rst:1172 +#: ../../c-api/init.rst:1158 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:1176 +#: ../../c-api/init.rst:1162 msgid "See also :c:func:`PyThreadState_GetUnchecked`." msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" -#: ../../c-api/init.rst:1181 +#: ../../c-api/init.rst:1167 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:1185 +#: ../../c-api/init.rst:1171 msgid "" "In Python 3.5 to 3.12, the function was private and known as " "``_PyThreadState_UncheckedGet()``." msgstr "" -#: ../../c-api/init.rst:1192 +#: ../../c-api/init.rst:1178 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." +"*tstate*, which may be ``NULL``." +msgstr "" + +#: ../../c-api/init.rst:1181 +msgid "" +"The :term:`GIL` does not need to be held, but will be held upon returning if " +"*tstate* is non-``NULL``." msgstr "" -#: ../../c-api/init.rst:1197 +#: ../../c-api/init.rst:1184 msgid "" "The following functions use thread-local storage, and are not compatible " "with sub-interpreters:" msgstr "" -#: ../../c-api/init.rst:1202 +#: ../../c-api/init.rst:1189 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " "of the current state of Python, or of the global interpreter lock. This may " "be called as many times as desired by a thread as long as each call is " "matched with a call to :c:func:`PyGILState_Release`. In general, other " -"thread-related APIs may be used between :c:func:`PyGILState_Ensure` " -"and :c:func:`PyGILState_Release` calls as long as the thread state is " -"restored to its previous state before the Release(). For example, normal " -"usage of the :c:macro:`Py_BEGIN_ALLOW_THREADS` " -"and :c:macro:`Py_END_ALLOW_THREADS` macros is acceptable." +"thread-related APIs may be used between :c:func:`PyGILState_Ensure` and :c:" +"func:`PyGILState_Release` calls as long as the thread state is restored to " +"its previous state before the Release(). For example, normal usage of the :" +"c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros " +"is acceptable." msgstr "" -#: ../../c-api/init.rst:1212 +#: ../../c-api/init.rst:1199 msgid "" -"The return value is an opaque \"handle\" to the thread state " -"when :c:func:`PyGILState_Ensure` was called, and must be passed " -"to :c:func:`PyGILState_Release` to ensure Python is left in the same state. " -"Even though recursive calls are allowed, these handles *cannot* be shared - " -"each unique call to :c:func:`PyGILState_Ensure` must save the handle for its " -"call to :c:func:`PyGILState_Release`." +"The return value is an opaque \"handle\" to the thread state when :c:func:" +"`PyGILState_Ensure` was called, and must be passed to :c:func:" +"`PyGILState_Release` to ensure Python is left in the same state. Even though " +"recursive calls are allowed, these handles *cannot* be shared - each unique " +"call to :c:func:`PyGILState_Ensure` must save the handle for its call to :c:" +"func:`PyGILState_Release`." msgstr "" -#: ../../c-api/init.rst:1219 +#: ../../c-api/init.rst:1206 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:1231 +#: ../../c-api/init.rst:1218 msgid "" "Release any resources previously acquired. After this call, Python's state " -"will be the same as it was prior to the " -"corresponding :c:func:`PyGILState_Ensure` call (but generally this state " -"will be unknown to the caller, hence the use of the GILState API)." +"will be the same as it was prior to the corresponding :c:func:" +"`PyGILState_Ensure` call (but generally this state will be unknown to the " +"caller, hence the use of the GILState API)." msgstr "" -#: ../../c-api/init.rst:1236 +#: ../../c-api/init.rst:1223 msgid "" -"Every call to :c:func:`PyGILState_Ensure` must be matched by a call " -"to :c:func:`PyGILState_Release` on the same thread." +"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:1242 +#: ../../c-api/init.rst:1229 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 " @@ -1549,7 +1535,7 @@ msgid "" "made on the main thread. This is mainly a helper/diagnostic function." msgstr "" -#: ../../c-api/init.rst:1250 +#: ../../c-api/init.rst:1237 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 " @@ -1560,248 +1546,248 @@ msgid "" "otherwise behave differently." msgstr "" -#: ../../c-api/init.rst:1262 +#: ../../c-api/init.rst:1249 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:1268 +#: ../../c-api/init.rst:1255 msgid "" -"This macro expands to ``{ PyThreadState *_save; _save = " -"PyEval_SaveThread();``. Note that it contains an opening brace; it must be " -"matched with a following :c:macro:`Py_END_ALLOW_THREADS` macro. See above " -"for further discussion of this macro." +"This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();" +"``. Note that it contains an opening brace; it must be matched with a " +"following :c:macro:`Py_END_ALLOW_THREADS` macro. See above for further " +"discussion of this macro." msgstr "" -#: ../../c-api/init.rst:1276 +#: ../../c-api/init.rst:1263 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " -"contains a closing brace; it must be matched with an " -"earlier :c:macro:`Py_BEGIN_ALLOW_THREADS` macro. See above for further " -"discussion of this macro." +"contains a closing brace; it must be matched with an earlier :c:macro:" +"`Py_BEGIN_ALLOW_THREADS` macro. See above for further discussion of this " +"macro." msgstr "" -#: ../../c-api/init.rst:1284 +#: ../../c-api/init.rst:1271 msgid "" -"This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent " -"to :c:macro:`Py_END_ALLOW_THREADS` without the closing brace." +"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:1290 +#: ../../c-api/init.rst:1277 msgid "" -"This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent " -"to :c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable " +"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:1296 +#: ../../c-api/init.rst:1283 msgid "Low-level API" msgstr "低階 API" -#: ../../c-api/init.rst:1298 +#: ../../c-api/init.rst:1285 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/init.rst:1300 +#: ../../c-api/init.rst:1287 msgid ":c:func:`Py_Initialize()` now initializes the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:1306 +#: ../../c-api/init.rst:1293 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:1310 +#: ../../c-api/init.rst:1297 msgid "" -"Raises an :ref:`auditing event ` " -"``cpython.PyInterpreterState_New`` with no arguments." +"Raises an :ref:`auditing event ` ``cpython." +"PyInterpreterState_New`` with no arguments." msgstr "" -"引發一個不附帶引數的\\ :ref:`稽核事件 ` " -"``cpython.PyInterpreterState_New``。" +"引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." +"PyInterpreterState_New``。" -#: ../../c-api/init.rst:1315 +#: ../../c-api/init.rst:1302 msgid "" "Reset all information in an interpreter state object. The global " "interpreter lock must be held." msgstr "" -#: ../../c-api/init.rst:1318 +#: ../../c-api/init.rst:1305 msgid "" -"Raises an :ref:`auditing event ` " -"``cpython.PyInterpreterState_Clear`` with no arguments." +"Raises an :ref:`auditing event ` ``cpython." +"PyInterpreterState_Clear`` with no arguments." msgstr "" -"引發一個不附帶引數的\\ :ref:`稽核事件 ` " -"``cpython.PyInterpreterState_Clear``。" +"引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." +"PyInterpreterState_Clear``。" -#: ../../c-api/init.rst:1323 +#: ../../c-api/init.rst:1310 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:1330 +#: ../../c-api/init.rst:1317 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:1337 +#: ../../c-api/init.rst:1324 msgid "" "Reset all information in a thread state object. The global interpreter lock " "must be held." msgstr "" -#: ../../c-api/init.rst:1340 +#: ../../c-api/init.rst:1327 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:1344 +#: ../../c-api/init.rst:1331 msgid "The :c:member:`PyThreadState.on_delete` callback was removed." msgstr ":c:member:`PyThreadState.on_delete` 回呼已被移除。" -#: ../../c-api/init.rst:1350 +#: ../../c-api/init.rst:1337 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`." +"held. The thread state must have been reset with a previous call to :c:func:" +"`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1357 +#: ../../c-api/init.rst:1344 msgid "" "Destroy the current thread state and release the global interpreter lock. " "Like :c:func:`PyThreadState_Delete`, the global interpreter lock must be " -"held. The thread state must have been reset with a previous call " -"to :c:func:`PyThreadState_Clear`." +"held. The thread state must have been reset with a previous call to :c:func:" +"`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1365 +#: ../../c-api/init.rst:1352 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1367 +#: ../../c-api/init.rst:1354 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: ../../c-api/init.rst:1370 +#: ../../c-api/init.rst:1357 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "也請見 :c:func:`PyEval_GetFrame`。" -#: ../../c-api/init.rst:1372 ../../c-api/init.rst:1381 -#: ../../c-api/init.rst:1390 +#: ../../c-api/init.rst:1359 ../../c-api/init.rst:1368 +#: ../../c-api/init.rst:1377 msgid "*tstate* must not be ``NULL``." msgstr "*tstate* 不可為 ``NULL``。" -#: ../../c-api/init.rst:1379 +#: ../../c-api/init.rst:1366 msgid "" "Get the unique thread state identifier of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1388 +#: ../../c-api/init.rst:1375 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1397 +#: ../../c-api/init.rst:1384 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1399 +#: ../../c-api/init.rst:1386 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: ../../c-api/init.rst:1406 +#: ../../c-api/init.rst:1393 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: ../../c-api/init.rst:1409 +#: ../../c-api/init.rst:1396 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: ../../c-api/init.rst:1417 +#: ../../c-api/init.rst:1404 msgid "Get the current interpreter." msgstr "" -#: ../../c-api/init.rst:1419 +#: ../../c-api/init.rst:1406 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:1422 ../../c-api/init.rst:1432 -#: ../../c-api/init.rst:1454 +#: ../../c-api/init.rst:1409 ../../c-api/init.rst:1419 +#: ../../c-api/init.rst:1441 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/init.rst:1429 +#: ../../c-api/init.rst:1416 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:1439 +#: ../../c-api/init.rst:1426 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:1443 +#: ../../c-api/init.rst:1430 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:1451 +#: ../../c-api/init.rst:1438 msgid "" "Return a :term:`strong reference` to the ``__main__`` :ref:`module object " "` for the given interpreter." msgstr "" -#: ../../c-api/init.rst:1461 +#: ../../c-api/init.rst:1448 msgid "Type of a frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1463 +#: ../../c-api/init.rst:1450 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" -#: ../../c-api/init.rst:1466 +#: ../../c-api/init.rst:1453 msgid "The function now takes a *tstate* parameter." msgstr "" -#: ../../c-api/init.rst:1469 +#: ../../c-api/init.rst:1456 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" -#: ../../c-api/init.rst:1474 +#: ../../c-api/init.rst:1461 msgid "Get the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1476 ../../c-api/init.rst:1484 +#: ../../c-api/init.rst:1463 ../../c-api/init.rst:1471 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" -#: ../../c-api/init.rst:1482 +#: ../../c-api/init.rst:1469 msgid "Set the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1491 +#: ../../c-api/init.rst:1478 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 " @@ -1810,7 +1796,7 @@ msgid "" "raised and the caller should assume no current thread state is available." msgstr "" -#: ../../c-api/init.rst:1500 +#: ../../c-api/init.rst:1487 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. " @@ -1822,34 +1808,33 @@ msgid "" "raises no exceptions." msgstr "" -#: ../../c-api/init.rst:1508 +#: ../../c-api/init.rst:1495 msgid "" -"The type of the *id* parameter changed from :c:expr:`long` " -"to :c:expr:`unsigned long`." +"The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" +"`unsigned long`." msgstr "" -#: ../../c-api/init.rst:1514 +#: ../../c-api/init.rst:1501 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:1525 +#: ../../c-api/init.rst:1512 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." +"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:1530 +#: ../../c-api/init.rst:1517 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:1536 +#: ../../c-api/init.rst:1523 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 " @@ -1858,17 +1843,17 @@ msgid "" "isn't, a fatal error is reported." msgstr "" -#: ../../c-api/init.rst:1542 +#: ../../c-api/init.rst:1529 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:1549 +#: ../../c-api/init.rst:1536 msgid "Sub-interpreter support" msgstr "" -#: ../../c-api/init.rst:1551 +#: ../../c-api/init.rst:1538 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 " @@ -1876,7 +1861,7 @@ msgid "" "to do that." msgstr "" -#: ../../c-api/init.rst:1556 +#: ../../c-api/init.rst:1543 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -1887,134 +1872,134 @@ msgid "" "returns a pointer to its state." msgstr "" -#: ../../c-api/init.rst:1563 +#: ../../c-api/init.rst:1550 msgid "" -"You can switch between sub-interpreters using " -"the :c:func:`PyThreadState_Swap` function. You can create and destroy them " -"using the following functions:" +"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:1569 +#: ../../c-api/init.rst:1556 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:1575 +#: ../../c-api/init.rst:1562 msgid "Structure fields:" msgstr "" -#: ../../c-api/init.rst:1579 +#: ../../c-api/init.rst:1566 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:1583 +#: ../../c-api/init.rst:1570 msgid "" -"If this is ``0`` " -"then :c:member:`~PyInterpreterConfig.check_multi_interp_extensions` must be " -"``1`` (non-zero). If this is ``1`` then :c:member:`~PyInterpreterConfig.gil` " -"must not be :c:macro:`PyInterpreterConfig_OWN_GIL`." +"If this is ``0`` then :c:member:`~PyInterpreterConfig." +"check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " +"then :c:member:`~PyInterpreterConfig.gil` must not be :c:macro:" +"`PyInterpreterConfig_OWN_GIL`." msgstr "" -#: ../../c-api/init.rst:1591 +#: ../../c-api/init.rst:1578 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:1595 +#: ../../c-api/init.rst:1582 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." msgstr "" -#: ../../c-api/init.rst:1600 +#: ../../c-api/init.rst:1587 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:1605 +#: ../../c-api/init.rst:1592 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." msgstr "" -#: ../../c-api/init.rst:1610 +#: ../../c-api/init.rst:1597 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:1616 +#: ../../c-api/init.rst:1603 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)." +"create daemon threads. Otherwise daemon threads are allowed (as long as :c:" +"member:`~PyInterpreterConfig.allow_threads` is non-zero)." msgstr "" -#: ../../c-api/init.rst:1623 +#: ../../c-api/init.rst:1610 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 " -"is currently active. Otherwise only multi-phase init extension modules " -"(see :pep:`489`) may be imported. (Also " -"see :c:macro:`Py_mod_multiple_interpreters`.)" +"is currently active. Otherwise only multi-phase init extension modules (see :" +"pep:`489`) may be imported. (Also see :c:macro:" +"`Py_mod_multiple_interpreters`.)" msgstr "" -#: ../../c-api/init.rst:1630 +#: ../../c-api/init.rst:1617 msgid "" -"This must be ``1`` (non-zero) " -"if :c:member:`~PyInterpreterConfig.use_main_obmalloc` is ``0``." +"This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." +"use_main_obmalloc` is ``0``." msgstr "" -#: ../../c-api/init.rst:1635 +#: ../../c-api/init.rst:1622 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" -#: ../../c-api/init.rst:1642 +#: ../../c-api/init.rst:1629 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" -#: ../../c-api/init.rst:1646 +#: ../../c-api/init.rst:1633 msgid "Use (share) the main interpreter's GIL." msgstr "" -#: ../../c-api/init.rst:1650 +#: ../../c-api/init.rst:1637 msgid "Use the sub-interpreter's own GIL." msgstr "" -#: ../../c-api/init.rst:1652 +#: ../../c-api/init.rst:1639 msgid "" -"If this is :c:macro:`PyInterpreterConfig_OWN_GIL` " -"then :c:member:`PyInterpreterConfig.use_main_obmalloc` must be ``0``." +"If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" +"`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" -#: ../../c-api/init.rst:1666 +#: ../../c-api/init.rst:1653 msgid "" "Create a new sub-interpreter. This is an (almost) totally separate " "environment for the execution of Python code. In particular, the new " "interpreter has separate, independent versions of all imported modules, " -"including the fundamental modules :mod:`builtins`, :mod:`__main__` " -"and :mod:`sys`. The table of loaded modules (``sys.modules``) and the " -"module search path (``sys.path``) are also separate. The new environment " -"has no ``sys.argv`` variable. It has new standard I/O stream file objects " -"``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` (however these refer to the " -"same underlying file descriptors)." +"including the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:" +"`sys`. The table of loaded modules (``sys.modules``) and the module search " +"path (``sys.path``) are also separate. The new environment has no ``sys." +"argv`` variable. It has new standard I/O stream file objects ``sys.stdin``, " +"``sys.stdout`` and ``sys.stderr`` (however these refer to the same " +"underlying file descriptors)." msgstr "" -#: ../../c-api/init.rst:1676 +#: ../../c-api/init.rst:1663 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." msgstr "" -#: ../../c-api/init.rst:1679 +#: ../../c-api/init.rst:1666 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 " @@ -2025,7 +2010,7 @@ msgid "" "state." msgstr "" -#: ../../c-api/init.rst:1688 +#: ../../c-api/init.rst:1675 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. " @@ -2037,13 +2022,13 @@ msgid "" "released here." msgstr "" -#: ../../c-api/init.rst:1699 +#: ../../c-api/init.rst:1686 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" -#: ../../c-api/init.rst:1702 +#: ../../c-api/init.rst:1689 msgid "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -2075,59 +2060,58 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init.rst:1717 +#: ../../c-api/init.rst:1704 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:`PyInterpreterState` values. A read-only copy of the config " -"may be stored internally on the :c:type:`PyInterpreterState`." +"initialization the config's values are converted into various :c:type:" +"`PyInterpreterState` values. A read-only copy of the config may be stored " +"internally on the :c:type:`PyInterpreterState`." msgstr "" -#: ../../c-api/init.rst:1726 +#: ../../c-api/init.rst:1713 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" -#: ../../c-api/init.rst:1728 +#: ../../c-api/init.rst:1715 msgid "" -"For modules using multi-phase initialization, " -"e.g. :c:func:`PyModule_FromDefAndSpec`, a separate module object is created " -"and initialized for each interpreter. Only C-level static and global " -"variables are shared between these module objects." +"For modules using multi-phase initialization, e.g. :c:func:" +"`PyModule_FromDefAndSpec`, a separate module object is created and " +"initialized for each interpreter. Only C-level static and global variables " +"are shared between these module objects." msgstr "" -#: ../../c-api/init.rst:1734 +#: ../../c-api/init.rst:1721 msgid "" -"For modules using single-phase initialization, " -"e.g. :c:func:`PyModule_Create`, the first time a particular extension is " -"imported, it is initialized normally, and a (shallow) copy of its module's " -"dictionary is squirreled away. When the same extension is imported by " -"another (sub-)interpreter, a new module is initialized and filled with the " -"contents of this copy; the extension's ``init`` function is not called. " -"Objects in the module's dictionary thus end up shared across " -"(sub-)interpreters, which might cause unwanted behavior (see `Bugs and " -"caveats`_ below)." +"For modules using single-phase initialization, e.g. :c:func:" +"`PyModule_Create`, the first time a particular extension is imported, it is " +"initialized normally, and a (shallow) copy of its module's dictionary is " +"squirreled away. When the same extension is imported by another " +"(sub-)interpreter, a new module is initialized and filled with the contents " +"of this copy; the extension's ``init`` function is not called. Objects in " +"the module's dictionary thus end up shared across (sub-)interpreters, which " +"might cause unwanted behavior (see `Bugs and caveats`_ below)." msgstr "" -#: ../../c-api/init.rst:1745 +#: ../../c-api/init.rst:1732 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:`Py_FinalizeEx` and :c:func:`Py_Initialize`; in that case, " -"the extension's ``initmodule`` function *is* called again. As with multi-" -"phase initialization, this means that only C-level static and global " -"variables are shared between these modules." +"after the interpreter has been completely re-initialized by calling :c:func:" +"`Py_FinalizeEx` and :c:func:`Py_Initialize`; in that case, the extension's " +"``initmodule`` function *is* called again. As with multi-phase " +"initialization, this means that only C-level static and global variables are " +"shared between these modules." msgstr "" -#: ../../c-api/init.rst:1765 +#: ../../c-api/init.rst:1752 msgid "" -"Create a new sub-interpreter. This is essentially just a wrapper " -"around :c:func:`Py_NewInterpreterFromConfig` with a config that preserves " -"the existing behavior. The result is an unisolated sub-interpreter that " -"shares the main interpreter's GIL, allows fork/exec, allows daemon threads, " -"and allows single-phase init modules." +"Create a new sub-interpreter. This is essentially just a wrapper around :c:" +"func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " +"behavior. The result is an unisolated sub-interpreter that shares the main " +"interpreter's GIL, allows fork/exec, allows daemon threads, and allows " +"single-phase init modules." msgstr "" -#: ../../c-api/init.rst:1777 +#: ../../c-api/init.rst:1764 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 " @@ -2137,17 +2121,17 @@ msgid "" "be held before calling this function. No GIL is held when it returns." msgstr "" -#: ../../c-api/init.rst:1785 +#: ../../c-api/init.rst:1772 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" -#: ../../c-api/init.rst:1790 +#: ../../c-api/init.rst:1777 msgid "A Per-Interpreter GIL" msgstr "直譯器各別持有的 GIL" -#: ../../c-api/init.rst:1792 +#: ../../c-api/init.rst:1779 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -2159,7 +2143,7 @@ msgid "" "just using threads. (See :pep:`554`.)" msgstr "" -#: ../../c-api/init.rst:1802 +#: ../../c-api/init.rst:1789 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -2173,7 +2157,7 @@ msgid "" "builtin objects." msgstr "" -#: ../../c-api/init.rst:1813 +#: ../../c-api/init.rst:1800 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " @@ -2181,7 +2165,7 @@ msgid "" "threading, including races and hard-to-debug crashes." msgstr "" -#: ../../c-api/init.rst:1818 +#: ../../c-api/init.rst:1805 msgid "" "Aside from that, one of the main challenges of using multiple isolated " "interpreters is how to communicate between them safely (not break isolation) " @@ -2191,11 +2175,11 @@ msgid "" "sharing) data between interpreters." msgstr "" -#: ../../c-api/init.rst:1829 +#: ../../c-api/init.rst:1816 msgid "Bugs and caveats" msgstr "" -#: ../../c-api/init.rst:1831 +#: ../../c-api/init.rst:1818 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -2208,7 +2192,7 @@ msgid "" "should be avoided if possible." msgstr "" -#: ../../c-api/init.rst:1841 +#: ../../c-api/init.rst:1828 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -2217,37 +2201,37 @@ msgid "" "objects from which the above are reachable." msgstr "" -#: ../../c-api/init.rst:1847 +#: ../../c-api/init.rst:1834 msgid "" "Also note that combining this functionality with ``PyGILState_*`` APIs is " "delicate, because these APIs assume a bijection between Python thread states " "and OS-level threads, an assumption broken by the presence of sub-" "interpreters. It is highly recommended that you don't switch sub-" -"interpreters between a pair of matching :c:func:`PyGILState_Ensure` " -"and :c:func:`PyGILState_Release` calls. Furthermore, extensions (such " -"as :mod:`ctypes`) using these APIs to allow calling of Python code from non-" -"Python created threads will probably be broken when using sub-interpreters." +"interpreters between a pair of matching :c:func:`PyGILState_Ensure` and :c:" +"func:`PyGILState_Release` calls. Furthermore, extensions (such as :mod:" +"`ctypes`) using these APIs to allow calling of Python code from non-Python " +"created threads will probably be broken when using sub-interpreters." msgstr "" -#: ../../c-api/init.rst:1858 +#: ../../c-api/init.rst:1845 msgid "Asynchronous Notifications" msgstr "" -#: ../../c-api/init.rst:1860 +#: ../../c-api/init.rst:1847 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:1867 +#: ../../c-api/init.rst:1854 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:1871 +#: ../../c-api/init.rst:1858 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -2255,17 +2239,17 @@ msgid "" "these conditions met:" msgstr "" -#: ../../c-api/init.rst:1876 +#: ../../c-api/init.rst:1863 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: ../../c-api/init.rst:1877 +#: ../../c-api/init.rst:1864 msgid "" "with the main thread holding the :term:`global interpreter lock` (*func* can " "therefore use the full C API)." msgstr "" -#: ../../c-api/init.rst:1880 +#: ../../c-api/init.rst:1867 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " @@ -2273,30 +2257,30 @@ msgid "" "if the global interpreter lock is released." msgstr "" -#: ../../c-api/init.rst:1885 +#: ../../c-api/init.rst:1872 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:1888 +#: ../../c-api/init.rst:1875 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:1893 +#: ../../c-api/init.rst:1880 msgid "" "This is a low-level function, only useful for very special cases. There is " "no guarantee that *func* will be called as quick as possible. If the main " "thread is busy executing a system call, *func* won't be called before the " "system call returns. This function is generally **not** suitable for " -"calling Python code from arbitrary C threads. Instead, use " -"the :ref:`PyGILState API`." +"calling Python code from arbitrary C threads. Instead, use the :ref:" +"`PyGILState API`." msgstr "" -#: ../../c-api/init.rst:1902 +#: ../../c-api/init.rst:1889 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 " @@ -2304,18 +2288,18 @@ msgid "" "scheduled calls." msgstr "" -#: ../../c-api/init.rst:1911 +#: ../../c-api/init.rst:1898 msgid "Profiling and Tracing" msgstr "" -#: ../../c-api/init.rst:1916 +#: ../../c-api/init.rst:1903 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:1920 +#: ../../c-api/init.rst:1907 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 " @@ -2325,76 +2309,78 @@ msgid "" "reported to the Python-level trace functions in previous versions." msgstr "" -#: ../../c-api/init.rst:1930 +#: ../../c-api/init.rst:1917 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 " "the registration function as *obj*, *frame* is the frame object to which the " -"event pertains, *what* is one of the " -"constants :c:data:`PyTrace_CALL`, :c:data:`PyTrace_EXCEPTION`, :c:data:`PyTrace_LINE`, :c:data:`PyTrace_RETURN`, :c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION`, :c:data:`PyTrace_C_RETURN`, " -"or :c:data:`PyTrace_OPCODE`, and *arg* depends on the value of *what*:" +"event pertains, *what* is one of the constants :c:data:`PyTrace_CALL`, :c:" +"data:`PyTrace_EXCEPTION`, :c:data:`PyTrace_LINE`, :c:data:`PyTrace_RETURN`, :" +"c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION`, :c:data:" +"`PyTrace_C_RETURN`, or :c:data:`PyTrace_OPCODE`, and *arg* depends on the " +"value of *what*:" msgstr "" -#: ../../c-api/init.rst:1939 +#: ../../c-api/init.rst:1926 msgid "Value of *what*" msgstr "" -#: ../../c-api/init.rst:1939 +#: ../../c-api/init.rst:1926 msgid "Meaning of *arg*" msgstr "*arg* 的含義" -#: ../../c-api/init.rst:1941 +#: ../../c-api/init.rst:1928 msgid ":c:data:`PyTrace_CALL`" msgstr ":c:data:`PyTrace_CALL`" -#: ../../c-api/init.rst:1941 ../../c-api/init.rst:1946 -#: ../../c-api/init.rst:1957 +#: ../../c-api/init.rst:1928 ../../c-api/init.rst:1933 +#: ../../c-api/init.rst:1944 msgid "Always :c:data:`Py_None`." msgstr "" -#: ../../c-api/init.rst:1943 +#: ../../c-api/init.rst:1930 msgid ":c:data:`PyTrace_EXCEPTION`" msgstr ":c:data:`PyTrace_EXCEPTION`" -#: ../../c-api/init.rst:1943 +#: ../../c-api/init.rst:1930 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr "" -#: ../../c-api/init.rst:1946 +#: ../../c-api/init.rst:1933 msgid ":c:data:`PyTrace_LINE`" msgstr ":c:data:`PyTrace_LINE`" -#: ../../c-api/init.rst:1948 +#: ../../c-api/init.rst:1935 msgid ":c:data:`PyTrace_RETURN`" msgstr ":c:data:`PyTrace_RETURN`" -#: ../../c-api/init.rst:1948 +#: ../../c-api/init.rst:1935 msgid "" "Value being returned to the caller, or ``NULL`` if caused by an exception." msgstr "" -#: ../../c-api/init.rst:1951 +#: ../../c-api/init.rst:1938 msgid ":c:data:`PyTrace_C_CALL`" msgstr ":c:data:`PyTrace_C_CALL`" -#: ../../c-api/init.rst:1951 ../../c-api/init.rst:1953 -#: ../../c-api/init.rst:1955 +#: ../../c-api/init.rst:1938 ../../c-api/init.rst:1940 +#: ../../c-api/init.rst:1942 msgid "Function object being called." msgstr "被呼叫的函式物件。" -#: ../../c-api/init.rst:1953 +#: ../../c-api/init.rst:1940 msgid ":c:data:`PyTrace_C_EXCEPTION`" msgstr ":c:data:`PyTrace_C_EXCEPTION`" -#: ../../c-api/init.rst:1955 +#: ../../c-api/init.rst:1942 msgid ":c:data:`PyTrace_C_RETURN`" msgstr ":c:data:`PyTrace_C_RETURN`" -#: ../../c-api/init.rst:1957 +#: ../../c-api/init.rst:1944 msgid ":c:data:`PyTrace_OPCODE`" msgstr ":c:data:`PyTrace_OPCODE`" -#: ../../c-api/init.rst:1962 +#: ../../c-api/init.rst:1949 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 " @@ -2403,7 +2389,7 @@ msgid "" "the corresponding frame." msgstr "" -#: ../../c-api/init.rst:1971 +#: ../../c-api/init.rst:1958 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 " @@ -2415,134 +2401,133 @@ msgid "" "profiler." msgstr "" -#: ../../c-api/init.rst:1982 +#: ../../c-api/init.rst:1969 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 " -"reported. It may be disabled for a frame by " -"setting :attr:`~frame.f_trace_lines` to *0* on that frame." +"reported. It may be disabled for a frame by setting :attr:`~frame." +"f_trace_lines` to *0* on that frame." msgstr "" -#: ../../c-api/init.rst:1990 +#: ../../c-api/init.rst:1977 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:1996 +#: ../../c-api/init.rst:1983 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:2002 +#: ../../c-api/init.rst:1989 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:2008 +#: ../../c-api/init.rst:1995 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has returned." msgstr "" -#: ../../c-api/init.rst:2014 +#: ../../c-api/init.rst:2001 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 " -"event is not emitted by default: it must be explicitly requested by " -"setting :attr:`~frame.f_trace_opcodes` to *1* on the frame." +"event is not emitted by default: it must be explicitly requested by setting :" +"attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" -#: ../../c-api/init.rst:2022 +#: ../../c-api/init.rst:2009 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``. " "If the profile function needs to maintain state, using a different value for " "*obj* for each thread provides a convenient and thread-safe place to store " -"it. The profile function is called for all monitored events " -"except :c:data:`PyTrace_LINE` :c:data:`PyTrace_OPCODE` " -"and :c:data:`PyTrace_EXCEPTION`." +"it. The profile function is called for all monitored events except :c:data:" +"`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." msgstr "" -#: ../../c-api/init.rst:2029 +#: ../../c-api/init.rst:2016 msgid "See also the :func:`sys.setprofile` function." msgstr "" -#: ../../c-api/init.rst:2031 ../../c-api/init.rst:2038 -#: ../../c-api/init.rst:2057 ../../c-api/init.rst:2064 +#: ../../c-api/init.rst:2018 ../../c-api/init.rst:2025 +#: ../../c-api/init.rst:2044 ../../c-api/init.rst:2051 msgid "The caller must hold the :term:`GIL`." msgstr "呼叫者必須持有 :term:`GIL`。" -#: ../../c-api/init.rst:2035 +#: ../../c-api/init.rst:2022 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:2040 +#: ../../c-api/init.rst:2027 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:2048 +#: ../../c-api/init.rst:2035 msgid "" -"Set the tracing function to *func*. This is similar " -"to :c:func:`PyEval_SetProfile`, except the tracing function does receive " -"line-number events and per-opcode events, but does not receive any event " -"related to C function objects being called. Any trace function registered " -"using :c:func:`PyEval_SetTrace` will not " -"receive :c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION` " -"or :c:data:`PyTrace_C_RETURN` as a value for the *what* parameter." +"Set the tracing function to *func*. This is similar to :c:func:" +"`PyEval_SetProfile`, except the tracing function does receive line-number " +"events and per-opcode events, but does not receive any event related to C " +"function objects being called. Any trace function registered using :c:func:" +"`PyEval_SetTrace` will not receive :c:data:`PyTrace_C_CALL`, :c:data:" +"`PyTrace_C_EXCEPTION` or :c:data:`PyTrace_C_RETURN` as a value for the " +"*what* parameter." msgstr "" -#: ../../c-api/init.rst:2055 +#: ../../c-api/init.rst:2042 msgid "See also the :func:`sys.settrace` function." msgstr "也請見 :func:`sys.settrace` 函式。" -#: ../../c-api/init.rst:2061 +#: ../../c-api/init.rst:2048 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:2066 +#: ../../c-api/init.rst:2053 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:2072 +#: ../../c-api/init.rst:2059 msgid "Reference tracing" msgstr "" -#: ../../c-api/init.rst:2078 +#: ../../c-api/init.rst:2065 msgid "" -"The type of the trace function registered " -"using :c:func:`PyRefTracer_SetTracer`. The first parameter is a Python " -"object that has been just created (when **event** is set " -"to :c:data:`PyRefTracer_CREATE`) or about to be destroyed (when **event** is " -"set to :c:data:`PyRefTracer_DESTROY`). The **data** argument is the opaque " -"pointer that was provided when :c:func:`PyRefTracer_SetTracer` was called." +"The type of the trace function registered using :c:func:" +"`PyRefTracer_SetTracer`. The first parameter is a Python object that has " +"been just created (when **event** is set to :c:data:`PyRefTracer_CREATE`) or " +"about to be destroyed (when **event** is set to :c:data:" +"`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer that was " +"provided when :c:func:`PyRefTracer_SetTracer` was called." msgstr "" -#: ../../c-api/init.rst:2088 +#: ../../c-api/init.rst:2075 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been created." msgstr "" -#: ../../c-api/init.rst:2093 +#: ../../c-api/init.rst:2080 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been destroyed." msgstr "" -#: ../../c-api/init.rst:2098 +#: ../../c-api/init.rst:2085 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 " @@ -2551,7 +2536,7 @@ msgid "" "return ``-1`` on error." msgstr "" -#: ../../c-api/init.rst:2104 +#: ../../c-api/init.rst:2091 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 " @@ -2559,11 +2544,11 @@ msgid "" "the tracer function is called." msgstr "" -#: ../../c-api/init.rst:2109 ../../c-api/init.rst:2120 +#: ../../c-api/init.rst:2096 ../../c-api/init.rst:2107 msgid "The GIL must be held when calling this function." msgstr "" -#: ../../c-api/init.rst:2115 +#: ../../c-api/init.rst:2102 msgid "" "Get the registered reference tracer function and the value of the opaque " "data pointer that was registered when :c:func:`PyRefTracer_SetTracer` was " @@ -2571,48 +2556,48 @@ msgid "" "set the **data** pointer to NULL." msgstr "" -#: ../../c-api/init.rst:2127 +#: ../../c-api/init.rst:2114 msgid "Advanced Debugger Support" msgstr "" -#: ../../c-api/init.rst:2132 +#: ../../c-api/init.rst:2119 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: ../../c-api/init.rst:2137 +#: ../../c-api/init.rst:2124 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: ../../c-api/init.rst:2142 +#: ../../c-api/init.rst:2129 msgid "Return the main interpreter state object." msgstr "" -#: ../../c-api/init.rst:2147 +#: ../../c-api/init.rst:2134 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: ../../c-api/init.rst:2153 +#: ../../c-api/init.rst:2140 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:2159 +#: ../../c-api/init.rst:2146 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:2166 +#: ../../c-api/init.rst:2153 msgid "Thread Local Storage Support" msgstr "" -#: ../../c-api/init.rst:2170 +#: ../../c-api/init.rst:2157 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -2622,42 +2607,42 @@ msgid "" "thread." msgstr "" -#: ../../c-api/init.rst:2177 +#: ../../c-api/init.rst:2164 msgid "" "The GIL does *not* need to be held when calling these functions; they supply " "their own locking." msgstr "" -#: ../../c-api/init.rst:2180 +#: ../../c-api/init.rst:2167 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:2184 +#: ../../c-api/init.rst:2171 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 the :c:expr:`void*` values happen to be :c:expr:`PyObject*`, " -"these functions don't do refcount operations on them either." +"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 " +"the :c:expr:`void*` values happen to be :c:expr:`PyObject*`, these functions " +"don't do refcount operations on them either." msgstr "" -#: ../../c-api/init.rst:2192 +#: ../../c-api/init.rst:2179 msgid "Thread Specific Storage (TSS) API" msgstr "" -#: ../../c-api/init.rst:2194 +#: ../../c-api/init.rst:2181 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:2200 +#: ../../c-api/init.rst:2187 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" msgstr "" -#: ../../c-api/init.rst:2205 +#: ../../c-api/init.rst:2192 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 " @@ -2665,67 +2650,66 @@ msgid "" "public members in this structure." msgstr "" -#: ../../c-api/init.rst:2210 +#: ../../c-api/init.rst:2197 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:2216 +#: ../../c-api/init.rst:2203 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:2221 +#: ../../c-api/init.rst:2208 msgid "Dynamic Allocation" msgstr "" -#: ../../c-api/init.rst:2223 +#: ../../c-api/init.rst:2210 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:2230 +#: ../../c-api/init.rst:2217 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." +"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:2237 +#: ../../c-api/init.rst:2224 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:2243 +#: ../../c-api/init.rst:2230 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" -#: ../../c-api/init.rst:2248 +#: ../../c-api/init.rst:2235 msgid "Methods" msgstr "方法" -#: ../../c-api/init.rst:2250 +#: ../../c-api/init.rst:2237 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 " -"undefined if the given :c:type:`Py_tss_t` has not been initialized " -"by :c:func:`PyThread_tss_create`." +"undefined if the given :c:type:`Py_tss_t` has not been initialized by :c:" +"func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2258 +#: ../../c-api/init.rst:2245 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:2264 +#: ../../c-api/init.rst:2251 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 " @@ -2734,40 +2718,40 @@ msgid "" "no-op and immediately returns success." msgstr "" -#: ../../c-api/init.rst:2273 +#: ../../c-api/init.rst:2260 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 " -"destroyed key is able to be initialized again " -"by :c:func:`PyThread_tss_create`. This function can be called repeatedly on " -"the same key -- calling it on an already destroyed key is a no-op." +"destroyed key is able to be initialized again by :c:func:" +"`PyThread_tss_create`. This function can be called repeatedly on the same " +"key -- calling it on an already destroyed key is a no-op." msgstr "" -#: ../../c-api/init.rst:2282 +#: ../../c-api/init.rst:2269 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:2289 +#: ../../c-api/init.rst:2276 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:2297 +#: ../../c-api/init.rst:2284 msgid "Thread Local Storage (TLS) API" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../c-api/init.rst:2299 +#: ../../c-api/init.rst:2286 msgid "" "This API is superseded by :ref:`Thread Specific Storage (TSS) API `." msgstr "" -#: ../../c-api/init.rst:2304 +#: ../../c-api/init.rst:2291 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 " @@ -2776,62 +2760,62 @@ msgid "" "platforms." msgstr "" -#: ../../c-api/init.rst:2309 +#: ../../c-api/init.rst:2296 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:2320 +#: ../../c-api/init.rst:2307 msgid "Synchronization Primitives" msgstr "" -#: ../../c-api/init.rst:2322 +#: ../../c-api/init.rst:2309 msgid "The C-API provides a basic mutual exclusion lock." msgstr "" -#: ../../c-api/init.rst:2326 +#: ../../c-api/init.rst:2313 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:2329 +#: ../../c-api/init.rst:2316 msgid "PyMutex mutex = {0};" msgstr "" -#: ../../c-api/init.rst:2331 +#: ../../c-api/init.rst:2318 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:2337 +#: ../../c-api/init.rst:2324 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:2345 +#: ../../c-api/init.rst:2332 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:2353 +#: ../../c-api/init.rst:2340 msgid "" "Unlock mutex *m*. The mutex must be locked --- otherwise, the function will " "issue a fatal error." msgstr "" -#: ../../c-api/init.rst:2361 +#: ../../c-api/init.rst:2348 msgid "Python Critical Section API" msgstr "" -#: ../../c-api/init.rst:2363 +#: ../../c-api/init.rst:2350 msgid "" "The critical section API provides a deadlock avoidance layer on top of per-" "object locks for :term:`free-threaded ` CPython. They are " @@ -2839,18 +2823,17 @@ msgid "" "no-ops in versions of Python with the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:2368 +#: ../../c-api/init.rst:2355 msgid "" "Critical sections avoid deadlocks by implicitly suspending active critical " -"sections and releasing the locks during calls " -"to :c:func:`PyEval_SaveThread`. When :c:func:`PyEval_RestoreThread` is " -"called, the most recent critical section is resumed, and its locks " -"reacquired. This means the critical section API provides weaker guarantees " -"than traditional locks -- they are useful because their behavior is similar " -"to the :term:`GIL`." +"sections and releasing the locks during calls to :c:func:" +"`PyEval_SaveThread`. When :c:func:`PyEval_RestoreThread` is called, the most " +"recent critical section is resumed, and its locks reacquired. This means " +"the critical section API provides weaker guarantees than traditional locks " +"-- they are useful because their behavior is similar to the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:2375 +#: ../../c-api/init.rst:2362 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 " @@ -2858,20 +2841,20 @@ msgid "" "future Python versions." msgstr "" -#: ../../c-api/init.rst:2382 +#: ../../c-api/init.rst:2369 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 lock more than one object at once, because the inner critical " -"section may suspend the outer critical sections. This API does not provide " -"a way to lock more than two objects at once." +"Operations that need to lock two objects at once must use :c:macro:" +"`Py_BEGIN_CRITICAL_SECTION2`. You *cannot* use nested critical sections to " +"lock more than one object at once, because the inner critical section may " +"suspend the outer critical sections. This API does not provide a way to " +"lock more than two objects at once." msgstr "" -#: ../../c-api/init.rst:2388 +#: ../../c-api/init.rst:2375 msgid "Example usage::" msgstr "" -#: ../../c-api/init.rst:2390 +#: ../../c-api/init.rst:2377 msgid "" "static PyObject *\n" "set_field(MyObject *self, PyObject *value)\n" @@ -2883,71 +2866,71 @@ msgid "" "}" msgstr "" -#: ../../c-api/init.rst:2399 +#: ../../c-api/init.rst:2386 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 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`." +"if the code triggered by the finalizer blocks and calls :c:func:" +"`PyEval_SaveThread`." msgstr "" -#: ../../c-api/init.rst:2407 +#: ../../c-api/init.rst:2394 msgid "" "Acquires the per-object lock for the object *op* and begins a critical " "section." msgstr "" -#: ../../c-api/init.rst:2410 ../../c-api/init.rst:2424 -#: ../../c-api/init.rst:2439 ../../c-api/init.rst:2453 +#: ../../c-api/init.rst:2397 ../../c-api/init.rst:2411 +#: ../../c-api/init.rst:2426 ../../c-api/init.rst:2440 msgid "In the free-threaded build, this macro expands to::" msgstr "" -#: ../../c-api/init.rst:2412 +#: ../../c-api/init.rst:2399 msgid "" "{\n" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" msgstr "" -#: ../../c-api/init.rst:2416 ../../c-api/init.rst:2445 +#: ../../c-api/init.rst:2403 ../../c-api/init.rst:2432 msgid "In the default build, this macro expands to ``{``." msgstr "" -#: ../../c-api/init.rst:2422 +#: ../../c-api/init.rst:2409 msgid "Ends the critical section and releases the per-object lock." msgstr "" -#: ../../c-api/init.rst:2426 +#: ../../c-api/init.rst:2413 msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" msgstr "" -#: ../../c-api/init.rst:2429 ../../c-api/init.rst:2458 +#: ../../c-api/init.rst:2416 ../../c-api/init.rst:2445 msgid "In the default build, this macro expands to ``}``." msgstr "" -#: ../../c-api/init.rst:2435 +#: ../../c-api/init.rst:2422 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:2441 +#: ../../c-api/init.rst:2428 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" msgstr "" -#: ../../c-api/init.rst:2451 +#: ../../c-api/init.rst:2438 msgid "Ends the critical section and releases the per-object locks." msgstr "" -#: ../../c-api/init.rst:2455 +#: ../../c-api/init.rst:2442 msgid "" " PyCriticalSection2_End(&_py_cs2);\n" "}" @@ -2961,147 +2944,147 @@ msgstr "PyEval_InitThreads()" msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../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 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 ../../c-api/init.rst:1131 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "module" msgstr "模組" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "__main__" msgstr "__main__" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "sys" msgstr "sys" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:696 msgid "path" msgstr "path(路徑)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1722 ../../c-api/init.rst:1775 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1709 ../../c-api/init.rst:1762 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/init.rst:576 +#: ../../c-api/init.rst:562 msgid "Py_Initialize()" msgstr "Py_Initialize()" -#: ../../c-api/init.rst:576 ../../c-api/init.rst:808 +#: ../../c-api/init.rst:562 ../../c-api/init.rst:794 msgid "main()" msgstr "main()" -#: ../../c-api/init.rst:576 +#: ../../c-api/init.rst:562 msgid "Py_GetPath()" msgstr "Py_GetPath()" -#: ../../c-api/init.rst:689 +#: ../../c-api/init.rst:675 msgid "executable (in module sys)" msgstr "executable(sys 模組中)" -#: ../../c-api/init.rst:743 ../../c-api/init.rst:785 ../../c-api/init.rst:799 +#: ../../c-api/init.rst:729 ../../c-api/init.rst:771 ../../c-api/init.rst:785 msgid "version (in module sys)" msgstr "version(sys 模組中)" -#: ../../c-api/init.rst:755 +#: ../../c-api/init.rst:741 msgid "platform (in module sys)" msgstr "platform(sys 模組中)" -#: ../../c-api/init.rst:772 +#: ../../c-api/init.rst:758 msgid "copyright (in module sys)" msgstr "copyright(sys 模組中)" -#: ../../c-api/init.rst:808 +#: ../../c-api/init.rst:794 msgid "Py_FatalError()" msgstr "Py_FatalError()" -#: ../../c-api/init.rst:808 +#: ../../c-api/init.rst:794 msgid "argv (in module sys)" msgstr "argv(sys 模組中)" -#: ../../c-api/init.rst:928 +#: ../../c-api/init.rst:914 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../c-api/init.rst:928 +#: ../../c-api/init.rst:914 msgid "interpreter lock" msgstr "interpreter lock(直譯器鎖)" -#: ../../c-api/init.rst:928 +#: ../../c-api/init.rst:914 msgid "lock, interpreter" msgstr "lock, interpreter(鎖、直譯器)" -#: ../../c-api/init.rst:941 +#: ../../c-api/init.rst:927 msgid "setswitchinterval (in module sys)" msgstr "setswitchinterval (sys 模組中)" -#: ../../c-api/init.rst:950 +#: ../../c-api/init.rst:936 msgid "PyThreadState (C type)" msgstr "PyThreadState(C 型別)" -#: ../../c-api/init.rst:976 +#: ../../c-api/init.rst:962 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" msgstr "Py_BEGIN_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:976 +#: ../../c-api/init.rst:962 msgid "Py_END_ALLOW_THREADS (C macro)" msgstr "Py_END_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:992 +#: ../../c-api/init.rst:978 msgid "PyEval_RestoreThread (C function)" msgstr "PyEval_RestoreThread(C 函式)" -#: ../../c-api/init.rst:992 +#: ../../c-api/init.rst:978 msgid "PyEval_SaveThread (C function)" msgstr "PyEval_SaveThread(C 函式)" -#: ../../c-api/init.rst:1123 +#: ../../c-api/init.rst:1109 msgid "PyEval_AcquireThread()" msgstr "PyEval_AcquireThread()" -#: ../../c-api/init.rst:1123 +#: ../../c-api/init.rst:1109 msgid "PyEval_ReleaseThread()" msgstr "PyEval_ReleaseThread()" -#: ../../c-api/init.rst:1123 +#: ../../c-api/init.rst:1109 msgid "PyEval_SaveThread()" msgstr "PyEval_SaveThread()" -#: ../../c-api/init.rst:1123 +#: ../../c-api/init.rst:1109 msgid "PyEval_RestoreThread()" msgstr "PyEval_RestoreThread()" -#: ../../c-api/init.rst:1145 +#: ../../c-api/init.rst:1131 msgid "_thread" msgstr "_thread" -#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "stdout (in module sys)" msgstr "stdout(sys 模組中)" -#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "stderr (in module sys)" msgstr "stderr(sys 模組中)" -#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:1645 ../../c-api/init.rst:1744 msgid "stdin (in module sys)" msgstr "stdin(sys 模組中)" -#: ../../c-api/init.rst:1722 +#: ../../c-api/init.rst:1709 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/init.rst:1752 +#: ../../c-api/init.rst:1739 msgid "close (in module os)" msgstr "close(os 模組中)" diff --git a/c-api/intro.po b/c-api/intro.po index f246ab03ee..12be45bb91 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-25 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -32,8 +32,8 @@ msgid "" "API. The first reason is to write *extension modules* for specific purposes; " "these are C modules that extend the Python interpreter. This is probably " "the most common use. The second reason is to use Python as a component in a " -"larger application; this technique is generally referred to " -"as :dfn:`embedding` Python in an application." +"larger application; this technique is generally referred to as :dfn:" +"`embedding` Python in an application." msgstr "" "對於 Python 的應用程式開發介面使得 C 和 C++ 開發者能夠在各種層級存取 Python " "直譯器。該 API 同樣可用於 C++,但為簡潔起見,通常將其稱為 Python/C API。使用 " @@ -105,8 +105,8 @@ msgstr "" #: ../../c-api/intro.rst:54 msgid "" "This implies inclusion of the following standard headers: ````, " -"````, ````, ````, ```` and " -"```` (if available)." +"````, ````, ````, ```` and ```` (if available)." msgstr "" "這意味著會引入以下標準標頭:````、````、````、" "````、```` 和 ````\\ (如果可用)。" @@ -154,17 +154,17 @@ msgstr "" #: ../../c-api/intro.rst:79 msgid "" "The header files are typically installed with Python. On Unix, these are " -"located in the directories :file:`{prefix}/include/pythonversion/` " -"and :file:`{exec_prefix}/include/pythonversion/`, where :option:`prefix <--" -"prefix>` and :option:`exec_prefix <--exec-prefix>` are defined by the " -"corresponding parameters to Python's :program:`configure` script and " -"*version* is ``'%d.%d' % sys.version_info[:2]``. On Windows, the headers " -"are installed in :file:`{prefix}/include`, where ``prefix`` is the " -"installation directory specified to the installer." +"located in the directories :file:`{prefix}/include/pythonversion/` and :file:" +"`{exec_prefix}/include/pythonversion/`, where :option:`prefix <--prefix>` " +"and :option:`exec_prefix <--exec-prefix>` are defined by the corresponding " +"parameters to Python's :program:`configure` script and *version* is ``'%d." +"%d' % sys.version_info[:2]``. On Windows, the headers are installed in :" +"file:`{prefix}/include`, where ``prefix`` is the installation directory " +"specified to the installer." msgstr "" "標頭檔通常隨 Python 一起安裝。在 Unix 上它們位於目錄 :file:`{prefix}/include/" -"pythonversion/` 和 :file:`{exec_prefix}/include/pythonversion/`,其" -"中 :option:`prefix <--prefix>` 和 :option:`exec_prefix <--exec-prefix>` 由 " +"pythonversion/` 和 :file:`{exec_prefix}/include/pythonversion/`,其中 :" +"option:`prefix <--prefix>` 和 :option:`exec_prefix <--exec-prefix>` 由 " "Python 的 :program:`configure` 腳本的相應參數定義,*version* 是 ``'%d.%d' % " "sys.version_info[:2]``。在 Windows 上,標頭安裝在 :file:`{prefix}/include` " "中,其中 ``prefix`` 是指定給安裝程式 (installer) 用的安裝目錄。" @@ -174,14 +174,14 @@ msgid "" "To include the headers, place both directories (if different) on your " "compiler's search path for includes. Do *not* place the parent directories " "on the search path and then use ``#include ``; this will " -"break on multi-platform builds since the platform independent headers " -"under :option:`prefix <--prefix>` include the platform specific headers " -"from :option:`exec_prefix <--exec-prefix>`." +"break on multi-platform builds since the platform independent headers under :" +"option:`prefix <--prefix>` include the platform specific headers from :" +"option:`exec_prefix <--exec-prefix>`." msgstr "" "要引入標頭,請將兩個(如果不同)目錄放在編譯器的引入搜尋路徑 (search path) " -"中。*不要*\\ 將父目錄放在搜尋路徑上,然後使用 ``#include ``;這會在多平台建置上壞掉,因為 :option:`prefix <--prefix>` 下獨立" -"於平台的標頭包括來自 :option:`exec_prefix <--exec-prefix>` 的平台特定標頭。" +"中。*不要*\\ 將父目錄放在搜尋路徑上,然後使用 ``#include ``;這會在多平台建置上壞掉,因為 :option:`prefix <--prefix>` 下獨立於平台的" +"標頭包括來自 :option:`exec_prefix <--exec-prefix>` 的平台特定標頭。" #: ../../c-api/intro.rst:95 msgid "" @@ -203,9 +203,8 @@ msgid "" "Others of a more general utility are defined here. This is not necessarily " "a complete listing." msgstr "" -"Python 標頭檔中定義了幾個有用的巨集,大多被定義在它們有用的地方附近(例" -"如 :c:macro:`Py_RETURN_NONE`),其他是更通用的工具程式。以下並不一定是完整的" -"列表。" +"Python 標頭檔中定義了幾個有用的巨集,大多被定義在它們有用的地方附近(例如 :c:" +"macro:`Py_RETURN_NONE`),其他是更通用的工具程式。以下並不一定是完整的列表。" #: ../../c-api/intro.rst:110 msgid "" @@ -225,7 +224,7 @@ msgstr "" #: ../../c-api/intro.rst:119 msgid "" "static struct PyModuleDef spam_module = {\n" -" PyModuleDef_HEAD_INIT,\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"spam\",\n" " ...\n" "};\n" @@ -233,11 +232,11 @@ msgid "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spam_module);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" msgstr "" "static struct PyModuleDef spam_module = {\n" -" PyModuleDef_HEAD_INIT,\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"spam\",\n" " ...\n" "};\n" @@ -245,7 +244,7 @@ msgstr "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spam_module);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" #: ../../c-api/intro.rst:134 @@ -280,13 +279,12 @@ msgstr "" #: ../../c-api/intro.rst:151 msgid "" -"If Python is :ref:`built in debug mode ` (if " -"the :c:macro:`Py_DEBUG` macro is defined), the :c:macro:`Py_ALWAYS_INLINE` " -"macro does nothing." +"If Python is :ref:`built in debug mode ` (if the :c:macro:" +"`Py_DEBUG` macro is defined), the :c:macro:`Py_ALWAYS_INLINE` macro does " +"nothing." msgstr "" -"如果 Python 是\\ :ref:`在除錯模式下建置 `\\ (如" -"果 :c:macro:`Py_DEBUG` 巨集有被定義),:c:macro:`Py_ALWAYS_INLINE` 巨集就什麼" -"都不會做。" +"如果 Python 是\\ :ref:`在除錯模式下建置 `\\ (如果 :c:macro:" +"`Py_DEBUG` 巨集有被定義),:c:macro:`Py_ALWAYS_INLINE` 巨集就什麼都不會做。" #: ../../c-api/intro.rst:154 msgid "It must be specified before the function return type. Usage::" @@ -346,8 +344,8 @@ msgstr "回傳 ``x`` 和 ``y`` 之間的最小值。" #: ../../c-api/intro.rst:202 msgid "" "Disable inlining on a function. For example, it reduces the C stack " -"consumption: useful on LTO+PGO builds which heavily inline code " -"(see :issue:`33720`)." +"consumption: useful on LTO+PGO builds which heavily inline code (see :issue:" +"`33720`)." msgstr "" "禁用函式的嵌入。例如,它減少了 C 堆疊的消耗:對大量嵌入程式碼的 LTO+PGO 建置" "很有用(請參閱 :issue:`33720`)。" @@ -392,8 +390,8 @@ msgid "" "A use for ``Py_UNREACHABLE()`` is following a call a function that never " "returns but that is not declared :c:macro:`_Py_NO_RETURN`." msgstr "" -"``Py_UNREACHABLE()`` 的一個用途是,在對一個永不回傳但並未聲明" -"為 :c:macro:`_Py_NO_RETURN` 的函式之呼叫後使用。" +"``Py_UNREACHABLE()`` 的一個用途是,在對一個永不回傳但並未聲明為 :c:macro:" +"`_Py_NO_RETURN` 的函式之呼叫後使用。" #: ../../c-api/intro.rst:233 msgid "" @@ -477,9 +475,9 @@ msgid "" "are treated the same way by the Python language in most situations (e.g., " "assignments, scope rules, and argument passing), it is only fitting that " "they should be represented by a single C type. Almost all Python objects " -"live on the heap: you never declare an automatic or static variable of " -"type :c:type:`PyObject`, only pointer variables of type :c:expr:`PyObject*` " -"can be declared. The sole exception are the type objects; since these must " +"live on the heap: you never declare an automatic or static variable of type :" +"c:type:`PyObject`, only pointer variables of type :c:expr:`PyObject*` can " +"be declared. The sole exception are the type objects; since these must " "never be deallocated, they are typically static :c:type:`PyTypeObject` " "objects." msgstr "" @@ -494,20 +492,19 @@ msgstr "" #: ../../c-api/intro.rst:301 msgid "" -"All Python objects (even Python integers) have a :dfn:`type` and " -"a :dfn:`reference count`. An object's type determines what kind of object " -"it is (e.g., an integer, a list, or a user-defined function; there are many " -"more as explained in :ref:`types`). For each of the well-known types there " -"is a macro to check whether an object is of that type; for instance, " +"All Python objects (even Python integers) have a :dfn:`type` and a :dfn:" +"`reference count`. An object's type determines what kind of object it is (e." +"g., an integer, a list, or a user-defined function; there are many more as " +"explained in :ref:`types`). For each of the well-known types there is a " +"macro to check whether an object is of that type; for instance, " "``PyList_Check(a)`` is true if (and only if) the object pointed to by *a* is " "a Python list." msgstr "" "所有 Python 物件(甚至是 Python 整數)都有一個型別 (:dfn:`type`) 和一個參照計" "數 (:dfn:`reference count`)。一個物件的型別決定了它是什麼種類的物件(例如一個" -"整數、一個 list 或一個使用者定義的函式;還有更多型別,請見" -"\\ :ref:`types`\\ )。對於每個眾所周知的型別,都有一個巨集來檢查物件是否屬於" -"該型別;例如,若(且唯若)*a* 指向的物件是 Python list 時," -"``PyList_Check(a)`` 為真。" +"整數、一個 list 或一個使用者定義的函式;還有更多型別,請見\\ :ref:" +"`types`\\ )。對於每個眾所周知的型別,都有一個巨集來檢查物件是否屬於該型別;" +"例如,若(且唯若)*a* 指向的物件是 Python list 時,``PyList_Check(a)`` 為真。" #: ../../c-api/intro.rst:312 msgid "Reference Counts" @@ -541,18 +538,18 @@ msgid "" "Reference counts are always manipulated explicitly. The normal way is to " "use the macro :c:func:`Py_INCREF` to take a new reference to an object (i.e. " "increment its reference count by one), and :c:func:`Py_DECREF` to release " -"that reference (i.e. decrement the reference count by one). " -"The :c:func:`Py_DECREF` macro is considerably more complex than the incref " -"one, since it must check whether the reference count becomes zero and then " -"cause the object's deallocator to be called. The deallocator is a function " -"pointer contained in the object's type structure. The type-specific " -"deallocator takes care of releasing references for other objects contained " -"in the object if this is a compound object type, such as a list, as well as " -"performing any additional finalization that's needed. There's no chance " -"that the reference count can overflow; at least as many bits are used to " -"hold the reference count as there are distinct memory locations in virtual " -"memory (assuming ``sizeof(Py_ssize_t) >= sizeof(void*)``). Thus, the " -"reference count increment is a simple operation." +"that reference (i.e. decrement the reference count by one). The :c:func:" +"`Py_DECREF` macro is considerably more complex than the incref one, since it " +"must check whether the reference count becomes zero and then cause the " +"object's deallocator to be called. The deallocator is a function pointer " +"contained in the object's type structure. The type-specific deallocator " +"takes care of releasing references for other objects contained in the object " +"if this is a compound object type, such as a list, as well as performing any " +"additional finalization that's needed. There's no chance that the reference " +"count can overflow; at least as many bits are used to hold the reference " +"count as there are distinct memory locations in virtual memory (assuming " +"``sizeof(Py_ssize_t) >= sizeof(void*)``). Thus, the reference count " +"increment is a simple operation." msgstr "" "參照計數總是被明確地操作。正常的方法是使用巨集 :c:func:`Py_INCREF` 來取得對於" "物件的參照(即參照計數加一),並使用巨集 :c:func:`Py_DECREF` 來釋放參照(即將" @@ -597,8 +594,8 @@ msgid "" "conceivably remove the object from the list, releasing that reference, and " "possibly deallocating it. The real danger is that innocent-looking " "operations may invoke arbitrary Python code which could do this; there is a " -"code path which allows control to flow back to the user from " -"a :c:func:`Py_DECREF`, so almost any operation is potentially dangerous." +"code path which allows control to flow back to the user from a :c:func:" +"`Py_DECREF`, so almost any operation is potentially dangerous." msgstr "" "然而,一個常見的陷阱是從一個 list 中提取一個物件並保留它一段時間而不取得其參" "照。某些其他操作可能會從列表中刪除該物件,減少其參照計數並可能取消分配它。真" @@ -633,22 +630,22 @@ msgid "" "shared). \"Owning a reference\" means being responsible for calling " "Py_DECREF on it when the reference is no longer needed. Ownership can also " "be transferred, meaning that the code that receives ownership of the " -"reference then becomes responsible for eventually releasing it by " -"calling :c:func:`Py_DECREF` or :c:func:`Py_XDECREF` when it's no longer " -"needed---or passing on this responsibility (usually to its caller). When a " -"function passes ownership of a reference on to its caller, the caller is " -"said to receive a *new* reference. When no ownership is transferred, the " -"caller is said to *borrow* the reference. Nothing needs to be done for " -"a :term:`borrowed reference`." +"reference then becomes responsible for eventually releasing it by calling :c:" +"func:`Py_DECREF` or :c:func:`Py_XDECREF` when it's no longer needed---or " +"passing on this responsibility (usually to its caller). When a function " +"passes ownership of a reference on to its caller, the caller is said to " +"receive a *new* reference. When no ownership is transferred, the caller is " +"said to *borrow* the reference. Nothing needs to be done for a :term:" +"`borrowed reference`." msgstr "" "Python/C API 中函式的參照計數行為最好用\\ *參照的所有權*\\ 來解釋。所有權附屬" "於參照而非物件(物件並非被擁有,它們總是共享的)。「擁有參照」意味著當不再需" "要該參照時,負責在其上呼叫 Py_DECREF。所有權也可以轉移,這意味著接收參照所有" -"權的程式碼最終會負責在不需要參照時透過呼叫 :c:func:`Py_DECREF` " -"或 :c:func:`Py_XDECREF` 釋放參照 --- 或者將這個責任再傳遞出去(通常是給它的呼" -"叫者)。當一個函式將參照的所有權傳遞給它的呼叫者時,呼叫者被稱為接收到一個\\ " -"*新*\\ 參照。當沒有所有權轉移時,呼叫者被稱為\\ *借用*\\ 參照。如果是" -"\\ :term:`借用參照 `\\ 就不需要做任何事情。" +"權的程式碼最終會負責在不需要參照時透過呼叫 :c:func:`Py_DECREF` 或 :c:func:" +"`Py_XDECREF` 釋放參照 --- 或者將這個責任再傳遞出去(通常是給它的呼叫者)。當" +"一個函式將參照的所有權傳遞給它的呼叫者時,呼叫者被稱為接收到一個\\ *新*\\ 參" +"照。當沒有所有權轉移時,呼叫者被稱為\\ *借用*\\ 參照。如果是\\ :term:`借用參" +"照 `\\ 就不需要做任何事情。" #: ../../c-api/intro.rst:397 msgid "" @@ -664,20 +661,20 @@ msgstr "" #: ../../c-api/intro.rst:407 msgid "" -"Few functions steal references; the two notable exceptions " -"are :c:func:`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a " -"reference to the item (but not to the tuple or list into which the item is " -"put!). These functions were designed to steal a reference because of a " -"common idiom for populating a tuple or list with newly created objects; for " -"example, the code to create the tuple ``(1, 2, \"three\")`` could look like " -"this (forgetting about error handling for the moment; a better way to code " -"this is shown below)::" -msgstr "" -"很少有函式會竊取參照;兩個值得注意的例外是 :c:func:`PyList_SetItem` " -"和 :c:func:`PyTuple_SetItem`,它們竊取了對項目的參照(但不是對項目所在的 " -"tuple 或 list 的參照!)。因為有著使用新建立的物件來增加 (populate) tuple 或 " -"list 的習慣,這些函式旨在竊取參照;例如,建立 tuple ``(1, 2, \"three\")`` 的" -"程式碼可以如下所示(先暫時忘記錯誤處理;更好的編寫方式如下所示):" +"Few functions steal references; the two notable exceptions are :c:func:" +"`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a reference to " +"the item (but not to the tuple or list into which the item is put!). These " +"functions were designed to steal a reference because of a common idiom for " +"populating a tuple or list with newly created objects; for example, the code " +"to create the tuple ``(1, 2, \"three\")`` could look like this (forgetting " +"about error handling for the moment; a better way to code this is shown " +"below)::" +msgstr "" +"很少有函式會竊取參照;兩個值得注意的例外是 :c:func:`PyList_SetItem` 和 :c:" +"func:`PyTuple_SetItem`,它們竊取了對項目的參照(但不是對項目所在的 tuple 或 " +"list 的參照!)。因為有著使用新建立的物件來增加 (populate) tuple 或 list 的習" +"慣,這些函式旨在竊取參照;例如,建立 tuple ``(1, 2, \"three\")`` 的程式碼可以" +"如下所示(先暫時忘記錯誤處理;更好的編寫方式如下所示):" #: ../../c-api/intro.rst:415 msgid "" @@ -702,26 +699,26 @@ msgid "" "although the reference to it will be stolen, use :c:func:`Py_INCREF` to grab " "another reference before calling the reference-stealing function." msgstr "" -"這裡 :c:func:`PyLong_FromLong` 會回傳一個新的參照,它立即" -"被 :c:func:`PyTuple_SetItem` 竊取。如果你想繼續使用一個物件,儘管對它的參照將" -"被竊取,請在呼叫參照竊取函式之前使用 :c:func:`Py_INCREF` 來取得另一個參照。" +"這裡 :c:func:`PyLong_FromLong` 會回傳一個新的參照,它立即被 :c:func:" +"`PyTuple_SetItem` 竊取。如果你想繼續使用一個物件,儘管對它的參照將被竊取,請" +"在呼叫參照竊取函式之前使用 :c:func:`Py_INCREF` 來取得另一個參照。" #: ../../c-api/intro.rst:427 msgid "" "Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple " "items; :c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to " -"do this since tuples are an immutable data type. You should only " -"use :c:func:`PyTuple_SetItem` for tuples that you are creating yourself." +"do this since tuples are an immutable data type. You should only use :c:" +"func:`PyTuple_SetItem` for tuples that you are creating yourself." msgstr "" -"附帶地說,:c:func:`PyTuple_SetItem` 是設定 tuple 項目的\\ *唯一*\\ 方" -"法; :c:func:`PySequence_SetItem` 和 :c:func:`PyObject_SetItem` 拒絕這樣做," -"因為 tuple 是一種不可變 (immutable) 的資料型別。你應該只對你自己建立的 tuple " -"使用 :c:func:`PyTuple_SetItem`。" +"附帶地說,:c:func:`PyTuple_SetItem` 是設定 tuple 項目的\\ *唯一*\\ 方法; :c:" +"func:`PySequence_SetItem` 和 :c:func:`PyObject_SetItem` 拒絕這樣做,因為 " +"tuple 是一種不可變 (immutable) 的資料型別。你應該只對你自己建立的 tuple 使" +"用 :c:func:`PyTuple_SetItem`。" #: ../../c-api/intro.rst:432 msgid "" -"Equivalent code for populating a list can be written " -"using :c:func:`PyList_New` and :c:func:`PyList_SetItem`." +"Equivalent code for populating a list can be written using :c:func:" +"`PyList_New` and :c:func:`PyList_SetItem`." msgstr "" "可以使用 :c:func:`PyList_New` 和 :c:func:`PyList_SetItem` 編寫用於填充列表的" "等效程式碼。" @@ -729,11 +726,10 @@ msgstr "" #: ../../c-api/intro.rst:435 msgid "" "However, in practice, you will rarely use these ways of creating and " -"populating a tuple or list. There's a generic " -"function, :c:func:`Py_BuildValue`, that can create most common objects from " -"C values, directed by a :dfn:`format string`. For example, the above two " -"blocks of code could be replaced by the following (which also takes care of " -"the error checking)::" +"populating a tuple or list. There's a generic function, :c:func:" +"`Py_BuildValue`, that can create most common objects from C values, directed " +"by a :dfn:`format string`. For example, the above two blocks of code could " +"be replaced by the following (which also takes care of the error checking)::" msgstr "" "但是在實際操作中你很少會使用這些方法來建立和增加 tuple 和 list。有一個通用函" "式 :c:func:`Py_BuildValue` 可以從 C 值建立最常見的物件,由 :dfn:`format " @@ -851,8 +847,8 @@ msgid "" "of the items in a list of integers; once using :c:func:`PyList_GetItem`, " "and once using :c:func:`PySequence_GetItem`. ::" msgstr "" -"以下是一個範例,說明如何編寫函式來計算一個整數 list 中項目的總和;一次使" -"用 :c:func:`PyList_GetItem`,一次使用 :c:func:`PySequence_GetItem`: ::" +"以下是一個範例,說明如何編寫函式來計算一個整數 list 中項目的總和;一次使用 :" +"c:func:`PyList_GetItem`,一次使用 :c:func:`PySequence_GetItem`: ::" #: ../../c-api/intro.rst:501 msgid "" @@ -917,12 +913,12 @@ msgstr "型別" #: ../../c-api/intro.rst:563 msgid "" "There are few other data types that play a significant role in the Python/C " -"API; most are simple C types such " -"as :c:expr:`int`, :c:expr:`long`, :c:expr:`double` and :c:expr:`char*`. A " -"few structure types are used to describe static tables used to list the " -"functions exported by a module or the data attributes of a new object type, " -"and another is used to describe the value of a complex number. These will " -"be discussed together with the functions that use them." +"API; most are simple C types such as :c:expr:`int`, :c:expr:`long`, :c:expr:" +"`double` and :c:expr:`char*`. A few structure types are used to describe " +"static tables used to list the functions exported by a module or the data " +"attributes of a new object type, and another is used to describe the value " +"of a complex number. These will be discussed together with the functions " +"that use them." msgstr "" "有少數幾個其他的資料型別在 Python/C API 中發揮重要作用;大多數是簡單的 C 型" "別,例如 :c:expr:`int`、:c:expr:`long`、:c:expr:`double` 和 :c:expr:`char*`。" @@ -937,8 +933,8 @@ msgid "" "positive value of type :c:type:`Py_ssize_t`." msgstr "" "一個帶符號的整數型別,使得 ``sizeof(Py_ssize_t) == sizeof(size_t)``。 C99 沒" -"有直接定義這樣的東西(size_t 是無符號整數型別)。有關詳細資訊,請參" -"閱 :pep:`353`。 ``PY_SSIZE_T_MAX`` 是 :c:type:`Py_ssize_t` 型別的最大正值。" +"有直接定義這樣的東西(size_t 是無符號整數型別)。有關詳細資訊,請參閱 :pep:" +"`353`。 ``PY_SSIZE_T_MAX`` 是 :c:type:`Py_ssize_t` 型別的最大正值。" #: ../../c-api/intro.rst:582 msgid "Exceptions" @@ -982,32 +978,32 @@ msgstr "" msgid "" "Exception state is maintained in per-thread storage (this is equivalent to " "using global storage in an unthreaded application). A thread can be in one " -"of two states: an exception has occurred, or not. The " -"function :c:func:`PyErr_Occurred` can be used to check for this: it returns " -"a borrowed reference to the exception type object when an exception has " -"occurred, and ``NULL`` otherwise. There are a number of functions to set " -"the exception state: :c:func:`PyErr_SetString` is the most common (though " -"not the most general) function to set the exception state, " -"and :c:func:`PyErr_Clear` clears the exception state." +"of two states: an exception has occurred, or not. The function :c:func:" +"`PyErr_Occurred` can be used to check for this: it returns a borrowed " +"reference to the exception type object when an exception has occurred, and " +"``NULL`` otherwise. There are a number of functions to set the exception " +"state: :c:func:`PyErr_SetString` is the most common (though not the most " +"general) function to set the exception state, and :c:func:`PyErr_Clear` " +"clears the exception state." msgstr "" "例外的狀態會在個別執行緒的存儲空間 (per-thread storage) 中維護(這相當於在非" "執行緒應用程式中使用全域存儲空間)。執行緒可以處於兩種狀態之一:發生例外或未" "發生例外。函式 :c:func:`PyErr_Occurred` 可用於檢查這一點:當例外發生時,它回" -"傳對例外型別物件的借用參照,否則回傳 ``NULL``。設定例外狀態的函式有很" -"多::c:func:`PyErr_SetString` 是最常見的(儘管不是最通用的)設定例外狀態的函" -"式,而 :c:func:`PyErr_Clear` 是用來清除例外狀態。" +"傳對例外型別物件的借用參照,否則回傳 ``NULL``。設定例外狀態的函式有很多::c:" +"func:`PyErr_SetString` 是最常見的(儘管不是最通用的)設定例外狀態的函式,而 :" +"c:func:`PyErr_Clear` 是用來清除例外狀態。" #: ../../c-api/intro.rst:617 msgid "" "The full exception state consists of three objects (all of which can be " "``NULL``): the exception type, the corresponding exception value, and the " -"traceback. These have the same meanings as the Python result of " -"``sys.exc_info()``; however, they are not the same: the Python objects " -"represent the last exception being handled by a " -"Python :keyword:`try` ... :keyword:`except` statement, while the C level " -"exception state only exists while an exception is being passed on between C " -"functions until it reaches the Python bytecode interpreter's main loop, " -"which takes care of transferring it to ``sys.exc_info()`` and friends." +"traceback. These have the same meanings as the Python result of ``sys." +"exc_info()``; however, they are not the same: the Python objects represent " +"the last exception being handled by a Python :keyword:`try` ... :keyword:" +"`except` statement, while the C level exception state only exists while an " +"exception is being passed on between C functions until it reaches the Python " +"bytecode interpreter's main loop, which takes care of transferring it to " +"``sys.exc_info()`` and friends." msgstr "" "完整的例外狀態由三個(都可以為 ``NULL`` 的)物件組成:例外型別、對應的例外值" "和回溯。這些與 ``sys.exc_info()`` 的 Python 結果具有相同的含義;但是它們並不" @@ -1019,15 +1015,15 @@ msgstr "" #: ../../c-api/intro.rst:629 msgid "" "Note that starting with Python 1.5, the preferred, thread-safe way to access " -"the exception state from Python code is to call the " -"function :func:`sys.exc_info`, which returns the per-thread exception state " -"for Python code. Also, the semantics of both ways to access the exception " -"state have changed so that a function which catches an exception will save " -"and restore its thread's exception state so as to preserve the exception " -"state of its caller. This prevents common bugs in exception handling code " -"caused by an innocent-looking function overwriting the exception being " -"handled; it also reduces the often unwanted lifetime extension for objects " -"that are referenced by the stack frames in the traceback." +"the exception state from Python code is to call the function :func:`sys." +"exc_info`, which returns the per-thread exception state for Python code. " +"Also, the semantics of both ways to access the exception state have changed " +"so that a function which catches an exception will save and restore its " +"thread's exception state so as to preserve the exception state of its " +"caller. This prevents common bugs in exception handling code caused by an " +"innocent-looking function overwriting the exception being handled; it also " +"reduces the often unwanted lifetime extension for objects that are " +"referenced by the stack frames in the traceback." msgstr "" "請注意,從 Python 1.5 開始,從 Python 程式碼存取例外狀態的首選且支援執行緒安" "全的方法是呼叫 :func:`sys.exc_info` 函式,它回傳 Python 程式碼的個別執行緒例" @@ -1126,22 +1122,21 @@ msgstr "" #: ../../c-api/intro.rst:716 msgid "" "This example represents an endorsed use of the ``goto`` statement in C! It " -"illustrates the use of :c:func:`PyErr_ExceptionMatches` " -"and :c:func:`PyErr_Clear` to handle specific exceptions, and the use " -"of :c:func:`Py_XDECREF` to dispose of owned references that may be ``NULL`` " -"(note the ``'X'`` in the name; :c:func:`Py_DECREF` would crash when " -"confronted with a ``NULL`` reference). It is important that the variables " -"used to hold owned references are initialized to ``NULL`` for this to work; " -"likewise, the proposed return value is initialized to ``-1`` (failure) and " -"only set to success after the final call made is successful." -msgstr "" -"這個例子代表了在 C 語言中對使用 ``goto`` 陳述句的認同!它闡述了" -"以 :c:func:`PyErr_ExceptionMatches` 和 :c:func:`PyErr_Clear` 來處理特定的例" -"外,以及以 :c:func:`Py_XDECREF` 來配置其所擁有且可能為 ``NULL`` 的參照(注意" -"名稱中的 ``'X'``\\ ;:c:func:`Py_DECREF` 在遇到 ``NULL`` 參照時會崩潰)。重要" -"的是,用於保存擁有的參照的變數被初始化為 ``NULL`` 以使其能夠順利作用;同樣" -"地,回傳值被初始化為 ``-1``\\ (失敗),並且僅在最後一次呼叫成功後才設定為成" -"功。" +"illustrates the use of :c:func:`PyErr_ExceptionMatches` and :c:func:" +"`PyErr_Clear` to handle specific exceptions, and the use of :c:func:" +"`Py_XDECREF` to dispose of owned references that may be ``NULL`` (note the " +"``'X'`` in the name; :c:func:`Py_DECREF` would crash when confronted with a " +"``NULL`` reference). It is important that the variables used to hold owned " +"references are initialized to ``NULL`` for this to work; likewise, the " +"proposed return value is initialized to ``-1`` (failure) and only set to " +"success after the final call made is successful." +msgstr "" +"這個例子代表了在 C 語言中對使用 ``goto`` 陳述句的認同!它闡述了以 :c:func:" +"`PyErr_ExceptionMatches` 和 :c:func:`PyErr_Clear` 來處理特定的例外,以及以 :" +"c:func:`Py_XDECREF` 來配置其所擁有且可能為 ``NULL`` 的參照(注意名稱中的 " +"``'X'``\\ ;:c:func:`Py_DECREF` 在遇到 ``NULL`` 參照時會崩潰)。重要的是,用" +"於保存擁有的參照的變數被初始化為 ``NULL`` 以使其能夠順利作用;同樣地,回傳值" +"被初始化為 ``-1``\\ (失敗),並且僅在最後一次呼叫成功後才設定為成功。" #: ../../c-api/intro.rst:730 msgid "Embedding Python" @@ -1170,16 +1165,15 @@ msgstr "" #: ../../c-api/intro.rst:750 msgid "" -":c:func:`Py_Initialize` does not set the \"script argument list\" " -"(``sys.argv``). If this variable is needed by Python code that will be " -"executed later, setting :c:member:`PyConfig.argv` " -"and :c:member:`PyConfig.parse_argv` must be set: see :ref:`Python " -"Initialization Configuration `." +":c:func:`Py_Initialize` does not set the \"script argument list\" (``sys." +"argv``). If this variable is needed by Python code that will be executed " +"later, setting :c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` " +"must be set: see :ref:`Python Initialization Configuration `." msgstr "" -":c:func:`Py_Initialize` 不設定「腳本引數列表 (script argument list)」 " -"(``sys.argv``)。如果稍後將要執行的 Python 程式碼需要此變數,則必須設" -"定 :c:member:`PyConfig.argv` 和 :c:member:`PyConfig.parse_argv`,請" -"見 :ref:`Python 初始化配置 `。" +":c:func:`Py_Initialize` 不設定「腳本引數列表 (script argument list)」 (``sys." +"argv``)。如果稍後將要執行的 Python 程式碼需要此變數,則必須設定 :c:member:" +"`PyConfig.argv` 和 :c:member:`PyConfig.parse_argv`,請見 :ref:`Python 初始化" +"配置 `。" #: ../../c-api/intro.rst:755 msgid "" @@ -1192,70 +1186,67 @@ msgid "" "to the parent directory where the executable named :file:`python` is found " "on the shell command search path (the environment variable :envvar:`PATH`)." msgstr "" -"在大多數系統上(特別是在 Unix 和 Windows 上,儘管細節略有不" -"同),:c:func:`Py_Initialize` 會假設Python 函式庫相對於 Python 直譯器可執行檔" -"案的位置固定,並根據其對標準 Python 直譯器可執行檔案位置的最佳猜測來計算模組" -"搜尋路徑。或者更詳細地說,它會在 shell 命令搜尋路徑(環境變" -"數 :envvar:`PATH`)中找到名為 :file:`python` 的可執行檔案,並在其父目錄中查找" -"一個名為 :file:`lib/python{X.Y}` 的目錄的相對位置。" +"在大多數系統上(特別是在 Unix 和 Windows 上,儘管細節略有不同),:c:func:" +"`Py_Initialize` 會假設Python 函式庫相對於 Python 直譯器可執行檔案的位置固定," +"並根據其對標準 Python 直譯器可執行檔案位置的最佳猜測來計算模組搜尋路徑。或者" +"更詳細地說,它會在 shell 命令搜尋路徑(環境變數 :envvar:`PATH`)中找到名為 :" +"file:`python` 的可執行檔案,並在其父目錄中查找一個名為 :file:`lib/python{X.Y}" +"` 的目錄的相對位置。" #: ../../c-api/intro.rst:764 msgid "" "For instance, if the Python executable is found in :file:`/usr/local/bin/" "python`, it will assume that the libraries are in :file:`/usr/local/lib/" "python{X.Y}`. (In fact, this particular path is also the \"fallback\" " -"location, used when no executable file named :file:`python` is found " -"along :envvar:`PATH`.) The user can override this behavior by setting the " +"location, used when no executable file named :file:`python` is found along :" +"envvar:`PATH`.) The user can override this behavior by setting the " "environment variable :envvar:`PYTHONHOME`, or insert additional directories " "in front of the standard path by setting :envvar:`PYTHONPATH`." msgstr "" "例如,如果在 :file:`/usr/local/bin/python` 中找到 Python 可執行檔案,它將假定" "函式庫位於 :file:`/usr/local/lib/python{X.Y}` 中。(事實上這個特定的路徑也是" "「後備 (fallback)」位置,當在 :envvar:`PATH` 中找不到名為 :file:`python` 的可" -"執行檔案時使用。)使用者可以透過設定環境變數來覆蓋此行" -"為 :envvar:`PYTHONHOME`,或者透過設定 :envvar:`PYTHONPATH` 在標準路徑前面插入" -"額外的目錄。" +"執行檔案時使用。)使用者可以透過設定環境變數來覆蓋此行為 :envvar:" +"`PYTHONHOME`,或者透過設定 :envvar:`PYTHONPATH` 在標準路徑前面插入額外的目" +"錄。" #: ../../c-api/intro.rst:778 -#, fuzzy -msgid "" -"The embedding application can steer the search by " -"setting :c:member:`PyConfig.program_name` *before* " -"calling :c:func:`Py_InitializeFromConfig`. Note that :envvar:`PYTHONHOME` " -"still overrides this and :envvar:`PYTHONPATH` is still inserted in front of " -"the standard path. An application that requires total control has to " -"provide its own implementation " -"of :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, " -"and :c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/" -"getpath.c`)." -msgstr "" -"嵌入的應用程式可以透過在呼叫 :c:func:`Py_Initialize` *之前*\\ 呼叫 " -"``Py_SetProgramName(file)`` 來引導搜尋。請注意 :envvar:`PYTHONHOME` 仍然覆蓋" +msgid "" +"The embedding application can steer the search by setting :c:member:" +"`PyConfig.program_name` *before* calling :c:func:`Py_InitializeFromConfig`. " +"Note that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` " +"is still inserted in front of the standard path. An application that " +"requires total control has to provide its own implementation of :c:func:" +"`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and :c:" +"func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`)." +msgstr "" +"嵌入的應用程式可以透過在呼叫 :c:func:`Py_InitializeFromConfig` *之前*\\ 設定 " +":c:member:`PyConfig.program_name` 來引導搜尋。請注意 :envvar:`PYTHONHOME` 仍然覆蓋" "它並且 :envvar:`PYTHONPATH` 仍然插入在標準路徑的前面。需要完全控制權的應用程" -"式必須實作自己" -"的 :c:func:`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:func:`Py_GetExecPrefix` " -"和 :c:func:`Py_GetProgramFullPath`\\(全部定義在 :file:`Modules/getpath.c`)。" +"式必須實作自己的 :c:func:`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:func:" +"`Py_GetExecPrefix` 和 :c:func:`Py_GetProgramFullPath`\\(全部定義在 :file:" +"`Modules/getpath.c`)。" #: ../../c-api/intro.rst:789 msgid "" "Sometimes, it is desirable to \"uninitialize\" Python. For instance, the " -"application may want to start over (make another call " -"to :c:func:`Py_Initialize`) or the application is simply done with its use " -"of Python and wants to free memory allocated by Python. This can be " -"accomplished by calling :c:func:`Py_FinalizeEx`. The " -"function :c:func:`Py_IsInitialized` returns true if Python is currently in " -"the initialized state. More information about these functions is given in a " -"later chapter. Notice that :c:func:`Py_FinalizeEx` does *not* free all " -"memory allocated by the Python interpreter, e.g. memory allocated by " -"extension modules currently cannot be released." +"application may want to start over (make another call to :c:func:" +"`Py_Initialize`) or the application is simply done with its use of Python " +"and wants to free memory allocated by Python. This can be accomplished by " +"calling :c:func:`Py_FinalizeEx`. The function :c:func:`Py_IsInitialized` " +"returns true if Python is currently in the initialized state. More " +"information about these functions is given in a later chapter. Notice that :" +"c:func:`Py_FinalizeEx` does *not* free all memory allocated by the Python " +"interpreter, e.g. memory allocated by extension modules currently cannot be " +"released." msgstr "" "有時會希望能夠「取消初始化 (uninitialize)」Python。例如,應用程式可能想要重新" "開始(再次呼叫 :c:func:`Py_Initialize`)或者應用程式簡單地完成了對 Python 的" "使用並想要釋放 Python 分配的記憶體。這可以透過呼叫 :c:func:`Py_FinalizeEx` 來" "完成。如果 Python 目前處於初始化狀態,函式 :c:func:`Py_IsInitialized` 會回傳 " -"true。有關這些功能的更多資訊將在後面的章節中給出。請注" -"意 :c:func:`Py_FinalizeEx` *不會*\\ 釋放由 Python 直譯器分配的所有記憶體,例" -"如目前無法釋放被擴充模組所分配的記憶體。" +"true。有關這些功能的更多資訊將在後面的章節中給出。請注意 :c:func:" +"`Py_FinalizeEx` *不會*\\ 釋放由 Python 直譯器分配的所有記憶體,例如目前無法釋" +"放被擴充模組所分配的記憶體。" #: ../../c-api/intro.rst:803 msgid "Debugging Builds" @@ -1272,11 +1263,11 @@ msgstr "" #: ../../c-api/intro.rst:809 msgid "" -"A full list of the various types of debugging builds is in the " -"file :file:`Misc/SpecialBuilds.txt` in the Python source distribution. " -"Builds are available that support tracing of reference counts, debugging the " -"memory allocator, or low-level profiling of the main interpreter loop. Only " -"the most frequently used builds will be described in the remainder of this " +"A full list of the various types of debugging builds is in the file :file:" +"`Misc/SpecialBuilds.txt` in the Python source distribution. Builds are " +"available that support tracing of reference counts, debugging the memory " +"allocator, or low-level profiling of the main interpreter loop. Only the " +"most frequently used builds will be described in the remainder of this " "section." msgstr "" "Python 原始碼發佈版本中的 :file:`Misc/SpecialBuilds.txt` 檔案有一份包含多種除" @@ -1287,17 +1278,17 @@ msgstr "" msgid "" "Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined " "produces what is generally meant by :ref:`a debug build of Python `. :c:macro:`!Py_DEBUG` is enabled in the Unix build by " -"adding :option:`--with-pydebug` to the :file:`./configure` command. It is " -"also implied by the presence of the not-Python-specific :c:macro:`!_DEBUG` " -"macro. When :c:macro:`!Py_DEBUG` is enabled in the Unix build, compiler " -"optimization is disabled." +"build>`. :c:macro:`!Py_DEBUG` is enabled in the Unix build by adding :option:" +"`--with-pydebug` to the :file:`./configure` command. It is also implied by " +"the presence of the not-Python-specific :c:macro:`!_DEBUG` macro. When :c:" +"macro:`!Py_DEBUG` is enabled in the Unix build, compiler optimization is " +"disabled." msgstr "" "使用定義的 :c:macro:`!Py_DEBUG` 巨集編譯直譯器會生成 :ref:`Python 的除錯建置 " "`。 :c:macro:`!Py_DEBUG` 在 Unix 建置中要透過在 :file:`./" -"configure` 命令中加入 :option:`--with-pydebug` 來啟用。非 Python 限定" -"的 :c:macro:`!_DEBUG` 巨集的存在也暗示了這一點。當 :c:macro:`!Py_DEBUG` 在 " -"Unix 建置中啟用時,編譯器最佳化會被禁用。" +"configure` 命令中加入 :option:`--with-pydebug` 來啟用。非 Python 限定的 :c:" +"macro:`!_DEBUG` 巨集的存在也暗示了這一點。當 :c:macro:`!Py_DEBUG` 在 Unix 建" +"置中啟用時,編譯器最佳化會被禁用。" #: ../../c-api/intro.rst:825 msgid "" @@ -1309,26 +1300,100 @@ msgstr "" #: ../../c-api/intro.rst:828 msgid "" -"Defining :c:macro:`Py_TRACE_REFS` enables reference tracing (see " -"the :option:`configure --with-trace-refs option <--with-trace-refs>`). When " -"defined, a circular doubly linked list of active objects is maintained by " -"adding two extra fields to every :c:type:`PyObject`. Total allocations are " -"tracked as well. Upon exit, all existing references are printed. (In " -"interactive mode this happens after every statement run by the interpreter.)" +"Defining :c:macro:`Py_TRACE_REFS` enables reference tracing (see the :option:" +"`configure --with-trace-refs option <--with-trace-refs>`). When defined, a " +"circular doubly linked list of active objects is maintained by adding two " +"extra fields to every :c:type:`PyObject`. Total allocations are tracked as " +"well. Upon exit, all existing references are printed. (In interactive mode " +"this happens after every statement run by the interpreter.)" msgstr "" "定義 :c:macro:`Py_TRACE_REFS` 來啟用參照追蹤(參見\\ :option:`設定 --with-" -"trace-refs 選項 <--with-trace-refs>`)。當有定義時,透過向每" -"個 :c:type:`PyObject` 新增兩個額外欄位來維護有效物件的循環雙向鍊表 (circular " -"doubly linked list)。全體分配也有被追蹤。退出時將印出所有現行參照。(在交互模" -"式下,這發生在直譯器運行的每個陳述句之後。)" +"trace-refs 選項 <--with-trace-refs>`)。當有定義時,透過向每個 :c:type:" +"`PyObject` 新增兩個額外欄位來維護有效物件的循環雙向鍊表 (circular doubly " +"linked list)。全體分配也有被追蹤。退出時將印出所有現行參照。(在交互模式下," +"這發生在直譯器運行的每個陳述句之後。)" #: ../../c-api/intro.rst:835 msgid "" "Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source " "distribution for more detailed information." msgstr "" -"有關更多詳細資訊,請參閱 Python 原始碼發布版中的 :file:`Misc/" -"SpecialBuilds.txt`。" +"有關更多詳細資訊,請參閱 Python 原始碼發布版中的 :file:`Misc/SpecialBuilds." +"txt`。" + +#: ../../c-api/intro.rst:842 +msgid "Recommended third party tools" +msgstr "" + +#: ../../c-api/intro.rst:844 +msgid "" +"The following third party tools offer both simpler and more sophisticated " +"approaches to creating C, C++ and Rust extensions for Python:" +msgstr "" + +#: ../../c-api/intro.rst:847 +msgid "`Cython `_" +msgstr "" + +#: ../../c-api/intro.rst:848 +msgid "`cffi `_" +msgstr "" + +#: ../../c-api/intro.rst:849 +msgid "`HPy `_" +msgstr "" + +#: ../../c-api/intro.rst:850 +msgid "`nanobind `_ (C++)" +msgstr "" + +#: ../../c-api/intro.rst:851 +msgid "`Numba `_" +msgstr "" + +#: ../../c-api/intro.rst:852 +msgid "`pybind11 `_ (C++)" +msgstr "" + +#: ../../c-api/intro.rst:853 +msgid "`PyO3 `_ (Rust)" +msgstr "" + +#: ../../c-api/intro.rst:854 +msgid "`SWIG `_" +msgstr "" + +#: ../../c-api/intro.rst:856 +msgid "" +"Using tools such as these can help avoid writing code that is tightly bound " +"to a particular version of CPython, avoid reference counting errors, and " +"focus more on your own code than on using the CPython API. In general, new " +"versions of Python can be supported by updating the tool, and your code will " +"often use newer and more efficient APIs automatically. Some tools also " +"support compiling for other implementations of Python from a single set of " +"sources." +msgstr "" + +#: ../../c-api/intro.rst:863 +msgid "" +"These projects are not supported by the same people who maintain Python, and " +"issues need to be raised with the projects directly. Remember to check that " +"the project is still maintained and supported, as the list above may become " +"outdated." +msgstr "" + +#: ../../c-api/intro.rst:870 +msgid "" +"`Python Packaging User Guide: Binary Extensions `_" +msgstr "" + +#: ../../c-api/intro.rst:871 +msgid "" +"The Python Packaging User Guide not only covers several available tools that " +"simplify the creation of binary extensions, but also discusses the various " +"reasons why creating an extension module may be desirable in the first place." +msgstr "" #: ../../c-api/intro.rst:288 msgid "object" diff --git a/c-api/long.po b/c-api/long.po index 0df0341414..a32b953e3e 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-10-22 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -402,10 +402,10 @@ msgstr "" #: ../../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, " -"and the higher bits are ignored. This matches the typical behavior of a C-" -"style downcast." +"If the returned value is greater than *n_bytes*, the value was truncated: as " +"many of the lowest bits of the value as could fit are written, and the " +"higher bits are ignored. This matches the typical behavior of a C-style " +"downcast." msgstr "" #: ../../c-api/long.rst:392 diff --git a/c-api/module.po b/c-api/module.po index 8df6ee5240..89ec8b6dcf 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: 2025-02-25 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -36,22 +36,21 @@ msgstr "" #: ../../c-api/module.rst:27 msgid "" -"Return true if *p* is a module object, but not a subtype " -"of :c:data:`PyModule_Type`. This function always succeeds." +"Return true if *p* is a module object, but not a subtype of :c:data:" +"`PyModule_Type`. This function always succeeds." msgstr "" #: ../../c-api/module.rst:40 msgid "" "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." +"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:272 -#: ../../c-api/module.rst:474 +#: ../../c-api/module.rst:492 msgid "Return ``NULL`` with an exception set on error." msgstr "在失敗時回傳 ``NULL`` 並設定例外。" @@ -80,8 +79,8 @@ msgstr "" #: ../../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__`." +"functions rather than directly manipulate a module's :attr:`~object." +"__dict__`." msgstr "" #: ../../c-api/module.rst:81 @@ -100,8 +99,8 @@ msgstr "" #: ../../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`." +"memory allocated at module creation time, or ``NULL``. See :c:member:" +"`PyModuleDef.m_size`." msgstr "" #: ../../c-api/module.rst:102 @@ -112,10 +111,10 @@ msgstr "" #: ../../c-api/module.rst:112 msgid "" -"Return the name of the file from which *module* was loaded using " -"*module*'s :attr:`~module.__file__` attribute. If this is not defined, or " -"if it is not a string, raise :exc:`SystemError` and return ``NULL``; " -"otherwise return a reference to a Unicode object." +"Return the name of the file from which *module* was loaded using *module*'s :" +"attr:`~module.__file__` attribute. If this is not defined, or if it is not " +"a string, raise :exc:`SystemError` and return ``NULL``; otherwise return a " +"reference to a Unicode object." msgstr "" #: ../../c-api/module.rst:122 @@ -144,10 +143,9 @@ msgstr "" #: ../../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." +"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:146 @@ -167,8 +165,8 @@ msgstr "" #: ../../c-api/module.rst:160 msgid "" -"Docstring for the module; usually a docstring variable created " -"with :c:macro:`PyDoc_STRVAR` is used." +"Docstring for the module; usually a docstring variable created with :c:macro:" +"`PyDoc_STRVAR` is used." msgstr "" #: ../../c-api/module.rst:165 @@ -181,8 +179,8 @@ msgstr "" #: ../../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." +"freed when the module object is deallocated, after the :c:member:" +"`~PyModuleDef.m_free` function has been called, if present." msgstr "" #: ../../c-api/module.rst:173 @@ -205,9 +203,8 @@ msgstr "更多詳情請見 :pep:`3121`。" #: ../../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." +"A pointer to a table of module-level functions, described by :c:type:" +"`PyMethodDef` values. Can be ``NULL`` if no functions are present." msgstr "" #: ../../c-api/module.rst:190 @@ -236,8 +233,8 @@ msgid "" "allocated yet. This is the case immediately after the module is created and " "before the module is executed (:c:data:`Py_mod_exec` function). More " "precisely, this function is not called if :c:member:`~PyModuleDef.m_size` is " -"greater than 0 and the module state (as returned " -"by :c:func:`PyModule_GetState`) is ``NULL``." +"greater than 0 and the module state (as returned by :c:func:" +"`PyModule_GetState`) is ``NULL``." msgstr "" #: ../../c-api/module.rst:213 ../../c-api/module.rst:234 @@ -280,8 +277,8 @@ msgstr "" #: ../../c-api/module.rst:261 msgid "" "Create a new module object, given the definition in *def*. This behaves " -"like :c:func:`PyModule_Create2` with *module_api_version* set " -"to :c:macro:`PYTHON_API_VERSION`." +"like :c:func:`PyModule_Create2` with *module_api_version* set to :c:macro:" +"`PYTHON_API_VERSION`." msgstr "" #: ../../c-api/module.rst:268 @@ -300,8 +297,8 @@ msgstr "" #: ../../c-api/module.rst:279 msgid "" "Before it is returned from in the initialization function, the resulting " -"module object is typically populated using functions " -"like :c:func:`PyModule_AddObjectRef`." +"module object is typically populated using functions like :c:func:" +"`PyModule_AddObjectRef`." msgstr "" #: ../../c-api/module.rst:285 @@ -314,98 +311,120 @@ msgid "" "initialization\". Extension modules created this way behave more like Python " "modules: the initialization is split between the *creation phase*, when the " "module object is created, and the *execution phase*, when it is populated. " -"The distinction is similar to the :py:meth:`!__new__` and :py:meth:`!" -"__init__` methods of classes." +"The distinction is similar to the :py:meth:`~object.__new__` and :py:meth:" +"`~object.__init__` methods of classes." msgstr "" #: ../../c-api/module.rst:294 msgid "" "Unlike modules created using single-phase initialization, these modules are " -"not singletons: if the *sys.modules* entry is removed and the module is re-" -"imported, a new module object is created, and the old module is subject to " -"normal garbage collection -- as with Python modules. By default, multiple " -"modules created from the same definition should be independent: changes to " -"one should not affect the others. This means that all state should be " -"specific to the module object (using e.g. " -"using :c:func:`PyModule_GetState`), or its contents (such as the " -"module's :attr:`~object.__dict__` or individual classes created " -"with :c:func:`PyType_FromSpec`)." +"not singletons. For example, if the :py:attr:`sys.modules` entry is removed " +"and the module is re-imported, a new module object is created, and typically " +"populated with fresh method and type objects. The old module is subject to " +"normal garbage collection. This mirrors the behavior of pure-Python modules." msgstr "" -#: ../../c-api/module.rst:304 +#: ../../c-api/module.rst:302 +msgid "" +"Additional module instances may be created in :ref:`sub-interpreters ` or after after Python runtime reinitialization (:c:" +"func:`Py_Finalize` and :c:func:`Py_Initialize`). In these cases, sharing " +"Python objects between module instances would likely cause crashes or " +"undefined behavior." +msgstr "" + +#: ../../c-api/module.rst:309 +msgid "" +"To avoid such issues, each instance of an extension module should be " +"*isolated*: changes to one instance should not implicitly affect the others, " +"and all state, including references to Python objects, should be specific to " +"a particular module instance. See :ref:`isolating-extensions-howto` for more " +"details and a practical guide." +msgstr "" + +#: ../../c-api/module.rst:315 +msgid "" +"A simpler way to avoid these issues is :ref:`raising an error on repeated " +"initialization `." +msgstr "" + +#: ../../c-api/module.rst:318 msgid "" "All modules created using multi-phase initialization are expected to " -"support :ref:`sub-interpreters `. Making sure " -"multiple modules are independent is typically enough to achieve this." +"support :ref:`sub-interpreters `, or otherwise " +"explicitly signal a lack of support. This is usually achieved by isolation " +"or blocking repeated initialization, as above. A module may also be limited " +"to the main interpreter using the :c:data:`Py_mod_multiple_interpreters` " +"slot." msgstr "" -#: ../../c-api/module.rst:308 +#: ../../c-api/module.rst:326 msgid "" "To request multi-phase initialization, the initialization function " -"(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-" -"empty :c:member:`~PyModuleDef.m_slots`. Before it is returned, the " -"``PyModuleDef`` instance must be initialized with the following function:" +"(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-empty :" +"c:member:`~PyModuleDef.m_slots`. Before it is returned, the ``PyModuleDef`` " +"instance must be initialized with the following function:" msgstr "" -#: ../../c-api/module.rst:315 +#: ../../c-api/module.rst:333 msgid "" "Ensures a module definition is a properly initialized Python object that " "correctly reports its type and reference count." msgstr "" -#: ../../c-api/module.rst:318 +#: ../../c-api/module.rst:336 msgid "Returns *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." msgstr "" -#: ../../c-api/module.rst:322 +#: ../../c-api/module.rst:340 msgid "" "The *m_slots* member of the module definition must point to an array of " "``PyModuleDef_Slot`` structures:" msgstr "" -#: ../../c-api/module.rst:329 +#: ../../c-api/module.rst:347 msgid "A slot ID, chosen from the available values explained below." msgstr "" -#: ../../c-api/module.rst:333 +#: ../../c-api/module.rst:351 msgid "Value of the slot, whose meaning depends on the slot ID." msgstr "" -#: ../../c-api/module.rst:337 +#: ../../c-api/module.rst:355 msgid "The *m_slots* array must be terminated by a slot with id 0." msgstr "" -#: ../../c-api/module.rst:339 +#: ../../c-api/module.rst:357 msgid "The available slot types are:" msgstr "" -#: ../../c-api/module.rst:343 +#: ../../c-api/module.rst:361 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:350 +#: ../../c-api/module.rst:368 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:355 +#: ../../c-api/module.rst:373 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:359 +#: ../../c-api/module.rst:377 msgid "" "Multiple ``Py_mod_create`` slots may not be specified in one module " "definition." msgstr "" -#: ../../c-api/module.rst:362 +#: ../../c-api/module.rst:380 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 " @@ -414,17 +433,17 @@ msgid "" "through symlinks, all while sharing a single module definition." msgstr "" -#: ../../c-api/module.rst:368 +#: ../../c-api/module.rst:386 msgid "" -"There is no requirement for the returned object to be an instance " -"of :c:type:`PyModule_Type`. Any type can be used, as long as it supports " -"setting and getting import-related attributes. However, only " -"``PyModule_Type`` instances may be returned if the ``PyModuleDef`` has non-" -"``NULL`` ``m_traverse``, ``m_clear``, ``m_free``; non-zero ``m_size``; or " -"slots other than ``Py_mod_create``." +"There is no requirement for the returned object to be an instance of :c:type:" +"`PyModule_Type`. Any type can be used, as long as it supports setting and " +"getting import-related attributes. However, only ``PyModule_Type`` instances " +"may be returned if the ``PyModuleDef`` has non-``NULL`` ``m_traverse``, " +"``m_clear``, ``m_free``; non-zero ``m_size``; or slots other than " +"``Py_mod_create``." msgstr "" -#: ../../c-api/module.rst:377 +#: ../../c-api/module.rst:395 msgid "" "Specifies a function that is called to *execute* the module. This is " "equivalent to executing the code of a Python module: typically, this " @@ -432,61 +451,61 @@ msgid "" "function is:" msgstr "" -#: ../../c-api/module.rst:386 +#: ../../c-api/module.rst:404 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:391 ../../c-api/module.rst:424 +#: ../../c-api/module.rst:409 ../../c-api/module.rst:442 msgid "Specifies one of the following values:" msgstr "" -#: ../../c-api/module.rst:397 +#: ../../c-api/module.rst:415 msgid "The module does not support being imported in subinterpreters." msgstr "" -#: ../../c-api/module.rst:401 +#: ../../c-api/module.rst:419 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:407 +#: ../../c-api/module.rst:425 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:411 +#: ../../c-api/module.rst:429 msgid "" "This slot determines whether or not importing this module in a " "subinterpreter will fail." msgstr "" -#: ../../c-api/module.rst:414 +#: ../../c-api/module.rst:432 msgid "" "Multiple ``Py_mod_multiple_interpreters`` slots may not be specified in one " "module definition." msgstr "" -#: ../../c-api/module.rst:417 +#: ../../c-api/module.rst:435 msgid "" "If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " "defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." msgstr "" -#: ../../c-api/module.rst:430 +#: ../../c-api/module.rst:448 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:435 +#: ../../c-api/module.rst:453 msgid "The module is safe to run without an active GIL." msgstr "" -#: ../../c-api/module.rst:437 +#: ../../c-api/module.rst:455 msgid "" "This slot is ignored by Python builds not configured with :option:`--disable-" "gil`. Otherwise, it determines whether or not importing this module will " @@ -494,26 +513,26 @@ msgid "" "threaded-cpython` for more detail." msgstr "" -#: ../../c-api/module.rst:442 +#: ../../c-api/module.rst:460 msgid "" "Multiple ``Py_mod_gil`` slots may not be specified in one module definition." msgstr "" -#: ../../c-api/module.rst:444 +#: ../../c-api/module.rst:462 msgid "" "If ``Py_mod_gil`` is not specified, the import machinery defaults to " "``Py_MOD_GIL_USED``." msgstr "" -#: ../../c-api/module.rst:449 +#: ../../c-api/module.rst:467 msgid "See :PEP:`489` for more details on multi-phase initialization." msgstr "" -#: ../../c-api/module.rst:452 +#: ../../c-api/module.rst:470 msgid "Low-level module creation functions" msgstr "" -#: ../../c-api/module.rst:454 +#: ../../c-api/module.rst:472 msgid "" "The following functions are called under the hood when using multi-phase " "initialization. They can be used directly, for example when creating module " @@ -521,14 +540,14 @@ msgid "" "``PyModule_ExecDef`` must be called to fully initialize a module." msgstr "" -#: ../../c-api/module.rst:461 +#: ../../c-api/module.rst:479 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:469 +#: ../../c-api/module.rst:487 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 " @@ -536,24 +555,24 @@ msgid "" "emitted." msgstr "" -#: ../../c-api/module.rst:478 +#: ../../c-api/module.rst:496 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:485 +#: ../../c-api/module.rst:503 msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" -#: ../../c-api/module.rst:491 +#: ../../c-api/module.rst:509 msgid "" "Set the docstring for *module* to *docstring*. This function is called " "automatically when creating a module from ``PyModuleDef``, using either " "``PyModule_Create`` or ``PyModule_FromDefAndSpec``." msgstr "" -#: ../../c-api/module.rst:500 +#: ../../c-api/module.rst:518 msgid "" "Add the functions from the ``NULL`` terminated *functions* array to " "*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " @@ -565,11 +584,11 @@ msgid "" "``PyModule_FromDefAndSpec``." msgstr "" -#: ../../c-api/module.rst:512 +#: ../../c-api/module.rst:530 msgid "Support functions" msgstr "支援的函式" -#: ../../c-api/module.rst:514 +#: ../../c-api/module.rst:532 msgid "" "The module initialization function (if using single phase initialization) or " "a function called from a module execution slot (if using multi-phase " @@ -577,23 +596,23 @@ msgid "" "module state:" msgstr "" -#: ../../c-api/module.rst:521 +#: ../../c-api/module.rst:539 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:524 +#: ../../c-api/module.rst:542 msgid "" "On success, return ``0``. On error, raise an exception and return ``-1``." msgstr "" -#: ../../c-api/module.rst:526 ../../c-api/module.rst:577 -#: ../../c-api/module.rst:604 +#: ../../c-api/module.rst:544 ../../c-api/module.rst:595 +#: ../../c-api/module.rst:622 msgid "Example usage::" msgstr "用法範例: ::" -#: ../../c-api/module.rst:528 +#: ../../c-api/module.rst:546 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -619,20 +638,20 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:540 +#: ../../c-api/module.rst:558 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 +#: ../../c-api/module.rst:562 msgid "" "The example can also be written without checking explicitly if *obj* is " "``NULL``::" msgstr "" -#: ../../c-api/module.rst:547 +#: ../../c-api/module.rst:565 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -652,23 +671,23 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:556 +#: ../../c-api/module.rst:574 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:559 +#: ../../c-api/module.rst:577 msgid "" "The number of different *name* strings passed to this function should be " "kept small, usually by only using statically allocated strings as *name*. " -"For names that aren't known at compile time, prefer " -"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` " -"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " -"may be used internally to create a key object." +"For names that aren't known at compile time, prefer calling :c:func:" +"`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly. For more " +"details, see :c:func:`PyUnicode_InternFromString`, which may be used " +"internally to create a key object." msgstr "" -#: ../../c-api/module.rst:572 +#: ../../c-api/module.rst:590 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 " @@ -676,39 +695,39 @@ msgid "" "variable." msgstr "" -#: ../../c-api/module.rst:579 +#: ../../c-api/module.rst:597 msgid "" "if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" " goto error;\n" "}" msgstr "" -#: ../../c-api/module.rst:588 +#: ../../c-api/module.rst:606 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to " "*value* on success (if it returns ``0``)." msgstr "" -#: ../../c-api/module.rst:591 +#: ../../c-api/module.rst:609 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:598 +#: ../../c-api/module.rst:616 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" -#: ../../c-api/module.rst:601 +#: ../../c-api/module.rst:619 msgid "" -"This means that its return value must be checked, and calling code " -"must :c:func:`Py_XDECREF` *value* manually on error." +"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:606 +#: ../../c-api/module.rst:624 msgid "" "PyObject *obj = PyBytes_FromString(value);\n" "if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" @@ -722,24 +741,24 @@ msgid "" "// Py_XDECREF(obj) is not needed here." msgstr "" -#: ../../c-api/module.rst:619 +#: ../../c-api/module.rst:637 msgid ":c:func:`PyModule_AddObject` is :term:`soft deprecated`." msgstr "" -#: ../../c-api/module.rst:624 +#: ../../c-api/module.rst:642 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:628 +#: ../../c-api/module.rst:646 msgid "" -"This is a convenience function that calls :c:func:`PyLong_FromLong` " -"and :c:func:`PyModule_AddObjectRef`; see their documentation for details." +"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:634 +#: ../../c-api/module.rst:652 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 " @@ -747,14 +766,14 @@ msgid "" "on success." msgstr "" -#: ../../c-api/module.rst:639 +#: ../../c-api/module.rst:657 msgid "" -"This is a convenience function that " -"calls :c:func:`PyUnicode_InternFromString` " -"and :c:func:`PyModule_AddObjectRef`; see their documentation for details." +"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:646 +#: ../../c-api/module.rst:664 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 " @@ -762,11 +781,11 @@ msgid "" "with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:654 +#: ../../c-api/module.rst:672 msgid "Add a string constant to *module*." msgstr "將字串常數加入到 *module* 中。" -#: ../../c-api/module.rst:658 +#: ../../c-api/module.rst:676 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 " @@ -774,7 +793,7 @@ msgid "" "``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:668 +#: ../../c-api/module.rst:686 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`. " @@ -785,25 +804,25 @@ msgid "" "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:681 +#: ../../c-api/module.rst:699 msgid "Module lookup" msgstr "模組查找" -#: ../../c-api/module.rst:683 +#: ../../c-api/module.rst:701 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:687 +#: ../../c-api/module.rst:705 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:692 +#: ../../c-api/module.rst:710 msgid "" "Returns the module object that was created from *def* for the current " "interpreter. This method requires that the module object has been attached " @@ -812,18 +831,18 @@ msgid "" "to the interpreter state yet, it returns ``NULL``." msgstr "" -#: ../../c-api/module.rst:699 +#: ../../c-api/module.rst:717 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`." +"This allows the module object to be accessible via :c:func:" +"`PyState_FindModule`." msgstr "" -#: ../../c-api/module.rst:702 +#: ../../c-api/module.rst:720 msgid "Only effective on modules created using single-phase initialization." msgstr "" -#: ../../c-api/module.rst:704 +#: ../../c-api/module.rst:722 msgid "" "Python calls ``PyState_AddModule`` automatically after importing a module, " "so it is unnecessary (but harmless) to call it from module initialization " @@ -834,15 +853,15 @@ msgid "" "state updates)." msgstr "" -#: ../../c-api/module.rst:712 ../../c-api/module.rst:723 +#: ../../c-api/module.rst:730 ../../c-api/module.rst:741 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/module.rst:714 +#: ../../c-api/module.rst:732 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "成功時回傳 ``0``,在失敗時回傳 ``-1`` 並設定例外。" -#: ../../c-api/module.rst:720 +#: ../../c-api/module.rst:738 msgid "" "Removes the module object created from *def* from the interpreter state. " "Return ``-1`` with an exception set on error, ``0`` on success." diff --git a/c-api/refcounting.po b/c-api/refcounting.po index fa04ff0352..01ae7ce871 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-24 07:20+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -331,11 +331,11 @@ msgstr "Py_SETREF(dst, src);" #: ../../c-api/refcounting.rst:204 msgid "" -"That arranges to set *dst* to *src* _before_ releasing the reference to the " +"That arranges to set *dst* to *src* *before* releasing the reference to the " "old value of *dst*, so that any code triggered as a side-effect of *dst* " "getting torn down no longer believes *dst* points to a valid object." msgstr "" -"這會在釋放對 *dst* 舊值的參照\\ _之前_\\ 將 *dst* 設定為 *src*,使得因 *dst* " +"這會在釋放對 *dst* 舊值的參照\\ *之前*\\ 將 *dst* 設定為 *src*,使得因 *dst* " "被拆除而觸發的任何副作用 (side-effect) 之程式碼不會相信 *dst* 是指向一個有效" "物件。" diff --git a/c-api/type.po b/c-api/type.po index 0ff3fc423c..3ddebe9e5c 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: 2025-04-03 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -301,40 +301,47 @@ msgid "" "type:`PyCMethod` calling convention." msgstr "" -#: ../../c-api/type.rst:274 +#: ../../c-api/type.rst:270 +msgid "" +"The returned reference is :term:`borrowed ` from *type*, " +"and will be valid as long as you hold a reference to *type*. Do not release " +"it with :c:func:`Py_DECREF` or similar." +msgstr "" + +#: ../../c-api/type.rst:278 msgid "Attempt to assign a version tag to the given type." msgstr "" -#: ../../c-api/type.rst:276 +#: ../../c-api/type.rst:280 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:283 +#: ../../c-api/type.rst:287 msgid "Creating Heap-Allocated Types" msgstr "" -#: ../../c-api/type.rst:285 +#: ../../c-api/type.rst:289 msgid "" "The following functions and structs are used to create :ref:`heap types " "`." msgstr "" -#: ../../c-api/type.rst:290 +#: ../../c-api/type.rst:294 msgid "" "Create and return a :ref:`heap type ` from the *spec* (see :c:" "macro:`Py_TPFLAGS_HEAPTYPE`)." msgstr "" -#: ../../c-api/type.rst:293 +#: ../../c-api/type.rst:297 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:297 +#: ../../c-api/type.rst:301 msgid "" "Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " "supported, except if ``tp_new`` is ``NULL``. (For backwards compatibility, " @@ -343,7 +350,7 @@ msgid "" "deprecated and in Python 3.14+ such metaclasses will not be supported.)" msgstr "" -#: ../../c-api/type.rst:304 +#: ../../c-api/type.rst:308 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 " @@ -352,7 +359,7 @@ msgid "" "derives from :class:`object`." msgstr "" -#: ../../c-api/type.rst:310 +#: ../../c-api/type.rst:314 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``, " @@ -361,11 +368,11 @@ msgid "" "subclasses; it must be specified for each class individually." msgstr "" -#: ../../c-api/type.rst:317 +#: ../../c-api/type.rst:321 msgid "This function calls :c:func:`PyType_Ready` on the new type." msgstr "" -#: ../../c-api/type.rst:319 +#: ../../c-api/type.rst:323 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. With user-" @@ -374,41 +381,41 @@ msgid "" "Specifically:" msgstr "" -#: ../../c-api/type.rst:326 +#: ../../c-api/type.rst:330 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:328 +#: ../../c-api/type.rst:332 msgid ":py:meth:`~object.__init__` is not called on the new class." msgstr "" -#: ../../c-api/type.rst:329 +#: ../../c-api/type.rst:333 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." msgstr "" -#: ../../c-api/type.rst:330 +#: ../../c-api/type.rst:334 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." msgstr "" -#: ../../c-api/type.rst:336 +#: ../../c-api/type.rst:340 msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, module, spec, bases)``。" -#: ../../c-api/type.rst:342 +#: ../../c-api/type.rst:346 msgid "" "The function now accepts a single class as the *bases* argument and ``NULL`` " "as the ``tp_doc`` slot." msgstr "" -#: ../../c-api/type.rst:347 ../../c-api/type.rst:364 +#: ../../c-api/type.rst:351 ../../c-api/type.rst:368 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:350 ../../c-api/type.rst:367 ../../c-api/type.rst:383 +#: ../../c-api/type.rst:354 ../../c-api/type.rst:371 ../../c-api/type.rst:387 msgid "" "The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " "may result in incomplete initialization. Creating classes whose metaclass " @@ -416,42 +423,42 @@ msgid "" "it will be no longer allowed." msgstr "" -#: ../../c-api/type.rst:358 +#: ../../c-api/type.rst:362 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, bases)``。" -#: ../../c-api/type.rst:375 +#: ../../c-api/type.rst:379 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``。" -#: ../../c-api/type.rst:379 +#: ../../c-api/type.rst:383 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:400 +#: ../../c-api/type.rst:404 msgid "Structure defining a type's behavior." msgstr "" -#: ../../c-api/type.rst:404 +#: ../../c-api/type.rst:408 msgid "Name of the type, used to set :c:member:`PyTypeObject.tp_name`." msgstr "" -#: ../../c-api/type.rst:408 +#: ../../c-api/type.rst:412 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:411 +#: ../../c-api/type.rst:415 msgid "" "If zero, specifies that :c:member:`~PyTypeObject.tp_basicsize` should be " "inherited." msgstr "" -#: ../../c-api/type.rst:414 +#: ../../c-api/type.rst:418 msgid "" "If negative, the absolute value specifies how much space instances of the " "class need *in addition* to the superclass. Use :c:func:" @@ -461,17 +468,17 @@ msgid "" "requirements." msgstr "" -#: ../../c-api/type.rst:424 +#: ../../c-api/type.rst:428 msgid "Previously, this field could not be negative." msgstr "" -#: ../../c-api/type.rst:428 +#: ../../c-api/type.rst:432 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:432 +#: ../../c-api/type.rst:436 msgid "" "If zero, :c:member:`~PyTypeObject.tp_itemsize` is inherited. Extending " "arbitrary variable-sized classes is dangerous, since some types use a fixed " @@ -480,58 +487,58 @@ msgid "" "only possible in the following situations:" msgstr "" -#: ../../c-api/type.rst:439 +#: ../../c-api/type.rst:443 msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize`)." msgstr "" -#: ../../c-api/type.rst:441 +#: ../../c-api/type.rst:445 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:443 +#: ../../c-api/type.rst:447 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:446 +#: ../../c-api/type.rst:450 msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." msgstr "" -#: ../../c-api/type.rst:450 +#: ../../c-api/type.rst:454 msgid "Type flags, used to set :c:member:`PyTypeObject.tp_flags`." msgstr "" -#: ../../c-api/type.rst:452 +#: ../../c-api/type.rst:456 msgid "" "If the ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" "`PyType_FromSpecWithBases` sets it automatically." msgstr "" -#: ../../c-api/type.rst:457 +#: ../../c-api/type.rst:461 msgid "" "Array of :c:type:`PyType_Slot` structures. Terminated by the special slot " "value ``{0, NULL}``." msgstr "" -#: ../../c-api/type.rst:460 +#: ../../c-api/type.rst:464 msgid "Each slot ID should be specified at most once." msgstr "" -#: ../../c-api/type.rst:470 +#: ../../c-api/type.rst:474 msgid "" "Structure defining optional functionality of a type, containing a slot ID " "and a value pointer." msgstr "" -#: ../../c-api/type.rst:475 +#: ../../c-api/type.rst:479 msgid "A slot ID." msgstr "" -#: ../../c-api/type.rst:477 +#: ../../c-api/type.rst:481 msgid "" "Slot IDs are named like the field names of the structures :c:type:" "`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" @@ -539,30 +546,30 @@ msgid "" "prefix. For example, use:" msgstr "" -#: ../../c-api/type.rst:483 +#: ../../c-api/type.rst:487 msgid "``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`" msgstr "" -#: ../../c-api/type.rst:484 +#: ../../c-api/type.rst:488 msgid "``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`" msgstr "" -#: ../../c-api/type.rst:485 +#: ../../c-api/type.rst:489 msgid "``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`" msgstr "" -#: ../../c-api/type.rst:487 +#: ../../c-api/type.rst:491 msgid "" "The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" -#: ../../c-api/type.rst:489 +#: ../../c-api/type.rst:493 msgid "" ":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" msgstr "" -#: ../../c-api/type.rst:491 +#: ../../c-api/type.rst:495 msgid "" ":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_DICT` instead if possible)" @@ -570,7 +577,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_dictoffset`\\ (如果可能,請改用 :c:macro:" "`Py_TPFLAGS_MANAGED_DICT`)" -#: ../../c-api/type.rst:493 +#: ../../c-api/type.rst:497 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " "``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" @@ -578,7 +585,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_vectorcall_offset`\\ (請用 :ref:`PyMemberDef " "` 中的 ``\"__vectorcalloffset__\"``)" -#: ../../c-api/type.rst:497 +#: ../../c-api/type.rst:501 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:" @@ -586,48 +593,48 @@ msgid "" "documentation ` for details." msgstr "" -#: ../../c-api/type.rst:503 +#: ../../c-api/type.rst:507 msgid "The following fields cannot be set at all when creating a heap type:" msgstr "" -#: ../../c-api/type.rst:505 +#: ../../c-api/type.rst:509 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall` (use :c:member:`~PyTypeObject." "tp_new` and/or :c:member:`~PyTypeObject.tp_init`)" msgstr "" -#: ../../c-api/type.rst:509 +#: ../../c-api/type.rst:513 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:516 +#: ../../c-api/type.rst:520 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:521 +#: ../../c-api/type.rst:525 msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." msgstr "" -#: ../../c-api/type.rst:524 +#: ../../c-api/type.rst:528 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:531 +#: ../../c-api/type.rst:535 msgid "" "The desired value of the slot. In most cases, this is a pointer to a " "function." msgstr "" -#: ../../c-api/type.rst:534 +#: ../../c-api/type.rst:538 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 3ffb4c871b..7751ec68ce 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-14 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -45,8 +45,8 @@ msgstr "" #: ../../c-api/typeobj.rst:23 msgid "" "In addition to the following quick reference, the :ref:`typedef-examples` " -"section provides at-a-glance insight into the meaning and use " -"of :c:type:`PyTypeObject`." +"section provides at-a-glance insight into the meaning and use of :c:type:" +"`PyTypeObject`." msgstr "" #: ../../c-api/typeobj.rst:29 @@ -128,7 +128,7 @@ msgstr ":c:member:`~PyTypeObject.tp_basicsize`" #: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:46 #: ../../c-api/typeobj.rst:48 ../../c-api/typeobj.rst:52 #: ../../c-api/typeobj.rst:99 ../../c-api/typeobj.rst:120 -#: ../../c-api/typeobj.rst:416 +#: ../../c-api/typeobj.rst:417 msgid ":c:type:`Py_ssize_t`" msgstr ":c:type:`Py_ssize_t`" @@ -141,7 +141,7 @@ msgid ":c:member:`~PyTypeObject.tp_dealloc`" msgstr ":c:member:`~PyTypeObject.tp_dealloc`" #: ../../c-api/typeobj.rst:50 ../../c-api/typeobj.rst:142 -#: ../../c-api/typeobj.rst:146 ../../c-api/typeobj.rst:346 +#: ../../c-api/typeobj.rst:146 ../../c-api/typeobj.rst:347 msgid ":c:type:`destructor`" msgstr ":c:type:`destructor`" @@ -153,7 +153,7 @@ msgstr ":c:member:`~PyTypeObject.tp_vectorcall_offset`" msgid "(:c:member:`~PyTypeObject.tp_getattr`)" msgstr "(:c:member:`~PyTypeObject.tp_getattr`)" -#: ../../c-api/typeobj.rst:54 ../../c-api/typeobj.rst:370 +#: ../../c-api/typeobj.rst:54 ../../c-api/typeobj.rst:371 msgid ":c:type:`getattrfunc`" msgstr ":c:type:`getattrfunc`" @@ -172,7 +172,7 @@ msgstr "G" msgid "(:c:member:`~PyTypeObject.tp_setattr`)" msgstr "(:c:member:`~PyTypeObject.tp_setattr`)" -#: ../../c-api/typeobj.rst:57 ../../c-api/typeobj.rst:375 +#: ../../c-api/typeobj.rst:57 ../../c-api/typeobj.rst:376 msgid ":c:type:`setattrfunc`" msgstr ":c:type:`setattrfunc`" @@ -190,6 +190,7 @@ msgstr ":c:type:`PyAsyncMethods` *" #: ../../c-api/typeobj.rst:60 ../../c-api/typeobj.rst:64 #: ../../c-api/typeobj.rst:66 ../../c-api/typeobj.rst:68 +#: ../../c-api/typeobj.rst:82 msgid ":ref:`sub-slots`" msgstr ":ref:`sub-slots`" @@ -204,7 +205,7 @@ msgid ":c:member:`~PyTypeObject.tp_repr`" msgstr ":c:member:`~PyTypeObject.tp_repr`" #: ../../c-api/typeobj.rst:62 ../../c-api/typeobj.rst:74 -#: ../../c-api/typeobj.rst:368 +#: ../../c-api/typeobj.rst:369 msgid ":c:type:`reprfunc`" msgstr ":c:type:`reprfunc`" @@ -240,7 +241,7 @@ msgstr ":c:type:`PyMappingMethods` *" msgid ":c:member:`~PyTypeObject.tp_hash`" msgstr ":c:member:`~PyTypeObject.tp_hash`" -#: ../../c-api/typeobj.rst:70 ../../c-api/typeobj.rst:404 +#: ../../c-api/typeobj.rst:70 ../../c-api/typeobj.rst:405 msgid ":c:type:`hashfunc`" msgstr ":c:type:`hashfunc`" @@ -253,7 +254,7 @@ msgid ":c:member:`~PyTypeObject.tp_call`" msgstr ":c:member:`~PyTypeObject.tp_call`" #: ../../c-api/typeobj.rst:72 ../../c-api/typeobj.rst:237 -#: ../../c-api/typeobj.rst:240 ../../c-api/typeobj.rst:440 +#: ../../c-api/typeobj.rst:240 ../../c-api/typeobj.rst:441 msgid ":c:type:`ternaryfunc`" msgstr ":c:type:`ternaryfunc`" @@ -273,7 +274,7 @@ msgstr "__str__" msgid ":c:member:`~PyTypeObject.tp_getattro`" msgstr ":c:member:`~PyTypeObject.tp_getattro`" -#: ../../c-api/typeobj.rst:76 ../../c-api/typeobj.rst:381 +#: ../../c-api/typeobj.rst:76 ../../c-api/typeobj.rst:382 msgid ":c:type:`getattrofunc`" msgstr ":c:type:`getattrofunc`" @@ -281,7 +282,7 @@ msgstr ":c:type:`getattrofunc`" msgid ":c:member:`~PyTypeObject.tp_setattro`" msgstr ":c:member:`~PyTypeObject.tp_setattro`" -#: ../../c-api/typeobj.rst:79 ../../c-api/typeobj.rst:386 +#: ../../c-api/typeobj.rst:79 ../../c-api/typeobj.rst:387 msgid ":c:type:`setattrofunc`" msgstr ":c:type:`setattrofunc`" @@ -320,7 +321,7 @@ msgstr "__doc__" msgid ":c:member:`~PyTypeObject.tp_traverse`" msgstr ":c:member:`~PyTypeObject.tp_traverse`" -#: ../../c-api/typeobj.rst:88 ../../c-api/typeobj.rst:350 +#: ../../c-api/typeobj.rst:88 ../../c-api/typeobj.rst:351 msgid ":c:type:`traverseproc`" msgstr ":c:type:`traverseproc`" @@ -329,7 +330,7 @@ msgid ":c:member:`~PyTypeObject.tp_clear`" msgstr ":c:member:`~PyTypeObject.tp_clear`" #: ../../c-api/typeobj.rst:90 ../../c-api/typeobj.rst:130 -#: ../../c-api/typeobj.rst:248 ../../c-api/typeobj.rst:429 +#: ../../c-api/typeobj.rst:248 ../../c-api/typeobj.rst:430 msgid ":c:type:`inquiry`" msgstr ":c:type:`inquiry`" @@ -337,7 +338,7 @@ msgstr ":c:type:`inquiry`" msgid ":c:member:`~PyTypeObject.tp_richcompare`" msgstr ":c:member:`~PyTypeObject.tp_richcompare`" -#: ../../c-api/typeobj.rst:92 ../../c-api/typeobj.rst:406 +#: ../../c-api/typeobj.rst:92 ../../c-api/typeobj.rst:407 msgid ":c:type:`richcmpfunc`" msgstr ":c:type:`richcmpfunc`" @@ -353,7 +354,7 @@ msgstr "(:c:member:`~PyTypeObject.tp_weaklistoffset`)" msgid ":c:member:`~PyTypeObject.tp_iter`" msgstr ":c:member:`~PyTypeObject.tp_iter`" -#: ../../c-api/typeobj.rst:101 ../../c-api/typeobj.rst:412 +#: ../../c-api/typeobj.rst:101 ../../c-api/typeobj.rst:413 msgid ":c:type:`getiterfunc`" msgstr ":c:type:`getiterfunc`" @@ -365,7 +366,7 @@ msgstr "__iter__" msgid ":c:member:`~PyTypeObject.tp_iternext`" msgstr ":c:member:`~PyTypeObject.tp_iternext`" -#: ../../c-api/typeobj.rst:103 ../../c-api/typeobj.rst:414 +#: ../../c-api/typeobj.rst:103 ../../c-api/typeobj.rst:415 msgid ":c:type:`iternextfunc`" msgstr ":c:type:`iternextfunc`" @@ -416,15 +417,15 @@ msgstr ":c:member:`~PyTypeObject.tp_dict`" #: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:113 #: ../../c-api/typeobj.rst:132 ../../c-api/typeobj.rst:134 #: ../../c-api/typeobj.rst:136 ../../c-api/typeobj.rst:140 -#: ../../c-api/typeobj.rst:341 ../../c-api/typeobj.rst:346 -#: ../../c-api/typeobj.rst:356 ../../c-api/typeobj.rst:368 -#: ../../c-api/typeobj.rst:370 ../../c-api/typeobj.rst:381 -#: ../../c-api/typeobj.rst:392 ../../c-api/typeobj.rst:404 -#: ../../c-api/typeobj.rst:406 ../../c-api/typeobj.rst:412 -#: ../../c-api/typeobj.rst:414 ../../c-api/typeobj.rst:416 -#: ../../c-api/typeobj.rst:429 ../../c-api/typeobj.rst:431 -#: ../../c-api/typeobj.rst:435 ../../c-api/typeobj.rst:440 -#: ../../c-api/typeobj.rst:446 +#: ../../c-api/typeobj.rst:342 ../../c-api/typeobj.rst:347 +#: ../../c-api/typeobj.rst:357 ../../c-api/typeobj.rst:369 +#: ../../c-api/typeobj.rst:371 ../../c-api/typeobj.rst:382 +#: ../../c-api/typeobj.rst:393 ../../c-api/typeobj.rst:405 +#: ../../c-api/typeobj.rst:407 ../../c-api/typeobj.rst:413 +#: ../../c-api/typeobj.rst:415 ../../c-api/typeobj.rst:417 +#: ../../c-api/typeobj.rst:430 ../../c-api/typeobj.rst:432 +#: ../../c-api/typeobj.rst:436 ../../c-api/typeobj.rst:441 +#: ../../c-api/typeobj.rst:447 msgid ":c:type:`PyObject` *" msgstr ":c:type:`PyObject` *" @@ -436,7 +437,7 @@ msgstr "__dict__" msgid ":c:member:`~PyTypeObject.tp_descr_get`" msgstr ":c:member:`~PyTypeObject.tp_descr_get`" -#: ../../c-api/typeobj.rst:115 ../../c-api/typeobj.rst:392 +#: ../../c-api/typeobj.rst:115 ../../c-api/typeobj.rst:393 msgid ":c:type:`descrgetfunc`" msgstr ":c:type:`descrgetfunc`" @@ -448,7 +449,7 @@ msgstr "__get__" msgid ":c:member:`~PyTypeObject.tp_descr_set`" msgstr ":c:member:`~PyTypeObject.tp_descr_set`" -#: ../../c-api/typeobj.rst:117 ../../c-api/typeobj.rst:398 +#: ../../c-api/typeobj.rst:117 ../../c-api/typeobj.rst:399 msgid ":c:type:`descrsetfunc`" msgstr ":c:type:`descrsetfunc`" @@ -464,7 +465,7 @@ msgstr "(:c:member:`~PyTypeObject.tp_dictoffset`)" msgid ":c:member:`~PyTypeObject.tp_init`" msgstr ":c:member:`~PyTypeObject.tp_init`" -#: ../../c-api/typeobj.rst:122 ../../c-api/typeobj.rst:362 +#: ../../c-api/typeobj.rst:122 ../../c-api/typeobj.rst:363 msgid ":c:type:`initproc`" msgstr ":c:type:`initproc`" @@ -476,7 +477,7 @@ msgstr "__init__" msgid ":c:member:`~PyTypeObject.tp_alloc`" msgstr ":c:member:`~PyTypeObject.tp_alloc`" -#: ../../c-api/typeobj.rst:124 ../../c-api/typeobj.rst:341 +#: ../../c-api/typeobj.rst:124 ../../c-api/typeobj.rst:342 msgid ":c:type:`allocfunc`" msgstr ":c:type:`allocfunc`" @@ -484,7 +485,7 @@ msgstr ":c:type:`allocfunc`" msgid ":c:member:`~PyTypeObject.tp_new`" msgstr ":c:member:`~PyTypeObject.tp_new`" -#: ../../c-api/typeobj.rst:126 ../../c-api/typeobj.rst:356 +#: ../../c-api/typeobj.rst:126 ../../c-api/typeobj.rst:357 msgid ":c:type:`newfunc`" msgstr ":c:type:`newfunc`" @@ -496,7 +497,7 @@ msgstr "__new__" msgid ":c:member:`~PyTypeObject.tp_free`" msgstr ":c:member:`~PyTypeObject.tp_free`" -#: ../../c-api/typeobj.rst:128 ../../c-api/typeobj.rst:348 +#: ../../c-api/typeobj.rst:128 ../../c-api/typeobj.rst:349 msgid ":c:type:`freefunc`" msgstr ":c:type:`freefunc`" @@ -533,7 +534,7 @@ msgid "[:c:member:`~PyTypeObject.tp_subclasses`]" msgstr "[:c:member:`~PyTypeObject.tp_subclasses`]" #: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:138 -#: ../../c-api/typeobj.rst:279 ../../c-api/typeobj.rst:348 +#: ../../c-api/typeobj.rst:279 ../../c-api/typeobj.rst:349 msgid "void *" msgstr "void *" @@ -667,7 +668,7 @@ msgstr ":c:member:`~PyAsyncMethods.am_await`" #: ../../c-api/typeobj.rst:244 ../../c-api/typeobj.rst:246 #: ../../c-api/typeobj.rst:250 ../../c-api/typeobj.rst:277 #: ../../c-api/typeobj.rst:281 ../../c-api/typeobj.rst:291 -#: ../../c-api/typeobj.rst:431 +#: ../../c-api/typeobj.rst:432 msgid ":c:type:`unaryfunc`" msgstr ":c:type:`unaryfunc`" @@ -717,7 +718,7 @@ msgstr ":c:member:`~PyNumberMethods.nb_add`" #: ../../c-api/typeobj.rst:289 ../../c-api/typeobj.rst:293 #: ../../c-api/typeobj.rst:296 ../../c-api/typeobj.rst:302 #: ../../c-api/typeobj.rst:311 ../../c-api/typeobj.rst:322 -#: ../../c-api/typeobj.rst:435 +#: ../../c-api/typeobj.rst:436 msgid ":c:type:`binaryfunc`" msgstr ":c:type:`binaryfunc`" @@ -1006,7 +1007,7 @@ msgid ":c:member:`~PyMappingMethods.mp_length`" msgstr ":c:member:`~PyMappingMethods.mp_length`" #: ../../c-api/typeobj.rst:300 ../../c-api/typeobj.rst:309 -#: ../../c-api/typeobj.rst:416 +#: ../../c-api/typeobj.rst:417 msgid ":c:type:`lenfunc`" msgstr ":c:type:`lenfunc`" @@ -1026,7 +1027,7 @@ msgstr "__getitem__" msgid ":c:member:`~PyMappingMethods.mp_ass_subscript`" msgstr ":c:member:`~PyMappingMethods.mp_ass_subscript`" -#: ../../c-api/typeobj.rst:304 ../../c-api/typeobj.rst:462 +#: ../../c-api/typeobj.rst:304 ../../c-api/typeobj.rst:463 msgid ":c:type:`objobjargproc`" msgstr ":c:type:`objobjargproc`" @@ -1051,7 +1052,7 @@ msgid ":c:member:`~PySequenceMethods.sq_repeat`" msgstr ":c:member:`~PySequenceMethods.sq_repeat`" #: ../../c-api/typeobj.rst:313 ../../c-api/typeobj.rst:315 -#: ../../c-api/typeobj.rst:324 ../../c-api/typeobj.rst:446 +#: ../../c-api/typeobj.rst:324 ../../c-api/typeobj.rst:447 msgid ":c:type:`ssizeargfunc`" msgstr ":c:type:`ssizeargfunc`" @@ -1067,7 +1068,7 @@ msgstr ":c:member:`~PySequenceMethods.sq_item`" msgid ":c:member:`~PySequenceMethods.sq_ass_item`" msgstr ":c:member:`~PySequenceMethods.sq_ass_item`" -#: ../../c-api/typeobj.rst:317 ../../c-api/typeobj.rst:451 +#: ../../c-api/typeobj.rst:317 ../../c-api/typeobj.rst:452 msgid ":c:type:`ssizeobjargproc`" msgstr ":c:type:`ssizeobjargproc`" @@ -1079,7 +1080,7 @@ msgstr "__setitem__ __delitem__" msgid ":c:member:`~PySequenceMethods.sq_contains`" msgstr ":c:member:`~PySequenceMethods.sq_contains`" -#: ../../c-api/typeobj.rst:320 ../../c-api/typeobj.rst:457 +#: ../../c-api/typeobj.rst:320 ../../c-api/typeobj.rst:458 msgid ":c:type:`objobjproc`" msgstr ":c:type:`objobjproc`" @@ -1103,6 +1104,11 @@ msgstr ":c:member:`~PyBufferProcs.bf_getbuffer`" msgid ":c:func:`getbufferproc`" msgstr ":c:func:`getbufferproc`" +#: ../../c-api/typeobj.rst:328 +#, fuzzy +msgid "__buffer__" +msgstr "__buffer__" + #: ../../c-api/typeobj.rst:330 msgid ":c:member:`~PyBufferProcs.bf_releasebuffer`" msgstr ":c:member:`~PyBufferProcs.bf_releasebuffer`" @@ -1111,24 +1117,28 @@ msgstr ":c:member:`~PyBufferProcs.bf_releasebuffer`" msgid ":c:func:`releasebufferproc`" msgstr ":c:func:`releasebufferproc`" -#: ../../c-api/typeobj.rst:336 +#: ../../c-api/typeobj.rst:330 +msgid "__release_\\ buffer\\__" +msgstr "" + +#: ../../c-api/typeobj.rst:337 msgid "slot typedefs" msgstr "" -#: ../../c-api/typeobj.rst:339 +#: ../../c-api/typeobj.rst:340 msgid "typedef" msgstr "typedef" -#: ../../c-api/typeobj.rst:339 +#: ../../c-api/typeobj.rst:340 msgid "Parameter Types" msgstr "" -#: ../../c-api/typeobj.rst:339 +#: ../../c-api/typeobj.rst:340 msgid "Return Type" msgstr "" -#: ../../c-api/typeobj.rst:346 ../../c-api/typeobj.rst:348 -#: ../../c-api/typeobj.rst:424 +#: ../../c-api/typeobj.rst:347 ../../c-api/typeobj.rst:349 +#: ../../c-api/typeobj.rst:425 msgid "void" msgstr "void" @@ -1136,20 +1146,20 @@ msgstr "void" msgid ":c:type:`visitproc`" msgstr ":c:type:`visitproc`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:350 -#: ../../c-api/typeobj.rst:362 ../../c-api/typeobj.rst:375 -#: ../../c-api/typeobj.rst:386 ../../c-api/typeobj.rst:398 -#: ../../c-api/typeobj.rst:418 ../../c-api/typeobj.rst:429 -#: ../../c-api/typeobj.rst:451 ../../c-api/typeobj.rst:457 -#: ../../c-api/typeobj.rst:462 +#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:351 +#: ../../c-api/typeobj.rst:363 ../../c-api/typeobj.rst:376 +#: ../../c-api/typeobj.rst:387 ../../c-api/typeobj.rst:399 +#: ../../c-api/typeobj.rst:419 ../../c-api/typeobj.rst:430 +#: ../../c-api/typeobj.rst:452 ../../c-api/typeobj.rst:458 +#: ../../c-api/typeobj.rst:463 msgid "int" msgstr "int" -#: ../../c-api/typeobj.rst:404 +#: ../../c-api/typeobj.rst:405 msgid "Py_hash_t" msgstr "Py_hash_t" -#: ../../c-api/typeobj.rst:418 +#: ../../c-api/typeobj.rst:419 msgid ":c:type:`getbufferproc`" msgstr ":c:type:`getbufferproc`" @@ -1157,26 +1167,26 @@ msgstr ":c:type:`getbufferproc`" msgid ":c:type:`Py_buffer` *" msgstr ":c:type:`Py_buffer` *" -#: ../../c-api/typeobj.rst:424 +#: ../../c-api/typeobj.rst:425 msgid ":c:type:`releasebufferproc`" msgstr ":c:type:`releasebufferproc`" -#: ../../c-api/typeobj.rst:469 +#: ../../c-api/typeobj.rst:470 msgid "See :ref:`slot-typedefs` below for more detail." msgstr "更多細節請見下方的 :ref:`slot-typedefs`。" -#: ../../c-api/typeobj.rst:473 +#: ../../c-api/typeobj.rst:474 msgid "PyTypeObject Definition" msgstr "" -#: ../../c-api/typeobj.rst:475 +#: ../../c-api/typeobj.rst:476 msgid "" -"The structure definition for :c:type:`PyTypeObject` can be found " -"in :file:`Include/cpython/object.h`. For convenience of reference, this " -"repeats the definition found there:" +"The structure definition for :c:type:`PyTypeObject` can be found in :file:" +"`Include/cpython/object.h`. For convenience of reference, this repeats the " +"definition found there:" msgstr "" -#: ../../c-api/typeobj.rst:481 +#: ../../c-api/typeobj.rst:482 msgid "" "typedef struct _typeobject {\n" " PyObject_VAR_HEAD\n" @@ -1266,72 +1276,71 @@ msgid "" "} PyTypeObject;\n" msgstr "" -#: ../../c-api/typeobj.rst:485 +#: ../../c-api/typeobj.rst:486 msgid "PyObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:487 +#: ../../c-api/typeobj.rst:488 msgid "" -"The type object structure extends the :c:type:`PyVarObject` structure. " -"The :c:member:`~PyVarObject.ob_size` field is used for dynamic types " -"(created by :c:func:`!type_new`, usually called from a class statement). " -"Note that :c:data:`PyType_Type` (the metatype) " -"initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its " -"instances (i.e. type objects) *must* have " +"The type object structure extends the :c:type:`PyVarObject` structure. The :" +"c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :" +"c:func:`!type_new`, usually called from a class statement). Note that :c:" +"data:`PyType_Type` (the metatype) initializes :c:member:`~PyTypeObject." +"tp_itemsize`, which means that its instances (i.e. type objects) *must* have " "the :c:member:`~PyVarObject.ob_size` field." msgstr "" -#: ../../c-api/typeobj.rst:496 +#: ../../c-api/typeobj.rst:497 msgid "" "This is the type object's reference count, initialized to ``1`` by the " "``PyObject_HEAD_INIT`` macro. Note that for :ref:`statically allocated type " -"objects `, the type's instances (objects " -"whose :c:member:`~PyObject.ob_type` points back to the type) do *not* count " -"as references. But for :ref:`dynamically allocated type objects `, the instances *do* count as references." -msgstr "" - -#: ../../c-api/typeobj.rst:503 ../../c-api/typeobj.rst:526 -#: ../../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 +"objects `, the type's instances (objects whose :c:member:" +"`~PyObject.ob_type` points back to the type) do *not* count as references. " +"But for :ref:`dynamically allocated type objects `, the " +"instances *do* count as references." +msgstr "" + +#: ../../c-api/typeobj.rst:504 ../../c-api/typeobj.rst:527 +#: ../../c-api/typeobj.rst:544 ../../c-api/typeobj.rst:588 +#: ../../c-api/typeobj.rst:666 ../../c-api/typeobj.rst:742 +#: ../../c-api/typeobj.rst:783 ../../c-api/typeobj.rst:800 +#: ../../c-api/typeobj.rst:817 ../../c-api/typeobj.rst:835 +#: ../../c-api/typeobj.rst:859 ../../c-api/typeobj.rst:876 +#: ../../c-api/typeobj.rst:888 ../../c-api/typeobj.rst:900 +#: ../../c-api/typeobj.rst:933 ../../c-api/typeobj.rst:955 +#: ../../c-api/typeobj.rst:975 ../../c-api/typeobj.rst:996 +#: ../../c-api/typeobj.rst:1022 ../../c-api/typeobj.rst:1041 +#: ../../c-api/typeobj.rst:1057 ../../c-api/typeobj.rst:1096 +#: ../../c-api/typeobj.rst:1107 ../../c-api/typeobj.rst:1117 +#: ../../c-api/typeobj.rst:1127 ../../c-api/typeobj.rst:1141 +#: ../../c-api/typeobj.rst:1159 ../../c-api/typeobj.rst:1182 +#: ../../c-api/typeobj.rst:1200 ../../c-api/typeobj.rst:1213 +#: ../../c-api/typeobj.rst:1235 ../../c-api/typeobj.rst:1279 +#: ../../c-api/typeobj.rst:1300 ../../c-api/typeobj.rst:1319 +#: ../../c-api/typeobj.rst:1349 ../../c-api/typeobj.rst:1371 +#: ../../c-api/typeobj.rst:1397 ../../c-api/typeobj.rst:1482 +#: ../../c-api/typeobj.rst:1556 ../../c-api/typeobj.rst:1617 +#: ../../c-api/typeobj.rst:1653 ../../c-api/typeobj.rst:1678 +#: ../../c-api/typeobj.rst:1701 ../../c-api/typeobj.rst:1714 +#: ../../c-api/typeobj.rst:1729 ../../c-api/typeobj.rst:1743 +#: ../../c-api/typeobj.rst:1773 ../../c-api/typeobj.rst:1805 +#: ../../c-api/typeobj.rst:1831 ../../c-api/typeobj.rst:1849 +#: ../../c-api/typeobj.rst:1878 ../../c-api/typeobj.rst:1922 +#: ../../c-api/typeobj.rst:1939 ../../c-api/typeobj.rst:1980 +#: ../../c-api/typeobj.rst:2002 ../../c-api/typeobj.rst:2034 +#: ../../c-api/typeobj.rst:2062 ../../c-api/typeobj.rst:2075 +#: ../../c-api/typeobj.rst:2085 ../../c-api/typeobj.rst:2102 +#: ../../c-api/typeobj.rst:2119 ../../c-api/typeobj.rst:2133 +#: ../../c-api/typeobj.rst:2166 ../../c-api/typeobj.rst:2189 msgid "**Inheritance:**" msgstr "" -#: ../../c-api/typeobj.rst:505 ../../c-api/typeobj.rst:545 -#: ../../c-api/typeobj.rst:589 +#: ../../c-api/typeobj.rst:506 ../../c-api/typeobj.rst:546 +#: ../../c-api/typeobj.rst:590 msgid "This field is not inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:510 +#: ../../c-api/typeobj.rst:511 msgid "" "This is the type's type, in other words its metatype. It is initialized by " "the argument to the ``PyObject_HEAD_INIT`` macro, and its value should " @@ -1343,78 +1352,76 @@ msgid "" "doing anything else. This is typically done like this::" msgstr "" -#: ../../c-api/typeobj.rst:519 +#: ../../c-api/typeobj.rst:520 msgid "Foo_Type.ob_type = &PyType_Type;" msgstr "Foo_Type.ob_type = &PyType_Type;" -#: ../../c-api/typeobj.rst:521 +#: ../../c-api/typeobj.rst:522 msgid "" -"This should be done before any instances of the type are " -"created. :c:func:`PyType_Ready` checks if :c:member:`~PyObject.ob_type` is " -"``NULL``, and if so, initializes it to the :c:member:`~PyObject.ob_type` " -"field of the base class. :c:func:`PyType_Ready` will not change this field " -"if it is non-zero." +"This should be done before any instances of the type are created. :c:func:" +"`PyType_Ready` checks if :c:member:`~PyObject.ob_type` is ``NULL``, and if " +"so, initializes it to the :c:member:`~PyObject.ob_type` field of the base " +"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: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 +#: ../../c-api/typeobj.rst:529 ../../c-api/typeobj.rst:744 +#: ../../c-api/typeobj.rst:861 ../../c-api/typeobj.rst:957 +#: ../../c-api/typeobj.rst:977 ../../c-api/typeobj.rst:1680 +#: ../../c-api/typeobj.rst:1703 ../../c-api/typeobj.rst:1833 +#: ../../c-api/typeobj.rst:1851 ../../c-api/typeobj.rst:1924 +#: ../../c-api/typeobj.rst:2036 ../../c-api/typeobj.rst:2168 msgid "This field is inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:532 +#: ../../c-api/typeobj.rst:533 msgid "PyVarObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:536 +#: ../../c-api/typeobj.rst:537 msgid "" "For :ref:`statically allocated type objects `, this should be " "initialized to zero. For :ref:`dynamically allocated type objects `, this field has a special internal meaning." msgstr "" -#: ../../c-api/typeobj.rst:540 +#: ../../c-api/typeobj.rst:541 msgid "" -"This field should be accessed using the :c:func:`Py_SIZE()` " -"and :c:func:`Py_SET_SIZE()` macros." +"This field should be accessed using the :c:func:`Py_SIZE()` and :c:func:" +"`Py_SET_SIZE()` macros." msgstr "" -#: ../../c-api/typeobj.rst:549 +#: ../../c-api/typeobj.rst:550 msgid "PyTypeObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:551 +#: ../../c-api/typeobj.rst:552 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 " -"\"Default\" section. (Note that many fields set " -"on :c:data:`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as " -"defaults.)" +"\"Default\" section. (Note that many fields set on :c:data:" +"`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as defaults.)" msgstr "" -#: ../../c-api/typeobj.rst:558 +#: ../../c-api/typeobj.rst:559 msgid "" "Pointer to a NUL-terminated string containing the name of the type. For " "types that are accessible as module globals, the string should be the full " "module name, followed by a dot, followed by the type name; for built-in " "types, it should be just the type name. If the module is a submodule of a " "package, the full package name is part of the full module name. For " -"example, a type named :class:`!T` defined in module :mod:`!M` in " -"subpackage :mod:`!Q` in package :mod:`!P` should have " -"the :c:member:`~PyTypeObject.tp_name` initializer ``\"P.Q.M.T\"``." +"example, a type named :class:`!T` defined in module :mod:`!M` in subpackage :" +"mod:`!Q` in package :mod:`!P` should have the :c:member:`~PyTypeObject." +"tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" -#: ../../c-api/typeobj.rst:566 +#: ../../c-api/typeobj.rst:567 msgid "" "For :ref:`dynamically allocated type objects `, this should just " "be the type name, and the module name explicitly stored in the type dict as " "the value for key ``'__module__'``." msgstr "" -#: ../../c-api/typeobj.rst:571 +#: ../../c-api/typeobj.rst:572 msgid "" "For :ref:`statically allocated type objects `, the *tp_name* " "field should contain a dot. Everything before the last dot is made " @@ -1422,115 +1429,114 @@ msgid "" "the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" -#: ../../c-api/typeobj.rst:577 +#: ../../c-api/typeobj.rst:578 msgid "" "If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is " -"made accessible as the :attr:`~type.__name__` attribute, and " -"the :attr:`~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." +"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:583 +#: ../../c-api/typeobj.rst:584 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`)." +"This field must not be ``NULL``. It is the only required field in :c:func:" +"`PyTypeObject` (other than potentially :c:member:`~PyTypeObject." +"tp_itemsize`)." msgstr "" -#: ../../c-api/typeobj.rst:595 +#: ../../c-api/typeobj.rst:596 msgid "" "These fields allow calculating the size in bytes of instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:597 +#: ../../c-api/typeobj.rst:598 msgid "" -"There are two kinds of types: types with fixed-length instances have a " -"zero :c:member:`!tp_itemsize` field, types with variable-length instances " -"have a 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`.)" +"There are two kinds of types: types with fixed-length instances have a zero :" +"c:member:`!tp_itemsize` field, types with variable-length instances have a " +"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:604 +#: ../../c-api/typeobj.rst:605 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:`!tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N " -"is the \"length\" of the object." +"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:`!" +"tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is the " +"\"length\" of the object." msgstr "" -#: ../../c-api/typeobj.rst:609 +#: ../../c-api/typeobj.rst:610 msgid "" "Functions like :c:func:`PyObject_NewVar` will take the value of N as an " "argument, and store in the instance's :c:member:`~PyVarObject.ob_size` " "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`." +"underlying storage and its size should be accessed using :c:func:" +"`PyLong_Export`." msgstr "" -#: ../../c-api/typeobj.rst:619 +#: ../../c-api/typeobj.rst:620 msgid "" -"The :c:member:`~PyVarObject.ob_size` field should be accessed using " -"the :c:func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros." +"The :c:member:`~PyVarObject.ob_size` field should be accessed using the :c:" +"func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros." msgstr "" -#: ../../c-api/typeobj.rst:622 +#: ../../c-api/typeobj.rst:623 msgid "" "Also, the presence of an :c:member:`~PyVarObject.ob_size` field in the " "instance layout doesn't mean that the instance structure is variable-length. " "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.)" +"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 +#: ../../c-api/typeobj.rst:630 msgid "" -"The :c:member:`!tp_basicsize` includes size needed for data of the " -"type's :c:member:`~PyTypeObject.tp_base`, plus any extra data needed by each " -"instance." +"The :c:member:`!tp_basicsize` includes size needed for data of the type's :c:" +"member:`~PyTypeObject.tp_base`, plus any extra data needed by each instance." msgstr "" -#: ../../c-api/typeobj.rst:633 +#: ../../c-api/typeobj.rst:634 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`." +"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 +#: ../../c-api/typeobj.rst:640 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." +"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:645 +#: ../../c-api/typeobj.rst:646 msgid "" "The basic size does not include the GC header size, as that header is not " "part of :c:macro:`PyObject_HEAD`." msgstr "" -#: ../../c-api/typeobj.rst:648 +#: ../../c-api/typeobj.rst:649 msgid "" -"For cases where struct used to declare the base type is unknown, " -"see :c:member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`." +"For cases where struct used to declare the base type is unknown, see :c:" +"member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`." msgstr "" -#: ../../c-api/typeobj.rst:651 +#: ../../c-api/typeobj.rst:652 msgid "Notes about alignment:" msgstr "" -#: ../../c-api/typeobj.rst:653 +#: ../../c-api/typeobj.rst:654 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 " @@ -1539,7 +1545,7 @@ msgid "" "you." msgstr "" -#: ../../c-api/typeobj.rst:658 +#: ../../c-api/typeobj.rst:659 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 " @@ -1547,14 +1553,14 @@ msgid "" "your responsibility that both fields are a multiple of ``_Alignof(double)``." msgstr "" -#: ../../c-api/typeobj.rst:667 +#: ../../c-api/typeobj.rst:668 msgid "" "These fields are inherited separately by subtypes. (That is, if the field is " "set to zero, :c:func:`PyType_Ready` will copy the value from the base type, " "indicating that the instances do not need additional storage.)" msgstr "" -#: ../../c-api/typeobj.rst:672 +#: ../../c-api/typeobj.rst:673 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 " @@ -1562,7 +1568,7 @@ msgid "" "implementation of the base type)." msgstr "" -#: ../../c-api/typeobj.rst:679 +#: ../../c-api/typeobj.rst:680 msgid "" "A pointer to the instance destructor function. This function must be " "defined unless the type guarantees that its instances will never be " @@ -1570,38 +1576,36 @@ msgid "" "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:683 +#: ../../c-api/typeobj.rst:684 msgid "void tp_dealloc(PyObject *self);" msgstr "void tp_dealloc(PyObject *self);" -#: ../../c-api/typeobj.rst:685 -msgid "" -"The destructor function is called by the :c:func:`Py_DECREF` " -"and :c:func:`Py_XDECREF` macros when the new reference count is zero. At " -"this point, the instance is still in existence, but there are no references " -"to it. The destructor function should free all references which the " -"instance owns, free all memory buffers owned by the instance (using the " -"freeing function corresponding to the allocation function used to allocate " -"the buffer), and call the type's :c:member:`~PyTypeObject.tp_free` " -"function. If the type is not subtypable (doesn't have " -"the :c:macro:`Py_TPFLAGS_BASETYPE` flag bit set), it is permissible to call " -"the object deallocator directly instead of " +#: ../../c-api/typeobj.rst:686 +msgid "" +"The destructor function is called by the :c:func:`Py_DECREF` and :c:func:" +"`Py_XDECREF` macros when the new reference count is zero. At this point, " +"the instance is still in existence, but there are no references to it. The " +"destructor function should free all references which the instance owns, free " +"all memory buffers owned by the instance (using the freeing function " +"corresponding to the allocation function used to allocate the buffer), and " +"call the type's :c:member:`~PyTypeObject.tp_free` function. If the type is " +"not subtypable (doesn't have the :c:macro:`Py_TPFLAGS_BASETYPE` flag bit " +"set), it is permissible to call the object deallocator directly instead of " "via :c:member:`~PyTypeObject.tp_free`. The object deallocator should be the " "one used to allocate the instance; this is normally :c:func:`PyObject_Del` " -"if the instance was allocated using :c:macro:`PyObject_New` " -"or :c:macro:`PyObject_NewVar`, or :c:func:`PyObject_GC_Del` if the instance " -"was allocated using :c:macro:`PyObject_GC_New` " -"or :c:macro:`PyObject_GC_NewVar`." +"if the instance was allocated using :c:macro:`PyObject_New` or :c:macro:" +"`PyObject_NewVar`, or :c:func:`PyObject_GC_Del` if the instance was " +"allocated using :c:macro:`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar`." msgstr "" -#: ../../c-api/typeobj.rst:700 +#: ../../c-api/typeobj.rst:701 msgid "" -"If the type supports garbage collection (has " -"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit set), the destructor should " -"call :c:func:`PyObject_GC_UnTrack` before clearing any member fields." +"If 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:704 +#: ../../c-api/typeobj.rst:705 msgid "" "static void foo_dealloc(foo_object *self) {\n" " PyObject_GC_UnTrack(self);\n" @@ -1615,15 +1619,15 @@ msgstr "" " Py_TYPE(self)->tp_free((PyObject *)self);\n" "}" -#: ../../c-api/typeobj.rst:712 +#: ../../c-api/typeobj.rst:713 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:func:`Py_DECREF`) after calling the type deallocator. In order to " -"avoid dangling pointers, the recommended way to achieve this is:" +"deallocator should release the owned reference to its type object (via :c:" +"func:`Py_DECREF`) after calling the type deallocator. In order to avoid " +"dangling pointers, the recommended way to achieve this is:" msgstr "" -#: ../../c-api/typeobj.rst:718 +#: ../../c-api/typeobj.rst:719 msgid "" "static void foo_dealloc(foo_object *self) {\n" " PyTypeObject *tp = Py_TYPE(self);\n" @@ -1633,7 +1637,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:729 +#: ../../c-api/typeobj.rst:730 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 " @@ -1642,69 +1646,68 @@ msgid "" "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." +"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 +#: ../../c-api/typeobj.rst:749 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:753 +#: ../../c-api/typeobj.rst:754 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:757 +#: ../../c-api/typeobj.rst:758 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:761 +#: ../../c-api/typeobj.rst:762 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 *vectorcallfunc* function. This can be done by setting " -"*tp_call* to :c:func:`PyVectorcall_Call`." +"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 " +"*vectorcallfunc* function. This can be done by setting *tp_call* to :c:func:" +"`PyVectorcall_Call`." msgstr "" -#: ../../c-api/typeobj.rst:768 +#: ../../c-api/typeobj.rst:769 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:774 +#: ../../c-api/typeobj.rst:775 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " -"` to implement the vectorcall protocol. When a user " -"sets :attr:`~object.__call__` in Python code, only *tp_call* is updated, " -"likely making it inconsistent with the vectorcall function. Since 3.12, " -"setting ``__call__`` will disable vectorcall optimization by clearing " -"the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag." +"` to implement the vectorcall protocol. When a user sets :attr:" +"`~object.__call__` in Python code, only *tp_call* is updated, likely making " +"it inconsistent with the vectorcall function. Since 3.12, setting " +"``__call__`` will disable vectorcall optimization by clearing the :c:macro:" +"`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" -#: ../../c-api/typeobj.rst:784 +#: ../../c-api/typeobj.rst:785 msgid "" -"This field is always inherited. However, " -"the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If " -"it's not set, then the subclass won't use :ref:`vectorcall `, " -"except when :c:func:`PyVectorcall_Call` is explicitly called." +"This field is always inherited. However, the :c:macro:" +"`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " +"then the subclass won't use :ref:`vectorcall `, except when :c:" +"func:`PyVectorcall_Call` is explicitly called." msgstr "" -#: ../../c-api/typeobj.rst:793 +#: ../../c-api/typeobj.rst:794 msgid "An optional pointer to the get-attribute-string function." msgstr "" -#: ../../c-api/typeobj.rst:795 +#: ../../c-api/typeobj.rst:796 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, " @@ -1712,28 +1715,29 @@ msgid "" "attribute name." msgstr "" -#: ../../c-api/typeobj.rst:801 ../../c-api/typeobj.rst:997 -msgid "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject.tp_getattro`" +#: ../../c-api/typeobj.rst:802 ../../c-api/typeobj.rst:998 +msgid "" +"Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." +"tp_getattro`" msgstr "" -"群" -"組::c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject.tp_getattro`" +"群組::c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject." +"tp_getattro`" -#: ../../c-api/typeobj.rst:803 +#: ../../c-api/typeobj.rst:804 msgid "" -"This field is inherited by subtypes together " -"with :c:member:`~PyTypeObject.tp_getattro`: a subtype inherits " -"both :c:member:`~PyTypeObject.tp_getattr` " +"This field is inherited by subtypes together with :c:member:`~PyTypeObject." +"tp_getattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " "and :c:member:`~PyTypeObject.tp_getattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_getattr` " -"and :c:member:`~PyTypeObject.tp_getattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject." +"tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:810 ../../c-api/typeobj.rst:1010 +#: ../../c-api/typeobj.rst:811 ../../c-api/typeobj.rst:1011 msgid "" "An optional pointer to the function for setting and deleting attributes." msgstr "" -#: ../../c-api/typeobj.rst:812 +#: ../../c-api/typeobj.rst:813 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, " @@ -1741,54 +1745,55 @@ msgid "" "attribute name." msgstr "" -#: ../../c-api/typeobj.rst:818 ../../c-api/typeobj.rst:1023 -msgid "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject.tp_setattro`" +#: ../../c-api/typeobj.rst:819 ../../c-api/typeobj.rst:1024 +msgid "" +"Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." +"tp_setattro`" msgstr "" -"群" -"組::c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject.tp_setattro`" +"群組::c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject." +"tp_setattro`" -#: ../../c-api/typeobj.rst:820 +#: ../../c-api/typeobj.rst:821 msgid "" -"This field is inherited by subtypes together " -"with :c:member:`~PyTypeObject.tp_setattro`: a subtype inherits " -"both :c:member:`~PyTypeObject.tp_setattr` " +"This field is inherited by subtypes together with :c:member:`~PyTypeObject." +"tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " "and :c:member:`~PyTypeObject.tp_setattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_setattr` " -"and :c:member:`~PyTypeObject.tp_setattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject." +"tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:827 +#: ../../c-api/typeobj.rst:828 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:831 +#: ../../c-api/typeobj.rst:832 msgid "Formerly known as ``tp_compare`` and ``tp_reserved``." msgstr "" -#: ../../c-api/typeobj.rst:836 +#: ../../c-api/typeobj.rst:837 msgid "" "The :c:member:`~PyTypeObject.tp_as_async` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:844 +#: ../../c-api/typeobj.rst:845 msgid "" -"An optional pointer to a function that implements the built-in " -"function :func:`repr`." +"An optional pointer to a function that implements the built-in function :" +"func:`repr`." msgstr "" -#: ../../c-api/typeobj.rst:847 +#: ../../c-api/typeobj.rst:848 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" msgstr "" -#: ../../c-api/typeobj.rst:849 +#: ../../c-api/typeobj.rst:850 msgid "PyObject *tp_repr(PyObject *self);" msgstr "PyObject *tp_repr(PyObject *self);" -#: ../../c-api/typeobj.rst:851 +#: ../../c-api/typeobj.rst:852 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 " @@ -1797,152 +1802,153 @@ msgid "" "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -#: ../../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 +#: ../../c-api/typeobj.rst:863 ../../c-api/typeobj.rst:942 +#: ../../c-api/typeobj.rst:979 ../../c-api/typeobj.rst:1004 +#: ../../c-api/typeobj.rst:1030 ../../c-api/typeobj.rst:1071 +#: ../../c-api/typeobj.rst:1626 ../../c-api/typeobj.rst:1660 +#: ../../c-api/typeobj.rst:1777 ../../c-api/typeobj.rst:1810 +#: ../../c-api/typeobj.rst:1885 ../../c-api/typeobj.rst:1926 +#: ../../c-api/typeobj.rst:1944 ../../c-api/typeobj.rst:1986 +#: ../../c-api/typeobj.rst:2007 ../../c-api/typeobj.rst:2038 msgid "**Default:**" msgstr "**預設:**" -#: ../../c-api/typeobj.rst:864 +#: ../../c-api/typeobj.rst:865 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:871 +#: ../../c-api/typeobj.rst:872 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:877 +#: ../../c-api/typeobj.rst:878 msgid "" "The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:883 +#: ../../c-api/typeobj.rst:884 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:889 +#: ../../c-api/typeobj.rst:890 msgid "" "The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:895 +#: ../../c-api/typeobj.rst:896 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:901 +#: ../../c-api/typeobj.rst:902 msgid "" "The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:909 +#: ../../c-api/typeobj.rst:910 msgid "" -"An optional pointer to a function that implements the built-in " -"function :func:`hash`." +"An optional pointer to a function that implements the built-in function :" +"func:`hash`." msgstr "" -#: ../../c-api/typeobj.rst:912 +#: ../../c-api/typeobj.rst:913 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" msgstr "" -#: ../../c-api/typeobj.rst:914 +#: ../../c-api/typeobj.rst:915 msgid "Py_hash_t tp_hash(PyObject *);" msgstr "Py_hash_t tp_hash(PyObject *);" -#: ../../c-api/typeobj.rst:916 +#: ../../c-api/typeobj.rst:917 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:920 +#: ../../c-api/typeobj.rst:921 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:`TypeError`. This is the same as setting it " -"to :c:func:`PyObject_HashNotImplemented`." +"is not set), an attempt to take the hash of the object raises :exc:" +"`TypeError`. This is the same as setting it to :c:func:" +"`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:924 +#: ../../c-api/typeobj.rst:925 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 " "as the equivalent of ``__hash__ = None`` at the Python level, causing " "``isinstance(o, collections.Hashable)`` to correctly return ``False``. Note " "that the converse is also true - setting ``__hash__ = None`` on a class at " -"the Python level will result in the ``tp_hash`` slot being set " -"to :c:func:`PyObject_HashNotImplemented`." +"the Python level will result in the ``tp_hash`` slot being set to :c:func:" +"`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:934 ../../c-api/typeobj.rst:1618 -msgid "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject.tp_richcompare`" +#: ../../c-api/typeobj.rst:935 ../../c-api/typeobj.rst:1619 +msgid "" +"Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." +"tp_richcompare`" msgstr "" -"群" -"組::c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject.tp_richcompare`" +"群組::c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject." +"tp_richcompare`" -#: ../../c-api/typeobj.rst:936 +#: ../../c-api/typeobj.rst:937 msgid "" -"This field is inherited by subtypes together " -"with :c:member:`~PyTypeObject.tp_richcompare`: a subtype inherits both " -"of :c:member:`~PyTypeObject.tp_richcompare` " -"and :c:member:`~PyTypeObject.tp_hash`, when the " -"subtype's :c:member:`~PyTypeObject.tp_richcompare` " -"and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." +"This field is inherited by subtypes together with :c:member:`~PyTypeObject." +"tp_richcompare`: a subtype inherits both of :c:member:`~PyTypeObject." +"tp_richcompare` and :c:member:`~PyTypeObject.tp_hash`, when the subtype's :c:" +"member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` " +"are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:943 +#: ../../c-api/typeobj.rst:944 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`." msgstr "" -#: ../../c-api/typeobj.rst:948 +#: ../../c-api/typeobj.rst:949 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:952 +#: ../../c-api/typeobj.rst:953 msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" msgstr "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" -#: ../../c-api/typeobj.rst:961 +#: ../../c-api/typeobj.rst:962 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 the constructor for that type. This constructor " -"calls :c:func:`PyObject_Str` to do the actual work, " -"and :c:func:`PyObject_Str` will call this handler.)" +"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 " +"the constructor for that type. This constructor calls :c:func:" +"`PyObject_Str` to do the actual work, and :c:func:`PyObject_Str` will call " +"this handler.)" msgstr "" -#: ../../c-api/typeobj.rst:966 +#: ../../c-api/typeobj.rst:967 msgid "The signature is the same as for :c:func:`PyObject_Str`::" msgstr "" -#: ../../c-api/typeobj.rst:968 +#: ../../c-api/typeobj.rst:969 msgid "PyObject *tp_str(PyObject *self);" msgstr "PyObject *tp_str(PyObject *self);" -#: ../../c-api/typeobj.rst:970 +#: ../../c-api/typeobj.rst:971 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 " @@ -1950,101 +1956,99 @@ msgid "" "function." msgstr "" -#: ../../c-api/typeobj.rst:980 +#: ../../c-api/typeobj.rst:981 msgid "" "When this field is not set, :c:func:`PyObject_Repr` is called to return a " "string representation." msgstr "" -#: ../../c-api/typeobj.rst:986 +#: ../../c-api/typeobj.rst:987 msgid "An optional pointer to the get-attribute function." msgstr "" -#: ../../c-api/typeobj.rst:988 +#: ../../c-api/typeobj.rst:989 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" msgstr "" -#: ../../c-api/typeobj.rst:990 +#: ../../c-api/typeobj.rst:991 msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" msgstr "PyObject *tp_getattro(PyObject *self, PyObject *attr);" -#: ../../c-api/typeobj.rst:992 +#: ../../c-api/typeobj.rst:993 msgid "" -"It is usually convenient to set this field " -"to :c:func:`PyObject_GenericGetAttr`, which implements the normal way of " -"looking for object attributes." +"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:999 +#: ../../c-api/typeobj.rst:1000 msgid "" -"This field is inherited by subtypes together " -"with :c:member:`~PyTypeObject.tp_getattr`: a subtype inherits " -"both :c:member:`~PyTypeObject.tp_getattr` " +"This field is inherited by subtypes together with :c:member:`~PyTypeObject." +"tp_getattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " "and :c:member:`~PyTypeObject.tp_getattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_getattr` " -"and :c:member:`~PyTypeObject.tp_getattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject." +"tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1005 +#: ../../c-api/typeobj.rst:1006 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1012 +#: ../../c-api/typeobj.rst:1013 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" msgstr "" -#: ../../c-api/typeobj.rst:1014 +#: ../../c-api/typeobj.rst:1015 msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" msgstr "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" -#: ../../c-api/typeobj.rst:1016 +#: ../../c-api/typeobj.rst:1017 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:`PyObject_GenericSetAttr`, which implements the normal way of " -"setting object attributes." +"supported. It is usually convenient to set this field to :c:func:" +"`PyObject_GenericSetAttr`, which implements the normal way of setting object " +"attributes." msgstr "" -#: ../../c-api/typeobj.rst:1025 +#: ../../c-api/typeobj.rst:1026 msgid "" -"This field is inherited by subtypes together " -"with :c:member:`~PyTypeObject.tp_setattr`: a subtype inherits " -"both :c:member:`~PyTypeObject.tp_setattr` " +"This field is inherited by subtypes together with :c:member:`~PyTypeObject." +"tp_setattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " "and :c:member:`~PyTypeObject.tp_setattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_setattr` " -"and :c:member:`~PyTypeObject.tp_setattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject." +"tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1031 +#: ../../c-api/typeobj.rst:1032 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1036 +#: ../../c-api/typeobj.rst:1037 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:1042 +#: ../../c-api/typeobj.rst:1043 msgid "" "The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:1048 +#: ../../c-api/typeobj.rst:1049 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 " -"fields in the type object (or in the extension structures referenced " -"via :c:member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject.tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, " -"and :c:member:`~PyTypeObject.tp_as_buffer`) that were historically not " -"always present are valid; if such a flag bit is clear, the type fields it " -"guards must not be accessed and must be considered to have a zero or " -"``NULL`` value instead." +"fields in the type object (or in the extension structures referenced via :c:" +"member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject." +"tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, and :c:member:" +"`~PyTypeObject.tp_as_buffer`) that were historically not always present are " +"valid; if such a flag bit is clear, the type fields it guards must not be " +"accessed and must be considered to have a zero or ``NULL`` value instead." msgstr "" -#: ../../c-api/typeobj.rst:1058 +#: ../../c-api/typeobj.rst:1059 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 " @@ -2053,14 +2057,14 @@ msgid "" "type's value of the flag bit is copied into the subtype together with a " "pointer to the extension structure. 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` fields, i.e. if " -"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and " -"the :c:member:`~PyTypeObject.tp_traverse` " -"and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have " -"``NULL`` values. .. XXX are most flag bits *really* inherited individually?" +"and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the :c:macro:" +"`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the :c:member:" +"`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in " +"the subtype exist and have ``NULL`` values. .. XXX are most flag bits " +"*really* inherited individually?" msgstr "" -#: ../../c-api/typeobj.rst:1072 +#: ../../c-api/typeobj.rst:1073 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." @@ -2068,20 +2072,20 @@ msgstr "" ":c:data:`PyBaseObject_Type` 使用 ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``。" -#: ../../c-api/typeobj.rst:1075 +#: ../../c-api/typeobj.rst:1076 msgid "**Bit Masks:**" msgstr "" -#: ../../c-api/typeobj.rst:1079 +#: ../../c-api/typeobj.rst:1080 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.tp_flags` field. The " -"macro :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and " -"*f*, and checks whether ``tp->tp_flags & f`` is non-zero." +"using the ``|`` operator to form the value of the :c:member:`~PyTypeObject." +"tp_flags` field. The macro :c:func:`PyType_HasFeature` takes a type and a " +"flags value, *tp* and *f*, and checks whether ``tp->tp_flags & f`` is non-" +"zero." msgstr "" -#: ../../c-api/typeobj.rst:1086 +#: ../../c-api/typeobj.rst:1087 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 " @@ -2089,257 +2093,256 @@ msgid "" "a reference to the type, and the type object is INCREF'ed when a new " "instance is created, and DECREF'ed when an instance is destroyed (this does " "not apply to instances of subtypes; only the type referenced by the " -"instance's ob_type gets INCREF'ed or DECREF'ed). Heap types should " -"also :ref:`support garbage collection ` as they " -"can form a reference cycle with their own module object." +"instance's ob_type gets INCREF'ed or DECREF'ed). Heap types should also :ref:" +"`support garbage collection ` as they can form a " +"reference cycle with their own module object." msgstr "" -#: ../../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 +#: ../../c-api/typeobj.rst:1098 ../../c-api/typeobj.rst:1109 +#: ../../c-api/typeobj.rst:1119 ../../c-api/typeobj.rst:1129 +#: ../../c-api/typeobj.rst:1161 msgid "???" msgstr "???" -#: ../../c-api/typeobj.rst:1102 +#: ../../c-api/typeobj.rst:1103 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:1113 +#: ../../c-api/typeobj.rst:1114 msgid "" -"This bit is set when the type object has been fully initialized " -"by :c:func:`PyType_Ready`." +"This bit is set when the type object has been fully initialized by :c:func:" +"`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1123 +#: ../../c-api/typeobj.rst:1124 msgid "" "This bit is set while :c:func:`PyType_Ready` is in the process of " "initializing the type object." msgstr "" -#: ../../c-api/typeobj.rst:1133 +#: ../../c-api/typeobj.rst:1134 msgid "" "This bit is set when the object supports garbage collection. If this bit is " "set, instances must be created using :c:macro:`PyObject_GC_New` and " -"destroyed using :c:func:`PyObject_GC_Del`. More information in " -"section :ref:`supporting-cycle-detection`. This bit also implies that the " -"GC-related fields :c:member:`~PyTypeObject.tp_traverse` " -"and :c:member:`~PyTypeObject.tp_clear` are present in the type object." +"destroyed using :c:func:`PyObject_GC_Del`. More information in section :ref:" +"`supporting-cycle-detection`. This bit also implies that the GC-related " +"fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject." +"tp_clear` are present in the type object." msgstr "" -#: ../../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`" +#: ../../c-api/typeobj.rst:1143 ../../c-api/typeobj.rst:1484 +#: ../../c-api/typeobj.rst:1558 +msgid "" +"Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." +"tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" -#: ../../c-api/typeobj.rst:1144 +#: ../../c-api/typeobj.rst:1145 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` fields, i.e. if " -"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and " -"the :c:member:`~PyTypeObject.tp_traverse` " -"and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have " -"``NULL`` values." +"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` " +"fields, i.e. if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the " +"subtype and the :c:member:`~PyTypeObject.tp_traverse` and :c:member:" +"`~PyTypeObject.tp_clear` fields in the subtype exist and have ``NULL`` " +"values." msgstr "" -#: ../../c-api/typeobj.rst:1154 +#: ../../c-api/typeobj.rst:1155 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:1165 +#: ../../c-api/typeobj.rst:1166 msgid "This bit indicates that objects behave like unbound methods." msgstr "" -#: ../../c-api/typeobj.rst:1167 +#: ../../c-api/typeobj.rst:1168 msgid "If this flag is set for ``type(meth)``, then:" msgstr "" -#: ../../c-api/typeobj.rst:1169 +#: ../../c-api/typeobj.rst:1170 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." msgstr "" -#: ../../c-api/typeobj.rst:1172 +#: ../../c-api/typeobj.rst:1173 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." msgstr "" -#: ../../c-api/typeobj.rst:1175 +#: ../../c-api/typeobj.rst:1176 msgid "" -"This flag enables an optimization for typical method calls like " -"``obj.meth()``: it avoids creating a temporary \"bound method\" object for " -"``obj.meth``." +"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:1183 +#: ../../c-api/typeobj.rst:1184 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." +"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:1189 +#: ../../c-api/typeobj.rst:1190 msgid "" -"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." +"This bit indicates that instances of the class have a :attr:`~object." +"__dict__` attribute, and that the space for the dictionary is managed by the " +"VM." msgstr "" -#: ../../c-api/typeobj.rst:1192 +#: ../../c-api/typeobj.rst:1193 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." msgstr "" -#: ../../c-api/typeobj.rst:1194 +#: ../../c-api/typeobj.rst:1195 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:1201 +#: ../../c-api/typeobj.rst:1202 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1207 +#: ../../c-api/typeobj.rst:1208 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" -#: ../../c-api/typeobj.rst:1214 +#: ../../c-api/typeobj.rst:1215 msgid "" -"This flag is inherited unless " -"the :c:member:`~PyTypeObject.tp_weaklistoffset` field is set in a superclass." +"This flag is inherited unless the :c:member:`~PyTypeObject." +"tp_weaklistoffset` field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1220 +#: ../../c-api/typeobj.rst:1221 msgid "" -"Only usable with variable-size types, i.e. ones with non-" -"zero :c:member:`~PyTypeObject.tp_itemsize`." +"Only usable with variable-size types, i.e. ones with non-zero :c:member:" +"`~PyTypeObject.tp_itemsize`." msgstr "" -#: ../../c-api/typeobj.rst:1223 +#: ../../c-api/typeobj.rst:1224 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:1228 +#: ../../c-api/typeobj.rst:1229 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:1236 +#: ../../c-api/typeobj.rst:1237 msgid "This flag is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1250 +#: ../../c-api/typeobj.rst:1251 msgid "" "These flags are used by functions such as :c:func:`PyLong_Check` to quickly " "determine if a type is a subclass of a built-in type; such specific checks " "are faster than a generic check, like :c:func:`PyObject_IsInstance`. Custom " -"types that inherit from built-ins should have " -"their :c:member:`~PyTypeObject.tp_flags` set appropriately, or the code that " -"interacts with such types will behave differently depending on what kind of " -"check is used." +"types that inherit from built-ins should have their :c:member:`~PyTypeObject." +"tp_flags` set appropriately, or the code that interacts with such types will " +"behave differently depending on what kind of check is used." msgstr "" -#: ../../c-api/typeobj.rst:1261 +#: ../../c-api/typeobj.rst:1262 msgid "" "This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is " "present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1266 +#: ../../c-api/typeobj.rst:1267 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." +"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:1274 +#: ../../c-api/typeobj.rst:1275 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:1280 +#: ../../c-api/typeobj.rst:1281 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" -#: ../../c-api/typeobj.rst:1287 +#: ../../c-api/typeobj.rst:1288 msgid "" -"This flag is now removed from a class when the " -"class's :py:meth:`~object.__call__` method is reassigned." +"This flag is now removed from a class when the class's :py:meth:`~object." +"__call__` method is reassigned." msgstr "" -#: ../../c-api/typeobj.rst:1290 +#: ../../c-api/typeobj.rst:1291 msgid "This flag can now be inherited by mutable classes." msgstr "" -#: ../../c-api/typeobj.rst:1294 +#: ../../c-api/typeobj.rst:1295 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" -#: ../../c-api/typeobj.rst:1296 +#: ../../c-api/typeobj.rst:1297 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" -#: ../../c-api/typeobj.rst:1301 +#: ../../c-api/typeobj.rst:1302 msgid "This flag is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:1307 +#: ../../c-api/typeobj.rst:1308 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." +"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:1311 +#: ../../c-api/typeobj.rst:1312 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:1314 +#: ../../c-api/typeobj.rst:1315 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." +"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:1320 +#: ../../c-api/typeobj.rst:1321 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:1327 +#: ../../c-api/typeobj.rst:1328 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:1338 +#: ../../c-api/typeobj.rst:1339 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 " @@ -2347,23 +2350,23 @@ msgid "" "unset when registering :class:`collections.abc.Sequence`." msgstr "" -#: ../../c-api/typeobj.rst:1345 ../../c-api/typeobj.rst:1367 +#: ../../c-api/typeobj.rst:1346 ../../c-api/typeobj.rst:1368 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:1350 +#: ../../c-api/typeobj.rst:1351 msgid "" -"This flag is inherited by types that do not already " -"set :c:macro:`Py_TPFLAGS_SEQUENCE`." +"This flag is inherited by types that do not already set :c:macro:" +"`Py_TPFLAGS_SEQUENCE`." msgstr "" -#: ../../c-api/typeobj.rst:1353 ../../c-api/typeobj.rst:1375 +#: ../../c-api/typeobj.rst:1354 ../../c-api/typeobj.rst:1376 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: ../../c-api/typeobj.rst:1360 +#: ../../c-api/typeobj.rst:1361 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 " @@ -2371,63 +2374,63 @@ msgid "" "unset when registering :class:`collections.abc.Mapping`." msgstr "" -#: ../../c-api/typeobj.rst:1372 +#: ../../c-api/typeobj.rst:1373 msgid "" -"This flag is inherited by types that do not already " -"set :c:macro:`Py_TPFLAGS_MAPPING`." +"This flag is inherited by types that do not already set :c:macro:" +"`Py_TPFLAGS_MAPPING`." msgstr "" -#: ../../c-api/typeobj.rst:1382 +#: ../../c-api/typeobj.rst:1383 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:1386 +#: ../../c-api/typeobj.rst:1387 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:1392 +#: ../../c-api/typeobj.rst:1393 msgid "" "An optional pointer to a NUL-terminated C string giving the docstring for " "this type object. This is exposed as the :attr:`~type.__doc__` attribute on " "the type and instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:1398 +#: ../../c-api/typeobj.rst:1399 msgid "This field is *not* inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:1403 +#: ../../c-api/typeobj.rst:1404 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:1406 +#: ../../c-api/typeobj.rst:1407 msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" msgstr "int tp_traverse(PyObject *self, visitproc visit, void *arg);" -#: ../../c-api/typeobj.rst:1408 ../../c-api/typeobj.rst:1552 +#: ../../c-api/typeobj.rst:1409 ../../c-api/typeobj.rst:1553 msgid "" "More information about Python's garbage collection scheme can be found in " "section :ref:`supporting-cycle-detection`." msgstr "" -#: ../../c-api/typeobj.rst:1411 +#: ../../c-api/typeobj.rst:1412 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage " -"collector to detect reference cycles. A typical implementation of " -"a :c:member:`~PyTypeObject.tp_traverse` function simply " -"calls :c:func:`Py_VISIT` on each of the instance's members that are Python " -"objects that the instance owns. For example, this is function :c:func:`!" -"local_traverse` from the :mod:`!_thread` extension module::" +"collector to detect reference cycles. A typical implementation of a :c:" +"member:`~PyTypeObject.tp_traverse` function simply calls :c:func:`Py_VISIT` " +"on each of the instance's members that are Python objects that the instance " +"owns. For example, this is function :c:func:`!local_traverse` from the :mod:" +"`!_thread` extension module::" msgstr "" -#: ../../c-api/typeobj.rst:1417 +#: ../../c-api/typeobj.rst:1418 msgid "" "static int\n" "local_traverse(localobject *self, visitproc visit, void *arg)\n" @@ -2447,7 +2450,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1426 +#: ../../c-api/typeobj.rst:1427 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`` " @@ -2455,29 +2458,29 @@ msgid "" "part of a reference cycle." msgstr "" -#: ../../c-api/typeobj.rst:1430 +#: ../../c-api/typeobj.rst:1431 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:1434 +#: ../../c-api/typeobj.rst:1435 msgid "" "Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with::" msgstr "" -#: ../../c-api/typeobj.rst:1436 +#: ../../c-api/typeobj.rst:1437 msgid "Py_VISIT(Py_TYPE(self));" msgstr "Py_VISIT(Py_TYPE(self));" -#: ../../c-api/typeobj.rst:1438 +#: ../../c-api/typeobj.rst:1439 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:1441 +#: ../../c-api/typeobj.rst:1442 msgid "" "#if PY_VERSION_HEX >= 0x03090000\n" " Py_VISIT(Py_TYPE(self));\n" @@ -2487,18 +2490,18 @@ msgstr "" " Py_VISIT(Py_TYPE(self));\n" "#endif" -#: ../../c-api/typeobj.rst:1445 +#: ../../c-api/typeobj.rst:1446 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::" +"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:1449 +#: ../../c-api/typeobj.rst:1450 msgid "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" msgstr "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" -#: ../../c-api/typeobj.rst:1452 +#: ../../c-api/typeobj.rst:1453 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:`Py_TYPE(self) `, or delegate this responsibility by " -"calling ``tp_traverse`` of another heap-allocated type (such as a heap-" -"allocated superclass). If they do not, the type object may not be garbage-" -"collected." +"their type. Their traversal function must therefore either visit :c:func:" +"`Py_TYPE(self) `, or delegate this responsibility by calling " +"``tp_traverse`` of another heap-allocated type (such as a heap-allocated " +"superclass). If they do not, the type object may not be garbage-collected." msgstr "" -#: ../../c-api/typeobj.rst:1476 +#: ../../c-api/typeobj.rst:1477 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:1485 +#: ../../c-api/typeobj.rst:1486 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:member:`~PyTypeObject.tp_traverse`, " -"and :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type " -"if they are all zero in the subtype." +"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:" +"member:`~PyTypeObject.tp_traverse`, and :c:member:`~PyTypeObject.tp_clear` " +"are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1493 +#: ../../c-api/typeobj.rst:1494 msgid "" "An optional pointer to a clear function for the garbage collector. This is " "only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " "signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1496 +#: ../../c-api/typeobj.rst:1497 msgid "int tp_clear(PyObject *);" msgstr "int tp_clear(PyObject *);" -#: ../../c-api/typeobj.rst:1498 +#: ../../c-api/typeobj.rst:1499 msgid "" "The :c:member:`~PyTypeObject.tp_clear` member function is used to break " "reference cycles in cyclic garbage detected by the garbage collector. Taken " @@ -2565,14 +2565,13 @@ msgid "" "doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For example, " "the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` " "function, because it's possible to prove that no reference cycle can be " -"composed entirely of tuples. Therefore " -"the :c:member:`~PyTypeObject.tp_clear` functions of other types must be " -"sufficient to break any cycle containing a tuple. This isn't immediately " -"obvious, and there's rarely a good reason to avoid " -"implementing :c:member:`~PyTypeObject.tp_clear`." +"composed entirely of tuples. Therefore the :c:member:`~PyTypeObject." +"tp_clear` functions of other types must be sufficient to break any cycle " +"containing a tuple. This isn't immediately obvious, and there's rarely a " +"good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1508 +#: ../../c-api/typeobj.rst:1509 msgid "" "Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the " "instance's references to those of its members that may be Python objects, " @@ -2580,7 +2579,7 @@ msgid "" "example::" msgstr "" -#: ../../c-api/typeobj.rst:1512 +#: ../../c-api/typeobj.rst:1513 msgid "" "static int\n" "local_clear(localobject *self)\n" @@ -2602,12 +2601,12 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1522 +#: ../../c-api/typeobj.rst:1523 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 :c:func:`Py_DECREF`) until after the pointer to the contained object is " -"set to ``NULL``. This is because releasing the reference may cause the " +"delicate: the reference to the contained object must not be released (via :" +"c:func:`Py_DECREF`) until after the pointer to the contained object is set " +"to ``NULL``. This is because releasing the reference may cause the " "contained object to become trash, triggering a chain of reclamation activity " "that may include invoking arbitrary Python code (due to finalizers, or " "weakref callbacks, associated with the contained object). If it's possible " @@ -2617,18 +2616,18 @@ msgid "" "performs the operations in a safe order." msgstr "" -#: ../../c-api/typeobj.rst:1534 +#: ../../c-api/typeobj.rst:1535 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::" +"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:1538 +#: ../../c-api/typeobj.rst:1539 msgid "PyObject_ClearManagedDict((PyObject*)self);" msgstr "PyObject_ClearManagedDict((PyObject*)self);" -#: ../../c-api/typeobj.rst:1540 +#: ../../c-api/typeobj.rst:1541 msgid "" "Note that :c:member:`~PyTypeObject.tp_clear` is not *always* called before " "an instance is deallocated. For example, when reference counting is enough " @@ -2636,7 +2635,7 @@ msgid "" "is not involved and :c:member:`~PyTypeObject.tp_dealloc` is called directly." msgstr "" -#: ../../c-api/typeobj.rst:1546 +#: ../../c-api/typeobj.rst:1547 msgid "" "Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break " "reference cycles, it's not necessary to clear contained objects like Python " @@ -2646,32 +2645,30 @@ msgid "" "invoke :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1559 +#: ../../c-api/typeobj.rst:1560 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, :c:member:`~PyTypeObject.tp_traverse`, " -"and :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type " -"if they are all zero in the subtype." +"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, :" +"c:member:`~PyTypeObject.tp_traverse`, and :c:member:`~PyTypeObject.tp_clear` " +"are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1567 +#: ../../c-api/typeobj.rst:1568 msgid "" "An optional pointer to the rich comparison function, whose signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1569 +#: ../../c-api/typeobj.rst:1570 msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" msgstr "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -#: ../../c-api/typeobj.rst:1571 +#: ../../c-api/typeobj.rst:1572 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:1574 +#: ../../c-api/typeobj.rst:1575 msgid "" "The function should return the result of the comparison (usually ``Py_True`` " "or ``Py_False``). If the comparison is undefined, it must return " @@ -2679,51 +2676,50 @@ msgid "" "set an exception condition." msgstr "" -#: ../../c-api/typeobj.rst:1579 +#: ../../c-api/typeobj.rst:1580 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`:" +"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:1585 +#: ../../c-api/typeobj.rst:1586 msgid "Constant" msgstr "常數" -#: ../../c-api/typeobj.rst:1585 +#: ../../c-api/typeobj.rst:1586 msgid "Comparison" msgstr "" -#: ../../c-api/typeobj.rst:1587 +#: ../../c-api/typeobj.rst:1588 msgid "``<``" msgstr "``<``" -#: ../../c-api/typeobj.rst:1589 +#: ../../c-api/typeobj.rst:1590 msgid "``<=``" msgstr "``<=``" -#: ../../c-api/typeobj.rst:1591 +#: ../../c-api/typeobj.rst:1592 msgid "``==``" msgstr "``==``" -#: ../../c-api/typeobj.rst:1593 +#: ../../c-api/typeobj.rst:1594 msgid "``!=``" msgstr "``!=``" -#: ../../c-api/typeobj.rst:1595 +#: ../../c-api/typeobj.rst:1596 msgid "``>``" msgstr "``>``" -#: ../../c-api/typeobj.rst:1597 +#: ../../c-api/typeobj.rst:1598 msgid "``>=``" msgstr "``>=``" -#: ../../c-api/typeobj.rst:1600 +#: ../../c-api/typeobj.rst:1601 msgid "" "The following macro is defined to ease writing rich comparison functions:" msgstr "" -#: ../../c-api/typeobj.rst:1604 +#: ../../c-api/typeobj.rst:1605 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 " @@ -2731,62 +2727,60 @@ msgid "" "specifies the requested operation, as for :c:func:`PyObject_RichCompare`." msgstr "" -#: ../../c-api/typeobj.rst:1610 +#: ../../c-api/typeobj.rst:1611 msgid "The returned value is a new :term:`strong reference`." msgstr "" -#: ../../c-api/typeobj.rst:1612 +#: ../../c-api/typeobj.rst:1613 msgid "On error, sets an exception and returns ``NULL`` from the function." msgstr "" -#: ../../c-api/typeobj.rst:1620 +#: ../../c-api/typeobj.rst:1621 msgid "" -"This field is inherited by subtypes together " -"with :c:member:`~PyTypeObject.tp_hash`: a subtype " -"inherits :c:member:`~PyTypeObject.tp_richcompare` " -"and :c:member:`~PyTypeObject.tp_hash` when the " -"subtype's :c:member:`~PyTypeObject.tp_richcompare` " -"and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." +"This field is inherited by subtypes together with :c:member:`~PyTypeObject." +"tp_hash`: a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:" +"member:`~PyTypeObject.tp_hash` when the subtype's :c:member:`~PyTypeObject." +"tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1627 +#: ../../c-api/typeobj.rst:1628 msgid "" -":c:data:`PyBaseObject_Type` provides " -"a :c:member:`~PyTypeObject.tp_richcompare` implementation, which may be " -"inherited. However, if only :c:member:`~PyTypeObject.tp_hash` is defined, " -"not even the inherited function is used and instances of the type will not " -"be able to participate in any comparisons." +":c:data:`PyBaseObject_Type` provides a :c:member:`~PyTypeObject." +"tp_richcompare` implementation, which may be inherited. However, if only :c:" +"member:`~PyTypeObject.tp_hash` is defined, not even the inherited function " +"is used and instances of the type will not be able to participate in any " +"comparisons." msgstr "" -#: ../../c-api/typeobj.rst:1636 +#: ../../c-api/typeobj.rst:1637 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:1639 +#: ../../c-api/typeobj.rst:1640 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 " "weak reference list head (ignoring the GC header, if present); this offset " "is used by :c:func:`PyObject_ClearWeakRefs` and the ``PyWeakref_*`` " -"functions. The instance structure needs to include a field of " -"type :c:expr:`PyObject*` which is initialized to ``NULL``." +"functions. The instance structure needs to include a field of type :c:expr:" +"`PyObject*` which is initialized to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1646 +#: ../../c-api/typeobj.rst:1647 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:1649 +#: ../../c-api/typeobj.rst:1650 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:1654 +#: ../../c-api/typeobj.rst:1655 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 " @@ -2795,116 +2789,115 @@ msgid "" "not be a problem." msgstr "" -#: ../../c-api/typeobj.rst:1661 +#: ../../c-api/typeobj.rst:1662 msgid "" -"If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in " -"the :c:member:`~PyTypeObject.tp_flags` field, " -"then :c:member:`~PyTypeObject.tp_weaklistoffset` will be set to a negative " -"value, to indicate that it is unsafe to use this field." +"If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" +"`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject." +"tp_weaklistoffset` will be set to a negative value, to indicate that it is " +"unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:1669 +#: ../../c-api/typeobj.rst:1670 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)." +"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:1673 +#: ../../c-api/typeobj.rst:1674 msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "" -#: ../../c-api/typeobj.rst:1675 +#: ../../c-api/typeobj.rst:1676 msgid "PyObject *tp_iter(PyObject *self);" msgstr "PyObject *tp_iter(PyObject *self);" -#: ../../c-api/typeobj.rst:1684 +#: ../../c-api/typeobj.rst:1685 msgid "" -"An optional pointer to a function that returns the next item in " -"an :term:`iterator`. The signature is::" +"An optional pointer to a function that returns the next item in an :term:" +"`iterator`. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1687 +#: ../../c-api/typeobj.rst:1688 msgid "PyObject *tp_iternext(PyObject *self);" msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1689 +#: ../../c-api/typeobj.rst:1690 msgid "" -"When the iterator is exhausted, it must return ``NULL``; " -"a :exc:`StopIteration` exception may or may not be set. When another error " -"occurs, it must return ``NULL`` too. Its presence signals that the " -"instances of this type are iterators." +"When the iterator is exhausted, it must return ``NULL``; a :exc:" +"`StopIteration` exception may or may not be set. When another error occurs, " +"it must return ``NULL`` too. Its presence signals that the instances of " +"this type are iterators." msgstr "" -#: ../../c-api/typeobj.rst:1694 +#: ../../c-api/typeobj.rst:1695 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:1698 +#: ../../c-api/typeobj.rst:1699 msgid "This function has the same signature as :c:func:`PyIter_Next`." msgstr "" -#: ../../c-api/typeobj.rst:1707 +#: ../../c-api/typeobj.rst:1708 msgid "" -"An optional pointer to a static ``NULL``-terminated array " -"of :c:type:`PyMethodDef` structures, declaring regular methods of this type." +"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:1710 +#: ../../c-api/typeobj.rst:1711 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:1715 +#: ../../c-api/typeobj.rst:1716 msgid "" "This field is not inherited by subtypes (methods are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1721 +#: ../../c-api/typeobj.rst:1722 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." +"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:1725 +#: ../../c-api/typeobj.rst:1726 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:1730 +#: ../../c-api/typeobj.rst:1731 msgid "" "This field is not inherited by subtypes (members are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1736 +#: ../../c-api/typeobj.rst:1737 msgid "" -"An optional pointer to a static ``NULL``-terminated array " -"of :c:type:`PyGetSetDef` structures, declaring computed attributes of " -"instances of this type." +"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:1739 +#: ../../c-api/typeobj.rst:1740 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:1744 +#: ../../c-api/typeobj.rst:1745 msgid "" "This field is not inherited by subtypes (computed attributes are inherited " "through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1750 +#: ../../c-api/typeobj.rst:1751 msgid "" "An optional pointer to a base type from which type properties are " "inherited. At this level, only single inheritance is supported; multiple " @@ -2912,7 +2905,7 @@ msgid "" "metatype." msgstr "" -#: ../../c-api/typeobj.rst:1758 +#: ../../c-api/typeobj.rst:1759 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " @@ -2920,176 +2913,173 @@ msgid "" "valid C99 address constants." msgstr "" -#: ../../c-api/typeobj.rst:1763 +#: ../../c-api/typeobj.rst:1764 msgid "" -"However, the unary '&' operator applied to a non-static variable " -"like :c:data:`PyBaseObject_Type` is not required to produce an address " -"constant. Compilers may support this (gcc does), MSVC does not. Both " -"compilers are strictly standard conforming in this particular behavior." +"However, the unary '&' operator applied to a non-static variable like :c:" +"data:`PyBaseObject_Type` is not required to produce an address constant. " +"Compilers may support this (gcc does), MSVC does not. Both compilers are " +"strictly standard conforming in this particular behavior." msgstr "" -#: ../../c-api/typeobj.rst:1769 +#: ../../c-api/typeobj.rst:1770 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" -#: ../../c-api/typeobj.rst:1774 +#: ../../c-api/typeobj.rst:1775 msgid "This field is not inherited by subtypes (obviously)." msgstr "" -#: ../../c-api/typeobj.rst:1778 +#: ../../c-api/typeobj.rst:1779 msgid "" "This field defaults to ``&PyBaseObject_Type`` (which to Python programmers " "is known as the type :class:`object`)." msgstr "" -#: ../../c-api/typeobj.rst:1784 +#: ../../c-api/typeobj.rst:1785 msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1786 +#: ../../c-api/typeobj.rst:1787 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " "attributes for the type. Once :c:func:`PyType_Ready` has initialized the " "type, extra attributes for the type may be added to this dictionary only if " -"they don't correspond to overloaded operations " -"(like :meth:`~object.__add__`). Once initialization for the type has " -"finished, this field should be treated as read-only." +"they don't correspond to overloaded operations (like :meth:`~object." +"__add__`). Once initialization for the type has finished, this field should " +"be treated as read-only." msgstr "" -#: ../../c-api/typeobj.rst:1794 +#: ../../c-api/typeobj.rst:1795 msgid "" -"Some types may not store their dictionary in this slot. " -"Use :c:func:`PyType_GetDict` to retrieve the dictionary for an arbitrary " -"type." +"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:1800 +#: ../../c-api/typeobj.rst:1801 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." +"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:1806 +#: ../../c-api/typeobj.rst:1807 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:1811 +#: ../../c-api/typeobj.rst:1812 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" -#: ../../c-api/typeobj.rst:1816 +#: ../../c-api/typeobj.rst:1817 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." +"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:1822 +#: ../../c-api/typeobj.rst:1823 msgid "An optional pointer to a \"descriptor get\" function." msgstr "" -#: ../../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 +#: ../../c-api/typeobj.rst:1825 ../../c-api/typeobj.rst:1841 +#: ../../c-api/typeobj.rst:1905 ../../c-api/typeobj.rst:1935 +#: ../../c-api/typeobj.rst:1959 msgid "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1826 +#: ../../c-api/typeobj.rst:1827 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:1837 +#: ../../c-api/typeobj.rst:1838 msgid "" "An optional pointer to a function for setting and deleting a descriptor's " "value." msgstr "" -#: ../../c-api/typeobj.rst:1842 +#: ../../c-api/typeobj.rst:1843 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:1844 +#: ../../c-api/typeobj.rst:1845 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "" -#: ../../c-api/typeobj.rst:1855 +#: ../../c-api/typeobj.rst:1856 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:1858 +#: ../../c-api/typeobj.rst:1859 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 " -"of the type of the instance variable dictionary; this offset is used " -"by :c:func:`PyObject_GenericGetAttr`." +"of the type of the instance variable dictionary; this offset is used by :c:" +"func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1863 +#: ../../c-api/typeobj.rst:1864 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:1866 +#: ../../c-api/typeobj.rst:1867 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." msgstr "" -#: ../../c-api/typeobj.rst:1868 +#: ../../c-api/typeobj.rst:1869 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" -"only. To get the pointer to the dictionary " -"call :c:func:`PyObject_GenericGetDict`. " -"Calling :c:func:`PyObject_GenericGetDict` may need to allocate memory for " -"the dictionary, so it is may be more efficient to " -"call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." +"only. To get the pointer to the dictionary call :c:func:" +"`PyObject_GenericGetDict`. Calling :c:func:`PyObject_GenericGetDict` may " +"need to allocate memory for the dictionary, so it is may be more efficient " +"to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" -#: ../../c-api/typeobj.rst:1874 +#: ../../c-api/typeobj.rst:1875 msgid "" -"It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_DICT` 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:1879 +#: ../../c-api/typeobj.rst:1880 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 " -"at the previous offset. To properly support inheritance, " -"use :c:macro:`Py_TPFLAGS_MANAGED_DICT`." +"at the previous offset. To properly support inheritance, use :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT`." msgstr "" -#: ../../c-api/typeobj.rst:1886 +#: ../../c-api/typeobj.rst:1887 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:1889 +#: ../../c-api/typeobj.rst:1890 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." +"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:1897 +#: ../../c-api/typeobj.rst:1898 msgid "An optional pointer to an instance initialization function." msgstr "" -#: ../../c-api/typeobj.rst:1899 +#: ../../c-api/typeobj.rst:1900 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " @@ -3097,112 +3087,110 @@ msgid "" "instance by calling its :meth:`!__init__` method again." msgstr "" -#: ../../c-api/typeobj.rst:1906 +#: ../../c-api/typeobj.rst:1907 msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" msgstr "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1908 +#: ../../c-api/typeobj.rst:1909 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__`." +"arguments represent positional and keyword arguments of the call to :meth:" +"`~object.__init__`." msgstr "" -#: ../../c-api/typeobj.rst:1912 +#: ../../c-api/typeobj.rst:1913 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 :c:member:`~PyTypeObject.tp_new` function has returned an instance of " -"the type. If the :c:member:`~PyTypeObject.tp_new` function returns an " -"instance of some other type that is not a subtype of the original type, " -"no :c:member:`~PyTypeObject.tp_init` function is called; " -"if :c:member:`~PyTypeObject.tp_new` returns an instance of a subtype of the " -"original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called." +"when an instance is created normally by calling its type, after the type's :" +"c:member:`~PyTypeObject.tp_new` function has returned an instance of the " +"type. If the :c:member:`~PyTypeObject.tp_new` function returns an instance " +"of some other type that is not a subtype of the original type, no :c:member:" +"`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject." +"tp_new` returns an instance of a subtype of the original type, the " +"subtype's :c:member:`~PyTypeObject.tp_init` is called." msgstr "" -#: ../../c-api/typeobj.rst:1919 +#: ../../c-api/typeobj.rst:1920 msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" -#: ../../c-api/typeobj.rst:1927 +#: ../../c-api/typeobj.rst:1928 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" -#: ../../c-api/typeobj.rst:1932 +#: ../../c-api/typeobj.rst:1933 msgid "An optional pointer to an instance allocation function." msgstr "" -#: ../../c-api/typeobj.rst:1936 +#: ../../c-api/typeobj.rst:1937 msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" msgstr "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -#: ../../c-api/typeobj.rst:1940 +#: ../../c-api/typeobj.rst:1941 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)." msgstr "" -#: ../../c-api/typeobj.rst:1945 +#: ../../c-api/typeobj.rst:1946 msgid "" -"For dynamic subtypes, this field is always set " -"to :c:func:`PyType_GenericAlloc`, to force a standard heap allocation " -"strategy." +"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:1949 +#: ../../c-api/typeobj.rst:1950 msgid "" -"For static subtypes, :c:data:`PyBaseObject_Type` " -"uses :c:func:`PyType_GenericAlloc`. That is the recommended value for all " -"statically defined types." +"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:1956 +#: ../../c-api/typeobj.rst:1957 msgid "An optional pointer to an instance creation function." msgstr "" -#: ../../c-api/typeobj.rst:1960 +#: ../../c-api/typeobj.rst:1961 msgid "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" msgstr "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1962 +#: ../../c-api/typeobj.rst:1963 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 " -"to the type. Note that *subtype* doesn't have to equal the type " -"whose :c:member:`~PyTypeObject.tp_new` function is called; it may be a " -"subtype of that type (but not an unrelated type)." +"to the type. Note that *subtype* doesn't have to equal the type whose :c:" +"member:`~PyTypeObject.tp_new` function is called; it may be a subtype of " +"that type (but not an unrelated type)." msgstr "" -#: ../../c-api/typeobj.rst:1968 +#: ../../c-api/typeobj.rst:1969 msgid "" "The :c:member:`~PyTypeObject.tp_new` function should call ``subtype-" ">tp_alloc(subtype, nitems)`` to allocate space for the object, and then do " "only as much further initialization as is absolutely necessary. " "Initialization that can safely be ignored or repeated should be placed in " "the :c:member:`~PyTypeObject.tp_init` handler. A good rule of thumb is that " -"for immutable types, all initialization should take place " -"in :c:member:`~PyTypeObject.tp_new`, while for mutable types, most " -"initialization should be deferred to :c:member:`~PyTypeObject.tp_init`." +"for immutable types, all initialization should take place in :c:member:" +"`~PyTypeObject.tp_new`, while for mutable types, most initialization should " +"be deferred to :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: ../../c-api/typeobj.rst:1976 +#: ../../c-api/typeobj.rst:1977 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" -#: ../../c-api/typeobj.rst:1981 +#: ../../c-api/typeobj.rst:1982 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``." +"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:1987 +#: ../../c-api/typeobj.rst:1988 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 " @@ -3210,142 +3198,142 @@ msgid "" "factory function." msgstr "" -#: ../../c-api/typeobj.rst:1995 +#: ../../c-api/typeobj.rst:1996 msgid "" "An optional pointer to an instance deallocation function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1997 +#: ../../c-api/typeobj.rst:1998 msgid "void tp_free(void *self);" msgstr "void tp_free(void *self);" -#: ../../c-api/typeobj.rst:1999 +#: ../../c-api/typeobj.rst:2000 msgid "" -"An initializer that is compatible with this signature " -"is :c:func:`PyObject_Free`." +"An initializer that is compatible with this signature is :c:func:" +"`PyObject_Free`." msgstr "" -#: ../../c-api/typeobj.rst:2003 +#: ../../c-api/typeobj.rst:2004 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)" msgstr "" -#: ../../c-api/typeobj.rst:2008 +#: ../../c-api/typeobj.rst:2009 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." +"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:2012 +#: ../../c-api/typeobj.rst:2013 msgid "" "For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Del`." msgstr "" -#: ../../c-api/typeobj.rst:2017 +#: ../../c-api/typeobj.rst:2018 msgid "An optional pointer to a function called by the garbage collector." msgstr "" -#: ../../c-api/typeobj.rst:2019 +#: ../../c-api/typeobj.rst:2020 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 " -"type's :c:member:`~PyTypeObject.tp_flags` field, and check " -"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit. But some types have a mixture " -"of statically and dynamically allocated instances, and the statically " -"allocated instances are not collectible. Such types should define this " -"function; it should return ``1`` for a collectible instance, and ``0`` for a " -"non-collectible instance. The signature is::" +"type's :c:member:`~PyTypeObject.tp_flags` field, and check the :c:macro:" +"`Py_TPFLAGS_HAVE_GC` flag bit. But some types have a mixture of statically " +"and dynamically allocated instances, and the statically allocated instances " +"are not collectible. Such types should define this function; it should " +"return ``1`` for a collectible instance, and ``0`` for a non-collectible " +"instance. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2027 +#: ../../c-api/typeobj.rst:2028 msgid "int tp_is_gc(PyObject *self);" msgstr "int tp_is_gc(PyObject *self);" -#: ../../c-api/typeobj.rst:2029 +#: ../../c-api/typeobj.rst:2030 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 `.)" +"(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:2039 +#: ../../c-api/typeobj.rst:2040 msgid "" -"This slot has no default. If this field is " -"``NULL``, :c:macro:`Py_TPFLAGS_HAVE_GC` is used as the functional equivalent." +"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:2045 +#: ../../c-api/typeobj.rst:2046 msgid "Tuple of base types." msgstr "" -#: ../../c-api/typeobj.rst:2047 ../../c-api/typeobj.rst:2071 +#: ../../c-api/typeobj.rst:2048 ../../c-api/typeobj.rst:2072 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:2050 +#: ../../c-api/typeobj.rst:2051 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." +"` can be used instead of the *bases* argument of :c:func:" +"`PyType_FromSpecWithBases`. The argument form is preferred." msgstr "" -#: ../../c-api/typeobj.rst:2057 +#: ../../c-api/typeobj.rst:2058 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:2063 ../../c-api/typeobj.rst:2086 -#: ../../c-api/typeobj.rst:2103 ../../c-api/typeobj.rst:2120 -#: ../../c-api/typeobj.rst:2134 +#: ../../c-api/typeobj.rst:2064 ../../c-api/typeobj.rst:2087 +#: ../../c-api/typeobj.rst:2104 ../../c-api/typeobj.rst:2121 +#: ../../c-api/typeobj.rst:2135 msgid "This field is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:2068 +#: ../../c-api/typeobj.rst:2069 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:2076 +#: ../../c-api/typeobj.rst:2077 msgid "" -"This field is not inherited; it is calculated fresh " -"by :c:func:`PyType_Ready`." +"This field is not inherited; it is calculated fresh by :c:func:" +"`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2082 +#: ../../c-api/typeobj.rst:2083 msgid "Unused. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2091 +#: ../../c-api/typeobj.rst:2092 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" -#: ../../c-api/typeobj.rst:2093 +#: ../../c-api/typeobj.rst:2094 msgid "" -"To get a list of subclasses, call the Python " -"method :py:meth:`~type.__subclasses__`." +"To get a list of subclasses, call the Python method :py:meth:`~type." +"__subclasses__`." msgstr "" -#: ../../c-api/typeobj.rst:2098 +#: ../../c-api/typeobj.rst:2099 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:2108 +#: ../../c-api/typeobj.rst:2109 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2113 +#: ../../c-api/typeobj.rst:2114 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 " @@ -3353,25 +3341,25 @@ msgid "" "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" -#: ../../c-api/typeobj.rst:2125 +#: ../../c-api/typeobj.rst:2126 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." msgstr "" -#: ../../c-api/typeobj.rst:2130 +#: ../../c-api/typeobj.rst:2131 msgid "Used to index into the method cache. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2139 +#: ../../c-api/typeobj.rst:2140 msgid "" "An optional pointer to an instance finalization function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2141 +#: ../../c-api/typeobj.rst:2142 msgid "void tp_finalize(PyObject *self);" msgstr "void tp_finalize(PyObject *self);" -#: ../../c-api/typeobj.rst:2143 +#: ../../c-api/typeobj.rst:2144 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 " @@ -3381,14 +3369,14 @@ msgid "" "object in a sane state." msgstr "" -#: ../../c-api/typeobj.rst:2150 +#: ../../c-api/typeobj.rst:2151 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:2153 +#: ../../c-api/typeobj.rst:2154 msgid "" "static void\n" "local_finalize(PyObject *self)\n" @@ -3403,114 +3391,114 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:2173 +#: ../../c-api/typeobj.rst:2174 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." +"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:2177 +#: ../../c-api/typeobj.rst:2178 msgid "\"Safe object finalization\" (:pep:`442`)" msgstr "" -#: ../../c-api/typeobj.rst:2182 +#: ../../c-api/typeobj.rst:2183 msgid "" "Vectorcall function to use for calls of this type object. In other words, it " "is used to implement :ref:`vectorcall ` for ``type.__call__``. " -"If ``tp_vectorcall`` is ``NULL``, the default call implementation " -"using :meth:`~object.__new__` and :meth:`~object.__init__` is used." +"If ``tp_vectorcall`` is ``NULL``, the default call implementation using :" +"meth:`~object.__new__` and :meth:`~object.__init__` is used." msgstr "" -#: ../../c-api/typeobj.rst:2190 +#: ../../c-api/typeobj.rst:2191 msgid "This field is never inherited." msgstr "" -#: ../../c-api/typeobj.rst:2192 +#: ../../c-api/typeobj.rst:2193 msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" -#: ../../c-api/typeobj.rst:2197 +#: ../../c-api/typeobj.rst:2198 msgid "Internal. Do not use." msgstr "" -#: ../../c-api/typeobj.rst:2205 +#: ../../c-api/typeobj.rst:2206 msgid "Static Types" msgstr "" -#: ../../c-api/typeobj.rst:2207 +#: ../../c-api/typeobj.rst:2208 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`." +"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:2211 +#: ../../c-api/typeobj.rst:2212 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" -#: ../../c-api/typeobj.rst:2213 +#: ../../c-api/typeobj.rst:2214 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." msgstr "" -#: ../../c-api/typeobj.rst:2215 +#: ../../c-api/typeobj.rst:2216 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:2217 +#: ../../c-api/typeobj.rst:2218 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" -#: ../../c-api/typeobj.rst:2221 +#: ../../c-api/typeobj.rst:2222 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:2229 +#: ../../c-api/typeobj.rst:2230 msgid "Heap Types" msgstr "" -#: ../../c-api/typeobj.rst:2231 +#: ../../c-api/typeobj.rst:2232 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " -"created by Python's ``class`` statement. Heap types have " -"the :c:macro:`Py_TPFLAGS_HEAPTYPE` flag set." +"created by Python's ``class`` statement. Heap types have the :c:macro:" +"`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" -#: ../../c-api/typeobj.rst:2236 +#: ../../c-api/typeobj.rst:2237 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`." +"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:2244 +#: ../../c-api/typeobj.rst:2245 msgid "Number Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2251 +#: ../../c-api/typeobj.rst:2252 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:2257 ../../c-api/typeobj.rst:2581 +#: ../../c-api/typeobj.rst:2258 ../../c-api/typeobj.rst:2582 msgid "Here is the structure definition::" msgstr "" -#: ../../c-api/typeobj.rst:2259 +#: ../../c-api/typeobj.rst:2260 msgid "" "typedef struct {\n" " binaryfunc nb_add;\n" @@ -3598,7 +3586,7 @@ msgstr "" " binaryfunc nb_inplace_matrix_multiply;\n" "} PyNumberMethods;" -#: ../../c-api/typeobj.rst:2304 +#: ../../c-api/typeobj.rst:2305 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 " @@ -3608,82 +3596,81 @@ msgid "" "and set an exception." msgstr "" -#: ../../c-api/typeobj.rst:2313 +#: ../../c-api/typeobj.rst:2314 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:2358 +#: ../../c-api/typeobj.rst:2359 msgid "Mapping Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2365 +#: ../../c-api/typeobj.rst:2366 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:2370 +#: ../../c-api/typeobj.rst:2371 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." +"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:2376 +#: ../../c-api/typeobj.rst:2377 msgid "" -"This function is used by :c:func:`PyObject_GetItem` " -"and :c:func:`PySequence_GetSlice`, and has the same signature as :c:func:`!" -"PyObject_GetItem`. This slot must be filled for " -"the :c:func:`PyMapping_Check` function to return ``1``, it can be ``NULL`` " -"otherwise." +"This function is used by :c:func:`PyObject_GetItem` and :c:func:" +"`PySequence_GetSlice`, and has the same signature as :c:func:`!" +"PyObject_GetItem`. This slot must be filled for the :c:func:" +"`PyMapping_Check` function to return ``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2384 +#: ../../c-api/typeobj.rst:2385 msgid "" -"This function is used " -"by :c:func:`PyObject_SetItem`, :c:func:`PyObject_DelItem`, :c:func:`PySequence_SetSlice` " -"and :c:func:`PySequence_DelSlice`. It has the same signature as :c:func:`!" +"This function is used by :c:func:`PyObject_SetItem`, :c:func:" +"`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" +"`PySequence_DelSlice`. It has the same signature as :c:func:`!" "PyObject_SetItem`, but *v* can also be set to ``NULL`` to delete an item. " "If this slot is ``NULL``, the object does not support item assignment and " "deletion." msgstr "" -#: ../../c-api/typeobj.rst:2395 +#: ../../c-api/typeobj.rst:2396 msgid "Sequence Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2402 +#: ../../c-api/typeobj.rst:2403 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the sequence protocol." msgstr "" -#: ../../c-api/typeobj.rst:2407 +#: ../../c-api/typeobj.rst:2408 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 negative indices via the :c:member:`~PySequenceMethods.sq_item` " -"and the :c:member:`~PySequenceMethods.sq_ass_item` slots." +"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 " +"negative indices via the :c:member:`~PySequenceMethods.sq_item` and the :c:" +"member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" -#: ../../c-api/typeobj.rst:2414 +#: ../../c-api/typeobj.rst:2415 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:2420 +#: ../../c-api/typeobj.rst:2421 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:2426 +#: ../../c-api/typeobj.rst:2427 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 " @@ -3692,43 +3679,42 @@ msgid "" "``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2432 +#: ../../c-api/typeobj.rst:2433 msgid "" -"Negative indexes are handled as follows: if " -"the :c:member:`~PySequenceMethods.sq_length` slot is filled, it is called " -"and the sequence length is used to compute a positive index which is passed " -"to :c:member:`~PySequenceMethods.sq_item`. If :c:member:`!sq_length` is " -"``NULL``, the index is passed as is to the function." +"Negative indexes are handled as follows: if the :c:member:" +"`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " +"length is used to compute a positive index which is passed to :c:member:" +"`~PySequenceMethods.sq_item`. If :c:member:`!sq_length` is ``NULL``, the " +"index is passed as is to the function." msgstr "" -#: ../../c-api/typeobj.rst:2439 +#: ../../c-api/typeobj.rst:2440 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:`PyObject_DelItem`, after trying the item assignment and " -"deletion via the :c:member:`~PyMappingMethods.mp_ass_subscript` slot. This " -"slot may be left to ``NULL`` if the object does not support item assignment " -"and deletion." +"signature. It is also used by :c:func:`PyObject_SetItem` and :c:func:" +"`PyObject_DelItem`, after trying the item assignment and deletion via the :c:" +"member:`~PyMappingMethods.mp_ass_subscript` slot. This slot may be left to " +"``NULL`` if the object does not support item assignment and deletion." msgstr "" -#: ../../c-api/typeobj.rst:2448 +#: ../../c-api/typeobj.rst:2449 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:2455 +#: ../../c-api/typeobj.rst:2456 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 " "may be left to ``NULL``, in this case :c:func:`!PySequence_InPlaceConcat` " "will fall back to :c:func:`PySequence_Concat`. It is also used by the " -"augmented assignment ``+=``, after trying numeric in-place addition via " -"the :c:member:`~PyNumberMethods.nb_inplace_add` slot." +"augmented assignment ``+=``, after trying numeric in-place addition via the :" +"c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:2464 +#: ../../c-api/typeobj.rst:2465 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 " @@ -3738,76 +3724,76 @@ msgid "" "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:2475 +#: ../../c-api/typeobj.rst:2476 msgid "Buffer Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2483 +#: ../../c-api/typeobj.rst:2484 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: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 +#: ../../c-api/typeobj.rst:2490 ../../c-api/typeobj.rst:2539 +#: ../../c-api/typeobj.rst:2593 ../../c-api/typeobj.rst:2604 +#: ../../c-api/typeobj.rst:2616 ../../c-api/typeobj.rst:2626 msgid "The signature of this function is::" msgstr "" -#: ../../c-api/typeobj.rst:2491 +#: ../../c-api/typeobj.rst:2492 msgid "int (PyObject *exporter, Py_buffer *view, int flags);" msgstr "int (PyObject *exporter, Py_buffer *view, int flags);" -#: ../../c-api/typeobj.rst:2493 +#: ../../c-api/typeobj.rst:2494 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:2497 +#: ../../c-api/typeobj.rst:2498 msgid "" -"Check if the request can be met. If not, raise :exc:`BufferError`, " -"set :c:expr:`view->obj` to ``NULL`` and return ``-1``." +"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:2500 +#: ../../c-api/typeobj.rst:2501 msgid "Fill in the requested fields." msgstr "" -#: ../../c-api/typeobj.rst:2502 +#: ../../c-api/typeobj.rst:2503 msgid "Increment an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2504 +#: ../../c-api/typeobj.rst:2505 msgid "" "Set :c:expr:`view->obj` to *exporter* and increment :c:expr:`view->obj`." msgstr "" -#: ../../c-api/typeobj.rst:2506 +#: ../../c-api/typeobj.rst:2507 msgid "Return ``0``." msgstr "回傳 ``0``。" -#: ../../c-api/typeobj.rst:2508 +#: ../../c-api/typeobj.rst:2509 msgid "" "If *exporter* is part of a chain or tree of buffer providers, two main " "schemes can be used:" msgstr "" -#: ../../c-api/typeobj.rst:2511 +#: ../../c-api/typeobj.rst:2512 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." +"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:2514 +#: ../../c-api/typeobj.rst:2515 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:2518 +#: ../../c-api/typeobj.rst:2519 msgid "" "The individual fields of *view* are described in section :ref:`Buffer " "structure `, the rules how an exporter must react to " @@ -3815,31 +3801,32 @@ msgid "" "types>`." msgstr "" -#: ../../c-api/typeobj.rst:2523 +#: ../../c-api/typeobj.rst:2524 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:`~Py_buffer.format`, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer.strides`, :c:member:`~Py_buffer.suboffsets` " -"and :c:member:`~Py_buffer.internal` are read-only for the consumer." +"exporter and must remain valid until there are no consumers left. :c:member:" +"`~Py_buffer.format`, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer." +"strides`, :c:member:`~Py_buffer.suboffsets` and :c:member:`~Py_buffer." +"internal` are read-only for the consumer." msgstr "" -#: ../../c-api/typeobj.rst:2530 +#: ../../c-api/typeobj.rst:2531 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:2533 +#: ../../c-api/typeobj.rst:2534 msgid "" ":c:func:`PyObject_GetBuffer` is the interface for the consumer that wraps " "this function." msgstr "" -#: ../../c-api/typeobj.rst:2540 +#: ../../c-api/typeobj.rst:2541 msgid "void (PyObject *exporter, Py_buffer *view);" msgstr "void (PyObject *exporter, Py_buffer *view);" -#: ../../c-api/typeobj.rst:2542 +#: ../../c-api/typeobj.rst:2543 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 " @@ -3847,15 +3834,15 @@ msgid "" "these optional steps:" msgstr "" -#: ../../c-api/typeobj.rst:2547 +#: ../../c-api/typeobj.rst:2548 msgid "Decrement an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2549 +#: ../../c-api/typeobj.rst:2550 msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" -#: ../../c-api/typeobj.rst:2551 +#: ../../c-api/typeobj.rst:2552 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 " @@ -3863,30 +3850,30 @@ msgid "" "*view* argument." msgstr "" -#: ../../c-api/typeobj.rst:2557 +#: ../../c-api/typeobj.rst:2558 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:2562 +#: ../../c-api/typeobj.rst:2563 msgid "" ":c:func:`PyBuffer_Release` is the interface for the consumer that wraps this " "function." msgstr "" -#: ../../c-api/typeobj.rst:2570 +#: ../../c-api/typeobj.rst:2571 msgid "Async Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2578 +#: ../../c-api/typeobj.rst:2579 msgid "" -"This structure holds pointers to the functions required to " -"implement :term:`awaitable` and :term:`asynchronous iterator` objects." +"This structure holds pointers to the functions required to implement :term:" +"`awaitable` and :term:`asynchronous iterator` objects." msgstr "" -#: ../../c-api/typeobj.rst:2583 +#: ../../c-api/typeobj.rst:2584 msgid "" "typedef struct {\n" " unaryfunc am_await;\n" @@ -3902,150 +3889,149 @@ msgstr "" " sendfunc am_send;\n" "} PyAsyncMethods;" -#: ../../c-api/typeobj.rst:2594 +#: ../../c-api/typeobj.rst:2595 msgid "PyObject *am_await(PyObject *self);" msgstr "" -#: ../../c-api/typeobj.rst:2596 +#: ../../c-api/typeobj.rst:2597 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:2599 +#: ../../c-api/typeobj.rst:2600 msgid "" "This slot may be set to ``NULL`` if an object is not an :term:`awaitable`." msgstr "" -#: ../../c-api/typeobj.rst:2605 +#: ../../c-api/typeobj.rst:2606 msgid "PyObject *am_aiter(PyObject *self);" msgstr "PyObject *am_aiter(PyObject *self);" -#: ../../c-api/typeobj.rst:2607 +#: ../../c-api/typeobj.rst:2608 msgid "" -"Must return an :term:`asynchronous iterator` object. " -"See :meth:`~object.__anext__` for details." +"Must return an :term:`asynchronous iterator` object. See :meth:`~object." +"__anext__` for details." msgstr "" -#: ../../c-api/typeobj.rst:2610 +#: ../../c-api/typeobj.rst:2611 msgid "" "This slot may be set to ``NULL`` if an object does not implement " "asynchronous iteration protocol." msgstr "" -#: ../../c-api/typeobj.rst:2617 +#: ../../c-api/typeobj.rst:2618 msgid "PyObject *am_anext(PyObject *self);" msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:2619 +#: ../../c-api/typeobj.rst:2620 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:2627 +#: ../../c-api/typeobj.rst:2628 msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" msgstr "" "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" -#: ../../c-api/typeobj.rst:2629 +#: ../../c-api/typeobj.rst:2630 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:2638 +#: ../../c-api/typeobj.rst:2639 msgid "Slot Type typedefs" msgstr "" -#: ../../c-api/typeobj.rst:2642 +#: ../../c-api/typeobj.rst:2643 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 " "length for the instance, suitably aligned, and initialized to zeros, but " -"with :c:member:`~PyObject.ob_refcnt` set to ``1`` " -"and :c:member:`~PyObject.ob_type` set to the type argument. If the " -"type's :c:member:`~PyTypeObject.tp_itemsize` is non-zero, the " -"object's :c:member:`~PyVarObject.ob_size` field should be initialized to " -"*nitems* and the length of the allocated memory block should be " -"``tp_basicsize + nitems*tp_itemsize``, rounded up to a multiple of " -"``sizeof(void*)``; otherwise, *nitems* is not used and the length of the " -"block should be :c:member:`~PyTypeObject.tp_basicsize`." +"with :c:member:`~PyObject.ob_refcnt` set to ``1`` and :c:member:`~PyObject." +"ob_type` set to the type argument. If the type's :c:member:`~PyTypeObject." +"tp_itemsize` is non-zero, the object's :c:member:`~PyVarObject.ob_size` " +"field should be initialized to *nitems* and the length of the allocated " +"memory block should be ``tp_basicsize + nitems*tp_itemsize``, rounded up to " +"a multiple of ``sizeof(void*)``; otherwise, *nitems* is not used and the " +"length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:2652 +#: ../../c-api/typeobj.rst:2653 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`." +"allocate additional memory; that should be done by :c:member:`~PyTypeObject." +"tp_new`." msgstr "" -#: ../../c-api/typeobj.rst:2659 +#: ../../c-api/typeobj.rst:2660 msgid "See :c:member:`~PyTypeObject.tp_free`." msgstr "請見 :c:member:`~PyTypeObject.tp_free`。" -#: ../../c-api/typeobj.rst:2663 +#: ../../c-api/typeobj.rst:2664 msgid "See :c:member:`~PyTypeObject.tp_new`." msgstr "請見 :c:member:`~PyTypeObject.tp_new`。" -#: ../../c-api/typeobj.rst:2667 +#: ../../c-api/typeobj.rst:2668 msgid "See :c:member:`~PyTypeObject.tp_init`." msgstr "請見 :c:member:`~PyTypeObject.tp_init`。" -#: ../../c-api/typeobj.rst:2671 +#: ../../c-api/typeobj.rst:2672 msgid "See :c:member:`~PyTypeObject.tp_repr`." msgstr "請見 :c:member:`~PyTypeObject.tp_repr`。" -#: ../../c-api/typeobj.rst:2675 ../../c-api/typeobj.rst:2684 +#: ../../c-api/typeobj.rst:2676 ../../c-api/typeobj.rst:2685 msgid "Return the value of the named attribute for the object." msgstr "" -#: ../../c-api/typeobj.rst:2679 ../../c-api/typeobj.rst:2690 +#: ../../c-api/typeobj.rst:2680 ../../c-api/typeobj.rst:2691 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:2686 +#: ../../c-api/typeobj.rst:2687 msgid "See :c:member:`~PyTypeObject.tp_getattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_getattro`。" -#: ../../c-api/typeobj.rst:2693 +#: ../../c-api/typeobj.rst:2694 msgid "See :c:member:`~PyTypeObject.tp_setattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_setattro`。" -#: ../../c-api/typeobj.rst:2697 +#: ../../c-api/typeobj.rst:2698 msgid "See :c:member:`~PyTypeObject.tp_descr_get`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_get`。" -#: ../../c-api/typeobj.rst:2701 +#: ../../c-api/typeobj.rst:2702 msgid "See :c:member:`~PyTypeObject.tp_descr_set`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_set`。" -#: ../../c-api/typeobj.rst:2705 +#: ../../c-api/typeobj.rst:2706 msgid "See :c:member:`~PyTypeObject.tp_hash`." msgstr "請見 :c:member:`~PyTypeObject.tp_hash`。" -#: ../../c-api/typeobj.rst:2709 +#: ../../c-api/typeobj.rst:2710 msgid "See :c:member:`~PyTypeObject.tp_richcompare`." msgstr "請見 :c:member:`~PyTypeObject.tp_richcompare`。" -#: ../../c-api/typeobj.rst:2713 +#: ../../c-api/typeobj.rst:2714 msgid "See :c:member:`~PyTypeObject.tp_iter`." msgstr "請見 :c:member:`~PyTypeObject.tp_iter`。" -#: ../../c-api/typeobj.rst:2717 +#: ../../c-api/typeobj.rst:2718 msgid "See :c:member:`~PyTypeObject.tp_iternext`." msgstr "請見 :c:member:`~PyTypeObject.tp_iternext`。" -#: ../../c-api/typeobj.rst:2731 +#: ../../c-api/typeobj.rst:2732 msgid "See :c:member:`~PyAsyncMethods.am_send`." msgstr "請見 :c:member:`~PyAsyncMethods.am_send`。" -#: ../../c-api/typeobj.rst:2747 +#: ../../c-api/typeobj.rst:2748 msgid "Examples" msgstr "範例" -#: ../../c-api/typeobj.rst:2749 +#: ../../c-api/typeobj.rst:2750 msgid "" "The following are simple examples of Python type definitions. They include " "common usage you may encounter. Some demonstrate tricky corner cases. For " @@ -4053,11 +4039,11 @@ msgid "" "and :ref:`new-types-topics`." msgstr "" -#: ../../c-api/typeobj.rst:2754 +#: ../../c-api/typeobj.rst:2755 msgid "A basic :ref:`static type `::" msgstr "" -#: ../../c-api/typeobj.rst:2756 +#: ../../c-api/typeobj.rst:2757 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4075,13 +4061,13 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2771 +#: ../../c-api/typeobj.rst:2772 msgid "" "You may also find older code (especially in the CPython code base) with a " "more verbose initializer::" msgstr "" -#: ../../c-api/typeobj.rst:2774 +#: ../../c-api/typeobj.rst:2775 msgid "" "static PyTypeObject MyObject_Type = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -4165,11 +4151,11 @@ msgstr "" " myobj_new, /* tp_new */\n" "};" -#: ../../c-api/typeobj.rst:2815 +#: ../../c-api/typeobj.rst:2816 msgid "A type that supports weakrefs, instance dicts, and hashing::" msgstr "" -#: ../../c-api/typeobj.rst:2817 +#: ../../c-api/typeobj.rst:2818 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4195,14 +4181,14 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2840 +#: ../../c-api/typeobj.rst:2841 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::" +"instances (e.g. uses a separate factory func) using :c:macro:" +"`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag::" msgstr "" -#: ../../c-api/typeobj.rst:2844 +#: ../../c-api/typeobj.rst:2845 msgid "" "typedef struct {\n" " PyUnicodeObject raw;\n" @@ -4220,12 +4206,12 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2859 +#: ../../c-api/typeobj.rst:2860 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" -#: ../../c-api/typeobj.rst:2861 +#: ../../c-api/typeobj.rst:2862 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4245,13 +4231,13 @@ msgstr "" " .tp_name = \"mymod.MyObject\",\n" "};" -#: ../../c-api/typeobj.rst:2870 +#: ../../c-api/typeobj.rst:2871 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" -#: ../../c-api/typeobj.rst:2872 +#: ../../c-api/typeobj.rst:2873 msgid "" "typedef struct {\n" " PyObject_VAR_HEAD\n" @@ -4277,14 +4263,14 @@ msgstr "" " .tp_itemsize = sizeof(char *),\n" "};" -#: ../../c-api/typeobj.rst:842 ../../c-api/typeobj.rst:907 +#: ../../c-api/typeobj.rst:843 ../../c-api/typeobj.rst:908 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/typeobj.rst:842 +#: ../../c-api/typeobj.rst:843 msgid "repr" msgstr "repr" -#: ../../c-api/typeobj.rst:907 +#: ../../c-api/typeobj.rst:908 msgid "hash" msgstr "hash(雜湊)" diff --git a/c-api/unicode.po b/c-api/unicode.po index f29bafb0e6..71b90e9650 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: 2025-04-30 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -866,25 +866,34 @@ msgstr "" #: ../../c-api/unicode.rst:626 msgid "" +"Return a mapping suitable for decoding a custom single-byte encoding. Given " +"a Unicode string *string* of up to 256 characters representing an encoding " +"table, returns either a compact internal mapping object or a dictionary " +"mapping character ordinals to byte values. Raises a :exc:`TypeError` and " +"return ``NULL`` on invalid input. .. versionadded:: 3.2" +msgstr "" + +#: ../../c-api/unicode.rst:636 +msgid "" "Return the name of the default string encoding, ``\"utf-8\"``. See :func:" "`sys.getdefaultencoding`." msgstr "" -#: ../../c-api/unicode.rst:629 +#: ../../c-api/unicode.rst:639 msgid "" "The returned string does not need to be freed, and is valid until " "interpreter shutdown." msgstr "" -#: ../../c-api/unicode.rst:635 +#: ../../c-api/unicode.rst:645 msgid "Return the length of the Unicode object, in code points." msgstr "" -#: ../../c-api/unicode.rst:637 +#: ../../c-api/unicode.rst:647 msgid "On error, set an exception and return ``-1``." msgstr "發生錯誤時,設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:648 +#: ../../c-api/unicode.rst:658 msgid "" "Copy characters from one Unicode object into another. This function " "performs character conversion when necessary and falls back to :c:func:`!" @@ -892,61 +901,61 @@ msgid "" "otherwise returns the number of copied characters." msgstr "" -#: ../../c-api/unicode.rst:659 +#: ../../c-api/unicode.rst:669 msgid "" "Fill a string with a character: write *fill_char* into ``unicode[start:" "start+length]``." msgstr "" -#: ../../c-api/unicode.rst:662 +#: ../../c-api/unicode.rst:672 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:665 +#: ../../c-api/unicode.rst:675 msgid "" "Return the number of written character, or return ``-1`` and raise an " "exception on error." msgstr "" -#: ../../c-api/unicode.rst:674 +#: ../../c-api/unicode.rst:684 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:678 +#: ../../c-api/unicode.rst:688 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:682 +#: ../../c-api/unicode.rst:692 msgid "Return ``0`` on success, ``-1`` on error with an exception set." msgstr "成功時回傳 ``0``,發生錯誤時設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:689 +#: ../../c-api/unicode.rst:699 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:693 +#: ../../c-api/unicode.rst:703 msgid "Return character on success, ``-1`` on error with an exception set." msgstr "成功時回傳字元,發生錯誤時設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:701 +#: ../../c-api/unicode.rst:711 msgid "" "Return a substring of *unicode*, from character index *start* (included) to " "character index *end* (excluded). Negative indices are not supported. On " "error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:711 +#: ../../c-api/unicode.rst:721 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 " @@ -954,7 +963,7 @@ msgid "" "*unicode*). *buffer* is returned on success." msgstr "" -#: ../../c-api/unicode.rst:721 +#: ../../c-api/unicode.rst:731 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:" @@ -962,17 +971,17 @@ msgid "" "appended." msgstr "" -#: ../../c-api/unicode.rst:730 +#: ../../c-api/unicode.rst:740 msgid "Locale Encoding" msgstr "" -#: ../../c-api/unicode.rst:732 +#: ../../c-api/unicode.rst:742 msgid "" "The current locale encoding can be used to decode text from the operating " "system." msgstr "" -#: ../../c-api/unicode.rst:739 +#: ../../c-api/unicode.rst:749 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 " @@ -981,21 +990,21 @@ msgid "" "null character but cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:746 +#: ../../c-api/unicode.rst:756 msgid "" "Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:749 ../../c-api/unicode.rst:784 +#: ../../c-api/unicode.rst:759 ../../c-api/unicode.rst:794 msgid "This function ignores the :ref:`Python UTF-8 Mode `." msgstr "此函式會忽略 :ref:`Python UTF-8 模式 `。" -#: ../../c-api/unicode.rst:753 ../../c-api/unicode.rst:869 +#: ../../c-api/unicode.rst:763 ../../c-api/unicode.rst:879 msgid "The :c:func:`Py_DecodeLocale` function." msgstr ":c:func:`Py_DecodeLocale` 函式。" -#: ../../c-api/unicode.rst:757 +#: ../../c-api/unicode.rst:767 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -1003,7 +1012,7 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:766 +#: ../../c-api/unicode.rst:776 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." @@ -1011,7 +1020,7 @@ msgstr "" "類似於 :c:func:`PyUnicode_DecodeLocaleAndSize`,但使用 :c:func:`!strlen` 計算" "字串長度。" -#: ../../c-api/unicode.rst:774 +#: ../../c-api/unicode.rst:784 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 " @@ -1020,17 +1029,17 @@ msgid "" "`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:781 +#: ../../c-api/unicode.rst:791 msgid "" "Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:788 ../../c-api/unicode.rst:900 +#: ../../c-api/unicode.rst:798 ../../c-api/unicode.rst:910 msgid "The :c:func:`Py_EncodeLocale` function." msgstr ":c:func:`Py_EncodeLocale` 函式。" -#: ../../c-api/unicode.rst:792 +#: ../../c-api/unicode.rst:802 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -1038,24 +1047,24 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:801 +#: ../../c-api/unicode.rst:811 msgid "File System Encoding" msgstr "檔案系統編碼" -#: ../../c-api/unicode.rst:803 +#: ../../c-api/unicode.rst:813 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" -#: ../../c-api/unicode.rst:806 +#: ../../c-api/unicode.rst:816 msgid "" "To encode file names to :class:`bytes` during argument parsing, the " "``\"O&\"`` converter should be used, passing :c:func:`!" "PyUnicode_FSConverter` as the conversion function:" msgstr "" -#: ../../c-api/unicode.rst:812 +#: ../../c-api/unicode.rst:822 msgid "" ":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " "-- obtained directly or through the :class:`os.PathLike` interface -- to :" @@ -1068,24 +1077,24 @@ msgid "" "not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:824 +#: ../../c-api/unicode.rst:834 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 +#: ../../c-api/unicode.rst:839 ../../c-api/unicode.rst:866 msgid "Accepts a :term:`path-like object`." msgstr "接受一個 :term:`path-like object`。" -#: ../../c-api/unicode.rst:832 +#: ../../c-api/unicode.rst:842 msgid "" "To decode file names to :class:`str` during argument parsing, the ``\"O&\"`` " "converter should be used, passing :c:func:`!PyUnicode_FSDecoder` as the " "conversion function:" msgstr "" -#: ../../c-api/unicode.rst:838 +#: ../../c-api/unicode.rst:848 msgid "" ":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " "-- obtained either directly or indirectly through the :class:`os.PathLike` " @@ -1099,63 +1108,63 @@ msgid "" "result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:851 +#: ../../c-api/unicode.rst:861 msgid "" "If *obj* is ``NULL``, release the strong reference to the object referred to " "by *result* and return ``1``." msgstr "" -#: ../../c-api/unicode.rst:862 +#: ../../c-api/unicode.rst:872 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:864 +#: ../../c-api/unicode.rst:874 msgid "" "If you need to decode a string from the current locale encoding, use :c:func:" "`PyUnicode_DecodeLocaleAndSize`." msgstr "" -#: ../../c-api/unicode.rst:871 ../../c-api/unicode.rst:884 -#: ../../c-api/unicode.rst:904 +#: ../../c-api/unicode.rst:881 ../../c-api/unicode.rst:894 +#: ../../c-api/unicode.rst:914 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" -#: ../../c-api/unicode.rst:878 +#: ../../c-api/unicode.rst:888 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" -#: ../../c-api/unicode.rst:881 +#: ../../c-api/unicode.rst:891 msgid "" "If the string length is known, use :c:func:" "`PyUnicode_DecodeFSDefaultAndSize`." msgstr "如果字串長度已知,請使用 :c:func:`PyUnicode_DecodeFSDefaultAndSize`。" -#: ../../c-api/unicode.rst:891 +#: ../../c-api/unicode.rst:901 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:895 +#: ../../c-api/unicode.rst:905 msgid "" "If you need to encode a string to the current locale encoding, use :c:func:" "`PyUnicode_EncodeLocale`." msgstr "" -#: ../../c-api/unicode.rst:909 +#: ../../c-api/unicode.rst:919 msgid "wchar_t Support" msgstr "wchar_t 支援" -#: ../../c-api/unicode.rst:911 +#: ../../c-api/unicode.rst:921 msgid ":c:type:`wchar_t` support for platforms which support it:" msgstr "對支援 :c:type:`wchar_t` 的平台提供支援:" -#: ../../c-api/unicode.rst:915 +#: ../../c-api/unicode.rst:925 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 " @@ -1163,7 +1172,7 @@ msgid "" "failure." msgstr "" -#: ../../c-api/unicode.rst:923 +#: ../../c-api/unicode.rst:933 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 " @@ -1171,13 +1180,13 @@ msgid "" "`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" -#: ../../c-api/unicode.rst:928 +#: ../../c-api/unicode.rst:938 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:931 +#: ../../c-api/unicode.rst:941 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:" @@ -1187,7 +1196,7 @@ msgid "" "most C functions." msgstr "" -#: ../../c-api/unicode.rst:941 +#: ../../c-api/unicode.rst:951 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 " @@ -1198,37 +1207,37 @@ msgid "" "`wchar_t*` string contains null characters a :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/unicode.rst:949 +#: ../../c-api/unicode.rst:959 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:956 +#: ../../c-api/unicode.rst:966 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" -#: ../../c-api/unicode.rst:964 +#: ../../c-api/unicode.rst:974 msgid "Built-in Codecs" msgstr "內建編解碼器" -#: ../../c-api/unicode.rst:966 +#: ../../c-api/unicode.rst:976 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:969 +#: ../../c-api/unicode.rst:979 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:973 +#: ../../c-api/unicode.rst:983 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 " @@ -1236,28 +1245,28 @@ msgid "" "handler` internally." msgstr "" -#: ../../c-api/unicode.rst:978 +#: ../../c-api/unicode.rst:988 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:982 +#: ../../c-api/unicode.rst:992 msgid "" "The codecs all use a similar interface. Only deviations from the following " "generic ones are documented for simplicity." msgstr "" -#: ../../c-api/unicode.rst:987 +#: ../../c-api/unicode.rst:997 msgid "Generic Codecs" msgstr "泛用編解碼器" -#: ../../c-api/unicode.rst:989 +#: ../../c-api/unicode.rst:999 msgid "These are the generic codec APIs:" msgstr "這些是泛用編解碼器的 API:" -#: ../../c-api/unicode.rst:995 +#: ../../c-api/unicode.rst:1005 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 " @@ -1266,7 +1275,7 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1005 +#: ../../c-api/unicode.rst:1015 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 " @@ -1275,21 +1284,21 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1013 +#: ../../c-api/unicode.rst:1023 msgid "UTF-8 Codecs" msgstr "UTF-8 編解碼器" -#: ../../c-api/unicode.rst:1015 +#: ../../c-api/unicode.rst:1025 msgid "These are the UTF-8 codec APIs:" msgstr "這些是 UTF-8 編解碼器的 API:" -#: ../../c-api/unicode.rst:1020 +#: ../../c-api/unicode.rst:1030 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:1027 +#: ../../c-api/unicode.rst:1037 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF8`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-8 byte sequences will " @@ -1297,20 +1306,20 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1035 +#: ../../c-api/unicode.rst:1045 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:1039 ../../c-api/unicode.rst:1054 +#: ../../c-api/unicode.rst:1049 ../../c-api/unicode.rst:1064 msgid "" "The function fails if the string contains surrogate code points (``U+D800`` " "- ``U+DFFF``)." msgstr "" -#: ../../c-api/unicode.rst:1045 +#: ../../c-api/unicode.rst:1055 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* " @@ -1319,7 +1328,7 @@ msgid "" "regardless of whether there are any other null code points." msgstr "" -#: ../../c-api/unicode.rst:1051 +#: ../../c-api/unicode.rst:1061 msgid "" "On error, set an exception, set *size* to ``-1`` (if it's not NULL) and " "return ``NULL``." @@ -1327,7 +1336,7 @@ msgstr "" "發生錯誤時,設定例外並將 *size* 設為 ``-1``\\ (如果不是 NULL),並回傳 " "``NULL``。" -#: ../../c-api/unicode.rst:1057 +#: ../../c-api/unicode.rst:1067 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 " @@ -1336,19 +1345,19 @@ msgid "" "collected." msgstr "" -#: ../../c-api/unicode.rst:1064 ../../c-api/unicode.rst:1086 +#: ../../c-api/unicode.rst:1074 ../../c-api/unicode.rst:1096 msgid "The return type is now ``const char *`` rather of ``char *``." msgstr "回傳型別現在是 ``const char *`` 而不是 ``char *``。" -#: ../../c-api/unicode.rst:1067 +#: ../../c-api/unicode.rst:1077 msgid "This function is a part of the :ref:`limited API `." msgstr "" -#: ../../c-api/unicode.rst:1073 +#: ../../c-api/unicode.rst:1083 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." msgstr "與 :c:func:`PyUnicode_AsUTF8AndSize` 類似,但不儲存大小。" -#: ../../c-api/unicode.rst:1077 +#: ../../c-api/unicode.rst:1087 msgid "" "This function does not have any special behavior for `null characters " "`_ embedded within *unicode*. " @@ -1358,35 +1367,35 @@ msgid "" "c:func:`PyUnicode_AsUTF8AndSize` instead." msgstr "" -#: ../../c-api/unicode.rst:1091 +#: ../../c-api/unicode.rst:1101 msgid "UTF-32 Codecs" msgstr "UTF-32 編解碼器" -#: ../../c-api/unicode.rst:1093 +#: ../../c-api/unicode.rst:1103 msgid "These are the UTF-32 codec APIs:" msgstr "這些是 UTF-32 編解碼器的 API:" -#: ../../c-api/unicode.rst:1099 +#: ../../c-api/unicode.rst:1109 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:1103 ../../c-api/unicode.rst:1153 +#: ../../c-api/unicode.rst:1113 ../../c-api/unicode.rst:1163 msgid "" "If *byteorder* is non-``NULL``, the decoder starts decoding using the given " "byte order::" msgstr "" -#: ../../c-api/unicode.rst:1106 ../../c-api/unicode.rst:1156 +#: ../../c-api/unicode.rst:1116 ../../c-api/unicode.rst:1166 msgid "" "*byteorder == -1: little endian\n" "*byteorder == 0: native order\n" "*byteorder == 1: big endian" msgstr "" -#: ../../c-api/unicode.rst:1110 +#: ../../c-api/unicode.rst:1120 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 " @@ -1394,21 +1403,21 @@ msgid "" "``-1`` or ``1``, any byte order mark is copied to the output." msgstr "" -#: ../../c-api/unicode.rst:1115 +#: ../../c-api/unicode.rst:1125 msgid "" "After completion, *\\*byteorder* is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1118 ../../c-api/unicode.rst:1169 +#: ../../c-api/unicode.rst:1128 ../../c-api/unicode.rst:1179 msgid "If *byteorder* is ``NULL``, the codec starts in native order mode." msgstr "" -#: ../../c-api/unicode.rst:1120 ../../c-api/unicode.rst:1171 +#: ../../c-api/unicode.rst:1130 ../../c-api/unicode.rst:1181 msgid "Return ``NULL`` if an exception was raised by the codec." msgstr "如果編解碼器引發例外則回傳 ``NULL``。" -#: ../../c-api/unicode.rst:1126 +#: ../../c-api/unicode.rst:1136 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF32`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF32Stateful` will not " @@ -1417,29 +1426,29 @@ msgid "" "number of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1135 +#: ../../c-api/unicode.rst:1145 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:1141 +#: ../../c-api/unicode.rst:1151 msgid "UTF-16 Codecs" msgstr "UTF-16 編解碼器" -#: ../../c-api/unicode.rst:1143 +#: ../../c-api/unicode.rst:1153 msgid "These are the UTF-16 codec APIs:" msgstr "這些是 UTF-16 編解碼器的 API:" -#: ../../c-api/unicode.rst:1149 +#: ../../c-api/unicode.rst:1159 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:1160 +#: ../../c-api/unicode.rst:1170 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 " @@ -1448,13 +1457,13 @@ msgid "" "result in either a ``\\ufeff`` or a ``\\ufffe`` character)." msgstr "" -#: ../../c-api/unicode.rst:1166 +#: ../../c-api/unicode.rst:1176 msgid "" "After completion, ``*byteorder`` is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1177 +#: ../../c-api/unicode.rst:1187 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF16`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF16Stateful` will not " @@ -1464,28 +1473,28 @@ msgid "" "*consumed*." msgstr "" -#: ../../c-api/unicode.rst:1186 +#: ../../c-api/unicode.rst:1196 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:1192 +#: ../../c-api/unicode.rst:1202 msgid "UTF-7 Codecs" msgstr "UTF-7 編解碼器" -#: ../../c-api/unicode.rst:1194 +#: ../../c-api/unicode.rst:1204 msgid "These are the UTF-7 codec APIs:" msgstr "這些是 UTF-7 編解碼器的 API:" -#: ../../c-api/unicode.rst:1199 +#: ../../c-api/unicode.rst:1209 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:1206 +#: ../../c-api/unicode.rst:1216 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF7`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-7 base-64 sections will " @@ -1493,101 +1502,101 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1213 +#: ../../c-api/unicode.rst:1223 msgid "Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1215 +#: ../../c-api/unicode.rst:1225 msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1221 +#: ../../c-api/unicode.rst:1231 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:1227 +#: ../../c-api/unicode.rst:1237 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:1233 +#: ../../c-api/unicode.rst:1243 msgid "Raw-Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1235 +#: ../../c-api/unicode.rst:1245 msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1241 +#: ../../c-api/unicode.rst:1251 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:1247 +#: ../../c-api/unicode.rst:1257 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:1253 +#: ../../c-api/unicode.rst:1263 msgid "Latin-1 Codecs" msgstr "Latin-1 編解碼器" -#: ../../c-api/unicode.rst:1255 +#: ../../c-api/unicode.rst:1265 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:1261 +#: ../../c-api/unicode.rst:1271 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:1267 +#: ../../c-api/unicode.rst:1277 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:1273 +#: ../../c-api/unicode.rst:1283 msgid "ASCII Codecs" msgstr "ASCII 編解碼器" -#: ../../c-api/unicode.rst:1275 +#: ../../c-api/unicode.rst:1285 msgid "" "These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All " "other codes generate errors." msgstr "" -#: ../../c-api/unicode.rst:1281 +#: ../../c-api/unicode.rst:1291 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:1287 +#: ../../c-api/unicode.rst:1297 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:1293 +#: ../../c-api/unicode.rst:1303 msgid "Character Map Codecs" msgstr "" -#: ../../c-api/unicode.rst:1295 +#: ../../c-api/unicode.rst:1305 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 " @@ -1597,18 +1606,18 @@ msgid "" "sequences work well." msgstr "" -#: ../../c-api/unicode.rst:1301 +#: ../../c-api/unicode.rst:1311 msgid "These are the mapping codec APIs:" msgstr "這些是對映編解碼器的 API:" -#: ../../c-api/unicode.rst:1306 +#: ../../c-api/unicode.rst:1316 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:1310 +#: ../../c-api/unicode.rst:1320 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 " @@ -1618,14 +1627,14 @@ msgid "" "treated as undefined mappings and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1321 +#: ../../c-api/unicode.rst:1331 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:1325 +#: ../../c-api/unicode.rst:1335 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " @@ -1633,41 +1642,41 @@ msgid "" "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1331 +#: ../../c-api/unicode.rst:1341 msgid "The following codec API is special in that maps Unicode to Unicode." msgstr "" -#: ../../c-api/unicode.rst:1335 +#: ../../c-api/unicode.rst:1345 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:1339 +#: ../../c-api/unicode.rst:1349 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:1342 +#: ../../c-api/unicode.rst:1352 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:1346 +#: ../../c-api/unicode.rst:1356 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:1351 +#: ../../c-api/unicode.rst:1361 msgid "MBCS codecs for Windows" msgstr "Windows 的 MBCS 編解碼器" -#: ../../c-api/unicode.rst:1353 +#: ../../c-api/unicode.rst:1363 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 " @@ -1675,13 +1684,13 @@ msgid "" "is defined by the user settings on the machine running the codec." msgstr "" -#: ../../c-api/unicode.rst:1360 +#: ../../c-api/unicode.rst:1370 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:1367 +#: ../../c-api/unicode.rst:1377 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeMBCS`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeMBCSStateful` will not " @@ -1689,50 +1698,46 @@ msgid "" "will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1376 +#: ../../c-api/unicode.rst:1386 msgid "" "Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " "specified by *code_page*." msgstr "" -#: ../../c-api/unicode.rst:1382 +#: ../../c-api/unicode.rst:1392 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:1389 +#: ../../c-api/unicode.rst:1399 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:1397 -msgid "Methods & Slots" -msgstr "" - -#: ../../c-api/unicode.rst:1403 +#: ../../c-api/unicode.rst:1409 msgid "Methods and Slot Functions" msgstr "" -#: ../../c-api/unicode.rst:1405 +#: ../../c-api/unicode.rst:1411 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:1409 +#: ../../c-api/unicode.rst:1415 msgid "They all return ``NULL`` or ``-1`` if an exception occurs." msgstr "如果發生例外,則回傳 ``NULL`` 或 ``-1``。" -#: ../../c-api/unicode.rst:1414 +#: ../../c-api/unicode.rst:1420 msgid "Concat two strings giving a new Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1419 +#: ../../c-api/unicode.rst:1425 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -1741,33 +1746,33 @@ msgid "" "list." msgstr "" -#: ../../c-api/unicode.rst:1424 ../../c-api/unicode.rst:1434 -#: ../../c-api/unicode.rst:1455 ../../c-api/unicode.rst:1468 +#: ../../c-api/unicode.rst:1430 ../../c-api/unicode.rst:1440 +#: ../../c-api/unicode.rst:1461 ../../c-api/unicode.rst:1474 msgid "On error, return ``NULL`` with an exception set." msgstr "於錯誤發生時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/unicode.rst:1426 +#: ../../c-api/unicode.rst:1432 msgid "Equivalent to :py:meth:`str.split`." msgstr "等價於 :py:meth:`str.split`。" -#: ../../c-api/unicode.rst:1431 +#: ../../c-api/unicode.rst:1437 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 +#: ../../c-api/unicode.rst:1442 msgid "Equivalent to :py:meth:`str.rsplit`." msgstr "等價於 :py:meth:`str.rsplit`。" -#: ../../c-api/unicode.rst:1441 +#: ../../c-api/unicode.rst:1447 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:1448 +#: ../../c-api/unicode.rst:1454 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 " @@ -1775,39 +1780,39 @@ msgid "" "tuple containing the string itself, followed by two empty strings." msgstr "" -#: ../../c-api/unicode.rst:1453 ../../c-api/unicode.rst:1466 +#: ../../c-api/unicode.rst:1459 ../../c-api/unicode.rst:1472 msgid "*sep* must not be empty." msgstr "*sep* 不得為空。" -#: ../../c-api/unicode.rst:1457 +#: ../../c-api/unicode.rst:1463 msgid "Equivalent to :py:meth:`str.partition`." msgstr "等價於 :py:meth:`str.partition`。" -#: ../../c-api/unicode.rst:1462 +#: ../../c-api/unicode.rst:1468 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 +#: ../../c-api/unicode.rst:1476 msgid "Equivalent to :py:meth:`str.rpartition`." msgstr "等價於 :py:meth:`str.rpartition`。" -#: ../../c-api/unicode.rst:1475 +#: ../../c-api/unicode.rst:1481 msgid "" "Join a sequence of strings using the given *separator* and return the " "resulting Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1482 +#: ../../c-api/unicode.rst:1488 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:1490 +#: ../../c-api/unicode.rst:1496 msgid "" "Return the first position of *substr* in ``unicode[start:end]`` using the " "given *direction* (*direction* == ``1`` means to do a forward search, " @@ -1816,7 +1821,7 @@ msgid "" "``-2`` indicates that an error occurred and an exception has been set." msgstr "" -#: ../../c-api/unicode.rst:1500 +#: ../../c-api/unicode.rst:1506 msgid "" "Return the first position of the character *ch* in ``unicode[start:end]`` " "using the given *direction* (*direction* == ``1`` means to do a forward " @@ -1826,37 +1831,37 @@ msgid "" "set." msgstr "" -#: ../../c-api/unicode.rst:1508 +#: ../../c-api/unicode.rst:1514 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" -#: ../../c-api/unicode.rst:1515 +#: ../../c-api/unicode.rst:1521 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:1522 +#: ../../c-api/unicode.rst:1528 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:1529 +#: ../../c-api/unicode.rst:1535 msgid "" "Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, " "and greater than, respectively." msgstr "" -#: ../../c-api/unicode.rst:1532 +#: ../../c-api/unicode.rst:1538 msgid "" "This function returns ``-1`` upon failure, so one should call :c:func:" "`PyErr_Occurred` to check for errors." msgstr "" -#: ../../c-api/unicode.rst:1538 +#: ../../c-api/unicode.rst:1544 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 " @@ -1865,18 +1870,18 @@ msgid "" "is returned." msgstr "" -#: ../../c-api/unicode.rst:1545 ../../c-api/unicode.rst:1566 +#: ../../c-api/unicode.rst:1551 ../../c-api/unicode.rst:1572 msgid "This function does not raise exceptions." msgstr "此函式不會引發例外。" -#: ../../c-api/unicode.rst:1552 +#: ../../c-api/unicode.rst:1558 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:1561 +#: ../../c-api/unicode.rst:1567 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 " @@ -1884,47 +1889,47 @@ msgid "" "string as ISO-8859-1 if it contains non-ASCII characters." msgstr "" -#: ../../c-api/unicode.rst:1571 +#: ../../c-api/unicode.rst:1577 msgid "Rich compare two Unicode strings and return one of the following:" msgstr "" -#: ../../c-api/unicode.rst:1573 +#: ../../c-api/unicode.rst:1579 msgid "``NULL`` in case an exception was raised" msgstr "" -#: ../../c-api/unicode.rst:1574 +#: ../../c-api/unicode.rst:1580 msgid ":c:data:`Py_True` or :c:data:`Py_False` for successful comparisons" msgstr "" -#: ../../c-api/unicode.rst:1575 +#: ../../c-api/unicode.rst:1581 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" msgstr "" -#: ../../c-api/unicode.rst:1577 +#: ../../c-api/unicode.rst:1583 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:1583 +#: ../../c-api/unicode.rst:1589 msgid "" "Return a new string object from *format* and *args*; this is analogous to " "``format % args``." msgstr "" -#: ../../c-api/unicode.rst:1589 +#: ../../c-api/unicode.rst:1595 msgid "" "Check whether *substr* is contained in *unicode* and return true or false " "accordingly." msgstr "" -#: ../../c-api/unicode.rst:1592 +#: ../../c-api/unicode.rst:1598 msgid "" "*substr* has to coerce to a one element Unicode string. ``-1`` is returned " "if there was an error." msgstr "" -#: ../../c-api/unicode.rst:1598 +#: ../../c-api/unicode.rst:1604 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. " @@ -1935,7 +1940,7 @@ msgid "" "interns it." msgstr "" -#: ../../c-api/unicode.rst:1605 +#: ../../c-api/unicode.rst:1611 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; " @@ -1943,39 +1948,39 @@ msgid "" "the result.)" msgstr "" -#: ../../c-api/unicode.rst:1610 +#: ../../c-api/unicode.rst:1616 msgid "" "This function never raises an exception. On error, it leaves its argument " "unchanged without interning it." msgstr "" -#: ../../c-api/unicode.rst:1613 +#: ../../c-api/unicode.rst:1619 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:1617 +#: ../../c-api/unicode.rst:1623 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:1623 +#: ../../c-api/unicode.rst:1629 msgid "" "A combination of :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace`, meant for statically allocated strings." msgstr "" -#: ../../c-api/unicode.rst:1626 +#: ../../c-api/unicode.rst:1632 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:1630 +#: ../../c-api/unicode.rst:1636 msgid "" "Python may keep a reference to the result, or make it :term:`immortal`, " "preventing it from being garbage-collected promptly. For interning an " @@ -1983,7 +1988,3 @@ msgid "" "prefer calling :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace` directly." msgstr "" - -#: ../../c-api/unicode.rst:1638 -msgid "Strings interned this way are made :term:`immortal`." -msgstr "" diff --git a/deprecations/index.po b/deprecations/index.po index 05c5babe57..9933eacdd4 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-30 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -431,6 +431,20 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:88 msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." +msgstr "" +"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* " +"參數 (``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = " +"TypedDict(\"TD\", None)``) 的做法自 Python 3.13 起已被棄用。請" +"使用 ``class TD(TypedDict): pass`` 或 ``TD = " +"TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#: ../../deprecations/pending-removal-in-3.15.rst: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." @@ -439,11 +453,11 @@ msgstr "" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" -#: ../../deprecations/pending-removal-in-3.15.rst:93 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:95 +#: ../../deprecations/pending-removal-in-3.15.rst:102 msgid "" "The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." "Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index 726d403414..345db845e3 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-28 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,10 +25,10 @@ msgstr "引入系統 (import system):" #: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to " -"set :attr:`__spec__.cached ` is " -"deprecated. In Python 3.15, :attr:`!__cached__` will cease to be set or take " -"into consideration by the import system or standard library. (:gh:`97879`)" +"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +"`__spec__.cached ` is deprecated. In " +"Python 3.15, :attr:`!__cached__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" "在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " "` 的做法已被棄用。在 Python 3.15 中," @@ -36,11 +36,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" -"Setting :attr:`~module.__package__` on a module while failing to " -"set :attr:`__spec__.parent ` is " -"deprecated. In Python 3.15, :attr:`!__package__` will cease to be set or " -"take into consideration by the import system or standard library. " -"(:gh:`97879`)" +"Setting :attr:`~module.__package__` on a module while failing to set :attr:" +"`__spec__.parent ` is deprecated. In " +"Python 3.15, :attr:`!__package__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" "在模組上設定 :attr:`~module.__package__` 而沒有設定 :attr:`__spec__.parent " "` 的做法已被棄用。在 Python 3.15 中," @@ -94,17 +93,15 @@ msgstr ":class:`locale`:" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" "The :func:`~locale.getdefaultlocale` function has been deprecated since " -"Python 3.11. Its removal was originally planned for Python 3.13 " -"(:gh:`90817`), but has been postponed to Python 3.15. " -"Use :func:`~locale.getlocale`, :func:`~locale.setlocale`, " -"and :func:`~locale.getencoding` instead. (Contributed by Hugo van Kemenade " -"in :gh:`111187`.)" +"Python 3.11. Its removal was originally planned for Python 3.13 (:gh:" +"`90817`), but has been postponed to Python 3.15. Use :func:`~locale." +"getlocale`, :func:`~locale.setlocale`, and :func:`~locale.getencoding` " +"instead. (Contributed by Hugo van Kemenade in :gh:`111187`.)" msgstr "" ":func:`~locale.getdefaultlocale` 已在 Python 3.11 中被棄用,原本計劃在 " -"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改" -"用 :func:`~locale.getlocale`、:func:`~locale.setlocale` " -"和 :func:`~locale.getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢" -"獻。)" +"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :func:" +"`~locale.getlocale`、:func:`~locale.setlocale` 和 :func:`~locale." +"getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:46 msgid ":mod:`pathlib`:" @@ -112,11 +109,11 @@ msgstr ":mod:`pathlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:48 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. " -"Use :func:`os.path.isreserved` to detect reserved paths on Windows." +":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +"func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請" -"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" +":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." +"isreserved` 來偵測 Windows 上的保留路徑。" #: ../../deprecations/pending-removal-in-3.15.rst:52 msgid ":mod:`platform`:" @@ -170,9 +167,9 @@ msgid "" "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" ":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發" -"出 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " -"於 :gh:`101866` 貢獻。)" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" +"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" +"`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:80 msgid ":mod:`typing`:" @@ -180,10 +177,10 @@ msgstr ":mod:`typing`:" #: ../../deprecations/pending-removal-in-3.15.rst:82 msgid "" -"The undocumented keyword argument syntax for " -"creating :class:`~typing.NamedTuple` classes (e.g. ``Point = " -"NamedTuple(\"Point\", x=int, y=int)``) has been deprecated since Python " -"3.13. Use the class-based syntax or the functional syntax instead." +"The undocumented keyword argument syntax for creating :class:`~typing." +"NamedTuple` classes (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:`~typing.NamedTuple` 類別的未以文件記錄之關鍵字引數語法 " "(``Point = NamedTuple(\"Point\", x=int, y=int)``) 已自 Python 3.13 棄用。請改" @@ -191,6 +188,20 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:88 msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." +msgstr "" +"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* " +"參數 (``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = " +"TypedDict(\"TD\", None)``) 的做法自 Python 3.13 起已被棄用。請" +"使用 ``class TD(TypedDict): pass`` 或 ``TD = " +"TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#: ../../deprecations/pending-removal-in-3.15.rst: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." @@ -199,17 +210,16 @@ msgstr "" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" -#: ../../deprecations/pending-removal-in-3.15.rst:93 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:95 +#: ../../deprecations/pending-removal-in-3.15.rst:102 msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, " -"and :meth:`~wave.Wave_read.getmarkers` methods of " -"the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been " -"deprecated since Python 3.13." +"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." +"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" +"`~wave.Wave_write` classes have been deprecated since Python 3.13." msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別" -"的 :meth:`~wave.Wave_read.getmark`、:meth:`!setmark` " -"和 :meth:`~wave.Wave_read.getmarkers` 方法自 Python 3.13 被棄用。" +"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" +"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." +"getmarkers` 方法自 Python 3.13 被棄用。" diff --git a/extending/building.po b/extending/building.po index 46539b1e5e..9285c3baea 100644 --- a/extending/building.po +++ b/extending/building.po @@ -8,7 +8,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-06-27 07:36+0000\n" "PO-Revision-Date: 2025-02-07 14:09+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,10 +33,10 @@ msgstr "" #: ../../extending/building.rst:12 msgid "" -"To be importable, the shared library must be available " -"on :envvar:`PYTHONPATH`, and must be named after the module name, with an " -"appropriate extension. When using setuptools, the correct filename is " -"generated automatically." +"To be importable, the shared library must be available on :envvar:" +"`PYTHONPATH`, and must be named after the module name, with an appropriate " +"extension. When using setuptools, the correct filename is generated " +"automatically." msgstr "" "要能夠被引入,共用函式庫必須在 :envvar:`PYTHONPATH` 上可用,並且必須以模組名" "稱命名,並且必須有適當的副檔名。使用 setuptools 時,正確的檔名會自動產生。" @@ -55,17 +55,17 @@ msgstr "" #: ../../extending/building.rst:25 msgid "" -"For modules with ASCII-only names, the function must be named " -"``PyInit_``, with ```` replaced by the name of the " -"module. When using :ref:`multi-phase-initialization`, non-ASCII module names " -"are allowed. In this case, the initialization function name is " -"``PyInitU_``, with ```` encoded using Python's " -"*punycode* encoding with hyphens replaced by underscores. In Python::" +"For modules with ASCII-only names, the function must be named :samp:" +"`PyInit_{}`, with ```` replaced by the name of the module. When " +"using :ref:`multi-phase-initialization`, non-ASCII module names are allowed. " +"In this case, the initialization function name is :samp:`PyInitU_{}`, " +"with ```` encoded using Python's *punycode* encoding with hyphens " +"replaced by underscores. In Python::" msgstr "" -"對於僅包含 ASCII 名稱的模組,函式必須以 ``PyInit_`` 命名,其中 " -"```` 要替換為模組的名稱。當使用 :ref:`multi-phase-" +"對於僅包含 ASCII 名稱的模組,函式必須以 :samp:`PyInit_{}` 命名,其中 " +"```` 要替換為模組的名稱。當使用 :ref:`multi-phase-" "initialization` 時,允許非 ASCII 模組名稱。在這種情況下,初始化函式名稱是 " -"``PyInitU_``,其中 ```` 使用 Python 的 *punycode* 編" +":samp:`PyInitU_{}`,其中 ```` 使用 Python 的 *punycode* 編" "碼,並將連字符號替換為底線。在 Python 中: ::" #: ../../extending/building.rst:32 @@ -107,6 +107,6 @@ msgid "" "setuptools.html to learn more about how build and distribute C/C++ " "extensions with setuptools." msgstr "" -"Python 3.12 與之後的版本不再帶有 distutils。請在 https://" -"setuptools.readthedocs.io/en/latest/setuptools.html 上參閱 ``setuptools`` 文" -"件,以了解如何使用 setuptools 建置和發佈 C/C++ 擴充套件。" +"Python 3.12 與之後的版本不再帶有 distutils。請在 https://setuptools." +"readthedocs.io/en/latest/setuptools.html 上參閱 ``setuptools`` 文件,以了解如" +"何使用 setuptools 建置和發佈 C/C++ 擴充套件。" diff --git a/extending/embedding.po b/extending/embedding.po index 4f1244dc1c..f08b001e48 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: 2025-03-07 15:49+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -124,6 +124,40 @@ msgid "" " Py_ExitStatusException(status);\n" "}" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" PyStatus status;\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* 建議但非必要 */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name, " +"argv[0]);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" +" PyRun_SimpleString(\"from time import time,ctime\\n\"\n" +" \"print('Today is', ctime(time()))\\n\");\n" +" if (Py_FinalizeEx() < 0) {\n" +" exit(120);\n" +" }\n" +" return 0;\n" +"\n" +" exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" +"}" #: ../../extending/embedding.rst:92 msgid "" @@ -420,31 +454,33 @@ msgid "" " return PyLong_FromLong(numargs);\n" "}\n" "\n" -"static PyMethodDef EmbMethods[] = {\n" +"static PyMethodDef emb_module_methods[] = {\n" " {\"numargs\", emb_numargs, METH_VARARGS,\n" " \"Return the number of arguments received by the process.\"},\n" " {NULL, NULL, 0, NULL}\n" "};\n" "\n" -"static PyModuleDef EmbModule = {\n" -" PyModuleDef_HEAD_INIT, \"emb\", NULL, -1, EmbMethods,\n" -" NULL, NULL, NULL, NULL\n" +"static struct PyModuleDef emb_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"emb\",\n" +" .m_size = 0,\n" +" .m_methods = emb_module_methods,\n" "};\n" "\n" "static PyObject*\n" "PyInit_emb(void)\n" "{\n" -" return PyModule_Create(&EmbModule);\n" +" return PyModuleDef_Init(&emb_module);\n" "}" msgstr "" -#: ../../extending/embedding.rst:265 +#: ../../extending/embedding.rst:267 msgid "" "Insert the above code just above the :c:func:`main` function. Also, insert " "the following two statements before the call to :c:func:`Py_Initialize`::" msgstr "" -#: ../../extending/embedding.rst:268 +#: ../../extending/embedding.rst:270 msgid "" "numargs = argc;\n" "PyImport_AppendInittab(\"emb\", &PyInit_emb);" @@ -452,30 +488,30 @@ msgstr "" "numargs = argc;\n" "PyImport_AppendInittab(\"emb\", &PyInit_emb);" -#: ../../extending/embedding.rst:271 +#: ../../extending/embedding.rst:273 msgid "" "These two lines initialize the ``numargs`` variable, and make the :func:`!" "emb.numargs` function accessible to the embedded Python interpreter. With " "these extensions, the Python script can do things like" msgstr "" -#: ../../extending/embedding.rst:275 +#: ../../extending/embedding.rst:277 msgid "" "import emb\n" "print(\"Number of arguments\", emb.numargs())" msgstr "" -#: ../../extending/embedding.rst:280 +#: ../../extending/embedding.rst:282 msgid "" "In a real application, the methods will expose an API of the application to " "Python." msgstr "" -#: ../../extending/embedding.rst:290 +#: ../../extending/embedding.rst:292 msgid "Embedding Python in C++" msgstr "" -#: ../../extending/embedding.rst:292 +#: ../../extending/embedding.rst:294 msgid "" "It is also possible to embed Python in a C++ program; precisely how this is " "done will depend on the details of the C++ system used; in general you will " @@ -484,11 +520,11 @@ msgid "" "+." msgstr "" -#: ../../extending/embedding.rst:301 +#: ../../extending/embedding.rst:303 msgid "Compiling and Linking under Unix-like systems" msgstr "" -#: ../../extending/embedding.rst:303 +#: ../../extending/embedding.rst:305 msgid "" "It is not necessarily trivial to find the right flags to pass to your " "compiler (and linker) in order to embed the Python interpreter into your " @@ -496,7 +532,7 @@ msgid "" "implemented as C dynamic extensions (:file:`.so` files) linked against it." msgstr "" -#: ../../extending/embedding.rst:309 +#: ../../extending/embedding.rst:311 msgid "" "To find out the required compiler and linker flags, you can execute the :" "file:`python{X.Y}-config` script which is generated as part of the " @@ -505,13 +541,13 @@ msgid "" "directly useful to you:" msgstr "" -#: ../../extending/embedding.rst:315 +#: ../../extending/embedding.rst:317 msgid "" "``pythonX.Y-config --cflags`` will give you the recommended flags when " "compiling:" msgstr "" -#: ../../extending/embedding.rst:318 +#: ../../extending/embedding.rst:320 msgid "" "$ /opt/bin/python3.11-config --cflags\n" "-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " @@ -521,13 +557,13 @@ msgstr "" "-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " "-g -fwrapv -O3 -Wall" -#: ../../extending/embedding.rst:323 +#: ../../extending/embedding.rst:325 msgid "" "``pythonX.Y-config --ldflags --embed`` will give you the recommended flags " "when linking:" msgstr "" -#: ../../extending/embedding.rst:326 +#: ../../extending/embedding.rst:328 msgid "" "$ /opt/bin/python3.11-config --ldflags --embed\n" "-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" @@ -537,7 +573,7 @@ msgstr "" "-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" "lpthread -ldl -lutil -lm" -#: ../../extending/embedding.rst:332 +#: ../../extending/embedding.rst:334 msgid "" "To avoid confusion between several Python installations (and especially " "between the system Python and your own compiled Python), it is recommended " @@ -545,7 +581,7 @@ msgid "" "above example." msgstr "" -#: ../../extending/embedding.rst:337 +#: ../../extending/embedding.rst:339 msgid "" "If this procedure doesn't work for you (it is not guaranteed to work for all " "Unix-like platforms; however, we welcome :ref:`bug reports >> import sysconfig\n" ">>> sysconfig.get_config_var('LIBS')\n" diff --git a/extending/extending.po b/extending/extending.po index da956c0dc4..df2ba80946 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-07 15:02+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2025-02-17 14:34+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -101,9 +101,9 @@ msgstr "" #: ../../extending/extending.rst:53 msgid "" "Begin by creating a file :file:`spammodule.c`. (Historically, if a module " -"is called ``spam``, the C file containing its implementation is " -"called :file:`spammodule.c`; if the module name is very long, like " -"``spammify``, the module name can be just :file:`spammify.c`.)" +"is called ``spam``, the C file containing its implementation is called :file:" +"`spammodule.c`; if the module name is very long, like ``spammify``, the " +"module name can be just :file:`spammify.c`.)" msgstr "" "首先建立一個檔案 :file:`spammodule.c`。(從過去歷史來看,如果一個模組叫做 " "``spam``,包含其實作的 C 檔案就會叫做 :file:`spammodule.c`;如果模組名稱很" @@ -113,7 +113,7 @@ msgstr "" msgid "The first two lines of our file can be::" msgstr "我們檔案的前兩列可以為: ::" -#: ../../extending/extending.rst:60 ../../extending/extending.rst:663 +#: ../../extending/extending.rst:60 ../../extending/extending.rst:681 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include " @@ -153,18 +153,18 @@ msgstr "" msgid "" "All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` " "or ``PY``, except those defined in standard header files. For convenience, " -"and since they are used extensively by the Python interpreter, " -"``\"Python.h\"`` includes a few standard header files: ````, " -"````, ````, and ````. If the latter header " -"file does not exist on your system, it declares the " -"functions :c:func:`malloc`, :c:func:`free` and :c:func:`realloc` directly." +"and since they are used extensively by the Python interpreter, ``\"Python." +"h\"`` includes a few standard header files: ````, ````, " +"````, and ````. If the latter header file does not exist " +"on your system, it declares the functions :c:func:`malloc`, :c:func:`free` " +"and :c:func:`realloc` directly." msgstr "" "除了那些在標準標頭檔中定義的符號以外,所有由 :file:`Python.h` 定義的使用者可" "見符號 (user-visible symbols) 的前綴都是 ``Py`` 或 ``PY``。為了方便,也因為 " -"Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:" -"````、````、```` 和 ````。如果 " -"```` 在你的系統上不存在,它會直接宣" -"告 :c:func:`malloc`、:c:func:`free` 和 :c:func:`realloc` 函式。" +"Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:````、````、```` 和 ````。如果 ```` 在" +"你的系統上不存在,它會直接宣告 :c:func:`malloc`、:c:func:`free` 和 :c:func:" +"`realloc` 函式。" #: ../../extending/extending.rst:85 msgid "" @@ -172,9 +172,9 @@ msgid "" "called when the Python expression ``spam.system(string)`` is evaluated " "(we'll see shortly how it ends up being called)::" msgstr "" -"接下來我們要加入到模組檔案的是 C 函式,當 Python 運算式 " -"``spam.system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它" -"最後是如何被呼叫的): ::" +"接下來我們要加入到模組檔案的是 C 函式,當 Python 運算式 ``spam." +"system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它最後是" +"如何被呼叫的): ::" #: ../../extending/extending.rst:89 msgid "" @@ -233,9 +233,9 @@ msgid "" msgstr "" "*args* 引數會是一個指向包含引數的 Python 元組物件的指標。元組中的每一項都對應" "於呼叫的引數串列中的一個引數。引數是 Python 物件 --- 為了在我們的 C 函式中對" -"它們做任何事情,我們必須先將它們轉換成 C 值。Python API 中" -"的 :c:func:`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用" -"模板字串來決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" +"它們做任何事情,我們必須先將它們轉換成 C 值。Python API 中的 :c:func:" +"`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用模板字串來" +"決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" #: ../../extending/extending.rst:118 msgid "" @@ -246,10 +246,10 @@ msgid "" "the calling function can return ``NULL`` immediately (as we saw in the " "example)." msgstr "" -"如果所有的引數都有正確的型別,且其元件已儲存在傳入位址的變數中," -"則 :c:func:`PyArg_ParseTuple` 會回傳 true(非零)。如果傳入的是無效引數串列則" -"回傳 false(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回" -"傳 ``NULL``\\ (就像我們在範例中所看到的)。" +"如果所有的引數都有正確的型別,且其元件已儲存在傳入位址的變數中,則 :c:func:" +"`PyArg_ParseTuple` 會回傳 true(非零)。如果傳入的是無效引數串列則回傳 false" +"(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回傳 " +"``NULL``\\ (就像我們在範例中所看到的)。" #: ../../extending/extending.rst:128 msgid "Intermezzo: Errors and Exceptions" @@ -295,28 +295,27 @@ msgstr "" msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " -"global variable :c:data:`errno`. The most general function " -"is :c:func:`PyErr_SetObject`, which takes two object arguments, the " -"exception and its associated value. You don't need to :c:func:`Py_INCREF` " -"the objects passed to any of these functions." +"global variable :c:data:`errno`. The most general function is :c:func:" +"`PyErr_SetObject`, which takes two object arguments, the exception and its " +"associated value. You don't need to :c:func:`Py_INCREF` the objects passed " +"to any of these functions." msgstr "" "另一個有用的函式是 :c:func:`PyErr_SetFromErrno`,它只接受一個例外引數,並透過" -"檢查全域變數 :c:data:`errno` 來建立關聯值。最一般的函式" -"是 :c:func:`PyErr_SetObject`,它接受兩個物件引數,即例外和它的關聯值。你不需" -"要對傳給任何這些函式的物件呼叫 :c:func:`Py_INCREF`。" +"檢查全域變數 :c:data:`errno` 來建立關聯值。最一般的函式是 :c:func:" +"`PyErr_SetObject`,它接受兩個物件引數,即例外和它的關聯值。你不需要對傳給任何" +"這些函式的物件呼叫 :c:func:`Py_INCREF`。" #: ../../extending/extending.rst:154 msgid "" -"You can test non-destructively whether an exception has been set " -"with :c:func:`PyErr_Occurred`. This returns the current exception object, " -"or ``NULL`` if no exception has occurred. You normally don't need to " -"call :c:func:`PyErr_Occurred` to see whether an error occurred in a function " -"call, since you should be able to tell from the return value." +"You can test non-destructively whether an exception has been set with :c:" +"func:`PyErr_Occurred`. This returns the current exception object, or " +"``NULL`` if no exception has occurred. You normally don't need to call :c:" +"func:`PyErr_Occurred` to see whether an error occurred in a function call, " +"since you should be able to tell from the return value." msgstr "" "你可以使用 :c:func:`PyErr_Occurred` 來不具破壞性地測試例外是否已被設定。這會" -"回傳目前的例外物件,如果沒有例外發生則回傳 ``NULL``。你通常不需要呼" -"叫 :c:func:`PyErr_Occurred` 來查看函式呼叫是否發生錯誤,因為你應可從回傳值就" -"得知。" +"回傳目前的例外物件,如果沒有例外發生則回傳 ``NULL``。你通常不需要呼叫 :c:" +"func:`PyErr_Occurred` 來查看函式呼叫是否發生錯誤,因為你應可從回傳值就得知。" #: ../../extending/extending.rst:160 msgid "" @@ -365,17 +364,16 @@ msgstr "" #: ../../extending/extending.rst:182 msgid "" "Every failing :c:func:`malloc` call must be turned into an exception --- the " -"direct caller of :c:func:`malloc` (or :c:func:`realloc`) must " -"call :c:func:`PyErr_NoMemory` and return a failure indicator itself. All " -"the object-creating functions (for example, :c:func:`PyLong_FromLong`) " -"already do this, so this note is only relevant to those who " -"call :c:func:`malloc` directly." -msgstr "" -"每個失敗的 :c:func:`malloc` 呼叫都必須被轉換成一個例外 " -"--- :c:func:`malloc`\\ (或 :c:func:`realloc`)的直接呼叫者必須呼" -"叫 :c:func:`PyErr_NoMemory` 並回傳一個失敗指示器。所有建立物件的函式(例" -"如 :c:func:`PyLong_FromLong`)都已經這麼做了,所以這個注意事項只和那些直接呼" -"叫 :c:func:`malloc` 的函式有關。" +"direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call :c:func:" +"`PyErr_NoMemory` and return a failure indicator itself. All the object-" +"creating functions (for example, :c:func:`PyLong_FromLong`) already do this, " +"so this note is only relevant to those who call :c:func:`malloc` directly." +msgstr "" +"每個失敗的 :c:func:`malloc` 呼叫都必須被轉換成一個例外 --- :c:func:" +"`malloc`\\ (或 :c:func:`realloc`)的直接呼叫者必須呼叫 :c:func:" +"`PyErr_NoMemory` 並回傳一個失敗指示器。所有建立物件的函式(例如 :c:func:" +"`PyLong_FromLong`)都已經這麼做了,所以這個注意事項只和那些直接呼叫 :c:func:" +"`malloc` 的函式有關。" #: ../../extending/extending.rst:188 msgid "" @@ -390,12 +388,12 @@ msgstr "" #: ../../extending/extending.rst:192 msgid "" -"Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` " -"or :c:func:`Py_DECREF` calls for objects you have already created) when you " +"Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or :" +"c:func:`Py_DECREF` calls for objects you have already created) when you " "return an error indicator!" msgstr "" -"最後,在回傳錯誤指示器時要注意垃圾清理(透過對你已經建立的物件呼" -"叫 :c:func:`Py_XDECREF` 或 :c:func:`Py_DECREF`)!" +"最後,在回傳錯誤指示器時要注意垃圾清理(透過對你已經建立的物件呼叫 :c:func:" +"`Py_XDECREF` 或 :c:func:`Py_DECREF`)!" #: ../../extending/extending.rst:196 msgid "" @@ -403,82 +401,95 @@ msgid "" "predeclared C objects corresponding to all built-in Python exceptions, such " "as :c:data:`PyExc_ZeroDivisionError`, which you can use directly. Of course, " "you should choose exceptions wisely --- don't use :c:data:`PyExc_TypeError` " -"to mean that a file couldn't be opened (that should probably " -"be :c:data:`PyExc_OSError`). If something's wrong with the argument list, " -"the :c:func:`PyArg_ParseTuple` function usually " -"raises :c:data:`PyExc_TypeError`. If you have an argument whose value must " -"be in a particular range or must satisfy other " -"conditions, :c:data:`PyExc_ValueError` is appropriate." +"to mean that a file couldn't be opened (that should probably be :c:data:" +"`PyExc_OSError`). If something's wrong with the argument list, the :c:func:" +"`PyArg_ParseTuple` function usually raises :c:data:`PyExc_TypeError`. If " +"you have an argument whose value must be in a particular range or must " +"satisfy other conditions, :c:data:`PyExc_ValueError` is appropriate." msgstr "" "你完全可以自行選擇要產生的例外。有一些預先宣告的 C 物件會對應到所有內建的 " "Python 例外,例如 :c:data:`PyExc_ZeroDivisionError`,你可以直接使用它們。當" "然,你應該明智地選擇例外,像是不要使用 :c:data:`PyExc_TypeError` 來表示檔案無" -"法打開(應該是 :c:data:`PyExc_OSError`)。如果引數串列有問" -"題,:c:func:`PyArg_ParseTuple` 函式通常會引發 :c:data:`PyExc_TypeError`。如果" -"你有一個引數的值必須在一個特定的範圍內或必須滿足其他條件,則可以使" -"用 :c:data:`PyExc_ValueError`。" +"法打開(應該是 :c:data:`PyExc_OSError`)。如果引數串列有問題,:c:func:" +"`PyArg_ParseTuple` 函式通常會引發 :c:data:`PyExc_TypeError`。如果你有一個引數" +"的值必須在一個特定的範圍內或必須滿足其他條件,則可以使用 :c:data:" +"`PyExc_ValueError`。" #: ../../extending/extending.rst:206 msgid "" -"You can also define a new exception that is unique to your module. For this, " -"you usually declare a static object variable at the beginning of your file::" +"You can also define a new exception that is unique to your module. The " +"simplest way to do this is to declare a static global object variable at the " +"beginning of the file::" msgstr "" -"你也可以定義一個你的模組特有的新例外。為此你通常會在檔案開頭宣告一個靜態物件" -"變數: ::" +"你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態全域物件變數: ::" -#: ../../extending/extending.rst:209 -msgid "static PyObject *SpamError;" -msgstr "static PyObject *SpamError;" +#: ../../extending/extending.rst:210 +msgid "static PyObject *SpamError = NULL;" +msgstr "static PyObject *SpamError = NULL;" -#: ../../extending/extending.rst:211 +#: ../../extending/extending.rst:212 msgid "" -"and initialize it in your module's initialization function (:c:func:`!" -"PyInit_spam`) with an exception object::" +"and initialize it by calling :c:func:`PyErr_NewException` in the module's :c:" +"data:`Py_mod_exec` function (:c:func:`!spam_module_exec`)::" +msgstr "" + +#: ../../extending/extending.rst:215 +msgid "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" msgstr "" -"並在你的模組初始化函式中使用一個例外物件來初始化它 (:c:func:`!" -"PyInit_spam`): ::" -#: ../../extending/extending.rst:214 +#: ../../extending/extending.rst:217 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" PyObject *m;\n" -"\n" -" m = PyModule_Create(&spammodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +"Since :c:data:`!SpamError` is a global variable, it will be overwitten every " +"time the module is reinitialized, when the :c:data:`Py_mod_exec` function is " +"called." +msgstr "" + +#: ../../extending/extending.rst:220 +msgid "" +"For now, let's avoid the issue: we will block repeated initialization by " +"raising an :py:exc:`ImportError`::" +msgstr "" + +#: ../../extending/extending.rst:223 +msgid "" +"static PyObject *SpamError = NULL;\n" "\n" +"static int\n" +"spam_module_exec(PyObject *m)\n" +"{\n" +" if (SpamError != NULL) {\n" +" PyErr_SetString(PyExc_ImportError,\n" +" \"cannot initialize spam module more than once\");\n" +" return -1;\n" +" }\n" " SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" -" if (PyModule_AddObjectRef(m, \"error\", SpamError) < 0) {\n" -" Py_CLEAR(SpamError);\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" if (PyModule_AddObjectRef(m, \"SpamError\", SpamError) < 0) {\n" +" return -1;\n" " }\n" "\n" -" return m;\n" -"}" -msgstr "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" PyObject *m;\n" +" return 0;\n" +"}\n" "\n" -" m = PyModule_Create(&spammodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +"static PyModuleDef_Slot spam_module_slots[] = {\n" +" {Py_mod_exec, spam_module_exec},\n" +" {0, NULL}\n" +"};\n" "\n" -" SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" -" if (PyModule_AddObjectRef(m, \"error\", SpamError) < 0) {\n" -" Py_CLEAR(SpamError);\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" +"static struct PyModuleDef spam_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" .m_size = 0, // non-negative\n" +" .m_slots = spam_module_slots,\n" +"};\n" "\n" -" return m;\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModuleDef_Init(&spam_module);\n" "}" +msgstr "" -#: ../../extending/extending.rst:233 +#: ../../extending/extending.rst:259 msgid "" "Note that the Python name for the exception object is :exc:`!spam.error`. " "The :c:func:`PyErr_NewException` function may create a class with the base " @@ -489,7 +500,7 @@ msgstr "" "exceptions`\\ 所述,:c:func:`PyErr_NewException` 函式可能會建立一個基底類別" "為 :exc:`Exception` 的類別(除非傳入另一個類別來代替 ``NULL``)。" -#: ../../extending/extending.rst:238 +#: ../../extending/extending.rst:264 msgid "" "Note also that the :c:data:`!SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -505,13 +516,21 @@ msgstr "" "如果它變成迷途指標,那產生例外的 C 程式碼可能會導致核心轉儲 (core dump) 或其" "他不預期的 side effect。" -#: ../../extending/extending.rst:245 +#: ../../extending/extending.rst:271 +msgid "" +"For now, the :c:func:`Py_DECREF` call to remove this reference is missing. " +"Even when the Python interpreter shuts down, the global :c:data:`!SpamError` " +"variable will not be garbage-collected. It will \"leak\". We did, however, " +"ensure that this will happen at most once per process." +msgstr "" + +#: ../../extending/extending.rst:276 msgid "" "We discuss the use of :c:macro:`PyMODINIT_FUNC` as a function return type " "later in this sample." msgstr "我們稍後會討論 :c:macro:`PyMODINIT_FUNC` 作為函式回傳型別的用法。" -#: ../../extending/extending.rst:248 +#: ../../extending/extending.rst:279 msgid "" "The :exc:`!spam.error` exception can be raised in your extension module " "using a call to :c:func:`PyErr_SetString` as shown below::" @@ -519,7 +538,7 @@ msgstr "" "可以在你的擴充模組中呼叫 :c:func:`PyErr_SetString` 來引發 :exc:`!spam.error` " "例外,如下所示: ::" -#: ../../extending/extending.rst:251 +#: ../../extending/extending.rst:282 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -553,17 +572,17 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:271 +#: ../../extending/extending.rst:302 msgid "Back to the Example" msgstr "回到範例" -#: ../../extending/extending.rst:273 +#: ../../extending/extending.rst:304 msgid "" "Going back to our example function, you should now be able to understand " "this statement::" msgstr "回到我們的範例函式,現在你應該可以理解這個陳述式了: ::" -#: ../../extending/extending.rst:276 +#: ../../extending/extending.rst:307 msgid "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" @@ -571,7 +590,7 @@ msgstr "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" -#: ../../extending/extending.rst:279 +#: ../../extending/extending.rst:310 msgid "" "It returns ``NULL`` (the error indicator for functions returning object " "pointers) if an error is detected in the argument list, relying on the " @@ -587,32 +606,32 @@ msgstr "" "的字串(所以在標準 C 中,:c:data:`!command` 變數應該正確地被宣告為 ``const " "char *command``)。" -#: ../../extending/extending.rst:287 +#: ../../extending/extending.rst:318 msgid "" "The next statement is a call to the Unix function :c:func:`system`, passing " "it the string we just got from :c:func:`PyArg_ParseTuple`::" msgstr "" -"接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才" -"從 :c:func:`PyArg_ParseTuple` 得到的字串傳給它:" +"接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才從 :c:func:" +"`PyArg_ParseTuple` 得到的字串傳給它:" -#: ../../extending/extending.rst:290 +#: ../../extending/extending.rst:321 msgid "sts = system(command);" msgstr "sts = system(command);" -#: ../../extending/extending.rst:292 +#: ../../extending/extending.rst:323 msgid "" "Our :func:`!spam.system` function must return the value of :c:data:`!sts` as " -"a Python object. This is done using the " -"function :c:func:`PyLong_FromLong`. ::" +"a Python object. This is done using the function :c:func:" +"`PyLong_FromLong`. ::" msgstr "" "我們的 :func:`!spam.system` 函式必須以 Python 物件的形式來回傳 :c:data:`!" "sts` 的值。這是透過 :c:func:`PyLong_FromLong` 函式來達成。 ::" -#: ../../extending/extending.rst:295 +#: ../../extending/extending.rst:326 msgid "return PyLong_FromLong(sts);" msgstr "return PyLong_FromLong(sts);" -#: ../../extending/extending.rst:297 +#: ../../extending/extending.rst:328 msgid "" "In this case, it will return an integer object. (Yes, even integers are " "objects on the heap in Python!)" @@ -620,18 +639,18 @@ msgstr "" "在這種情況下它會回傳一個整數物件。(是的,在 Python 中連整數也是堆積 (heap) 上" "的物件!)" -#: ../../extending/extending.rst:300 +#: ../../extending/extending.rst:331 msgid "" "If you have a C function that returns no useful argument (a function " "returning :c:expr:`void`), the corresponding Python function must return " -"``None``. You need this idiom to do so (which is implemented by " -"the :c:macro:`Py_RETURN_NONE` macro)::" +"``None``. You need this idiom to do so (which is implemented by the :c:" +"macro:`Py_RETURN_NONE` macro)::" msgstr "" "如果你有一個不回傳任何有用引數的 C 函式(一個回傳 :c:expr:`void` 的函式),對" -"應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成" -"(由 :c:macro:`Py_RETURN_NONE` 巨集實作): ::" +"應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成(由 :c:macro:" +"`Py_RETURN_NONE` 巨集實作): ::" -#: ../../extending/extending.rst:305 +#: ../../extending/extending.rst:336 msgid "" "Py_INCREF(Py_None);\n" "return Py_None;" @@ -639,7 +658,7 @@ msgstr "" "Py_INCREF(Py_None);\n" "return Py_None;" -#: ../../extending/extending.rst:308 +#: ../../extending/extending.rst:339 msgid "" ":c:data:`Py_None` is the C name for the special Python object ``None``. It " "is a genuine Python object rather than a ``NULL`` pointer, which means " @@ -649,11 +668,11 @@ msgstr "" "Python 物件而不是一個 ``NULL`` 指標,在大多數的情況下它的意思是「錯誤」,如我" "們所見過的那樣。" -#: ../../extending/extending.rst:316 +#: ../../extending/extending.rst:347 msgid "The Module's Method Table and Initialization Function" msgstr "模組的方法表和初始化函式" -#: ../../extending/extending.rst:318 +#: ../../extending/extending.rst:349 msgid "" "I promised to show how :c:func:`!spam_system` is called from Python " "programs. First, we need to list its name and address in a \"method table\"::" @@ -661,9 +680,9 @@ msgstr "" "我承諾過要展示 :c:func:`!spam_system` 是如何從 Python 程式中呼叫的。首先,我" "們需要在「方法表」中列出它的名稱和位址: ::" -#: ../../extending/extending.rst:321 +#: ../../extending/extending.rst:352 msgid "" -"static PyMethodDef SpamMethods[] = {\n" +"static PyMethodDef spam_methods[] = {\n" " ...\n" " {\"system\", spam_system, METH_VARARGS,\n" " \"Execute a shell command.\"},\n" @@ -671,7 +690,7 @@ msgid "" " {NULL, NULL, 0, NULL} /* Sentinel */\n" "};" msgstr "" -"static PyMethodDef SpamMethods[] = {\n" +"static PyMethodDef spam_methods[] = {\n" " ...\n" " {\"system\", spam_system, METH_VARARGS,\n" " \"Execute a shell command.\"},\n" @@ -679,7 +698,7 @@ msgstr "" " {NULL, NULL, 0, NULL} /* Sentinel */\n" "};" -#: ../../extending/extending.rst:329 +#: ../../extending/extending.rst:360 msgid "" "Note the third entry (``METH_VARARGS``). This is a flag telling the " "interpreter the calling convention to be used for the C function. It should " @@ -691,18 +710,17 @@ msgstr "" "標。通常應該是 ``METH_VARARGS`` 或 ``METH_VARARGS | METH_KEYWORDS``;``0`` 表" "示是使用 :c:func:`PyArg_ParseTuple` 的一個過時變體。" -#: ../../extending/extending.rst:334 +#: ../../extending/extending.rst:365 msgid "" "When using only ``METH_VARARGS``, the function should expect the Python-" -"level parameters to be passed in as a tuple acceptable for parsing " -"via :c:func:`PyArg_ParseTuple`; more information on this function is " -"provided below." +"level parameters to be passed in as a tuple acceptable for parsing via :c:" +"func:`PyArg_ParseTuple`; more information on this function is provided below." msgstr "" "當只使用 ``METH_VARARGS`` 時,函式應預期 Python 層級的參數是以元組形式傳入且" "能夠接受以 :c:func:`PyArg_ParseTuple` 進行剖析;有關此函式的更多資訊將在下面" "提供。" -#: ../../extending/extending.rst:338 +#: ../../extending/extending.rst:369 msgid "" "The :c:macro:`METH_KEYWORDS` bit may be set in the third field if keyword " "arguments should be passed to the function. In this case, the C function " @@ -715,57 +733,46 @@ msgstr "" "是關鍵字的字典。可使用 :c:func:`PyArg_ParseTupleAndKeywords` 來剖析這種函式的" "引數。" -#: ../../extending/extending.rst:344 +#: ../../extending/extending.rst:375 msgid "" "The method table must be referenced in the module definition structure::" msgstr "方法表必須在模組定義結構中被參照: ::" -#: ../../extending/extending.rst:346 +#: ../../extending/extending.rst:377 msgid "" -"static struct PyModuleDef spammodule = {\n" -" PyModuleDef_HEAD_INIT,\n" -" \"spam\", /* name of module */\n" -" spam_doc, /* module documentation, may be NULL */\n" -" -1, /* size of per-interpreter state of the module,\n" -" or -1 if the module keeps state in global variables. */\n" -" SpamMethods\n" +"static struct PyModuleDef spam_module = {\n" +" ...\n" +" .m_methods = spam_methods,\n" +" ...\n" "};" msgstr "" -"static struct PyModuleDef spammodule = {\n" -" PyModuleDef_HEAD_INIT,\n" -" \"spam\", /* 模組名稱 */\n" -" spam_doc, /* 模組文件,可能為 NULL */\n" -" -1, /* 模組的個別直譯器狀態的大小,\n" -" 如果模組將狀態保存在全域變數中則為 -1 */\n" -" SpamMethods\n" -"};" -#: ../../extending/extending.rst:355 +#: ../../extending/extending.rst:383 msgid "" "This structure, in turn, must be passed to the interpreter in the module's " -"initialization function. The initialization function must be " -"named :c:func:`!PyInit_name`, where *name* is the name of the module, and " -"should be the only non-\\ ``static`` item defined in the module file::" +"initialization function. The initialization function must be named :c:func:" +"`!PyInit_name`, where *name* is the name of the module, and should be the " +"only non-\\ ``static`` item defined in the module file::" msgstr "" "反過來說,這個結構必須在模組的初始化函式中被傳給直譯器。初始化函式必須被命名" "為 :c:func:`!PyInit_name`,其中 *name* 是模組的名稱,且應該是模組檔案中唯一定" "義的非「靜態 (``static``)」項目: ::" -#: ../../extending/extending.rst:360 +#: ../../extending/extending.rst:388 msgid "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spammodule);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" msgstr "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" "{\n" -" return PyModule_Create(&spammodule);\n" +" return PyModuleDef_Init(&spam_module);\n" "}" -#: ../../extending/extending.rst:366 +#: ../../extending/extending.rst:394 msgid "" "Note that :c:macro:`PyMODINIT_FUNC` declares the function as ``PyObject *`` " "return type, declares any special linkage declarations required by the " @@ -774,41 +781,27 @@ msgstr "" "請注意,:c:macro:`PyMODINIT_FUNC` 宣告函式的回傳型別為 ``PyObject *``、宣告平" "台所需的任何特殊連結宣告、並針對 C++ 宣告函式為 ``extern \"C\"``。" -#: ../../extending/extending.rst:370 -msgid "" -"When the Python program imports module :mod:`!spam` for the first " -"time, :c:func:`!PyInit_spam` is called. (See below for comments about " -"embedding Python.) It calls :c:func:`PyModule_Create`, which returns a " -"module object, and inserts built-in function objects into the newly created " -"module based upon the table (an array of :c:type:`PyMethodDef` structures) " -"found in the module definition. :c:func:`PyModule_Create` returns a pointer " -"to the module object that it creates. It may abort with a fatal error for " -"certain errors, or return ``NULL`` if the module could not be initialized " -"satisfactorily. The init function must return the module object to its " -"caller, so that it then gets inserted into ``sys.modules``." -msgstr "" -"當 Python 程式第一次引入模組 :mod:`!spam` 時,:c:func:`!PyInit_spam` 會被呼" -"叫。(有關嵌入 Python 的註解請參見下文。)它會呼叫回傳一個模組物件" -"的 :c:func:`PyModule_Create`,並根據在模組定義中所找到的表(一" -"個 :c:type:`PyMethodDef` 結構的陣列)將內建的函式物件插入到新建立的模組" -"中。:c:func:`PyModule_Create` 會回傳一個指向它建立之模組物件的指標。對於某些" -"錯誤情況,它可能會以嚴重錯誤的形式來中止;如果模組無法令人滿意地被初始化,它" -"也會回傳 ``NULL``。初始化函式必須把模組物件回傳給它的呼叫者,這樣它才會被插入" -"到 ``sys.modules`` 中。" - -#: ../../extending/extending.rst:381 +#: ../../extending/extending.rst:398 +msgid "" +":c:func:`!PyInit_spam` is called when each interpreter imports its module :" +"mod:`!spam` for the first time. (See below for comments about embedding " +"Python.) A pointer to the module definition must be returned via :c:func:" +"`PyModuleDef_Init`, so that the import machinery can create the module and " +"store it in ``sys.modules``." +msgstr "" + +#: ../../extending/extending.rst:403 msgid "" "When embedding Python, the :c:func:`!PyInit_spam` function is not called " "automatically unless there's an entry in the :c:data:`PyImport_Inittab` " -"table. To add the module to the initialization table, " -"use :c:func:`PyImport_AppendInittab`, optionally followed by an import of " -"the module::" +"table. To add the module to the initialization table, use :c:func:" +"`PyImport_AppendInittab`, optionally followed by an import of the module::" msgstr "" "嵌入 Python 時,除非在 :c:data:`PyImport_Inittab` 表中有相關條目,否則不會自" -"動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使" -"用 :c:func:`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" +"動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:func:" +"`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" -#: ../../extending/extending.rst:386 +#: ../../extending/extending.rst:408 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -910,55 +903,42 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../extending/extending.rst:436 +#: ../../extending/extending.rst:458 msgid "" -"Removing entries from ``sys.modules`` or importing compiled modules into " +"If you declare a global variable or a local static one, the module may " +"experience unintended side-effects on re-initialisation, for example when " +"removing entries from ``sys.modules`` or importing compiled modules into " "multiple interpreters within a process (or following a :c:func:`fork` " -"without an intervening :c:func:`exec`) can create problems for some " -"extension modules. Extension module authors should exercise caution when " -"initializing internal data structures." +"without an intervening :c:func:`exec`). If module state is not yet fully :" +"ref:`isolated `, authors should consider marking " +"the module as having no support for subinterpreters (via :c:macro:" +"`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)." msgstr "" -"從 ``sys.modules`` 中移除項目,或在一個行程中將已編譯模組引入到多個直譯器中" -"(或在沒有 :c:func:`exec` 介入的情況下使用 :c:func:`fork`)可能會對某些擴充模" -"組造成問題。擴充模組作者在初始化內部資料結構時應特別小心。" -#: ../../extending/extending.rst:442 +#: ../../extending/extending.rst:467 msgid "" "A more substantial example module is included in the Python source " -"distribution as :file:`Modules/xxmodule.c`. This file may be used as a " +"distribution as :file:`Modules/xxlimited.c`. This file may be used as a " "template or simply read as an example." msgstr "" -"Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/" -"xxmodule.c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" - -#: ../../extending/extending.rst:448 -msgid "" -"Unlike our ``spam`` example, ``xxmodule`` uses *multi-phase initialization* " -"(new in Python 3.5), where a PyModuleDef structure is returned from " -"``PyInit_spam``, and creation of the module is left to the import machinery. " -"For details on multi-phase initialization, see :PEP:`489`." -msgstr "" -"不像我們的 ``spam`` 範例,``xxmodule`` 使用了\\ *多階段初始化 (multi-phase " -"initialization)*\\ (Python 3.5 新增),其中的 PyModuleDef 結構會從 " -"``PyInit_spam`` 回傳,而模組的建立則交由引入機制來完成。關於多階段初始化的詳" -"細資訊請參閱 :PEP:`489`。" +"Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/xxlimited." +"c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" -#: ../../extending/extending.rst:457 +#: ../../extending/extending.rst:475 msgid "Compilation and Linkage" msgstr "" -#: ../../extending/extending.rst:459 +#: ../../extending/extending.rst:477 msgid "" "There are two more things to do before you can use your new extension: " "compiling and linking it with the Python system. If you use dynamic " "loading, the details may depend on the style of dynamic loading your system " -"uses; see the chapters about building extension modules " -"(chapter :ref:`building`) and additional information that pertains only to " -"building on Windows (chapter :ref:`building-on-windows`) for more " -"information about this." +"uses; see the chapters about building extension modules (chapter :ref:" +"`building`) and additional information that pertains only to building on " +"Windows (chapter :ref:`building-on-windows`) for more information about this." msgstr "" -#: ../../extending/extending.rst:466 +#: ../../extending/extending.rst:484 msgid "" "If you can't use dynamic loading, or if you want to make your module a " "permanent part of the Python interpreter, you will have to change the " @@ -968,11 +948,11 @@ msgid "" "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" -#: ../../extending/extending.rst:473 +#: ../../extending/extending.rst:491 msgid "spam spammodule.o" msgstr "spam spammodule.o" -#: ../../extending/extending.rst:477 +#: ../../extending/extending.rst:495 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " "directory. You can also run :program:`make` in the :file:`Modules/` " @@ -981,21 +961,21 @@ msgid "" "the :file:`Setup` file.)" msgstr "" -#: ../../extending/extending.rst:483 +#: ../../extending/extending.rst:501 msgid "" "If your module requires additional libraries to link with, these can be " "listed on the line in the configuration file as well, for instance:" msgstr "" -#: ../../extending/extending.rst:486 +#: ../../extending/extending.rst:504 msgid "spam spammodule.o -lX11" msgstr "spam spammodule.o -lX11" -#: ../../extending/extending.rst:494 +#: ../../extending/extending.rst:512 msgid "Calling Python Functions from C" msgstr "" -#: ../../extending/extending.rst:496 +#: ../../extending/extending.rst:514 msgid "" "So far we have concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " @@ -1006,7 +986,7 @@ msgid "" "uses are also imaginable." msgstr "" -#: ../../extending/extending.rst:504 +#: ../../extending/extending.rst:522 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (I won't dwell on how to " @@ -1015,7 +995,7 @@ msgid "" "line option in :file:`Modules/main.c` from the Python source code.)" msgstr "" -#: ../../extending/extending.rst:510 +#: ../../extending/extending.rst:528 msgid "" "Calling a Python function is easy. First, the Python program must somehow " "pass you the Python function object. You should provide a function (or some " @@ -1025,7 +1005,7 @@ msgid "" "function might be part of a module definition::" msgstr "" -#: ../../extending/extending.rst:517 +#: ../../extending/extending.rst:535 msgid "" "static PyObject *my_callback = NULL;\n" "\n" @@ -1052,15 +1032,15 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:540 +#: ../../extending/extending.rst:558 msgid "" -"This function must be registered with the interpreter using " -"the :c:macro:`METH_VARARGS` flag; this is described in " -"section :ref:`methodtable`. The :c:func:`PyArg_ParseTuple` function and its " -"arguments are documented in section :ref:`parsetuple`." +"This function must be registered with the interpreter using the :c:macro:" +"`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" +"c:func:`PyArg_ParseTuple` function and its arguments are documented in " +"section :ref:`parsetuple`." msgstr "" -#: ../../extending/extending.rst:545 +#: ../../extending/extending.rst:563 msgid "" "The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement " "the reference count of an object and are safe in the presence of ``NULL`` " @@ -1068,20 +1048,19 @@ msgid "" "info on them in section :ref:`refcounts`." msgstr "" -#: ../../extending/extending.rst:552 +#: ../../extending/extending.rst:570 msgid "" -"Later, when it is time to call the function, you call the C " -"function :c:func:`PyObject_CallObject`. This function has two arguments, " -"both pointers to arbitrary Python objects: the Python function, and the " -"argument list. The argument list must always be a tuple object, whose " -"length is the number of arguments. To call the Python function with no " -"arguments, pass in ``NULL``, or an empty tuple; to call it with one " -"argument, pass a singleton tuple. :c:func:`Py_BuildValue` returns a tuple " -"when its format string consists of zero or more format codes between " -"parentheses. For example::" +"Later, when it is time to call the function, you call the C function :c:func:" +"`PyObject_CallObject`. This function has two arguments, both pointers to " +"arbitrary Python objects: the Python function, and the argument list. The " +"argument list must always be a tuple object, whose length is the number of " +"arguments. To call the Python function with no arguments, pass in ``NULL``, " +"or an empty tuple; to call it with one argument, pass a singleton tuple. :c:" +"func:`Py_BuildValue` returns a tuple when its format string consists of zero " +"or more format codes between parentheses. For example::" msgstr "" -#: ../../extending/extending.rst:561 +#: ../../extending/extending.rst:579 msgid "" "int arg;\n" "PyObject *arglist;\n" @@ -1095,17 +1074,16 @@ msgid "" "Py_DECREF(arglist);" msgstr "" -#: ../../extending/extending.rst:572 +#: ../../extending/extending.rst:590 msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " "\"reference-count-neutral\" with respect to its arguments. In the example a " -"new tuple was created to serve as the argument list, which " -"is :c:func:`Py_DECREF`\\ -ed immediately after " -"the :c:func:`PyObject_CallObject` call." +"new tuple was created to serve as the argument list, which is :c:func:" +"`Py_DECREF`\\ -ed immediately after the :c:func:`PyObject_CallObject` call." msgstr "" -#: ../../extending/extending.rst:579 +#: ../../extending/extending.rst:597 msgid "" "The return value of :c:func:`PyObject_CallObject` is \"new\": either it is a " "brand new object, or it is an existing object whose reference count has been " @@ -1114,7 +1092,7 @@ msgid "" "not interested in its value." msgstr "" -#: ../../extending/extending.rst:585 +#: ../../extending/extending.rst:603 msgid "" "Before you do this, however, it is important to check that the return value " "isn't ``NULL``. If it is, the Python function terminated by raising an " @@ -1125,7 +1103,7 @@ msgid "" "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" -#: ../../extending/extending.rst:593 +#: ../../extending/extending.rst:611 msgid "" "if (result == NULL)\n" " return NULL; /* Pass error back */\n" @@ -1133,7 +1111,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:598 +#: ../../extending/extending.rst:616 msgid "" "Depending on the desired interface to the Python callback function, you may " "also have to provide an argument list to :c:func:`PyObject_CallObject`. In " @@ -1145,7 +1123,7 @@ msgid "" "you want to pass an integral event code, you might use the following code::" msgstr "" -#: ../../extending/extending.rst:607 +#: ../../extending/extending.rst:625 msgid "" "PyObject *arglist;\n" "...\n" @@ -1158,7 +1136,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:617 +#: ../../extending/extending.rst:635 msgid "" "Note the placement of ``Py_DECREF(arglist)`` immediately after the call, " "before the error check! Also note that strictly speaking this code is not " @@ -1166,15 +1144,14 @@ msgid "" "checked." msgstr "" -#: ../../extending/extending.rst:621 +#: ../../extending/extending.rst:639 msgid "" -"You may also call a function with keyword arguments by " -"using :c:func:`PyObject_Call`, which supports arguments and keyword " -"arguments. As in the above example, we use :c:func:`Py_BuildValue` to " -"construct the dictionary. ::" +"You may also call a function with keyword arguments by using :c:func:" +"`PyObject_Call`, which supports arguments and keyword arguments. As in the " +"above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" msgstr "" -#: ../../extending/extending.rst:625 +#: ../../extending/extending.rst:643 msgid "" "PyObject *dict;\n" "...\n" @@ -1187,19 +1164,19 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:639 +#: ../../extending/extending.rst:657 msgid "Extracting Parameters in Extension Functions" msgstr "" -#: ../../extending/extending.rst:643 +#: ../../extending/extending.rst:661 msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:645 +#: ../../extending/extending.rst:663 msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" msgstr "" -#: ../../extending/extending.rst:647 +#: ../../extending/extending.rst:665 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " "from Python to a C function. The *format* argument must be a format string, " @@ -1208,7 +1185,7 @@ msgid "" "whose type is determined by the format string." msgstr "" -#: ../../extending/extending.rst:653 +#: ../../extending/extending.rst:671 msgid "" "Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments " "have the required types, it cannot check the validity of the addresses of C " @@ -1216,17 +1193,17 @@ msgid "" "probably crash or at least overwrite random bits in memory. So be careful!" msgstr "" -#: ../../extending/extending.rst:658 +#: ../../extending/extending.rst:676 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" msgstr "" -#: ../../extending/extending.rst:661 +#: ../../extending/extending.rst:679 msgid "Some example calls::" msgstr "一些呼叫範例: ::" -#: ../../extending/extending.rst:668 +#: ../../extending/extending.rst:686 msgid "" "int ok;\n" "int i, j;\n" @@ -1246,27 +1223,27 @@ msgstr "" "ok = PyArg_ParseTuple(args, \"\"); /* 沒有引數 */\n" " /* Python 呼叫:f() */" -#: ../../extending/extending.rst:679 +#: ../../extending/extending.rst:697 msgid "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" " /* Possible Python call: f('whoops!') */" msgstr "" -#: ../../extending/extending.rst:684 +#: ../../extending/extending.rst:702 msgid "" "ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " "*/\n" " /* Possible Python call: f(1, 2, 'three') */" msgstr "" -#: ../../extending/extending.rst:689 +#: ../../extending/extending.rst:707 msgid "" "ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" " /* A pair of ints and a string, whose size is also returned */\n" " /* Possible Python call: f((1, 2), 'three') */" msgstr "" -#: ../../extending/extending.rst:695 +#: ../../extending/extending.rst:713 msgid "" "{\n" " const char *file;\n" @@ -1281,7 +1258,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:709 +#: ../../extending/extending.rst:727 msgid "" "{\n" " int left, top, right, bottom, h, v;\n" @@ -1293,7 +1270,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:720 +#: ../../extending/extending.rst:738 msgid "" "{\n" " Py_complex c;\n" @@ -1303,16 +1280,16 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:731 +#: ../../extending/extending.rst:749 msgid "Keyword Parameters for Extension Functions" msgstr "" -#: ../../extending/extending.rst:735 +#: ../../extending/extending.rst:753 msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:737 +#: ../../extending/extending.rst:755 msgid "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" " const char *format, char * const " @@ -1322,32 +1299,32 @@ msgstr "" " const char *format, char * const " "*kwlist, ...);" -#: ../../extending/extending.rst:740 +#: ../../extending/extending.rst:758 msgid "" -"The *arg* and *format* parameters are identical to those of " -"the :c:func:`PyArg_ParseTuple` function. The *kwdict* parameter is the " -"dictionary of keywords received as the third parameter from the Python " -"runtime. The *kwlist* parameter is a ``NULL``-terminated list of strings " -"which identify the parameters; the names are matched with the type " -"information from *format* from left to right. On " -"success, :c:func:`PyArg_ParseTupleAndKeywords` returns true, otherwise it " -"returns false and raises an appropriate exception." +"The *arg* and *format* parameters are identical to those of the :c:func:" +"`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " +"keywords received as the third parameter from the Python runtime. The " +"*kwlist* parameter is a ``NULL``-terminated list of strings which identify " +"the parameters; the names are matched with the type information from " +"*format* from left to right. On success, :c:func:" +"`PyArg_ParseTupleAndKeywords` returns true, otherwise it returns false and " +"raises an appropriate exception." msgstr "" -#: ../../extending/extending.rst:750 +#: ../../extending/extending.rst:768 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " -"parameters passed in which are not present in the *kwlist* will " -"cause :exc:`TypeError` to be raised." +"parameters passed in which are not present in the *kwlist* will cause :exc:" +"`TypeError` to be raised." msgstr "" -#: ../../extending/extending.rst:756 +#: ../../extending/extending.rst:774 msgid "" "Here is an example module which uses keywords, based on an example by Geoff " "Philbrick (philbrick@hks.com)::" msgstr "" -#: ../../extending/extending.rst:759 +#: ../../extending/extending.rst:777 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1386,44 +1363,43 @@ msgid "" " {NULL, NULL, 0, NULL} /* sentinel */\n" "};\n" "\n" -"static struct PyModuleDef keywdargmodule = {\n" -" PyModuleDef_HEAD_INIT,\n" -" \"keywdarg\",\n" -" NULL,\n" -" -1,\n" -" keywdarg_methods\n" +"static struct PyModuleDef keywdarg_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"keywdarg\",\n" +" .m_size = 0,\n" +" .m_methods = keywdarg_methods,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_keywdarg(void)\n" "{\n" -" return PyModule_Create(&keywdargmodule);\n" +" return PyModuleDef_Init(&keywdarg_module);\n" "}" msgstr "" -#: ../../extending/extending.rst:811 +#: ../../extending/extending.rst:828 msgid "Building Arbitrary Values" msgstr "" -#: ../../extending/extending.rst:813 +#: ../../extending/extending.rst:830 msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "" -#: ../../extending/extending.rst:816 +#: ../../extending/extending.rst:833 msgid "PyObject *Py_BuildValue(const char *format, ...);" msgstr "PyObject *Py_BuildValue(const char *format, ...);" -#: ../../extending/extending.rst:818 +#: ../../extending/extending.rst:835 msgid "" -"It recognizes a set of format units similar to the ones recognized " -"by :c:func:`PyArg_ParseTuple`, but the arguments (which are input to the " -"function, not output) must not be pointers, just values. It returns a new " -"Python object, suitable for returning from a C function called from Python." +"It recognizes a set of format units similar to the ones recognized by :c:" +"func:`PyArg_ParseTuple`, but the arguments (which are input to the function, " +"not output) must not be pointers, just values. It returns a new Python " +"object, suitable for returning from a C function called from Python." msgstr "" -#: ../../extending/extending.rst:823 +#: ../../extending/extending.rst:840 msgid "" "One difference with :c:func:`PyArg_ParseTuple`: while the latter requires " "its first argument to be a tuple (since Python argument lists are always " @@ -1435,12 +1411,12 @@ msgid "" "parenthesize the format string." msgstr "" -#: ../../extending/extending.rst:831 +#: ../../extending/extending.rst:848 msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "" -#: ../../extending/extending.rst:833 +#: ../../extending/extending.rst:850 msgid "" "Py_BuildValue(\"\") None\n" "Py_BuildValue(\"i\", 123) 123\n" @@ -1478,11 +1454,11 @@ msgstr "" "Py_BuildValue(\"((ii)(ii)) (ii)\",\n" " 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" -#: ../../extending/extending.rst:857 +#: ../../extending/extending.rst:874 msgid "Reference Counts" msgstr "" -#: ../../extending/extending.rst:859 +#: ../../extending/extending.rst:876 msgid "" "In languages like C or C++, the programmer is responsible for dynamic " "allocation and deallocation of memory on the heap. In C, this is done using " @@ -1491,22 +1467,22 @@ msgid "" "restrict the following discussion to the C case." msgstr "" -#: ../../extending/extending.rst:865 +#: ../../extending/extending.rst:882 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " -"returned to the pool of available memory by exactly one call " -"to :c:func:`free`. It is important to call :c:func:`free` at the right " -"time. If a block's address is forgotten but :c:func:`free` is not called " -"for it, the memory it occupies cannot be reused until the program " -"terminates. This is called a :dfn:`memory leak`. On the other hand, if a " -"program calls :c:func:`free` for a block and then continues to use the " -"block, it creates a conflict with reuse of the block through " -"another :c:func:`malloc` call. This is called :dfn:`using freed memory`. It " -"has the same bad consequences as referencing uninitialized data --- core " -"dumps, wrong results, mysterious crashes." +"returned to the pool of available memory by exactly one call to :c:func:" +"`free`. It is important to call :c:func:`free` at the right time. If a " +"block's address is forgotten but :c:func:`free` is not called for it, the " +"memory it occupies cannot be reused until the program terminates. This is " +"called a :dfn:`memory leak`. On the other hand, if a program calls :c:func:" +"`free` for a block and then continues to use the block, it creates a " +"conflict with reuse of the block through another :c:func:`malloc` call. " +"This is called :dfn:`using freed memory`. It has the same bad consequences " +"as referencing uninitialized data --- core dumps, wrong results, mysterious " +"crashes." msgstr "" -#: ../../extending/extending.rst:876 +#: ../../extending/extending.rst:893 msgid "" "Common causes of memory leaks are unusual paths through the code. For " "instance, a function may allocate a block of memory, do some calculation, " @@ -1523,7 +1499,7 @@ msgid "" "of errors." msgstr "" -#: ../../extending/extending.rst:889 +#: ../../extending/extending.rst:906 msgid "" "Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it " "needs a strategy to avoid memory leaks as well as the use of freed memory. " @@ -1534,7 +1510,7 @@ msgid "" "reference to the object has been deleted and the object is freed." msgstr "" -#: ../../extending/extending.rst:897 +#: ../../extending/extending.rst:914 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1550,7 +1526,7 @@ msgid "" "with reference counts." msgstr "" -#: ../../extending/extending.rst:909 +#: ../../extending/extending.rst:926 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1564,30 +1540,30 @@ msgid "" "though there are no further references to the cycle itself." msgstr "" -#: ../../extending/extending.rst:920 +#: ../../extending/extending.rst:937 msgid "" "The cycle detector is able to detect garbage cycles and can reclaim them. " -"The :mod:`gc` module exposes a way to run the detector " -"(the :func:`~gc.collect` function), as well as configuration interfaces and " -"the ability to disable the detector at runtime." +"The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." +"collect` function), as well as configuration interfaces and the ability to " +"disable the detector at runtime." msgstr "" -#: ../../extending/extending.rst:929 +#: ../../extending/extending.rst:946 msgid "Reference Counting in Python" msgstr "" -#: ../../extending/extending.rst:931 +#: ../../extending/extending.rst:948 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " -"the incrementing and decrementing of the reference " -"count. :c:func:`Py_DECREF` also frees the object when the count reaches " -"zero. For flexibility, it doesn't call :c:func:`free` directly --- rather, " -"it makes a call through a function pointer in the object's :dfn:`type " -"object`. For this purpose (and others), every object also contains a " -"pointer to its type object." +"the incrementing and decrementing of the reference count. :c:func:" +"`Py_DECREF` also frees the object when the count reaches zero. For " +"flexibility, it doesn't call :c:func:`free` directly --- rather, it makes a " +"call through a function pointer in the object's :dfn:`type object`. For " +"this purpose (and others), every object also contains a pointer to its type " +"object." msgstr "" -#: ../../extending/extending.rst:938 +#: ../../extending/extending.rst:955 msgid "" "The big question now remains: when to use ``Py_INCREF(x)`` and " "``Py_DECREF(x)``? Let's first introduce some terms. Nobody \"owns\" an " @@ -1600,7 +1576,7 @@ msgid "" "reference creates a memory leak." msgstr "" -#: ../../extending/extending.rst:947 +#: ../../extending/extending.rst:964 msgid "" "It is also possible to :dfn:`borrow` [#]_ a reference to an object. The " "borrower of a reference should not call :c:func:`Py_DECREF`. The borrower " @@ -1609,7 +1585,7 @@ msgid "" "risks using freed memory and should be avoided completely [#]_." msgstr "" -#: ../../extending/extending.rst:953 +#: ../../extending/extending.rst:970 msgid "" "The advantage of borrowing over owning a reference is that you don't need to " "take care of disposing of the reference on all possible paths through the " @@ -1620,68 +1596,67 @@ msgid "" "borrowed has in fact disposed of it." msgstr "" -#: ../../extending/extending.rst:961 +#: ../../extending/extending.rst:978 msgid "" -"A borrowed reference can be changed into an owned reference by " -"calling :c:func:`Py_INCREF`. This does not affect the status of the owner " -"from which the reference was borrowed --- it creates a new owned reference, " -"and gives full owner responsibilities (the new owner must dispose of the " -"reference properly, as well as the previous owner)." +"A borrowed reference can be changed into an owned reference by calling :c:" +"func:`Py_INCREF`. This does not affect the status of the owner from which " +"the reference was borrowed --- it creates a new owned reference, and gives " +"full owner responsibilities (the new owner must dispose of the reference " +"properly, as well as the previous owner)." msgstr "" -#: ../../extending/extending.rst:971 +#: ../../extending/extending.rst:988 msgid "Ownership Rules" msgstr "" -#: ../../extending/extending.rst:973 +#: ../../extending/extending.rst:990 msgid "" "Whenever an object reference is passed into or out of a function, it is part " "of the function's interface specification whether ownership is transferred " "with the reference or not." msgstr "" -#: ../../extending/extending.rst:977 +#: ../../extending/extending.rst:994 msgid "" "Most functions that return a reference to an object pass on ownership with " "the reference. In particular, all functions whose function it is to create " "a new object, such as :c:func:`PyLong_FromLong` and :c:func:`Py_BuildValue`, " "pass ownership to the receiver. Even if the object is not actually new, you " -"still receive ownership of a new reference to that object. For " -"instance, :c:func:`PyLong_FromLong` maintains a cache of popular values and " -"can return a reference to a cached item." +"still receive ownership of a new reference to that object. For instance, :c:" +"func:`PyLong_FromLong` maintains a cache of popular values and can return a " +"reference to a cached item." msgstr "" -#: ../../extending/extending.rst:985 +#: ../../extending/extending.rst:1002 msgid "" "Many functions that extract objects from other objects also transfer " -"ownership with the reference, for " -"instance :c:func:`PyObject_GetAttrString`. The picture is less clear, here, " -"however, since a few common routines are " -"exceptions: :c:func:`PyTuple_GetItem`, :c:func:`PyList_GetItem`, :c:func:`PyDict_GetItem`, " -"and :c:func:`PyDict_GetItemString` all return references that you borrow " -"from the tuple, list or dictionary." +"ownership with the reference, for instance :c:func:" +"`PyObject_GetAttrString`. The picture is less clear, here, however, since a " +"few common routines are exceptions: :c:func:`PyTuple_GetItem`, :c:func:" +"`PyList_GetItem`, :c:func:`PyDict_GetItem`, and :c:func:" +"`PyDict_GetItemString` all return references that you borrow from the tuple, " +"list or dictionary." msgstr "" -#: ../../extending/extending.rst:992 +#: ../../extending/extending.rst:1009 msgid "" "The function :c:func:`PyImport_AddModule` also returns a borrowed reference, " "even though it may actually create the object it returns: this is possible " "because an owned reference to the object is stored in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:996 +#: ../../extending/extending.rst:1013 msgid "" "When you pass an object reference into another function, in general, the " "function borrows the reference from you --- if it needs to store it, it will " "use :c:func:`Py_INCREF` to become an independent owner. There are exactly " -"two important exceptions to this rule: :c:func:`PyTuple_SetItem` " -"and :c:func:`PyList_SetItem`. These functions take over ownership of the " -"item passed to them --- even if they fail! (Note " -"that :c:func:`PyDict_SetItem` and friends don't take over ownership --- they " -"are \"normal.\")" +"two important exceptions to this rule: :c:func:`PyTuple_SetItem` and :c:func:" +"`PyList_SetItem`. These functions take over ownership of the item passed to " +"them --- even if they fail! (Note that :c:func:`PyDict_SetItem` and friends " +"don't take over ownership --- they are \"normal.\")" msgstr "" -#: ../../extending/extending.rst:1004 +#: ../../extending/extending.rst:1021 msgid "" "When a C function is called from Python, it borrows references to its " "arguments from the caller. The caller owns a reference to the object, so " @@ -1690,18 +1665,18 @@ msgid "" "turned into an owned reference by calling :c:func:`Py_INCREF`." msgstr "" -#: ../../extending/extending.rst:1010 +#: ../../extending/extending.rst:1027 msgid "" "The object reference returned from a C function that is called from Python " "must be an owned reference --- ownership is transferred from the function to " "its caller." msgstr "" -#: ../../extending/extending.rst:1018 +#: ../../extending/extending.rst:1035 msgid "Thin Ice" msgstr "" -#: ../../extending/extending.rst:1020 +#: ../../extending/extending.rst:1037 msgid "" "There are a few situations where seemingly harmless use of a borrowed " "reference can lead to problems. These all have to do with implicit " @@ -1709,14 +1684,14 @@ msgid "" "dispose of it." msgstr "" -#: ../../extending/extending.rst:1024 +#: ../../extending/extending.rst:1041 msgid "" "The first and most important case to know about is using :c:func:`Py_DECREF` " "on an unrelated object while borrowing a reference to a list item. For " "instance::" msgstr "" -#: ../../extending/extending.rst:1027 +#: ../../extending/extending.rst:1044 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1736,14 +1711,14 @@ msgstr "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" -#: ../../extending/extending.rst:1036 +#: ../../extending/extending.rst:1053 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " "``list[1]`` with the value ``0``, and finally prints the borrowed reference. " "Looks harmless, right? But it's not!" msgstr "" -#: ../../extending/extending.rst:1040 +#: ../../extending/extending.rst:1057 msgid "" "Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns " "references to all its items, so when item 1 is replaced, it has to dispose " @@ -1753,7 +1728,7 @@ msgid "" "count of 1, disposing of it will call its :meth:`!__del__` method." msgstr "" -#: ../../extending/extending.rst:1047 +#: ../../extending/extending.rst:1064 msgid "" "Since it is written in Python, the :meth:`!__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -1764,13 +1739,13 @@ msgid "" "associated with it, thereby invalidating ``item``." msgstr "" -#: ../../extending/extending.rst:1055 +#: ../../extending/extending.rst:1072 msgid "" "The solution, once you know the source of the problem, is easy: temporarily " "increment the reference count. The correct version of the function reads::" msgstr "" -#: ../../extending/extending.rst:1058 +#: ../../extending/extending.rst:1075 msgid "" "void\n" "no_bug(PyObject *list)\n" @@ -1794,27 +1769,27 @@ msgstr "" " Py_DECREF(item);\n" "}" -#: ../../extending/extending.rst:1069 +#: ../../extending/extending.rst:1086 msgid "" "This is a true story. An older version of Python contained variants of this " "bug and someone spent a considerable amount of time in a C debugger to " "figure out why his :meth:`!__del__` methods would fail..." msgstr "" -#: ../../extending/extending.rst:1073 +#: ../../extending/extending.rst:1090 msgid "" "The second case of problems with a borrowed reference is a variant involving " "threads. Normally, multiple threads in the Python interpreter can't get in " -"each other's way, because there is a global lock protecting Python's entire " -"object space. However, it is possible to temporarily release this lock " -"using the macro :c:macro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it " -"using :c:macro:`Py_END_ALLOW_THREADS`. This is common around blocking I/O " -"calls, to let other threads use the processor while waiting for the I/O to " -"complete. Obviously, the following function has the same problem as the " -"previous one::" +"each other's way, because there is a :term:`global lock ` protecting Python's entire object space. However, it is possible to " +"temporarily release this lock using the macro :c:macro:" +"`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using :c:macro:" +"`Py_END_ALLOW_THREADS`. This is common around blocking I/O calls, to let " +"other threads use the processor while waiting for the I/O to complete. " +"Obviously, the following function has the same problem as the previous one::" msgstr "" -#: ../../extending/extending.rst:1082 +#: ../../extending/extending.rst:1100 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1827,11 +1802,11 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1096 +#: ../../extending/extending.rst:1114 msgid "NULL Pointers" msgstr "NULL 指標" -#: ../../extending/extending.rst:1098 +#: ../../extending/extending.rst:1116 msgid "" "In general, functions that take object references as arguments do not expect " "you to pass them ``NULL`` pointers, and will dump core (or cause later core " @@ -1843,21 +1818,21 @@ msgid "" "more slowly." msgstr "" -#: ../../extending/extending.rst:1106 +#: ../../extending/extending.rst:1124 msgid "" "It is better to test for ``NULL`` only at the \"source:\" when a pointer " "that may be ``NULL`` is received, for example, from :c:func:`malloc` or from " "a function that may raise an exception." msgstr "" -#: ../../extending/extending.rst:1110 +#: ../../extending/extending.rst:1128 msgid "" "The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for " -"``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` " -"and :c:func:`Py_XDECREF` do." +"``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` and :c:" +"func:`Py_XDECREF` do." msgstr "" -#: ../../extending/extending.rst:1114 +#: ../../extending/extending.rst:1132 msgid "" "The macros for checking for a particular object type (``Pytype_Check()``) " "don't check for ``NULL`` pointers --- again, there is much code that calls " @@ -1866,24 +1841,24 @@ msgid "" "variants with ``NULL`` checking." msgstr "" -#: ../../extending/extending.rst:1120 +#: ../../extending/extending.rst:1138 msgid "" "The C function calling mechanism guarantees that the argument list passed to " "C functions (``args`` in the examples) is never ``NULL`` --- in fact it " "guarantees that it is always a tuple [#]_." msgstr "" -#: ../../extending/extending.rst:1124 +#: ../../extending/extending.rst:1142 msgid "" "It is a severe error to ever let a ``NULL`` pointer \"escape\" to the Python " "user." msgstr "" -#: ../../extending/extending.rst:1135 +#: ../../extending/extending.rst:1153 msgid "Writing Extensions in C++" msgstr "" -#: ../../extending/extending.rst:1137 +#: ../../extending/extending.rst:1155 msgid "" "It is possible to write extension modules in C++. Some restrictions apply. " "If the main program (the Python interpreter) is compiled and linked by the C " @@ -1896,11 +1871,11 @@ msgid "" "(all recent C++ compilers define this symbol)." msgstr "" -#: ../../extending/extending.rst:1151 +#: ../../extending/extending.rst:1169 msgid "Providing a C API for an Extension Module" msgstr "" -#: ../../extending/extending.rst:1156 +#: ../../extending/extending.rst:1174 msgid "" "Many extension modules just provide new functions and types to be used from " "Python, but sometimes the code in an extension module can be useful for " @@ -1911,7 +1886,7 @@ msgid "" "functions for direct manipulation from other extension modules." msgstr "" -#: ../../extending/extending.rst:1164 +#: ../../extending/extending.rst:1182 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -1927,7 +1902,7 @@ msgid "" "call might not have been loaded yet!" msgstr "" -#: ../../extending/extending.rst:1176 +#: ../../extending/extending.rst:1194 msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " @@ -1937,7 +1912,7 @@ msgid "" "accessible from other extension modules must be exported in a different way." msgstr "" -#: ../../extending/extending.rst:1183 +#: ../../extending/extending.rst:1201 msgid "" "Python provides a special mechanism to pass C-level information (pointers) " "from one extension module to another one: Capsules. A Capsule is a Python " @@ -1949,7 +1924,7 @@ msgid "" "the Capsule." msgstr "" -#: ../../extending/extending.rst:1191 +#: ../../extending/extending.rst:1209 msgid "" "There are many ways in which Capsules can be used to export the C API of an " "extension module. Each function could get its own Capsule, or all C API " @@ -1959,7 +1934,7 @@ msgid "" "client modules." msgstr "" -#: ../../extending/extending.rst:1197 +#: ../../extending/extending.rst:1215 msgid "" "Whichever method you choose, it's important to name your Capsules properly. " "The function :c:func:`PyCapsule_New` takes a name parameter (:c:expr:`const " @@ -1969,17 +1944,17 @@ msgid "" "from another." msgstr "" -#: ../../extending/extending.rst:1204 +#: ../../extending/extending.rst:1222 msgid "" "In particular, Capsules used to expose C APIs should be given a name " "following this convention::" msgstr "" -#: ../../extending/extending.rst:1207 +#: ../../extending/extending.rst:1225 msgid "modulename.attributename" msgstr "modulename.attributename" -#: ../../extending/extending.rst:1209 +#: ../../extending/extending.rst:1227 msgid "" "The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " "C API provided via a Capsule, but only if the Capsule's name matches this " @@ -1987,7 +1962,7 @@ msgid "" "the Capsule they load contains the correct C API." msgstr "" -#: ../../extending/extending.rst:1214 +#: ../../extending/extending.rst:1232 msgid "" "The following example demonstrates an approach that puts most of the burden " "on the writer of the exporting module, which is appropriate for commonly " @@ -1998,7 +1973,7 @@ msgid "" "modules only have to call this macro before accessing the C API." msgstr "" -#: ../../extending/extending.rst:1222 +#: ../../extending/extending.rst:1240 msgid "" "The exporting module is a modification of the :mod:`!spam` module from " "section :ref:`extending-simpleexample`. The function :func:`!spam.system` " @@ -2009,13 +1984,13 @@ msgid "" "modules." msgstr "" -#: ../../extending/extending.rst:1229 +#: ../../extending/extending.rst:1247 msgid "" "The function :c:func:`!PySpam_System` is a plain C function, declared " "``static`` like everything else::" msgstr "" -#: ../../extending/extending.rst:1232 +#: ../../extending/extending.rst:1250 msgid "" "static int\n" "PySpam_System(const char *command)\n" @@ -2029,11 +2004,11 @@ msgstr "" " return system(command);\n" "}" -#: ../../extending/extending.rst:1238 +#: ../../extending/extending.rst:1256 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" msgstr "" -#: ../../extending/extending.rst:1240 +#: ../../extending/extending.rst:1258 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -2059,19 +2034,19 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:1252 +#: ../../extending/extending.rst:1270 msgid "In the beginning of the module, right after the line ::" msgstr "" -#: ../../extending/extending.rst:1254 +#: ../../extending/extending.rst:1272 msgid "#include " msgstr "#include " -#: ../../extending/extending.rst:1256 +#: ../../extending/extending.rst:1274 msgid "two more lines must be added::" msgstr "" -#: ../../extending/extending.rst:1258 +#: ../../extending/extending.rst:1276 msgid "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" @@ -2079,27 +2054,22 @@ msgstr "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" -#: ../../extending/extending.rst:1261 +#: ../../extending/extending.rst:1279 msgid "" "The ``#define`` is used to tell the header file that it is being included in " -"the exporting module, not a client module. Finally, the module's " -"initialization function must take care of initializing the C API pointer " -"array::" +"the exporting module, not a client module. Finally, the module's :c:data:" +"`mod_exec ` function must take care of initializing the C API " +"pointer array::" msgstr "" -#: ../../extending/extending.rst:1265 +#: ../../extending/extending.rst:1283 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" +"static int\n" +"spam_module_exec(PyObject *m)\n" "{\n" -" PyObject *m;\n" " static void *PySpam_API[PySpam_API_pointers];\n" " PyObject *c_api_object;\n" "\n" -" m = PyModule_Create(&spammodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" " /* Initialize the C API pointer array */\n" " PySpam_API[PySpam_System_NUM] = (void *)PySpam_System;\n" "\n" @@ -2108,27 +2078,26 @@ msgid "" "NULL);\n" "\n" " if (PyModule_Add(m, \"_C_API\", c_api_object) < 0) {\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" "}" msgstr "" -#: ../../extending/extending.rst:1290 +#: ../../extending/extending.rst:1302 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " "would disappear when :c:func:`!PyInit_spam` terminates!" msgstr "" -#: ../../extending/extending.rst:1293 +#: ../../extending/extending.rst:1305 msgid "" "The bulk of the work is in the header file :file:`spammodule.h`, which looks " "like this::" msgstr "" -#: ../../extending/extending.rst:1296 +#: ../../extending/extending.rst:1308 msgid "" "#ifndef Py_SPAMMODULE_H\n" "#define Py_SPAMMODULE_H\n" @@ -2180,38 +2149,34 @@ msgid "" "#endif /* !defined(Py_SPAMMODULE_H) */" msgstr "" -#: ../../extending/extending.rst:1344 +#: ../../extending/extending.rst:1356 msgid "" -"All that a client module must do in order to have access to the " -"function :c:func:`!PySpam_System` is to call the function (or rather " -"macro) :c:func:`!import_spam` in its initialization function::" +"All that a client module must do in order to have access to the function :c:" +"func:`!PySpam_System` is to call the function (or rather macro) :c:func:`!" +"import_spam` in its :c:data:`mod_exec ` function::" msgstr "" -#: ../../extending/extending.rst:1348 +#: ../../extending/extending.rst:1360 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_client(void)\n" +"static int\n" +"client_module_exec(PyObject *m)\n" "{\n" -" PyObject *m;\n" -"\n" -" m = PyModule_Create(&clientmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -" if (import_spam() < 0)\n" -" return NULL;\n" +" if (import_spam() < 0) {\n" +" return -1;\n" +" }\n" " /* additional initialization can happen here */\n" -" return m;\n" +" return 0;\n" "}" msgstr "" -#: ../../extending/extending.rst:1362 +#: ../../extending/extending.rst:1370 msgid "" "The main disadvantage of this approach is that the file :file:`spammodule.h` " "is rather complicated. However, the basic structure is the same for each " "function that is exported, so it has to be learned only once." msgstr "" -#: ../../extending/extending.rst:1366 +#: ../../extending/extending.rst:1374 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -2221,47 +2186,157 @@ msgid "" "in the Python source code distribution)." msgstr "" -#: ../../extending/extending.rst:1374 +#: ../../extending/extending.rst:1382 msgid "Footnotes" msgstr "註腳" -#: ../../extending/extending.rst:1375 +#: ../../extending/extending.rst:1383 msgid "" -"An interface for this function already exists in the standard " -"module :mod:`os` --- it was chosen as a simple and straightforward example." +"An interface for this function already exists in the standard module :mod:" +"`os` --- it was chosen as a simple and straightforward example." msgstr "" -#: ../../extending/extending.rst:1378 +#: ../../extending/extending.rst:1386 msgid "" "The metaphor of \"borrowing\" a reference is not completely correct: the " "owner still has a copy of the reference." msgstr "" -#: ../../extending/extending.rst:1381 +#: ../../extending/extending.rst:1389 msgid "" "Checking that the reference count is at least 1 **does not work** --- the " "reference count itself could be in freed memory and may thus be reused for " "another object!" msgstr "" -#: ../../extending/extending.rst:1385 +#: ../../extending/extending.rst:1393 msgid "" "These guarantees don't hold when you use the \"old\" style calling " "convention --- this is still found in much existing code." msgstr "" -#: ../../extending/extending.rst:550 +#: ../../extending/extending.rst:568 msgid "PyObject_CallObject (C function)" msgstr "PyObject_CallObject(C 函式)" -#: ../../extending/extending.rst:641 +#: ../../extending/extending.rst:659 msgid "PyArg_ParseTuple (C function)" msgstr "PyArg_ParseTuple(C 函式)" -#: ../../extending/extending.rst:733 +#: ../../extending/extending.rst:751 msgid "PyArg_ParseTupleAndKeywords (C function)" msgstr "PyArg_ParseTupleAndKeywords(C 函式)" -#: ../../extending/extending.rst:754 +#: ../../extending/extending.rst:772 msgid "Philbrick, Geoff" msgstr "Philbrick, Geoff" + +#~ msgid "" +#~ "and initialize it in your module's initialization function (:c:func:`!" +#~ "PyInit_spam`) with an exception object::" +#~ msgstr "" +#~ "並在你的模組初始化函式中使用一個例外物件來初始化它 (:c:func:`!" +#~ "PyInit_spam`): ::" + +#~ msgid "" +#~ "PyMODINIT_FUNC\n" +#~ "PyInit_spam(void)\n" +#~ "{\n" +#~ " PyObject *m;\n" +#~ "\n" +#~ " m = PyModule_Create(&spammodule);\n" +#~ " if (m == NULL)\n" +#~ " return NULL;\n" +#~ "\n" +#~ " SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" +#~ " if (PyModule_AddObjectRef(m, \"error\", SpamError) < 0) {\n" +#~ " Py_CLEAR(SpamError);\n" +#~ " Py_DECREF(m);\n" +#~ " return NULL;\n" +#~ " }\n" +#~ "\n" +#~ " return m;\n" +#~ "}" +#~ msgstr "" +#~ "PyMODINIT_FUNC\n" +#~ "PyInit_spam(void)\n" +#~ "{\n" +#~ " PyObject *m;\n" +#~ "\n" +#~ " m = PyModule_Create(&spammodule);\n" +#~ " if (m == NULL)\n" +#~ " return NULL;\n" +#~ "\n" +#~ " SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" +#~ " if (PyModule_AddObjectRef(m, \"error\", SpamError) < 0) {\n" +#~ " Py_CLEAR(SpamError);\n" +#~ " Py_DECREF(m);\n" +#~ " return NULL;\n" +#~ " }\n" +#~ "\n" +#~ " return m;\n" +#~ "}" + +#~ msgid "" +#~ "static struct PyModuleDef spammodule = {\n" +#~ " PyModuleDef_HEAD_INIT,\n" +#~ " \"spam\", /* name of module */\n" +#~ " spam_doc, /* module documentation, may be NULL */\n" +#~ " -1, /* size of per-interpreter state of the module,\n" +#~ " or -1 if the module keeps state in global variables. */\n" +#~ " SpamMethods\n" +#~ "};" +#~ msgstr "" +#~ "static struct PyModuleDef spammodule = {\n" +#~ " PyModuleDef_HEAD_INIT,\n" +#~ " \"spam\", /* 模組名稱 */\n" +#~ " spam_doc, /* 模組文件,可能為 NULL */\n" +#~ " -1, /* 模組的個別直譯器狀態的大小,\n" +#~ " 如果模組將狀態保存在全域變數中則為 -1 */\n" +#~ " SpamMethods\n" +#~ "};" + +#~ msgid "" +#~ "When the Python program imports module :mod:`!spam` for the first time, :" +#~ "c:func:`!PyInit_spam` is called. (See below for comments about embedding " +#~ "Python.) It calls :c:func:`PyModule_Create`, which returns a module " +#~ "object, and inserts built-in function objects into the newly created " +#~ "module based upon the table (an array of :c:type:`PyMethodDef` " +#~ "structures) found in the module definition. :c:func:`PyModule_Create` " +#~ "returns a pointer to the module object that it creates. It may abort " +#~ "with a fatal error for certain errors, or return ``NULL`` if the module " +#~ "could not be initialized satisfactorily. The init function must return " +#~ "the module object to its caller, so that it then gets inserted into ``sys." +#~ "modules``." +#~ msgstr "" +#~ "當 Python 程式第一次引入模組 :mod:`!spam` 時,:c:func:`!PyInit_spam` 會被" +#~ "呼叫。(有關嵌入 Python 的註解請參見下文。)它會呼叫回傳一個模組物件的 :c:" +#~ "func:`PyModule_Create`,並根據在模組定義中所找到的表(一個 :c:type:" +#~ "`PyMethodDef` 結構的陣列)將內建的函式物件插入到新建立的模組中。:c:func:" +#~ "`PyModule_Create` 會回傳一個指向它建立之模組物件的指標。對於某些錯誤情況," +#~ "它可能會以嚴重錯誤的形式來中止;如果模組無法令人滿意地被初始化,它也會回" +#~ "傳 ``NULL``。初始化函式必須把模組物件回傳給它的呼叫者,這樣它才會被插入到 " +#~ "``sys.modules`` 中。" + +#~ msgid "" +#~ "Removing entries from ``sys.modules`` or importing compiled modules into " +#~ "multiple interpreters within a process (or following a :c:func:`fork` " +#~ "without an intervening :c:func:`exec`) can create problems for some " +#~ "extension modules. Extension module authors should exercise caution when " +#~ "initializing internal data structures." +#~ msgstr "" +#~ "從 ``sys.modules`` 中移除項目,或在一個行程中將已編譯模組引入到多個直譯器" +#~ "中(或在沒有 :c:func:`exec` 介入的情況下使用 :c:func:`fork`)可能會對某些" +#~ "擴充模組造成問題。擴充模組作者在初始化內部資料結構時應特別小心。" + +#~ msgid "" +#~ "Unlike our ``spam`` example, ``xxmodule`` uses *multi-phase " +#~ "initialization* (new in Python 3.5), where a PyModuleDef structure is " +#~ "returned from ``PyInit_spam``, and creation of the module is left to the " +#~ "import machinery. For details on multi-phase initialization, see :PEP:" +#~ "`489`." +#~ msgstr "" +#~ "不像我們的 ``spam`` 範例,``xxmodule`` 使用了\\ *多階段初始化 (multi-" +#~ "phase initialization)*\\ (Python 3.5 新增),其中的 PyModuleDef 結構會從 " +#~ "``PyInit_spam`` 回傳,而模組的建立則交由引入機制來完成。關於多階段初始化的" +#~ "詳細資訊請參閱 :PEP:`489`。" diff --git a/extending/index.po b/extending/index.po index 2518825082..e8888e248b 100644 --- a/extending/index.po +++ b/extending/index.po @@ -8,7 +8,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: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2021-07-06 22:18+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -66,39 +66,19 @@ msgstr "推薦的第三方工具" #: ../../extending/index.rst:28 msgid "" "This guide only covers the basic tools for creating extensions provided as " -"part of this version of CPython. Third party tools like `Cython `_, `cffi `_, `SWIG `_ and `Numba `_ offer both simpler and " -"more sophisticated approaches to creating C and C++ extensions for Python." +"part of this version of CPython. Some :ref:`third party tools ` " +"offer both simpler and more sophisticated approaches to creating C and C++ " +"extensions for Python." msgstr "" -"這份指南僅涵蓋了此 CPython 版本所提供的、用以建立擴充的基本工具。第三方工具," -"例如 `Cython `_、`cffi `_、" -"`SWIG `_ 和 `Numba `_,提供" -"了更為簡單及更為複雜的多種方法,來為 Python 建立 C 和 C ++ 擴充。" +"這份指南僅涵蓋了此 CPython 版本所提供的、用以建立擴充的基本工具。有一些\\ " +":ref:`第三方工具 `,提供了更為簡單及更為複雜的多種方法,來為 Python 建立 " +"C 和 C++ 擴充。" -#: ../../extending/index.rst:37 -msgid "" -"`Python Packaging User Guide: Binary Extensions `_" -msgstr "" -"`Python 封裝使用者指南:二進制擴充 `_" - -#: ../../extending/index.rst:38 -msgid "" -"The Python Packaging User Guide not only covers several available tools that " -"simplify the creation of binary extensions, but also discusses the various " -"reasons why creating an extension module may be desirable in the first place." -msgstr "" -"Python 封裝使用者指南 (Python Packaging User Guide) 不僅涵蓋了數個可以用來簡" -"化二進制擴充建立過程的工具,也會討論為何建立一個擴充模組可能會是你的優先考" -"量。" - -#: ../../extending/index.rst:45 +#: ../../extending/index.rst:35 msgid "Creating extensions without third party tools" msgstr "不使用第三方工具建立擴充" -#: ../../extending/index.rst:47 +#: ../../extending/index.rst:37 msgid "" "This section of the guide covers creating C and C++ extensions without " "assistance from third party tools. It is intended primarily for creators of " @@ -108,11 +88,15 @@ msgstr "" "本指南中的這一節將說明,在沒有第三方工具的協助下,如何建立 C 和 C ++ 擴充。它" "主要是寫給使用那些工具的創作者們,而不是讓你建立自己的 C 擴充的推薦方法。" -#: ../../extending/index.rst:63 +#: ../../extending/index.rst:44 +msgid ":pep:`489` -- Multi-phase extension module initialization" +msgstr "" + +#: ../../extending/index.rst:57 msgid "Embedding the CPython runtime in a larger application" msgstr "在更大的應用程式中嵌入 CPython 運行環境 (runtime)" -#: ../../extending/index.rst:65 +#: ../../extending/index.rst:59 msgid "" "Sometimes, rather than creating an extension that runs inside the Python " "interpreter as the main application, it is desirable to instead embed the " @@ -122,3 +106,20 @@ msgstr "" "有時候,相較於建立一個擴充,使其在 Python 直譯器中可作為主應用程式運行,還不" "如將 CPython 運行環境嵌入至一個更大的應用程式中更可取。本節將涵蓋一些要成功完" "成此任務所涉及的細節。" + +#~ msgid "" +#~ "`Python Packaging User Guide: Binary Extensions `_" +#~ msgstr "" +#~ "`Python 封裝使用者指南:二進制擴充 `_" + +#~ msgid "" +#~ "The Python Packaging User Guide not only covers several available tools " +#~ "that simplify the creation of binary extensions, but also discusses the " +#~ "various reasons why creating an extension module may be desirable in the " +#~ "first place." +#~ msgstr "" +#~ "Python 封裝使用者指南 (Python Packaging User Guide) 不僅涵蓋了數個可以用來" +#~ "簡化二進制擴充建立過程的工具,也會討論為何建立一個擴充模組可能會是你的優先" +#~ "考量。" diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index 3481c835b2..525d9b3a7b 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-27 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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" @@ -33,14 +33,14 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:26 msgid "" -"The :term:`CPython` runtime sees all Python objects as variables of " -"type :c:expr:`PyObject*`, which serves as a \"base type\" for all Python " -"objects. The :c:type:`PyObject` structure itself only contains the " -"object's :term:`reference count` and a pointer to the object's \"type " -"object\". This is where the action is; the type object determines which (C) " -"functions get called by the interpreter when, for instance, an attribute " -"gets looked up on an object, a method called, or it is multiplied by another " -"object. These C functions are called \"type methods\"." +"The :term:`CPython` runtime sees all Python objects as variables of type :c:" +"expr:`PyObject*`, which serves as a \"base type\" for all Python objects. " +"The :c:type:`PyObject` structure itself only contains the object's :term:" +"`reference count` and a pointer to the object's \"type object\". This is " +"where the action is; the type object determines which (C) functions get " +"called by the interpreter when, for instance, an attribute gets looked up on " +"an object, a method called, or it is multiplied by another object. These C " +"functions are called \"type methods\"." msgstr "" #: ../../extending/newtypes_tutorial.rst:35 @@ -60,8 +60,8 @@ msgstr "" msgid "" "What we're showing here is the traditional way of defining *static* " "extension types. It should be adequate for most uses. The C API also " -"allows defining heap-allocated extension types using " -"the :c:func:`PyType_FromSpec` function, which isn't covered in this tutorial." +"allows defining heap-allocated extension types using the :c:func:" +"`PyType_FromSpec` function, which isn't covered in this tutorial." msgstr "" #: ../../extending/newtypes_tutorial.rst:48 @@ -84,31 +84,41 @@ msgid "" " .tp_new = PyType_GenericNew,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" // Just use this while using static types\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" @@ -133,15 +143,17 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:58 msgid "" -"How to initialize the :mod:`!custom` module: this is the ``PyInit_custom`` " -"function and the associated ``custommodule`` struct." +"How to define and execute the :mod:`!custom` module: this is the " +"``PyInit_custom`` function and the associated ``custom_module`` struct for " +"defining the module, and the ``custom_module_exec`` function to set up a " +"fresh module object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:61 +#: ../../extending/newtypes_tutorial.rst:63 msgid "The first bit is::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:63 +#: ../../extending/newtypes_tutorial.rst:65 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -151,7 +163,7 @@ msgstr "" " PyObject_HEAD\n" "} CustomObject;" -#: ../../extending/newtypes_tutorial.rst:67 +#: ../../extending/newtypes_tutorial.rst:69 msgid "" "This is what a Custom object will contain. ``PyObject_HEAD`` is mandatory " "at the start of each object struct and defines a field called ``ob_base`` of " @@ -162,20 +174,20 @@ msgid "" "builds `." msgstr "" -#: ../../extending/newtypes_tutorial.rst:76 +#: ../../extending/newtypes_tutorial.rst:78 msgid "" "There is no semicolon above after the :c:macro:`PyObject_HEAD` macro. Be " "wary of adding one by accident: some compilers will complain." msgstr "" -#: ../../extending/newtypes_tutorial.rst:79 +#: ../../extending/newtypes_tutorial.rst:81 msgid "" "Of course, objects generally store additional data besides the standard " "``PyObject_HEAD`` boilerplate; for example, here is the definition for " "standard Python floats::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:83 +#: ../../extending/newtypes_tutorial.rst:85 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -187,11 +199,11 @@ msgstr "" " double ob_fval;\n" "} PyFloatObject;" -#: ../../extending/newtypes_tutorial.rst:88 +#: ../../extending/newtypes_tutorial.rst:90 msgid "The second bit is the definition of the type object. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:90 +#: ../../extending/newtypes_tutorial.rst:92 msgid "" "static PyTypeObject CustomType = {\n" " .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -213,14 +225,14 @@ msgstr "" " .tp_new = PyType_GenericNew,\n" "};" -#: ../../extending/newtypes_tutorial.rst:101 +#: ../../extending/newtypes_tutorial.rst:103 msgid "" "We recommend using C99-style designated initializers as above, to avoid " "listing all the :c:type:`PyTypeObject` fields that you don't care about and " "also to avoid caring about the fields' declaration order." msgstr "" -#: ../../extending/newtypes_tutorial.rst:105 +#: ../../extending/newtypes_tutorial.rst:107 msgid "" "The actual definition of :c:type:`PyTypeObject` in :file:`object.h` has many " "more :ref:`fields ` than the definition above. The remaining " @@ -228,31 +240,31 @@ msgid "" "to not specify them explicitly unless you need them." msgstr "" -#: ../../extending/newtypes_tutorial.rst:110 +#: ../../extending/newtypes_tutorial.rst:112 msgid "We're going to pick it apart, one field at a time::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:112 +#: ../../extending/newtypes_tutorial.rst:114 msgid ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" msgstr ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" -#: ../../extending/newtypes_tutorial.rst:114 +#: ../../extending/newtypes_tutorial.rst:116 msgid "" "This line is mandatory boilerplate to initialize the ``ob_base`` field " "mentioned above. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:117 +#: ../../extending/newtypes_tutorial.rst:119 msgid ".tp_name = \"custom.Custom\"," msgstr ".tp_name = \"custom.Custom\"," -#: ../../extending/newtypes_tutorial.rst:119 +#: ../../extending/newtypes_tutorial.rst:121 msgid "" "The name of our type. This will appear in the default textual " "representation of our objects and in some error messages, for example:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:122 +#: ../../extending/newtypes_tutorial.rst:124 msgid "" ">>> \"\" + custom.Custom()\n" "Traceback (most recent call last):\n" @@ -260,17 +272,16 @@ msgid "" "TypeError: can only concatenate str (not \"custom.Custom\") to str" msgstr "" -#: ../../extending/newtypes_tutorial.rst:129 +#: ../../extending/newtypes_tutorial.rst:131 msgid "" "Note that the name is a dotted name that includes both the module name and " "the name of the type within the module. The module in this case is :mod:`!" -"custom` and the type is :class:`!Custom`, so we set the type name " -"to :class:`!custom.Custom`. Using the real dotted import path is important " -"to make your type compatible with the :mod:`pydoc` and :mod:`pickle` " -"modules. ::" +"custom` and the type is :class:`!Custom`, so we set the type name to :class:" +"`!custom.Custom`. Using the real dotted import path is important to make " +"your type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:135 +#: ../../extending/newtypes_tutorial.rst:137 msgid "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," @@ -278,14 +289,14 @@ msgstr "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," -#: ../../extending/newtypes_tutorial.rst:138 +#: ../../extending/newtypes_tutorial.rst:140 msgid "" -"This is so that Python knows how much memory to allocate when creating " -"new :class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is " -"only used for variable-sized objects and should otherwise be zero." +"This is so that Python knows how much memory to allocate when creating new :" +"class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is only " +"used for variable-sized objects and should otherwise be zero." msgstr "" -#: ../../extending/newtypes_tutorial.rst:144 +#: ../../extending/newtypes_tutorial.rst:146 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 " @@ -299,83 +310,83 @@ msgid "" "your base type, and therefore increasing its size." msgstr "" -#: ../../extending/newtypes_tutorial.rst:154 +#: ../../extending/newtypes_tutorial.rst:156 msgid "We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:156 +#: ../../extending/newtypes_tutorial.rst:158 msgid ".tp_flags = Py_TPFLAGS_DEFAULT," msgstr ".tp_flags = Py_TPFLAGS_DEFAULT," -#: ../../extending/newtypes_tutorial.rst:158 +#: ../../extending/newtypes_tutorial.rst:160 msgid "" "All types should include this constant in their flags. It enables all of " "the members defined until at least Python 3.3. If you need further members, " "you will need to OR the corresponding flags." msgstr "" -#: ../../extending/newtypes_tutorial.rst:162 +#: ../../extending/newtypes_tutorial.rst:164 msgid "" "We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:164 +#: ../../extending/newtypes_tutorial.rst:166 msgid ".tp_doc = PyDoc_STR(\"Custom objects\")," msgstr ".tp_doc = PyDoc_STR(\"Custom objects\")," -#: ../../extending/newtypes_tutorial.rst:166 +#: ../../extending/newtypes_tutorial.rst:168 msgid "" -"To enable object creation, we have to provide " -"a :c:member:`~PyTypeObject.tp_new` handler. This is the equivalent of the " -"Python method :meth:`~object.__new__`, but has to be specified explicitly. " -"In this case, we can just use the default implementation provided by the API " -"function :c:func:`PyType_GenericNew`. ::" +"To enable object creation, we have to provide a :c:member:`~PyTypeObject." +"tp_new` handler. This is the equivalent of the Python method :meth:`~object." +"__new__`, but has to be specified explicitly. In this case, we can just use " +"the default implementation provided by the API function :c:func:" +"`PyType_GenericNew`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:171 +#: ../../extending/newtypes_tutorial.rst:173 msgid ".tp_new = PyType_GenericNew," msgstr ".tp_new = PyType_GenericNew," -#: ../../extending/newtypes_tutorial.rst:173 +#: ../../extending/newtypes_tutorial.rst:175 msgid "" -"Everything else in the file should be familiar, except for some code " -"in :c:func:`!PyInit_custom`::" +"Everything else in the file should be familiar, except for some code in :c:" +"func:`!custom_module_exec`::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:176 +#: ../../extending/newtypes_tutorial.rst:178 msgid "" -"if (PyType_Ready(&CustomType) < 0)\n" -" return;" +"if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +"}" msgstr "" -"if (PyType_Ready(&CustomType) < 0)\n" -" return;" +"if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:179 +#: ../../extending/newtypes_tutorial.rst:182 msgid "" "This initializes the :class:`!Custom` type, filling in a number of members " "to the appropriate default values, including :c:member:`~PyObject.ob_type` " "that we initially set to ``NULL``. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:183 +#: ../../extending/newtypes_tutorial.rst:186 msgid "" "if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" return -1;\n" "}" msgstr "" "if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" return -1;\n" "}" -#: ../../extending/newtypes_tutorial.rst:188 +#: ../../extending/newtypes_tutorial.rst:190 msgid "" -"This adds the type to the module dictionary. This allows us to " -"create :class:`!Custom` instances by calling the :class:`!Custom` class:" +"This adds the type to the module dictionary. This allows us to create :" +"class:`!Custom` instances by calling the :class:`!Custom` class:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:191 +#: ../../extending/newtypes_tutorial.rst:193 msgid "" ">>> import custom\n" ">>> mycustom = custom.Custom()" @@ -383,13 +394,13 @@ msgstr "" ">>> import custom\n" ">>> mycustom = custom.Custom()" -#: ../../extending/newtypes_tutorial.rst:196 +#: ../../extending/newtypes_tutorial.rst:198 msgid "" "That's it! All that remains is to build it; put the above code in a file " "called :file:`custom.c`," msgstr "" -#: ../../extending/newtypes_tutorial.rst:199 +#: ../../extending/newtypes_tutorial.rst:201 msgid "" "[build-system]\n" "requires = [\"setuptools\"]\n" @@ -407,11 +418,11 @@ msgstr "" "name = \"custom\"\n" "version = \"1\"\n" -#: ../../extending/newtypes_tutorial.rst:201 +#: ../../extending/newtypes_tutorial.rst:203 msgid "in a file called :file:`pyproject.toml`, and" msgstr "" -#: ../../extending/newtypes_tutorial.rst:203 +#: ../../extending/newtypes_tutorial.rst:205 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" @@ -419,44 +430,44 @@ msgstr "" "from setuptools import Extension, setup\n" "setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" -#: ../../extending/newtypes_tutorial.rst:208 +#: ../../extending/newtypes_tutorial.rst:210 msgid "in a file called :file:`setup.py`; then typing" msgstr "" -#: ../../extending/newtypes_tutorial.rst:210 -#: ../../extending/newtypes_tutorial.rst:525 +#: ../../extending/newtypes_tutorial.rst:212 +#: ../../extending/newtypes_tutorial.rst:527 msgid "$ python -m pip install ." msgstr "$ python -m pip install ." -#: ../../extending/newtypes_tutorial.rst:214 +#: ../../extending/newtypes_tutorial.rst:216 msgid "" "in a shell should produce a file :file:`custom.so` in a subdirectory and " "install it; now fire up Python --- you should be able to ``import custom`` " "and play around with ``Custom`` objects." msgstr "" -#: ../../extending/newtypes_tutorial.rst:218 +#: ../../extending/newtypes_tutorial.rst:220 msgid "That wasn't so hard, was it?" msgstr "" -#: ../../extending/newtypes_tutorial.rst:220 +#: ../../extending/newtypes_tutorial.rst:222 msgid "" "Of course, the current Custom type is pretty uninteresting. It has no data " "and doesn't do anything. It can't even be subclassed." msgstr "" -#: ../../extending/newtypes_tutorial.rst:225 +#: ../../extending/newtypes_tutorial.rst:227 msgid "Adding data and methods to the Basic example" msgstr "" -#: ../../extending/newtypes_tutorial.rst:227 +#: ../../extending/newtypes_tutorial.rst:229 msgid "" "Let's extend the basic example to add some data and methods. Let's also " "make the type usable as a base class. We'll create a new module, :mod:`!" "custom2` that adds these capabilities:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:231 +#: ../../extending/newtypes_tutorial.rst:233 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -563,39 +574,48 @@ msgid "" " .tp_methods = Custom_methods,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" -" .m_base =PyModuleDef_HEAD_INIT,\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom2\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom2(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:234 +#: ../../extending/newtypes_tutorial.rst:236 msgid "This version of the module has a number of changes." msgstr "" -#: ../../extending/newtypes_tutorial.rst:236 +#: ../../extending/newtypes_tutorial.rst:238 msgid "" "The :class:`!Custom` type now has three data attributes in its C struct, " "*first*, *last*, and *number*. The *first* and *last* variables are Python " @@ -603,11 +623,11 @@ msgid "" "integer." msgstr "" -#: ../../extending/newtypes_tutorial.rst:240 +#: ../../extending/newtypes_tutorial.rst:242 msgid "The object structure is updated accordingly::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:242 +#: ../../extending/newtypes_tutorial.rst:244 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -623,13 +643,13 @@ msgstr "" " int number;\n" "} CustomObject;" -#: ../../extending/newtypes_tutorial.rst:249 +#: ../../extending/newtypes_tutorial.rst:251 msgid "" "Because we now have data to manage, we have to be more careful about object " "allocation and deallocation. At a minimum, we need a deallocation method::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:252 +#: ../../extending/newtypes_tutorial.rst:254 msgid "" "static void\n" "Custom_dealloc(CustomObject *self)\n" @@ -647,26 +667,26 @@ msgstr "" " Py_TYPE(self)->tp_free((PyObject *) self);\n" "}" -#: ../../extending/newtypes_tutorial.rst:260 +#: ../../extending/newtypes_tutorial.rst:262 msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:262 +#: ../../extending/newtypes_tutorial.rst:264 msgid ".tp_dealloc = (destructor) Custom_dealloc," msgstr ".tp_dealloc = (destructor) Custom_dealloc," -#: ../../extending/newtypes_tutorial.rst:264 +#: ../../extending/newtypes_tutorial.rst:266 msgid "" -"This method first clears the reference counts of the two Python " -"attributes. :c:func:`Py_XDECREF` correctly handles the case where its " -"argument is ``NULL`` (which might happen here if ``tp_new`` failed midway). " -"It then calls the :c:member:`~PyTypeObject.tp_free` member of the object's " -"type (computed by ``Py_TYPE(self)``) to free the object's memory. Note that " -"the object's type might not be :class:`!CustomType`, because the object may " -"be an instance of a subclass." +"This method first clears the reference counts of the two Python attributes. :" +"c:func:`Py_XDECREF` correctly handles the case where its argument is " +"``NULL`` (which might happen here if ``tp_new`` failed midway). It then " +"calls the :c:member:`~PyTypeObject.tp_free` member of the object's type " +"(computed by ``Py_TYPE(self)``) to free the object's memory. Note that the " +"object's type might not be :class:`!CustomType`, because the object may be " +"an instance of a subclass." msgstr "" -#: ../../extending/newtypes_tutorial.rst:273 +#: ../../extending/newtypes_tutorial.rst:275 msgid "" "The explicit cast to ``destructor`` above is needed because we defined " "``Custom_dealloc`` to take a ``CustomObject *`` argument, but the " @@ -675,13 +695,13 @@ msgid "" "oriented polymorphism, in C!" msgstr "" -#: ../../extending/newtypes_tutorial.rst:279 +#: ../../extending/newtypes_tutorial.rst:281 msgid "" "We want to make sure that the first and last names are initialized to empty " "strings, so we provide a ``tp_new`` implementation::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:282 +#: ../../extending/newtypes_tutorial.rst:284 msgid "" "static PyObject *\n" "Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" @@ -725,60 +745,58 @@ msgstr "" " return (PyObject *) self;\n" "}" -#: ../../extending/newtypes_tutorial.rst:303 +#: ../../extending/newtypes_tutorial.rst:305 msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:305 +#: ../../extending/newtypes_tutorial.rst:307 msgid ".tp_new = Custom_new," msgstr ".tp_new = Custom_new," -#: ../../extending/newtypes_tutorial.rst:307 +#: ../../extending/newtypes_tutorial.rst:309 msgid "" "The ``tp_new`` handler is responsible for creating (as opposed to " -"initializing) objects of the type. It is exposed in Python as " -"the :meth:`~object.__new__` method. It is not required to define a " -"``tp_new`` member, and indeed many extension types will simply " -"reuse :c:func:`PyType_GenericNew` as done in the first version of " -"the :class:`!Custom` type above. In this case, we use the ``tp_new`` " -"handler to initialize the ``first`` and ``last`` attributes to non-``NULL`` " -"default values." +"initializing) objects of the type. It is exposed in Python as the :meth:" +"`~object.__new__` method. It is not required to define a ``tp_new`` member, " +"and indeed many extension types will simply reuse :c:func:" +"`PyType_GenericNew` as done in the first version of the :class:`!Custom` " +"type above. In this case, we use the ``tp_new`` handler to initialize the " +"``first`` and ``last`` attributes to non-``NULL`` default values." msgstr "" -#: ../../extending/newtypes_tutorial.rst:315 +#: ../../extending/newtypes_tutorial.rst:317 msgid "" "``tp_new`` is passed the type being instantiated (not necessarily " "``CustomType``, if a subclass is instantiated) and any arguments passed when " "the type was called, and is expected to return the instance created. " "``tp_new`` handlers always accept positional and keyword arguments, but they " -"often ignore the arguments, leaving the argument handling to initializer " -"(a.k.a. ``tp_init`` in C or ``__init__`` in Python) methods." +"often ignore the arguments, leaving the argument handling to initializer (a." +"k.a. ``tp_init`` in C or ``__init__`` in Python) methods." msgstr "" -#: ../../extending/newtypes_tutorial.rst:323 +#: ../../extending/newtypes_tutorial.rst:325 msgid "" "``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do " "it itself." msgstr "" -#: ../../extending/newtypes_tutorial.rst:326 +#: ../../extending/newtypes_tutorial.rst:328 msgid "" "The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` " "slot to allocate memory::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:329 +#: ../../extending/newtypes_tutorial.rst:331 msgid "self = (CustomObject *) type->tp_alloc(type, 0);" msgstr "self = (CustomObject *) type->tp_alloc(type, 0);" -#: ../../extending/newtypes_tutorial.rst:331 +#: ../../extending/newtypes_tutorial.rst:333 msgid "" -"Since memory allocation may fail, we must check " -"the :c:member:`~PyTypeObject.tp_alloc` result against ``NULL`` before " -"proceeding." +"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject." +"tp_alloc` result against ``NULL`` before proceeding." msgstr "" -#: ../../extending/newtypes_tutorial.rst:335 +#: ../../extending/newtypes_tutorial.rst:337 msgid "" "We didn't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. " "Rather :c:func:`PyType_Ready` fills it for us by inheriting it from our base " @@ -786,27 +804,26 @@ msgid "" "allocation strategy." msgstr "" -#: ../../extending/newtypes_tutorial.rst:341 +#: ../../extending/newtypes_tutorial.rst:343 msgid "" "If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one " -"that calls a base type's :c:member:`~PyTypeObject.tp_new` " -"or :meth:`~object.__new__`), you must *not* try to determine what method to " -"call using method resolution order at runtime. Always statically determine " -"what type you are going to call, and call " -"its :c:member:`~PyTypeObject.tp_new` directly, or via ``type->tp_base-" -">tp_new``. If you do not do this, Python subclasses of your type that also " -"inherit from other Python-defined classes may not work correctly. " -"(Specifically, you may not be able to create instances of such subclasses " -"without getting a :exc:`TypeError`.)" +"that calls a base type's :c:member:`~PyTypeObject.tp_new` or :meth:`~object." +"__new__`), you must *not* try to determine what method to call using method " +"resolution order at runtime. Always statically determine what type you are " +"going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or " +"via ``type->tp_base->tp_new``. If you do not do this, Python subclasses of " +"your type that also inherit from other Python-defined classes may not work " +"correctly. (Specifically, you may not be able to create instances of such " +"subclasses without getting a :exc:`TypeError`.)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:351 +#: ../../extending/newtypes_tutorial.rst:353 msgid "" "We also define an initialization function which accepts arguments to provide " "initial values for our instance::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:354 +#: ../../extending/newtypes_tutorial.rst:356 msgid "" "static int\n" "Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" @@ -860,23 +877,23 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:380 +#: ../../extending/newtypes_tutorial.rst:382 msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:382 +#: ../../extending/newtypes_tutorial.rst:384 msgid ".tp_init = (initproc) Custom_init," msgstr ".tp_init = (initproc) Custom_init," -#: ../../extending/newtypes_tutorial.rst:384 +#: ../../extending/newtypes_tutorial.rst:386 msgid "" -"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as " -"the :meth:`~object.__init__` method. It is used to initialize an object " -"after it's created. Initializers always accept positional and keyword " -"arguments, and they should return either ``0`` on success or ``-1`` on error." +"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:" +"`~object.__init__` method. It is used to initialize an object after it's " +"created. Initializers always accept positional and keyword arguments, and " +"they should return either ``0`` on success or ``-1`` on error." msgstr "" -#: ../../extending/newtypes_tutorial.rst:389 +#: ../../extending/newtypes_tutorial.rst:391 msgid "" "Unlike the ``tp_new`` handler, there is no guarantee that ``tp_init`` is " "called at all (for example, the :mod:`pickle` module by default doesn't " @@ -887,7 +904,7 @@ msgid "" "``first`` member like this::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:397 +#: ../../extending/newtypes_tutorial.rst:399 msgid "" "if (first) {\n" " Py_XDECREF(self->first);\n" @@ -901,7 +918,7 @@ msgstr "" " self->first = first;\n" "}" -#: ../../extending/newtypes_tutorial.rst:403 +#: ../../extending/newtypes_tutorial.rst:405 msgid "" "But this would be risky. Our type doesn't restrict the type of the " "``first`` member, so it could be any kind of object. It could have a " @@ -911,37 +928,37 @@ msgid "" "accesses and modifies our object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:410 +#: ../../extending/newtypes_tutorial.rst:412 msgid "" "To be paranoid and protect ourselves against this possibility, we almost " "always reassign members before decrementing their reference counts. When " "don't we have to do this?" msgstr "" -#: ../../extending/newtypes_tutorial.rst:414 +#: ../../extending/newtypes_tutorial.rst:416 msgid "when we absolutely know that the reference count is greater than 1;" msgstr "" -#: ../../extending/newtypes_tutorial.rst:416 +#: ../../extending/newtypes_tutorial.rst:418 msgid "" -"when we know that deallocation of the object [#]_ will neither release " -"the :term:`GIL` nor cause any calls back into our type's code;" +"when we know that deallocation of the object [#]_ will neither release the :" +"term:`GIL` nor cause any calls back into our type's code;" msgstr "" -#: ../../extending/newtypes_tutorial.rst:419 +#: ../../extending/newtypes_tutorial.rst:421 msgid "" -"when decrementing a reference count in " -"a :c:member:`~PyTypeObject.tp_dealloc` handler on a type which doesn't " -"support cyclic garbage collection [#]_." +"when decrementing a reference count in a :c:member:`~PyTypeObject." +"tp_dealloc` handler on a type which doesn't support cyclic garbage " +"collection [#]_." msgstr "" -#: ../../extending/newtypes_tutorial.rst:422 +#: ../../extending/newtypes_tutorial.rst:424 msgid "" "We want to expose our instance variables as attributes. There are a number " "of ways to do that. The simplest way is to define member definitions::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:425 +#: ../../extending/newtypes_tutorial.rst:427 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" @@ -954,23 +971,23 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:435 +#: ../../extending/newtypes_tutorial.rst:437 msgid "" "and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:437 +#: ../../extending/newtypes_tutorial.rst:439 msgid ".tp_members = Custom_members," msgstr ".tp_members = Custom_members," -#: ../../extending/newtypes_tutorial.rst:439 +#: ../../extending/newtypes_tutorial.rst:441 msgid "" "Each member definition has a member name, type, offset, access flags and " "documentation string. See the :ref:`Generic-Attribute-Management` section " "below for details." msgstr "" -#: ../../extending/newtypes_tutorial.rst:443 +#: ../../extending/newtypes_tutorial.rst:445 msgid "" "A disadvantage of this approach is that it doesn't provide a way to restrict " "the types of objects that can be assigned to the Python attributes. We " @@ -981,13 +998,13 @@ msgid "" "deleted." msgstr "" -#: ../../extending/newtypes_tutorial.rst:450 +#: ../../extending/newtypes_tutorial.rst:452 msgid "" "We define a single method, :meth:`!Custom.name`, that outputs the objects " "name as the concatenation of the first and last names. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:453 +#: ../../extending/newtypes_tutorial.rst:455 msgid "" "static PyObject *\n" "Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" @@ -1017,17 +1034,17 @@ msgstr "" " return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" "}" -#: ../../extending/newtypes_tutorial.rst:467 +#: ../../extending/newtypes_tutorial.rst:469 msgid "" -"The method is implemented as a C function that takes a :class:`!Custom` " -"(or :class:`!Custom` subclass) instance as the first argument. Methods " -"always take an instance as the first argument. Methods often take positional " -"and keyword arguments as well, but in this case we don't take any and don't " -"need to accept a positional argument tuple or keyword argument dictionary. " -"This method is equivalent to the Python method:" +"The method is implemented as a C function that takes a :class:`!Custom` (or :" +"class:`!Custom` subclass) instance as the first argument. Methods always " +"take an instance as the first argument. Methods often take positional and " +"keyword arguments as well, but in this case we don't take any and don't need " +"to accept a positional argument tuple or keyword argument dictionary. This " +"method is equivalent to the Python method:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:474 +#: ../../extending/newtypes_tutorial.rst:476 msgid "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" @@ -1035,22 +1052,22 @@ msgstr "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" -#: ../../extending/newtypes_tutorial.rst:479 +#: ../../extending/newtypes_tutorial.rst:481 msgid "" -"Note that we have to check for the possibility that our :attr:`!first` " -"and :attr:`!last` members are ``NULL``. This is because they can be " -"deleted, in which case they are set to ``NULL``. It would be better to " -"prevent deletion of these attributes and to restrict the attribute values to " -"be strings. We'll see how to do that in the next section." +"Note that we have to check for the possibility that our :attr:`!first` and :" +"attr:`!last` members are ``NULL``. This is because they can be deleted, in " +"which case they are set to ``NULL``. It would be better to prevent deletion " +"of these attributes and to restrict the attribute values to be strings. " +"We'll see how to do that in the next section." msgstr "" -#: ../../extending/newtypes_tutorial.rst:485 +#: ../../extending/newtypes_tutorial.rst:487 msgid "" "Now that we've defined the method, we need to create an array of method " "definitions::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:488 +#: ../../extending/newtypes_tutorial.rst:490 msgid "" "static PyMethodDef Custom_methods[] = {\n" " {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" @@ -1060,21 +1077,21 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:495 +#: ../../extending/newtypes_tutorial.rst:497 msgid "" "(note that we used the :c:macro:`METH_NOARGS` flag to indicate that the " "method is expecting no arguments other than *self*)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:498 +#: ../../extending/newtypes_tutorial.rst:500 msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:500 +#: ../../extending/newtypes_tutorial.rst:502 msgid ".tp_methods = Custom_methods," msgstr ".tp_methods = Custom_methods," -#: ../../extending/newtypes_tutorial.rst:502 +#: ../../extending/newtypes_tutorial.rst:504 msgid "" "Finally, we'll make our type usable as a base class for subclassing. We've " "written our methods carefully so far so that they don't make any assumptions " @@ -1082,22 +1099,22 @@ msgid "" "to add the :c:macro:`Py_TPFLAGS_BASETYPE` to our class flag definition::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:507 +#: ../../extending/newtypes_tutorial.rst:509 msgid ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," msgstr ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," -#: ../../extending/newtypes_tutorial.rst:509 +#: ../../extending/newtypes_tutorial.rst:511 msgid "" "We rename :c:func:`!PyInit_custom` to :c:func:`!PyInit_custom2`, update the " "module name in the :c:type:`PyModuleDef` struct, and update the full class " "name in the :c:type:`PyTypeObject` struct." msgstr "" -#: ../../extending/newtypes_tutorial.rst:513 +#: ../../extending/newtypes_tutorial.rst:515 msgid "Finally, we update our :file:`setup.py` file to include the new module," msgstr "" -#: ../../extending/newtypes_tutorial.rst:515 +#: ../../extending/newtypes_tutorial.rst:517 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[\n" @@ -1111,24 +1128,24 @@ msgstr "" " Extension(\"custom2\", [\"custom2.c\"]),\n" "])" -#: ../../extending/newtypes_tutorial.rst:523 +#: ../../extending/newtypes_tutorial.rst:525 msgid "and then we re-install so that we can ``import custom2``:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:530 +#: ../../extending/newtypes_tutorial.rst:532 msgid "Providing finer control over data attributes" msgstr "" -#: ../../extending/newtypes_tutorial.rst:532 +#: ../../extending/newtypes_tutorial.rst:534 msgid "" "In this section, we'll provide finer control over how the :attr:`!first` " "and :attr:`!last` attributes are set in the :class:`!Custom` example. In the " -"previous version of our module, the instance variables :attr:`!first` " -"and :attr:`!last` could be set to non-string values or even deleted. We want " -"to make sure that these attributes always contain strings." +"previous version of our module, the instance variables :attr:`!first` and :" +"attr:`!last` could be set to non-string values or even deleted. We want to " +"make sure that these attributes always contain strings." msgstr "" -#: ../../extending/newtypes_tutorial.rst:538 +#: ../../extending/newtypes_tutorial.rst:540 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1278,42 +1295,51 @@ msgid "" " .tp_getset = Custom_getsetters,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom3\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom3(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:541 +#: ../../extending/newtypes_tutorial.rst:543 msgid "" "To provide greater control, over the :attr:`!first` and :attr:`!last` " "attributes, we'll use custom getter and setter functions. Here are the " "functions for getting and setting the :attr:`!first` attribute::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:545 +#: ../../extending/newtypes_tutorial.rst:547 msgid "" "static PyObject *\n" "Custom_getfirst(CustomObject *self, void *closure)\n" @@ -1344,7 +1370,7 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes_tutorial.rst:572 +#: ../../extending/newtypes_tutorial.rst:574 msgid "" "The getter function is passed a :class:`!Custom` object and a \"closure\", " "which is a void pointer. In this case, the closure is ignored. (The " @@ -1354,7 +1380,7 @@ msgid "" "data in the closure.)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:578 +#: ../../extending/newtypes_tutorial.rst:580 msgid "" "The setter function is passed the :class:`!Custom` object, the new value, " "and the closure. The new value may be ``NULL``, in which case the attribute " @@ -1362,11 +1388,11 @@ msgid "" "deleted or if its new value is not a string." msgstr "" -#: ../../extending/newtypes_tutorial.rst:583 +#: ../../extending/newtypes_tutorial.rst:585 msgid "We create an array of :c:type:`PyGetSetDef` structures::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:585 +#: ../../extending/newtypes_tutorial.rst:587 msgid "" "static PyGetSetDef Custom_getsetters[] = {\n" " {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" @@ -1377,26 +1403,26 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:593 +#: ../../extending/newtypes_tutorial.rst:595 msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:595 +#: ../../extending/newtypes_tutorial.rst:597 msgid ".tp_getset = Custom_getsetters," msgstr ".tp_getset = Custom_getsetters," -#: ../../extending/newtypes_tutorial.rst:597 +#: ../../extending/newtypes_tutorial.rst:599 msgid "" "The last item in a :c:type:`PyGetSetDef` structure is the \"closure\" " "mentioned above. In this case, we aren't using a closure, so we just pass " "``NULL``." msgstr "" -#: ../../extending/newtypes_tutorial.rst:600 +#: ../../extending/newtypes_tutorial.rst:602 msgid "We also remove the member definitions for these attributes::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:602 +#: ../../extending/newtypes_tutorial.rst:604 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" @@ -1405,13 +1431,13 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:608 +#: ../../extending/newtypes_tutorial.rst:610 msgid "" "We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " "allow strings [#]_ to be passed::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:611 +#: ../../extending/newtypes_tutorial.rst:613 msgid "" "static int\n" "Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" @@ -1440,7 +1466,7 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes_tutorial.rst:637 +#: ../../extending/newtypes_tutorial.rst:639 msgid "" "With these changes, we can assure that the ``first`` and ``last`` members " "are never ``NULL`` so we can remove checks for ``NULL`` values in almost all " @@ -1450,25 +1476,25 @@ msgid "" "possibility that the initialization of these members failed in ``tp_new``." msgstr "" -#: ../../extending/newtypes_tutorial.rst:644 +#: ../../extending/newtypes_tutorial.rst:646 msgid "" "We also rename the module initialization function and module name in the " "initialization function, as we did before, and we add an extra definition to " "the :file:`setup.py` file." msgstr "" -#: ../../extending/newtypes_tutorial.rst:650 +#: ../../extending/newtypes_tutorial.rst:652 msgid "Supporting cyclic garbage collection" msgstr "" -#: ../../extending/newtypes_tutorial.rst:652 +#: ../../extending/newtypes_tutorial.rst:654 msgid "" "Python has a :term:`cyclic garbage collector (GC) ` that " "can identify unneeded objects even when their reference counts are not zero. " "This can happen when objects are involved in cycles. For example, consider:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:656 +#: ../../extending/newtypes_tutorial.rst:658 msgid "" ">>> l = []\n" ">>> l.append(l)\n" @@ -1478,7 +1504,7 @@ msgstr "" ">>> l.append(l)\n" ">>> del l" -#: ../../extending/newtypes_tutorial.rst:662 +#: ../../extending/newtypes_tutorial.rst:664 msgid "" "In this example, we create a list that contains itself. When we delete it, " "it still has a reference from itself. Its reference count doesn't drop to " @@ -1486,17 +1512,16 @@ msgid "" "out that the list is garbage and free it." msgstr "" -#: ../../extending/newtypes_tutorial.rst:667 +#: ../../extending/newtypes_tutorial.rst:669 msgid "" "In the second version of the :class:`!Custom` example, we allowed any kind " "of object to be stored in the :attr:`!first` or :attr:`!last` attributes " -"[#]_. Besides, in the second and third versions, we allowed " -"subclassing :class:`!Custom`, and subclasses may add arbitrary attributes. " -"For any of those two reasons, :class:`!Custom` objects can participate in " -"cycles:" +"[#]_. Besides, in the second and third versions, we allowed subclassing :" +"class:`!Custom`, and subclasses may add arbitrary attributes. For any of " +"those two reasons, :class:`!Custom` objects can participate in cycles:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:673 +#: ../../extending/newtypes_tutorial.rst:675 msgid "" ">>> import custom3\n" ">>> class Derived(custom3.Custom): pass\n" @@ -1510,7 +1535,7 @@ msgstr "" ">>> n = Derived()\n" ">>> n.some_attribute = n" -#: ../../extending/newtypes_tutorial.rst:681 +#: ../../extending/newtypes_tutorial.rst:683 msgid "" "To allow a :class:`!Custom` instance participating in a reference cycle to " "be properly detected and collected by the cyclic GC, our :class:`!Custom` " @@ -1518,7 +1543,7 @@ msgid "" "these slots:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:685 +#: ../../extending/newtypes_tutorial.rst:687 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1687,41 +1712,50 @@ msgid "" " .tp_getset = Custom_getsetters,\n" "};\n" "\n" -"static PyModuleDef custommodule = {\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom4\",\n" " .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" "};\n" "\n" "PyMODINIT_FUNC\n" "PyInit_custom4(void)\n" "{\n" -" PyObject *m;\n" -" if (PyType_Ready(&CustomType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&custommodule);\n" -" if (m == NULL)\n" -" return NULL;\n" -"\n" -" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " -"{\n" -" Py_DECREF(m);\n" -" return NULL;\n" -" }\n" -"\n" -" return m;\n" +" return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:688 +#: ../../extending/newtypes_tutorial.rst:690 msgid "" "First, the traversal method lets the cyclic GC know about subobjects that " "could participate in cycles::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:691 +#: ../../extending/newtypes_tutorial.rst:693 msgid "" "static int\n" "Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" @@ -1757,23 +1791,23 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:708 +#: ../../extending/newtypes_tutorial.rst:710 msgid "" -"For each subobject that can participate in cycles, we need to call " -"the :c:func:`!visit` function, which is passed to the traversal method. " -"The :c:func:`!visit` function takes as arguments the subobject and the extra " -"argument *arg* passed to the traversal method. It returns an integer value " -"that must be returned if it is non-zero." +"For each subobject that can participate in cycles, we need to call the :c:" +"func:`!visit` function, which is passed to the traversal method. The :c:func:" +"`!visit` function takes as arguments the subobject and the extra argument " +"*arg* passed to the traversal method. It returns an integer value that must " +"be returned if it is non-zero." msgstr "" -#: ../../extending/newtypes_tutorial.rst:714 +#: ../../extending/newtypes_tutorial.rst:716 msgid "" "Python provides a :c:func:`Py_VISIT` macro that automates calling visit " "functions. With :c:func:`Py_VISIT`, we can minimize the amount of " "boilerplate in ``Custom_traverse``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:718 +#: ../../extending/newtypes_tutorial.rst:720 msgid "" "static int\n" "Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" @@ -1791,19 +1825,19 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:727 +#: ../../extending/newtypes_tutorial.rst:729 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` implementation must name its " "arguments exactly *visit* and *arg* in order to use :c:func:`Py_VISIT`." msgstr "" -#: ../../extending/newtypes_tutorial.rst:730 +#: ../../extending/newtypes_tutorial.rst:732 msgid "" "Second, we need to provide a method for clearing any subobjects that can " "participate in cycles::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:733 +#: ../../extending/newtypes_tutorial.rst:735 msgid "" "static int\n" "Custom_clear(CustomObject *self)\n" @@ -1821,7 +1855,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:741 +#: ../../extending/newtypes_tutorial.rst:743 msgid "" "Notice the use of the :c:func:`Py_CLEAR` macro. It is the recommended and " "safe way to clear data attributes of arbitrary types while decrementing " @@ -1831,11 +1865,11 @@ msgid "" "again (*especially* if there is a reference cycle)." msgstr "" -#: ../../extending/newtypes_tutorial.rst:749 +#: ../../extending/newtypes_tutorial.rst:751 msgid "You could emulate :c:func:`Py_CLEAR` by writing::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:751 +#: ../../extending/newtypes_tutorial.rst:753 msgid "" "PyObject *tmp;\n" "tmp = self->first;\n" @@ -1847,24 +1881,24 @@ msgstr "" "self->first = NULL;\n" "Py_XDECREF(tmp);" -#: ../../extending/newtypes_tutorial.rst:756 +#: ../../extending/newtypes_tutorial.rst:758 msgid "" -"Nevertheless, it is much easier and less error-prone to always " -"use :c:func:`Py_CLEAR` when deleting an attribute. Don't try to micro-" -"optimize at the expense of robustness!" +"Nevertheless, it is much easier and less error-prone to always use :c:func:" +"`Py_CLEAR` when deleting an attribute. Don't try to micro-optimize at the " +"expense of robustness!" msgstr "" -#: ../../extending/newtypes_tutorial.rst:760 +#: ../../extending/newtypes_tutorial.rst:762 msgid "" "The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " "attributes. It means the circular GC can be triggered inside the function. " "Since the GC assumes reference count is not zero, we need to untrack the " "object from the GC by calling :c:func:`PyObject_GC_UnTrack` before clearing " -"members. Here is our reimplemented deallocator " -"using :c:func:`PyObject_GC_UnTrack` and ``Custom_clear``::" +"members. Here is our reimplemented deallocator using :c:func:" +"`PyObject_GC_UnTrack` and ``Custom_clear``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:767 +#: ../../extending/newtypes_tutorial.rst:769 msgid "" "static void\n" "Custom_dealloc(CustomObject *self)\n" @@ -1882,31 +1916,30 @@ msgstr "" " Py_TYPE(self)->tp_free((PyObject *) self);\n" "}" -#: ../../extending/newtypes_tutorial.rst:775 +#: ../../extending/newtypes_tutorial.rst:777 msgid "" "Finally, we add the :c:macro:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:777 +#: ../../extending/newtypes_tutorial.rst:779 msgid "" ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," msgstr "" ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," -#: ../../extending/newtypes_tutorial.rst:779 +#: ../../extending/newtypes_tutorial.rst:781 msgid "" -"That's pretty much it. If we had written " -"custom :c:member:`~PyTypeObject.tp_alloc` " -"or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify them for " -"cyclic garbage collection. Most extensions will use the versions " +"That's pretty much it. If we had written custom :c:member:`~PyTypeObject." +"tp_alloc` or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify " +"them for cyclic garbage collection. Most extensions will use the versions " "automatically provided." msgstr "" -#: ../../extending/newtypes_tutorial.rst:785 +#: ../../extending/newtypes_tutorial.rst:787 msgid "Subclassing other types" msgstr "" -#: ../../extending/newtypes_tutorial.rst:787 +#: ../../extending/newtypes_tutorial.rst:789 msgid "" "It is possible to create new extension types that are derived from existing " "types. It is easiest to inherit from the built in types, since an extension " @@ -1914,7 +1947,7 @@ msgid "" "share these :c:type:`PyTypeObject` structures between extension modules." msgstr "" -#: ../../extending/newtypes_tutorial.rst:792 +#: ../../extending/newtypes_tutorial.rst:794 msgid "" "In this example we will create a :class:`!SubList` type that inherits from " "the built-in :class:`list` type. The new type will be completely compatible " @@ -1922,7 +1955,7 @@ msgid "" "that increases an internal counter:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:797 +#: ../../extending/newtypes_tutorial.rst:799 msgid "" ">>> import sublist\n" ">>> s = sublist.SubList(range(3))\n" @@ -1944,7 +1977,7 @@ msgstr "" ">>> print(s.increment())\n" "2" -#: ../../extending/newtypes_tutorial.rst:809 +#: ../../extending/newtypes_tutorial.rst:811 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1977,7 +2010,7 @@ msgid "" "}\n" "\n" "static PyTypeObject SubListType = {\n" -" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" " .tp_name = \"sublist.SubList\",\n" " .tp_doc = PyDoc_STR(\"SubList objects\"),\n" " .tp_basicsize = sizeof(SubListObject),\n" @@ -1987,43 +2020,52 @@ msgid "" " .tp_methods = SubList_methods,\n" "};\n" "\n" -"static PyModuleDef sublistmodule = {\n" -" PyModuleDef_HEAD_INIT,\n" -" .m_name = \"sublist\",\n" -" .m_doc = \"Example module that creates an extension type.\",\n" -" .m_size = -1,\n" -"};\n" -"\n" -"PyMODINIT_FUNC\n" -"PyInit_sublist(void)\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" "{\n" -" PyObject *m;\n" " SubListType.tp_base = &PyList_Type;\n" -" if (PyType_Ready(&SubListType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&sublistmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" "\n" " if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " "0) {\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot sublist_module_slots[] = {\n" +" {Py_mod_exec, sublist_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef sublist_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"sublist\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = 0,\n" +" .m_slots = sublist_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_sublist(void)\n" +"{\n" +" return PyModuleDef_Init(&sublist_module);\n" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:812 +#: ../../extending/newtypes_tutorial.rst:814 msgid "" "As you can see, the source code closely resembles the :class:`!Custom` " "examples in previous sections. We will break down the main differences " "between them. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:815 +#: ../../extending/newtypes_tutorial.rst:817 msgid "" "typedef struct {\n" " PyListObject list;\n" @@ -2035,21 +2077,21 @@ msgstr "" " int state;\n" "} SubListObject;" -#: ../../extending/newtypes_tutorial.rst:820 +#: ../../extending/newtypes_tutorial.rst:822 msgid "" "The primary difference for derived type objects is that the base type's " "object structure must be the first value. The base type will already " "include the :c:func:`PyObject_HEAD` at the beginning of its structure." msgstr "" -#: ../../extending/newtypes_tutorial.rst:824 +#: ../../extending/newtypes_tutorial.rst:826 msgid "" "When a Python object is a :class:`!SubList` instance, its ``PyObject *`` " "pointer can be safely cast to both ``PyListObject *`` and ``SubListObject " "*``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:827 +#: ../../extending/newtypes_tutorial.rst:829 msgid "" "static int\n" "SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)\n" @@ -2069,107 +2111,95 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:836 +#: ../../extending/newtypes_tutorial.rst:838 msgid "" "We see above how to call through to the :meth:`~object.__init__` method of " "the base type." msgstr "" -#: ../../extending/newtypes_tutorial.rst:839 +#: ../../extending/newtypes_tutorial.rst:841 msgid "" -"This pattern is important when writing a type with " -"custom :c:member:`~PyTypeObject.tp_new` " -"and :c:member:`~PyTypeObject.tp_dealloc` members. " +"This pattern is important when writing a type with custom :c:member:" +"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " "The :c:member:`~PyTypeObject.tp_new` handler should not actually create the " "memory for the object with its :c:member:`~PyTypeObject.tp_alloc`, but let " "the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." msgstr "" -#: ../../extending/newtypes_tutorial.rst:845 +#: ../../extending/newtypes_tutorial.rst:847 msgid "" -"The :c:type:`PyTypeObject` struct supports " -"a :c:member:`~PyTypeObject.tp_base` specifying the type's concrete base " -"class. Due to cross-platform compiler issues, you can't fill that field " -"directly with a reference to :c:type:`PyList_Type`; it should be done later " -"in the module initialization function::" +"The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." +"tp_base` specifying the type's concrete base class. Due to cross-platform " +"compiler issues, you can't fill that field directly with a reference to :c:" +"type:`PyList_Type`; it should be done in the :c:data:`Py_mod_exec` function::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:851 +#: ../../extending/newtypes_tutorial.rst:853 msgid "" -"PyMODINIT_FUNC\n" -"PyInit_sublist(void)\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" "{\n" -" PyObject* m;\n" " SubListType.tp_base = &PyList_Type;\n" -" if (PyType_Ready(&SubListType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&sublistmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" "\n" " if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " "0) {\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" "}" msgstr "" -"PyMODINIT_FUNC\n" -"PyInit_sublist(void)\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" "{\n" -" PyObject* m;\n" " SubListType.tp_base = &PyList_Type;\n" -" if (PyType_Ready(&SubListType) < 0)\n" -" return NULL;\n" -"\n" -" m = PyModule_Create(&sublistmodule);\n" -" if (m == NULL)\n" -" return NULL;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" "\n" " if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " "0) {\n" -" Py_DECREF(m);\n" -" return NULL;\n" +" return -1;\n" " }\n" "\n" -" return m;\n" +" return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:871 +#: ../../extending/newtypes_tutorial.rst:868 msgid "" -"Before calling :c:func:`PyType_Ready`, the type structure must have " -"the :c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving " -"an existing type, it is not necessary to fill out " -"the :c:member:`~PyTypeObject.tp_alloc` slot with :c:func:`PyType_GenericNew` " -"-- the allocation function from the base type will be inherited." +"Before calling :c:func:`PyType_Ready`, the type structure must have the :c:" +"member:`~PyTypeObject.tp_base` slot filled in. When we are deriving an " +"existing type, it is not necessary to fill out the :c:member:`~PyTypeObject." +"tp_alloc` slot with :c:func:`PyType_GenericNew` -- the allocation function " +"from the base type will be inherited." msgstr "" -#: ../../extending/newtypes_tutorial.rst:877 +#: ../../extending/newtypes_tutorial.rst:874 msgid "" "After that, calling :c:func:`PyType_Ready` and adding the type object to the " "module is the same as with the basic :class:`!Custom` examples." msgstr "" -#: ../../extending/newtypes_tutorial.rst:882 +#: ../../extending/newtypes_tutorial.rst:879 msgid "Footnotes" msgstr "註腳" -#: ../../extending/newtypes_tutorial.rst:883 +#: ../../extending/newtypes_tutorial.rst:880 msgid "" "This is true when we know that the object is a basic type, like a string or " "a float." msgstr "" -#: ../../extending/newtypes_tutorial.rst:886 +#: ../../extending/newtypes_tutorial.rst:883 msgid "" "We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " "this example, because our type doesn't support garbage collection." msgstr "" -#: ../../extending/newtypes_tutorial.rst:889 +#: ../../extending/newtypes_tutorial.rst:886 msgid "" "We now know that the first and last members are strings, so perhaps we could " "be less careful about decrementing their reference counts, however, we " @@ -2179,7 +2209,7 @@ msgid "" "objects." msgstr "" -#: ../../extending/newtypes_tutorial.rst:895 +#: ../../extending/newtypes_tutorial.rst:892 msgid "" "Also, even with our attributes restricted to strings instances, the user " "could pass arbitrary :class:`str` subclasses and therefore still create " diff --git a/faq/extending.po b/faq/extending.po index 9e82c59186..897980a1cd 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-24 07:20+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -34,11 +34,11 @@ msgstr "我可以在 C 中建立自己的函式嗎?" #: ../../faq/extending.rst:18 msgid "" "Yes, you can create built-in modules containing functions, variables, " -"exceptions and even new types in C. This is explained in the " -"document :ref:`extending-index`." +"exceptions and even new types in C. This is explained in the document :ref:" +"`extending-index`." msgstr "" -"是的,你可以在 C 中建立包含函式、變數、例外甚至新型別的內建模" -"組,:ref:`extending-index` 文件中有相關說明。" +"是的,你可以在 C 中建立包含函式、變數、例外甚至新型別的內建模組,:ref:" +"`extending-index` 文件中有相關說明。" #: ../../faq/extending.rst:22 msgid "Most intermediate or advanced Python books will also cover this topic." @@ -49,16 +49,15 @@ msgid "Can I create my own functions in C++?" 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 直譯器呼叫的函式之前。" -"具有構造函式的全局或靜態 C++ 物件可能不是一個好主意。" +"是的,可使用 C++ 中的 C 相容性功能。將 ``extern \"C\" { ... }`` 放在 Python 引入" +"檔案周圍,並將 ``extern \"C\"`` 放在每個將由 Python 直譯器呼叫的函式之前。" +"但具有構造函式的全域或靜態 C++ 物件可能不是一個好主意。" #: ../../faq/extending.rst:37 msgid "Writing C is hard; are there any alternatives?" @@ -67,114 +66,84 @@ msgstr "寫 C 很難;還有其他選擇嗎?" #: ../../faq/extending.rst:39 msgid "" "There are a number of alternatives to writing your own C extensions, " -"depending on what you're trying to do." -msgstr "要編寫你自己的 C 擴充有許多替代方法,取決於你要執行的具體操作為何。" - -#: ../../faq/extending.rst:44 -#, fuzzy -msgid "" -"`Cython `_ and its relative `Pyrex `_ are compilers that " -"accept a slightly modified form of Python and generate the corresponding C " -"code. Cython and Pyrex make it possible to write an extension without " -"having to learn Python's C API." +"depending on what you're trying to do. :ref:`Recommended third party tools " +"` offer both simpler and more sophisticated approaches to " +"creating C and C++ extensions for Python." msgstr "" -"`Cython `_ 及其相關的 `Pyrex `_ 是接受稍微修改 Python " -"形式並生成相應的 C 程式碼。 Cython 和 Pyrex 使編寫擴充程式成為可能,而無需學" -"習 Python 的 C API。" -#: ../../faq/extending.rst:50 -#, fuzzy -msgid "" -"If you need to interface to some C or C++ library for which no Python " -"extension currently exists, you can try wrapping the library's data types " -"and functions with a tool such as `SWIG `_. `SIP " -"`__, `CXX `_ `Boost `_, or `Weave " -"`_ are also alternatives for wrapping C++ " -"libraries." -msgstr "" -"如果你需要連接到目前不存在 Python 擴充的某些 C 或 C++ 函式庫,你可以嘗試使用 " -"`SWIG `_ 等工具包裝函式庫的資料型別和函式。`SIP " -"`__、`CXX `_ `Boost `_ 或 `Weave " -"`_ 也是包裝 C++ 函式庫的替代方法。" - -#: ../../faq/extending.rst:61 +#: ../../faq/extending.rst:46 msgid "How can I execute arbitrary Python statements from C?" msgstr "如何從 C 執行任意 Python 陳述式?" -#: ../../faq/extending.rst:63 +#: ../../faq/extending.rst:48 #, fuzzy msgid "" "The highest-level function to do this is :c:func:`PyRun_SimpleString` which " "takes a single string argument to be executed in the context of the module " "``__main__`` and returns ``0`` for success and ``-1`` when an exception " -"occurred (including :exc:`SyntaxError`). If you want more control, " -"use :c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` " -"in ``Python/pythonrun.c``." +"occurred (including :exc:`SyntaxError`). If you want more control, use :c:" +"func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in " +"``Python/pythonrun.c``." msgstr "" "執行此操作的最高級別函式是 :c:func:`PyRun_SimpleString`,它採用單個字串引數在" "模組 ``__main__`` 的上下文中執行,並回傳 ``0`` 表示成功,``- 1`` 發生例外時" -"(包括 :exc:`SyntaxError`)。如果你想要更多的控制,使" -"用 :c:func:`PyRun_String`;在 ``Python/pythonrun.c`` 中查" -"看 :c:func:`PyRun_SimpleString` 的原始碼。" +"(包括 :exc:`SyntaxError`)。如果你想要更多的控制,使用 :c:func:" +"`PyRun_String`;在 ``Python/pythonrun.c`` 中查看 :c:func:" +"`PyRun_SimpleString` 的原始碼。" -#: ../../faq/extending.rst:72 +#: ../../faq/extending.rst:57 #, fuzzy msgid "How can I evaluate an arbitrary Python expression from C?" msgstr "如何計算來自 C 的任意 Python 運算式?" -#: ../../faq/extending.rst:74 +#: ../../faq/extending.rst:59 #, fuzzy msgid "" "Call the function :c:func:`PyRun_String` from the previous question with the " "start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it " "and returns its value." msgstr "" -"呼叫上一個問題中的函式 :c:func:`PyRun_String` 開始符" -"號 :c:data:`Py_eval_input`;它解析一個運算式,對其求值並回傳它的值。" +"呼叫上一個問題中的函式 :c:func:`PyRun_String` 開始符號 :c:data:" +"`Py_eval_input`;它解析一個運算式,對其求值並回傳它的值。" -#: ../../faq/extending.rst:80 +#: ../../faq/extending.rst:65 msgid "How do I extract C values from a Python object?" msgstr "如何從 Python 物件中提取 C 值?" -#: ../../faq/extending.rst:82 +#: ../../faq/extending.rst:67 #, fuzzy msgid "" "That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` " "returns its length and :c:func:`PyTuple_GetItem` returns the item at a " -"specified index. Lists have similar functions, :c:func:`PyList_Size` " -"and :c:func:`PyList_GetItem`." +"specified index. Lists have similar functions, :c:func:`PyList_Size` and :c:" +"func:`PyList_GetItem`." msgstr "" -"這取決於物件的型別。如果它是一個元組,:c:func:`PyTuple_Size` 回傳它的長" -"度,:c:func:`PyTuple_GetItem` 回傳指定索引的項目。列表具有類似的函式:" -"c:func:`PyList_Size` 和 :c:func:`PyList_GetItem`。" +"這取決於物件的型別。如果它是一個元組,:c:func:`PyTuple_Size` 回傳它的長度,:" +"c:func:`PyTuple_GetItem` 回傳指定索引的項目。列表具有類似的函式:c:func:" +"`PyList_Size` 和 :c:func:`PyList_GetItem`。" -#: ../../faq/extending.rst:87 +#: ../../faq/extending.rst:72 #, fuzzy msgid "" -"For bytes, :c:func:`PyBytes_Size` returns its length " -"and :c:func:`PyBytes_AsStringAndSize` provides a pointer to its value and " -"its length. Note that Python bytes objects may contain null bytes so " -"C's :c:func:`!strlen` should not be used." +"For bytes, :c:func:`PyBytes_Size` returns its length and :c:func:" +"`PyBytes_AsStringAndSize` provides a pointer to its value and its length. " +"Note that Python bytes objects may contain null bytes so C's :c:func:`!" +"strlen` should not be used." msgstr "" -"對於位元組,:c:func:`PyBytes_Size` 回傳它的長" -"度,:c:func:`PyBytes_AsStringAndSize` 提供指向它的值和長度的指標。請注意," -"Python 位元組物件可能包含空位元組,因此不應使用 C 的 :c:func:`!strlen`。" +"對於位元組,:c:func:`PyBytes_Size` 回傳它的長度,:c:func:" +"`PyBytes_AsStringAndSize` 提供指向它的值和長度的指標。請注意,Python 位元組物" +"件可能包含空位元組,因此不應使用 C 的 :c:func:`!strlen`。" -#: ../../faq/extending.rst:92 +#: ../../faq/extending.rst:77 msgid "" "To test the type of an object, first make sure it isn't ``NULL``, and then " -"use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, " -"etc." +"use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:" +"`PyList_Check`, etc." msgstr "" -"要測試物件的型別,首先確保它不是 ``NULL``,然後再使" -"用 :c:func:`PyBytes_Check`、:c:func:`PyTuple_Check`、:c:func:`PyList_Check` " -"等函式。" +"要測試物件的型別,首先確保它不是 ``NULL``,然後再使用 :c:func:" +"`PyBytes_Check`、:c:func:`PyTuple_Check`、:c:func:`PyList_Check` 等函式。" -#: ../../faq/extending.rst:95 +#: ../../faq/extending.rst:80 #, fuzzy msgid "" "There is also a high-level API to Python objects which is provided by the so-" @@ -185,24 +154,23 @@ msgid "" "al.) and mappings in the PyMapping APIs." msgstr "" "還有一個針對 Python 物件的高級 API,它由所謂的「抽象」介面提供——閱讀 " -"``Include/abstract.h`` 了解更多詳細資訊。它允許使" -"用 :c:func:`PySequence_Length`、:c:func:`PySequence_GetItem` 等呼叫以及許多其" -"他有用的協議(例如數字 (:c:func:`PyNumber_Index) ` 等)和 PyMapping API 中的" -"對映。" +"``Include/abstract.h`` 了解更多詳細資訊。它允許使用 :c:func:" +"`PySequence_Length`、:c:func:`PySequence_GetItem` 等呼叫以及許多其他有用的協" +"議(例如數字 (:c:func:`PyNumber_Index) ` 等)和 PyMapping API 中的對映。" -#: ../../faq/extending.rst:104 +#: ../../faq/extending.rst:89 msgid "How do I use Py_BuildValue() to create a tuple of arbitrary length?" msgstr "如何使用 Py_BuildValue() 建立任意長度的元組?" -#: ../../faq/extending.rst:106 +#: ../../faq/extending.rst:91 msgid "You can't. Use :c:func:`PyTuple_Pack` instead." msgstr "這無法做到。請改用 :c:func:`PyTuple_Pack`。" -#: ../../faq/extending.rst:110 +#: ../../faq/extending.rst:95 msgid "How do I call an object's method from C?" msgstr "如何從 C 呼叫物件的方法?" -#: ../../faq/extending.rst:112 +#: ../../faq/extending.rst:97 #, fuzzy msgid "" "The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary " @@ -214,7 +182,7 @@ msgstr "" "叫的方法的名稱、與 :c:func:`Py_BuildValue` 一起使用的格式字串,以及引數" "值: ::" -#: ../../faq/extending.rst:117 +#: ../../faq/extending.rst:102 msgid "" "PyObject *\n" "PyObject_CallMethod(PyObject *object, const char *method_name,\n" @@ -224,17 +192,16 @@ msgstr "" "PyObject_CallMethod(PyObject *object, const char *method_name,\n" " const char *arg_format, ...);" -#: ../../faq/extending.rst:121 -#, fuzzy +#: ../../faq/extending.rst:106 msgid "" "This works for any object that has methods -- whether built-in or user-" "defined. You are responsible for eventually :c:func:`Py_DECREF`\\ 'ing the " "return value." msgstr "" -"這適用於任何具有方法的物件——無論是內建的還是使用者定義的。你負責最" -"終 :c:func:`Py_DECREF`\\ 'ing 回傳值。" +"這適用於任何具有方法的物件 —— 無論是內建的還是使用者定義的。你負責最終為回傳值來 :c:func:" +"`Py_DECREF`。" -#: ../../faq/extending.rst:124 +#: ../../faq/extending.rst:109 msgid "" "To call, e.g., a file object's \"seek\" method with arguments 10, 0 " "(assuming the file object pointer is \"f\")::" @@ -242,7 +209,7 @@ msgstr "" "例如,使用引數 10、0 呼叫檔案物件的 \"seek\" 方法(假設檔案物件指標為 " "\"f\"): ::" -#: ../../faq/extending.rst:127 +#: ../../faq/extending.rst:112 msgid "" "res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" "if (res == NULL) {\n" @@ -252,26 +219,32 @@ msgid "" " Py_DECREF(res);\n" "}" msgstr "" +"res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" +"if (res == NULL) {\n" +" ... 發生一個例外 ...\n" +"}\n" +"else {\n" +" Py_DECREF(res);\n" +"}" -#: ../../faq/extending.rst:135 -#, fuzzy +#: ../../faq/extending.rst:120 msgid "" "Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the " "argument list, to call a function without arguments, pass \"()\" for the " "format, and to call a function with one argument, surround the argument in " "parentheses, e.g. \"(i)\"." msgstr "" -"請注意,由於 :c:func:`PyObject_CallObject` *總是* 需要一個元組作為引數列表," -"呼叫一個不帶引數的函式,傳遞 \"()\" 作為格式,並呼叫一個帶有一個引數的函式," -"將參數括起來在括號中,例如 \"(i)\"。" +"請注意,由於 :c:func:`PyObject_CallObject` *總是*\\ 需要一個元組作為引數列表," +"若要呼叫一個不帶引數的函式,要傳遞 \"()\" 作為格式,並呼叫一個帶有一個引數的函式," +"將引數括起來在括號中,例如 \"(i)\"。" -#: ../../faq/extending.rst:142 +#: ../../faq/extending.rst:127 msgid "" "How do I catch the output from PyErr_Print() (or anything that prints to " "stdout/stderr)?" msgstr "我如何捕捉 PyErr_Print() 的輸出(或任何印出到 stdout/stderr 的東西)?" -#: ../../faq/extending.rst:144 +#: ../../faq/extending.rst:129 #, fuzzy msgid "" "In Python code, define an object that supports the ``write()`` method. " @@ -279,15 +252,15 @@ msgid "" "print_error, or just allow the standard traceback mechanism to work. Then, " "the output will go wherever your ``write()`` method sends it." msgstr "" -"在 Python 程式碼中,定義一個支援 ``write()`` 方法的物件。將此物件分配" -"給 :data:`sys.stdout` 和 :data:`sys.stderr`。呼叫 print_error,或者只允許標準" -"的回溯機制起作用。然後,輸出將到達你的 ``write()`` 方法發送它的任何地方。" +"在 Python 程式碼中,定義一個支援 ``write()`` 方法的物件。將此物件分配給 :" +"data:`sys.stdout` 和 :data:`sys.stderr`。呼叫 print_error,或者只允許標準的回" +"溯機制起作用。然後,輸出將到達你的 ``write()`` 方法發送它的任何地方。" -#: ../../faq/extending.rst:149 +#: ../../faq/extending.rst:134 msgid "The easiest way to do this is to use the :class:`io.StringIO` class:" msgstr "最簡單的方法是使用 :class:`io.StringIO` 類別:" -#: ../../faq/extending.rst:151 +#: ../../faq/extending.rst:136 msgid "" ">>> import io, sys\n" ">>> sys.stdout = io.StringIO()\n" @@ -305,12 +278,11 @@ msgstr "" "foo\n" "hello world!" -#: ../../faq/extending.rst:161 -#, fuzzy +#: ../../faq/extending.rst:146 msgid "A custom object to do the same would look like this:" msgstr "執行相同操作的自定義物件如下所示:" -#: ../../faq/extending.rst:163 +#: ../../faq/extending.rst:148 msgid "" ">>> import io, sys\n" ">>> class StdoutCatcher(io.TextIOBase):\n" @@ -342,57 +314,54 @@ msgstr "" "foo\n" "hello world!" -#: ../../faq/extending.rst:182 +#: ../../faq/extending.rst:167 msgid "How do I access a module written in Python from C?" msgstr "如何從 C 存取用 Python 編寫的模組?" -#: ../../faq/extending.rst:184 -#, fuzzy +#: ../../faq/extending.rst:169 msgid "You can get a pointer to the module object as follows::" -msgstr "你可以獲得指向模組物件的指標,如下所示: ::" +msgstr "你可以取得指向模組物件的指標,如下所示: ::" -#: ../../faq/extending.rst:186 +#: ../../faq/extending.rst:171 msgid "module = PyImport_ImportModule(\"\");" msgstr "module = PyImport_ImportModule(\"\");" -#: ../../faq/extending.rst:188 +#: ../../faq/extending.rst:173 #, fuzzy msgid "" -"If the module hasn't been imported yet (i.e. it is not yet present " -"in :data:`sys.modules`), this initializes the module; otherwise it simply " -"returns the value of ``sys.modules[\"\"]``. Note that it " -"doesn't enter the module into any namespace -- it only ensures it has been " -"initialized and is stored in :data:`sys.modules`." +"If the module hasn't been imported yet (i.e. it is not yet present in :data:" +"`sys.modules`), this initializes the module; otherwise it simply returns the " +"value of ``sys.modules[\"\"]``. Note that it doesn't enter the " +"module into any namespace -- it only ensures it has been initialized and is " +"stored in :data:`sys.modules`." msgstr "" "如果模組還沒有被引入(即它還沒有出現在 :data:`sys.modules` 中),這會初始化模" "組;否則它只回傳 ``sys.modules[\"\"]`` 的值。請注意,它不會將模組" "輸入任何命名空間——它只會確保它已被初始化並存儲在 :data:`sys.modules` 中。" -#: ../../faq/extending.rst:194 +#: ../../faq/extending.rst:179 #, fuzzy msgid "" "You can then access the module's attributes (i.e. any name defined in the " "module) as follows::" msgstr "然後,你可以存取模組的屬性(即模組中定義的任何名稱),如下所示: ::" -#: ../../faq/extending.rst:197 +#: ../../faq/extending.rst:182 msgid "attr = PyObject_GetAttrString(module, \"\");" msgstr "attr = PyObject_GetAttrString(module, \"\");" -#: ../../faq/extending.rst:199 +#: ../../faq/extending.rst:184 #, fuzzy msgid "" "Calling :c:func:`PyObject_SetAttrString` to assign to variables in the " "module also works." msgstr "呼叫 :c:func:`PyObject_SetAttrString` 以分配給模組中的變數也可以。" -#: ../../faq/extending.rst:204 -#, fuzzy +#: ../../faq/extending.rst:189 msgid "How do I interface to C++ objects from Python?" -msgstr "我如何從 Python 連接到 C++ 物件?" +msgstr "我如何從 Python 介接到 C++ 物件?" -#: ../../faq/extending.rst:206 -#, fuzzy +#: ../../faq/extending.rst:191 msgid "" "Depending on your requirements, there are many approaches. To do this " "manually, begin by reading :ref:`the \"Extending and Embedding\" document " @@ -401,20 +370,20 @@ msgid "" "building a new Python type around a C structure (pointer) type will also " "work for C++ objects." msgstr "" -"根據你的要求,有多種方法。要手動執行此操作,請先閱讀 :ref:`「擴充和嵌入」說明" -"檔案 `。意識到對於 Python 執行環境 (run-time) 系統,C 和 C+" -"+ 之間並沒有太多區別——因此圍繞 C 結構(指標)型別構建新 Python 型別的策略也適" +"根據你的要求不同而有多種不同方法。要手動執行此操作,請先閱讀\\ :ref:`「擴充和嵌入」說明" +"文件 `。對於 Python run-time 系統,C 和 C++ 之間並" +"沒有太多區別 —— 因此圍繞 C 結構(指標)型別來構建新 Python 型別的策略也適" "用於 C++ 物件。" -#: ../../faq/extending.rst:212 +#: ../../faq/extending.rst:197 msgid "For C++ libraries, see :ref:`c-wrapper-software`." msgstr "對於 C++ 函式庫,請參閱 :ref:`c-wrapper-software`。" -#: ../../faq/extending.rst:216 +#: ../../faq/extending.rst:201 msgid "I added a module using the Setup file and the make fails; why?" msgstr "我使用安裝檔案新增了一個模組,但 make 失敗了;為什麼?" -#: ../../faq/extending.rst:218 +#: ../../faq/extending.rst:203 #, fuzzy msgid "" "Setup must end in a newline, if there is no newline there, the build process " @@ -424,11 +393,11 @@ msgstr "" "安裝程式必須以換行符結尾,如果那裡沒有換行符,構建過程將失敗。(解決這個問題" "需要一些醜陋的 shell 腳本 hackery,而且這個錯誤很小,似乎不值得付出努力。)" -#: ../../faq/extending.rst:224 +#: ../../faq/extending.rst:209 msgid "How do I debug an extension?" msgstr "如何為擴充套件除錯?" -#: ../../faq/extending.rst:226 +#: ../../faq/extending.rst:211 #, fuzzy msgid "" "When using GDB with dynamically loaded extensions, you can't set a " @@ -436,20 +405,19 @@ msgid "" msgstr "" "將 GDB 與動態載入的擴充一起使用時,在載入擴充之前不能在擴充中設定斷點。" -#: ../../faq/extending.rst:229 -#, fuzzy +#: ../../faq/extending.rst:214 msgid "In your ``.gdbinit`` file (or interactively), add the command:" msgstr "在你的 ``.gdbinit`` 檔案中(或交互地),新增命令:" -#: ../../faq/extending.rst:231 +#: ../../faq/extending.rst:216 msgid "br _PyImport_LoadDynamicModule" msgstr "br _PyImport_LoadDynamicModule" -#: ../../faq/extending.rst:235 +#: ../../faq/extending.rst:220 msgid "Then, when you run GDB:" msgstr "然後,當你運行 GDB 時:" -#: ../../faq/extending.rst:237 +#: ../../faq/extending.rst:222 msgid "" "$ gdb /local/bin/python\n" "gdb) run myscript.py\n" @@ -459,14 +427,14 @@ msgid "" "gdb) continue" msgstr "" -#: ../../faq/extending.rst:247 +#: ../../faq/extending.rst:232 msgid "" "I want to compile a Python module on my Linux system, but some files are " "missing. Why?" msgstr "" "我想在我的 Linux 系統上編譯一個 Python 模組,但是缺少一些檔案。為什麼?" -#: ../../faq/extending.rst:249 +#: ../../faq/extending.rst:234 #, fuzzy msgid "" "Most packaged versions of Python omit some files required for compiling " @@ -475,19 +443,19 @@ msgstr "" "大多數打包版本的 Python 不包含 :file:`/usr/lib/python2.{x}/config/` 目錄,該" "目錄包含編譯 Python 擴充所需的各種檔案。" -#: ../../faq/extending.rst:252 +#: ../../faq/extending.rst:237 msgid "For Red Hat, install the python3-devel RPM to get the necessary files." msgstr "在 Red Hat 上,請安裝 python3-devel RPM 來取得必要的檔案。" -#: ../../faq/extending.rst:254 +#: ../../faq/extending.rst:239 msgid "For Debian, run ``apt-get install python3-dev``." msgstr "對於 Debian,運行 ``apt-get install python3-dev``。" -#: ../../faq/extending.rst:257 +#: ../../faq/extending.rst:242 msgid "How do I tell \"incomplete input\" from \"invalid input\"?" msgstr "如何從「無效輸入」區分出「不完整輸入」?" -#: ../../faq/extending.rst:259 +#: ../../faq/extending.rst:244 #, fuzzy msgid "" "Sometimes you want to emulate the Python interactive interpreter's behavior, " @@ -500,7 +468,7 @@ msgstr "" "(例如,你鍵入了 \"if\" 陳述句的開頭或者你沒有關閉你的括號或三重字串引號)," "但是當輸入無效時,它會立即為你提供語法錯誤消息。" -#: ../../faq/extending.rst:265 +#: ../../faq/extending.rst:250 msgid "" "In Python you can use the :mod:`codeop` module, which approximates the " "parser's behavior sufficiently. IDLE uses this, for example." @@ -508,7 +476,7 @@ msgstr "" "在 Python 中,你可以使用 :mod:`codeop` 模組,它充分模擬了剖析器 (parser) 的行" "為。像是 IDLE 就有使用它。" -#: ../../faq/extending.rst:268 +#: ../../faq/extending.rst:253 #, fuzzy msgid "" "The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` " @@ -518,15 +486,15 @@ msgid "" "``Parser/myreadline.c`` for more hints." msgstr "" "在 C 中執行此操作的最簡單方法是呼叫:c:func:`PyRun_InteractiveLoop`(可能在單" -"獨的執行緒中)並讓 Python 直譯器為你處理輸入。你還可以" -"將 :c:func:`PyOS_ReadlineFunctionPointer` 設定為指向你的自定義輸入函式。有關" -"更多提示,請參閱``Modules/readline.c`` 和``Parser/myreadline.c``。" +"獨的執行緒中)並讓 Python 直譯器為你處理輸入。你還可以將 :c:func:" +"`PyOS_ReadlineFunctionPointer` 設定為指向你的自定義輸入函式。有關更多提示,請" +"參閱``Modules/readline.c`` 和``Parser/myreadline.c``。" -#: ../../faq/extending.rst:275 +#: ../../faq/extending.rst:260 msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?" msgstr "如何找到未定義的 g++ 符號 __builtin_new 或 __pure_virtual?" -#: ../../faq/extending.rst:277 +#: ../../faq/extending.rst:262 #, fuzzy msgid "" "To dynamically load g++ extension modules, you must recompile Python, relink " @@ -537,8 +505,7 @@ msgstr "" "Python 模組 Makefile 中的 LINKCC),並使用 g++ 鏈接你的擴充模組(例如,``g++ " "-shared -o mymodule.so mymodule.o` `)。" -#: ../../faq/extending.rst:283 -#, fuzzy +#: ../../faq/extending.rst:268 msgid "" "Can I create an object class with some methods implemented in C and others " "in Python (e.g. through inheritance)?" @@ -546,19 +513,19 @@ msgstr "" "我可以用一些用 C 實作的方法和用 Python 實作的其他方法(例如透過繼承)建立一個" "物件類別嗎?" -#: ../../faq/extending.rst:285 +#: ../../faq/extending.rst:270 msgid "" -"Yes, you can inherit from built-in classes such " -"as :class:`int`, :class:`list`, :class:`dict`, etc." +"Yes, you can inherit from built-in classes such as :class:`int`, :class:" +"`list`, :class:`dict`, etc." msgstr "" "是的,你可以繼承內建類別,例如 :class:`int`、:class:`list`、:class:`dict` " "等。" -#: ../../faq/extending.rst:288 +#: ../../faq/extending.rst:273 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 extension class written in C++ using the BPL)." +"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 " +"extension class written in C++ using the BPL)." msgstr "" "Boost Python 函式庫(BPL,https://www.boost.org/libs/python/doc/index.html)" "提供了一種從 C++ 執行此操作的方法(即你可以使用 BPL 來繼承用 C++ 編寫的擴充類" diff --git a/howto/cporting.po b/howto/cporting.po index 97bd67e1da..06a67dd24b 100644 --- a/howto/cporting.po +++ b/howto/cporting.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -44,8 +44,8 @@ msgstr "" #: ../../howto/cporting.rst:17 msgid "" -"The `Cython`_ and `CFFI`_ libraries offer abstractions over Python's C API. " -"Extensions generally need to be re-written to use one of them, but the " -"library then handles differences between various Python versions and " -"implementations." +":ref:`Recommended third party tools ` offer abstractions over " +"the Python's C API. Extensions generally need to be re-written to use one of " +"them, but the library then handles differences between various Python " +"versions and implementations." msgstr "" diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po index 83e6596e5d..5ce4f89173 100644 --- a/howto/free-threading-extensions.po +++ b/howto/free-threading-extensions.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -18,7 +18,7 @@ msgstr "" #: ../../howto/free-threading-extensions.rst:7 msgid "C API Extension Support for Free Threading" -msgstr "" +msgstr "支援自由執行緒的 C API 擴充" #: ../../howto/free-threading-extensions.rst:9 msgid "" @@ -47,29 +47,37 @@ msgid "" "#endif" msgstr "" -#: ../../howto/free-threading-extensions.rst:27 +#: ../../howto/free-threading-extensions.rst:28 +msgid "" +"On Windows, this macro is not defined automatically, but must be specified " +"to the compiler when building. The :func:`sysconfig.get_config_var` function " +"can be used to determine whether the current running interpreter had the " +"macro defined." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:35 msgid "Module Initialization" msgstr "" -#: ../../howto/free-threading-extensions.rst:29 +#: ../../howto/free-threading-extensions.rst:37 msgid "" "Extension modules need to explicitly indicate that they support running with " "the GIL disabled; otherwise importing the extension will raise a warning and " "enable the GIL at runtime." msgstr "" -#: ../../howto/free-threading-extensions.rst:33 +#: ../../howto/free-threading-extensions.rst:41 msgid "" "There are two ways to indicate that an extension module supports running " "with the GIL disabled depending on whether the extension uses multi-phase or " "single-phase initialization." msgstr "" -#: ../../howto/free-threading-extensions.rst:38 +#: ../../howto/free-threading-extensions.rst:46 msgid "Multi-Phase Initialization" msgstr "" -#: ../../howto/free-threading-extensions.rst:40 +#: ../../howto/free-threading-extensions.rst:48 msgid "" "Extensions that use multi-phase initialization (i.e., :c:func:" "`PyModuleDef_Init`) should add a :c:data:`Py_mod_gil` slot in the module " @@ -77,7 +85,7 @@ msgid "" "should guard the slot with a :c:data:`PY_VERSION_HEX` check." msgstr "" -#: ../../howto/free-threading-extensions.rst:47 +#: ../../howto/free-threading-extensions.rst:55 msgid "" "static struct PyModuleDef_Slot module_slots[] = {\n" " ...\n" @@ -93,12 +101,25 @@ msgid "" " ...\n" "};" msgstr "" +"static struct PyModuleDef_Slot module_slots[] = {\n" +" ...\n" +"#if PY_VERSION_HEX >= 0x030D0000\n" +" {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" +"#endif\n" +" {0, NULL}\n" +"};\n" +"\n" +"static struct PyModuleDef moduledef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_slots = module_slots,\n" +" ...\n" +"};" -#: ../../howto/free-threading-extensions.rst:63 +#: ../../howto/free-threading-extensions.rst:71 msgid "Single-Phase Initialization" -msgstr "" +msgstr "單一階段初始化 (Single-Phase Initialization)" -#: ../../howto/free-threading-extensions.rst:65 +#: ../../howto/free-threading-extensions.rst:73 msgid "" "Extensions that use single-phase initialization (i.e., :c:func:" "`PyModule_Create`) should call :c:func:`PyUnstable_Module_SetGIL` to " @@ -107,7 +128,7 @@ msgid "" "``#ifdef Py_GIL_DISABLED`` to avoid compilation errors in the regular build." msgstr "" -#: ../../howto/free-threading-extensions.rst:73 +#: ../../howto/free-threading-extensions.rst:81 msgid "" "static struct PyModuleDef moduledef = {\n" " PyModuleDef_HEAD_INIT,\n" @@ -145,28 +166,28 @@ msgstr "" " return m;\n" "}" -#: ../../howto/free-threading-extensions.rst:93 +#: ../../howto/free-threading-extensions.rst:101 msgid "General API Guidelines" msgstr "" -#: ../../howto/free-threading-extensions.rst:95 +#: ../../howto/free-threading-extensions.rst:103 msgid "Most of the C API is thread-safe, but there are some exceptions." msgstr "" -#: ../../howto/free-threading-extensions.rst:97 +#: ../../howto/free-threading-extensions.rst:105 msgid "" "**Struct Fields**: Accessing fields in Python C API objects or structs " "directly is not thread-safe if the field may be concurrently modified." msgstr "" -#: ../../howto/free-threading-extensions.rst:99 +#: ../../howto/free-threading-extensions.rst:107 msgid "" "**Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM` and :c:macro:" "`PyList_SET_ITEM` do not perform any error checking or locking. These macros " "are not thread-safe if the container object may be modified concurrently." msgstr "" -#: ../../howto/free-threading-extensions.rst:103 +#: ../../howto/free-threading-extensions.rst:111 msgid "" "**Borrowed References**: C API functions that return :term:`borrowed " "references ` may not be thread-safe if the containing " @@ -174,11 +195,11 @@ msgid "" "references ` for more information." msgstr "" -#: ../../howto/free-threading-extensions.rst:110 +#: ../../howto/free-threading-extensions.rst:118 msgid "Container Thread Safety" -msgstr "" +msgstr "容器執行緒安全性" -#: ../../howto/free-threading-extensions.rst:112 +#: ../../howto/free-threading-extensions.rst:120 msgid "" "Containers like :c:struct:`PyListObject`, :c:struct:`PyDictObject`, and :c:" "struct:`PySetObject` perform internal locking in the free-threaded build. " @@ -186,11 +207,11 @@ msgid "" "an item." msgstr "" -#: ../../howto/free-threading-extensions.rst:120 +#: ../../howto/free-threading-extensions.rst:128 msgid "``PyDict_Next``" msgstr "``PyDict_Next``" -#: ../../howto/free-threading-extensions.rst:122 +#: ../../howto/free-threading-extensions.rst:130 msgid "" "A notable exception is :c:func:`PyDict_Next`, which does not lock the " "dictionary. You should use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to protect " @@ -198,7 +219,7 @@ msgid "" "modified::" msgstr "" -#: ../../howto/free-threading-extensions.rst:127 +#: ../../howto/free-threading-extensions.rst:135 msgid "" "Py_BEGIN_CRITICAL_SECTION(dict);\n" "PyObject *key, *value;\n" @@ -208,12 +229,19 @@ msgid "" "}\n" "Py_END_CRITICAL_SECTION();" msgstr "" +"Py_BEGIN_CRITICAL_SECTION(dict);\n" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"while (PyDict_Next(dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" -#: ../../howto/free-threading-extensions.rst:137 +#: ../../howto/free-threading-extensions.rst:145 msgid "Borrowed References" -msgstr "" +msgstr "借用參照" -#: ../../howto/free-threading-extensions.rst:141 +#: ../../howto/free-threading-extensions.rst:149 msgid "" "Some C API functions return :term:`borrowed references `. These APIs are not thread-safe if the containing object is " @@ -221,87 +249,87 @@ msgid "" "`PyList_GetItem` if the list may be modified concurrently." msgstr "" -#: ../../howto/free-threading-extensions.rst:146 +#: ../../howto/free-threading-extensions.rst:154 msgid "" "The following table lists some borrowed reference APIs and their " "replacements that return :term:`strong references `." msgstr "" -#: ../../howto/free-threading-extensions.rst:150 +#: ../../howto/free-threading-extensions.rst:158 msgid "Borrowed reference API" -msgstr "" +msgstr "借用參照 API" -#: ../../howto/free-threading-extensions.rst:150 +#: ../../howto/free-threading-extensions.rst:158 msgid "Strong reference API" -msgstr "" +msgstr "強參照 API" -#: ../../howto/free-threading-extensions.rst:152 +#: ../../howto/free-threading-extensions.rst:160 msgid ":c:func:`PyList_GetItem`" msgstr ":c:func:`PyList_GetItem`" -#: ../../howto/free-threading-extensions.rst:152 +#: ../../howto/free-threading-extensions.rst:160 msgid ":c:func:`PyList_GetItemRef`" msgstr ":c:func:`PyList_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:154 +#: ../../howto/free-threading-extensions.rst:162 msgid ":c:func:`PyDict_GetItem`" msgstr ":c:func:`PyDict_GetItem`" -#: ../../howto/free-threading-extensions.rst:154 -#: ../../howto/free-threading-extensions.rst:156 +#: ../../howto/free-threading-extensions.rst:162 +#: ../../howto/free-threading-extensions.rst:164 msgid ":c:func:`PyDict_GetItemRef`" msgstr ":c:func:`PyDict_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:156 +#: ../../howto/free-threading-extensions.rst:164 msgid ":c:func:`PyDict_GetItemWithError`" msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../howto/free-threading-extensions.rst:158 +#: ../../howto/free-threading-extensions.rst:166 msgid ":c:func:`PyDict_GetItemString`" msgstr ":c:func:`PyDict_GetItemString`" -#: ../../howto/free-threading-extensions.rst:158 +#: ../../howto/free-threading-extensions.rst:166 msgid ":c:func:`PyDict_GetItemStringRef`" msgstr ":c:func:`PyDict_GetItemStringRef`" -#: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:168 msgid ":c:func:`PyDict_SetDefault`" msgstr ":c:func:`PyDict_SetDefault`" -#: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:168 msgid ":c:func:`PyDict_SetDefaultRef`" msgstr ":c:func:`PyDict_SetDefaultRef`" -#: ../../howto/free-threading-extensions.rst:162 +#: ../../howto/free-threading-extensions.rst:170 msgid ":c:func:`PyDict_Next`" msgstr ":c:func:`PyDict_Next`" -#: ../../howto/free-threading-extensions.rst:162 +#: ../../howto/free-threading-extensions.rst:170 msgid "none (see :ref:`PyDict_Next`)" msgstr "" -#: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:172 msgid ":c:func:`PyWeakref_GetObject`" msgstr ":c:func:`PyWeakref_GetObject`" -#: ../../howto/free-threading-extensions.rst:164 -#: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:172 +#: ../../howto/free-threading-extensions.rst:174 msgid ":c:func:`PyWeakref_GetRef`" msgstr ":c:func:`PyWeakref_GetRef`" -#: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:174 msgid ":c:func:`PyWeakref_GET_OBJECT`" msgstr ":c:func:`PyWeakref_GET_OBJECT`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:176 msgid ":c:func:`PyImport_AddModule`" msgstr ":c:func:`PyImport_AddModule`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:176 msgid ":c:func:`PyImport_AddModuleRef`" msgstr ":c:func:`PyImport_AddModuleRef`" -#: ../../howto/free-threading-extensions.rst:171 +#: ../../howto/free-threading-extensions.rst:179 msgid "" "Not all APIs that return borrowed references are problematic. For example, :" "c:func:`PyTuple_GetItem` is safe because tuples are immutable. Similarly, " @@ -312,18 +340,18 @@ msgid "" "context is safe." msgstr "" -#: ../../howto/free-threading-extensions.rst:179 +#: ../../howto/free-threading-extensions.rst:187 msgid "" "Some of these functions were added in Python 3.13. You can use the " "`pythoncapi-compat `_ package " "to provide implementations of these functions for older Python versions." msgstr "" -#: ../../howto/free-threading-extensions.rst:187 +#: ../../howto/free-threading-extensions.rst:195 msgid "Memory Allocation APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:189 +#: ../../howto/free-threading-extensions.rst:197 msgid "" "Python's memory management C API provides functions in three different :ref:" "`allocation domains `: \"raw\", \"mem\", and \"object\". " @@ -333,36 +361,36 @@ msgid "" "where this was only a best practice and not a hard requirement." msgstr "" -#: ../../howto/free-threading-extensions.rst:198 +#: ../../howto/free-threading-extensions.rst:206 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:205 +#: ../../howto/free-threading-extensions.rst:213 msgid "Thread State and GIL APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:207 +#: ../../howto/free-threading-extensions.rst:215 msgid "" "Python provides a set of functions and macros to manage thread state and the " "GIL, such as:" msgstr "" -#: ../../howto/free-threading-extensions.rst:210 +#: ../../howto/free-threading-extensions.rst:218 msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" msgstr ":c:func:`PyGILState_Ensure` 和 :c:func:`PyGILState_Release`" -#: ../../howto/free-threading-extensions.rst:211 +#: ../../howto/free-threading-extensions.rst:219 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`" -#: ../../howto/free-threading-extensions.rst:212 +#: ../../howto/free-threading-extensions.rst:220 msgid ":c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS`" msgstr ":c:macro:`Py_BEGIN_ALLOW_THREADS` 和 :c:macro:`Py_END_ALLOW_THREADS`" -#: ../../howto/free-threading-extensions.rst:214 +#: ../../howto/free-threading-extensions.rst:222 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 " @@ -371,7 +399,7 @@ msgid "" "Python thread state." msgstr "" -#: ../../howto/free-threading-extensions.rst:220 +#: ../../howto/free-threading-extensions.rst:228 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 " @@ -379,25 +407,25 @@ msgid "" "collector `." msgstr "" -#: ../../howto/free-threading-extensions.rst:227 +#: ../../howto/free-threading-extensions.rst:235 msgid "Protecting Internal Extension State" msgstr "" -#: ../../howto/free-threading-extensions.rst:229 +#: ../../howto/free-threading-extensions.rst:237 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:233 +#: ../../howto/free-threading-extensions.rst:241 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:236 +#: ../../howto/free-threading-extensions.rst:244 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 " @@ -405,34 +433,34 @@ msgid "" "language/storage_duration>`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:243 +#: ../../howto/free-threading-extensions.rst:251 msgid "Building Extensions for the Free-Threaded Build" msgstr "" -#: ../../howto/free-threading-extensions.rst:245 +#: ../../howto/free-threading-extensions.rst:253 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:248 +#: ../../howto/free-threading-extensions.rst:256 msgid "" "`pypa/manylinux `_ supports the free-" "threaded build, with the ``t`` suffix, such as ``python3.13t``." msgstr "" -#: ../../howto/free-threading-extensions.rst:250 +#: ../../howto/free-threading-extensions.rst:258 msgid "" "`pypa/cibuildwheel `_ supports the " -"free-threaded build if you set `CIBW_FREE_THREADED_SUPPORT `_." +"free-threaded build if you set `CIBW_ENABLE to cpython-freethreading " +"`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:255 +#: ../../howto/free-threading-extensions.rst:263 msgid "Limited C API and Stable ABI" msgstr "" -#: ../../howto/free-threading-extensions.rst:257 +#: ../../howto/free-threading-extensions.rst:265 msgid "" "The free-threaded build does not currently support the :ref:`Limited C API " "` or the stable ABI. If you use `setuptools `_: A community-maintained porting guide for " diff --git a/howto/free-threading-python.po b/howto/free-threading-python.po index 2d43d4ae62..ada1b6f51f 100644 --- a/howto/free-threading-python.po +++ b/howto/free-threading-python.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-05 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -65,7 +65,7 @@ msgstr "" #: ../../howto/free-threading-python.rst:34 msgid "" "For information on other platforms, see the `Installing a Free-Threaded " -"Python `_, a " +"Python `_, a " "community-maintained installation guide for installing free-threaded Python." msgstr "" diff --git a/howto/functional.po b/howto/functional.po index b41774276d..ff0682092a 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: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -884,7 +884,7 @@ msgstr "" #: ../../howto/functional.rst:605 msgid "" -":meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the " +":meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the " "generator to terminate the iteration. On receiving this exception, the " "generator's code must either raise :exc:`GeneratorExit` or :exc:" "`StopIteration`; catching the exception and doing anything else is illegal " diff --git a/howto/isolating-extensions.po b/howto/isolating-extensions.po index 9399fe584b..7b72abc5c8 100644 --- a/howto/isolating-extensions.po +++ b/howto/isolating-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-03 11:11+0800\n" +"POT-Creation-Date: 2025-06-27 07:36+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,6 +160,13 @@ msgid "" ">>> old_binascii == binascii\n" "False" msgstr "" +">>> import sys\n" +">>> import binascii\n" +">>> old_binascii = binascii\n" +">>> del sys.modules['binascii']\n" +">>> import binascii # 建立一個新的模組物件\n" +">>> old_binascii == binascii\n" +"False" #: ../../howto/isolating-extensions.rst:103 msgid "" @@ -265,8 +272,8 @@ msgstr "" msgid "" "If it is necessary to use process-global state, the simplest way to avoid " "issues with multiple interpreters is to explicitly prevent a module from " -"being loaded more than once per process—see `Opt-Out: Limiting to One Module " -"Object per Process`_." +"being loaded more than once per process—see :ref:`isolating-extensions-" +"optout`." msgstr "" #: ../../howto/isolating-extensions.rst:175 @@ -322,11 +329,11 @@ msgid "" "c>`__; example module initialization shown at the bottom of the file." msgstr "" -#: ../../howto/isolating-extensions.rst:211 +#: ../../howto/isolating-extensions.rst:213 msgid "Opt-Out: Limiting to One Module Object per Process" msgstr "" -#: ../../howto/isolating-extensions.rst:213 +#: ../../howto/isolating-extensions.rst:215 msgid "" "A non-negative ``PyModuleDef.m_size`` signals that a module supports " "multiple interpreters correctly. If this is not yet the case for your " @@ -334,35 +341,51 @@ msgid "" "For example::" msgstr "" -#: ../../howto/isolating-extensions.rst:218 +#: ../../howto/isolating-extensions.rst:220 msgid "" +"// A process-wide flag\n" "static int loaded = 0;\n" "\n" +"// Mutex to provide thread safety (only needed for free-threaded Python)\n" +"static PyMutex modinit_mutex = {0};\n" +"\n" "static int\n" "exec_module(PyObject* module)\n" "{\n" +" PyMutex_Lock(&modinit_mutex);\n" " if (loaded) {\n" +" PyMutex_Unlock(&modinit_mutex);\n" " PyErr_SetString(PyExc_ImportError,\n" " \"cannot load module more than once per process\");\n" " return -1;\n" " }\n" " loaded = 1;\n" +" PyMutex_Unlock(&modinit_mutex);\n" " // ... rest of initialization\n" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:234 +#: ../../howto/isolating-extensions.rst:242 +msgid "" +"If your module's :c:member:`PyModuleDef.m_clear` function is able to prepare " +"for future re-initialization, it should clear the ``loaded`` flag. In this " +"case, your module won't support multiple instances existing *concurrently*, " +"but it will, for example, support being loaded after Python runtime shutdown " +"(:c:func:`Py_FinalizeEx`) and re-initialization (:c:func:`Py_Initialize`)." +msgstr "" + +#: ../../howto/isolating-extensions.rst:251 msgid "Module State Access from Functions" msgstr "" -#: ../../howto/isolating-extensions.rst:236 +#: ../../howto/isolating-extensions.rst:253 msgid "" "Accessing the state from module-level functions is straightforward. " "Functions get the module object as their first argument; for extracting the " "state, you can use ``PyModule_GetState``::" msgstr "" -#: ../../howto/isolating-extensions.rst:240 +#: ../../howto/isolating-extensions.rst:257 msgid "" "static PyObject *\n" "func(PyObject *module, PyObject *args)\n" @@ -375,25 +398,25 @@ msgid "" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:251 +#: ../../howto/isolating-extensions.rst:268 msgid "" "``PyModule_GetState`` may return ``NULL`` without setting an exception if " "there is no module state, i.e. ``PyModuleDef.m_size`` was zero. In your own " "module, you're in control of ``m_size``, so this is easy to prevent." msgstr "" -#: ../../howto/isolating-extensions.rst:258 +#: ../../howto/isolating-extensions.rst:275 msgid "Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:260 +#: ../../howto/isolating-extensions.rst:277 msgid "" "Traditionally, types defined in C code are *static*; that is, ``static " "PyTypeObject`` structures defined directly in code and initialized using " "``PyType_Ready()``." msgstr "" -#: ../../howto/isolating-extensions.rst:264 +#: ../../howto/isolating-extensions.rst:281 msgid "" "Such types are necessarily shared across the process. Sharing them between " "module objects requires paying attention to any state they own or access. To " @@ -401,7 +424,7 @@ msgid "" "for example, you can't set ``str.myattribute = 123``." msgstr "" -#: ../../howto/isolating-extensions.rst:270 +#: ../../howto/isolating-extensions.rst:287 msgid "" "Sharing truly immutable objects between interpreters is fine, as long as " "they don't provide access to mutable objects. However, in CPython, every " @@ -411,7 +434,7 @@ msgid "" "process-wide GIL." msgstr "" -#: ../../howto/isolating-extensions.rst:277 +#: ../../howto/isolating-extensions.rst:294 msgid "" "Because they are immutable and process-global, static types cannot access " "\"their\" module state. If any method of such a type requires access to " @@ -420,15 +443,15 @@ msgid "" "Python's ``class`` statement." msgstr "" -#: ../../howto/isolating-extensions.rst:284 +#: ../../howto/isolating-extensions.rst:301 msgid "For new modules, using heap types by default is a good rule of thumb." msgstr "" -#: ../../howto/isolating-extensions.rst:288 +#: ../../howto/isolating-extensions.rst:305 msgid "Changing Static Types to Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:290 +#: ../../howto/isolating-extensions.rst:307 msgid "" "Static types can be converted to heap types, but note that the heap type API " "was not designed for \"lossless\" conversion from static types—that is, " @@ -438,101 +461,101 @@ msgid "" "slots). Always test the details that are important to you." msgstr "" -#: ../../howto/isolating-extensions.rst:299 +#: ../../howto/isolating-extensions.rst:316 msgid "" "Watch out for the following two points in particular (but note that this is " "not a comprehensive list):" msgstr "" -#: ../../howto/isolating-extensions.rst:302 +#: ../../howto/isolating-extensions.rst:319 msgid "" "Unlike static types, heap type objects are mutable by default. Use the :c:" "macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability." msgstr "" -#: ../../howto/isolating-extensions.rst:304 +#: ../../howto/isolating-extensions.rst:321 msgid "" "Heap types inherit :c:member:`~PyTypeObject.tp_new` by default, so it may " "become possible to instantiate them from Python code. You can prevent this " "with the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag." msgstr "" -#: ../../howto/isolating-extensions.rst:310 +#: ../../howto/isolating-extensions.rst:327 msgid "Defining Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:312 +#: ../../howto/isolating-extensions.rst:329 msgid "" "Heap types can be created by filling a :c:struct:`PyType_Spec` structure, a " "description or \"blueprint\" of a class, and calling :c:func:" "`PyType_FromModuleAndSpec` to construct a new class object." msgstr "" -#: ../../howto/isolating-extensions.rst:317 +#: ../../howto/isolating-extensions.rst:334 msgid "" "Other functions, like :c:func:`PyType_FromSpec`, can also create heap types, " "but :c:func:`PyType_FromModuleAndSpec` associates the module with the class, " "allowing access to the module state from methods." msgstr "" -#: ../../howto/isolating-extensions.rst:321 +#: ../../howto/isolating-extensions.rst:338 msgid "" "The class should generally be stored in *both* the module state (for safe " "access from C) and the module's ``__dict__`` (for access from Python code)." msgstr "" -#: ../../howto/isolating-extensions.rst:327 +#: ../../howto/isolating-extensions.rst:344 msgid "Garbage-Collection Protocol" msgstr "" -#: ../../howto/isolating-extensions.rst:329 +#: ../../howto/isolating-extensions.rst:346 msgid "" "Instances of heap types hold a reference to their type. This ensures that " "the type isn't destroyed before all its instances are, but may result in " "reference cycles that need to be broken by the garbage collector." msgstr "" -#: ../../howto/isolating-extensions.rst:334 +#: ../../howto/isolating-extensions.rst:351 msgid "" "To avoid memory leaks, instances of heap types must implement the garbage " "collection protocol. That is, heap types should:" msgstr "" -#: ../../howto/isolating-extensions.rst:338 +#: ../../howto/isolating-extensions.rst:355 msgid "Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" -#: ../../howto/isolating-extensions.rst:339 +#: ../../howto/isolating-extensions.rst:356 msgid "" "Define a traverse function using ``Py_tp_traverse``, which visits the type " "(e.g. using ``Py_VISIT(Py_TYPE(self))``)." msgstr "" -#: ../../howto/isolating-extensions.rst:342 +#: ../../howto/isolating-extensions.rst:359 msgid "" "Please refer to the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` and :c:" "member:`~PyTypeObject.tp_traverse` for additional considerations." msgstr "" -#: ../../howto/isolating-extensions.rst:346 +#: ../../howto/isolating-extensions.rst:363 msgid "" "The API for defining heap types grew organically, leaving it somewhat " "awkward to use in its current state. The following sections will guide you " "through common issues." msgstr "" -#: ../../howto/isolating-extensions.rst:352 +#: ../../howto/isolating-extensions.rst:369 msgid "``tp_traverse`` in Python 3.8 and lower" msgstr "" -#: ../../howto/isolating-extensions.rst:354 +#: ../../howto/isolating-extensions.rst:371 msgid "" "The requirement to visit the type from ``tp_traverse`` was added in Python " "3.9. If you support Python 3.8 and lower, the traverse function must *not* " "visit the type, so it must be more complicated::" msgstr "" -#: ../../howto/isolating-extensions.rst:358 +#: ../../howto/isolating-extensions.rst:375 msgid "" "static int my_traverse(PyObject *self, visitproc visit, void *arg)\n" "{\n" @@ -550,27 +573,27 @@ msgstr "" " return 0;\n" "}" -#: ../../howto/isolating-extensions.rst:366 +#: ../../howto/isolating-extensions.rst:383 msgid "" "Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a " "replacement, use:" msgstr "" -#: ../../howto/isolating-extensions.rst:369 +#: ../../howto/isolating-extensions.rst:386 msgid ":c:macro:`PY_VERSION_HEX`, if not using the stable ABI, or" msgstr "" -#: ../../howto/isolating-extensions.rst:370 +#: ../../howto/isolating-extensions.rst:387 msgid "" ":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` and :c:func:" "`PyArg_ParseTuple`)." msgstr "" -#: ../../howto/isolating-extensions.rst:375 +#: ../../howto/isolating-extensions.rst:392 msgid "Delegating ``tp_traverse``" msgstr "" -#: ../../howto/isolating-extensions.rst:377 +#: ../../howto/isolating-extensions.rst:394 msgid "" "If your traverse function delegates to the :c:member:`~PyTypeObject." "tp_traverse` of its base class (or another type), ensure that " @@ -578,19 +601,19 @@ msgid "" "expected to visit the type in ``tp_traverse``." msgstr "" -#: ../../howto/isolating-extensions.rst:382 +#: ../../howto/isolating-extensions.rst:399 msgid "For example, if your traverse function includes::" msgstr "" -#: ../../howto/isolating-extensions.rst:384 +#: ../../howto/isolating-extensions.rst:401 msgid "base->tp_traverse(self, visit, arg)" msgstr "base->tp_traverse(self, visit, arg)" -#: ../../howto/isolating-extensions.rst:386 +#: ../../howto/isolating-extensions.rst:403 msgid "...and ``base`` may be a static type, then it should also include::" msgstr "" -#: ../../howto/isolating-extensions.rst:388 +#: ../../howto/isolating-extensions.rst:405 msgid "" "if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" " // a heap type's tp_traverse already visited Py_TYPE(self)\n" @@ -601,38 +624,38 @@ msgid "" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:396 +#: ../../howto/isolating-extensions.rst:413 msgid "" "It is not necessary to handle the type's reference count in :c:member:" "`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../howto/isolating-extensions.rst:401 +#: ../../howto/isolating-extensions.rst:418 msgid "Defining ``tp_dealloc``" msgstr "" -#: ../../howto/isolating-extensions.rst:403 +#: ../../howto/isolating-extensions.rst:420 msgid "" "If your type has a custom :c:member:`~PyTypeObject.tp_dealloc` function, it " "needs to:" msgstr "" -#: ../../howto/isolating-extensions.rst:406 +#: ../../howto/isolating-extensions.rst:423 msgid "" "call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and" msgstr "" -#: ../../howto/isolating-extensions.rst:407 +#: ../../howto/isolating-extensions.rst:424 msgid "decrement the reference count of the type." msgstr "" -#: ../../howto/isolating-extensions.rst:409 +#: ../../howto/isolating-extensions.rst:426 msgid "" "To keep the type valid while ``tp_free`` is called, the type's refcount " "needs to be decremented *after* the instance is deallocated. For example::" msgstr "" -#: ../../howto/isolating-extensions.rst:412 +#: ../../howto/isolating-extensions.rst:429 msgid "" "static void my_dealloc(PyObject *self)\n" "{\n" @@ -652,57 +675,57 @@ msgstr "" " Py_DECREF(type);\n" "}" -#: ../../howto/isolating-extensions.rst:421 +#: ../../howto/isolating-extensions.rst:438 msgid "" "The default ``tp_dealloc`` function does this, so if your type does *not* " "override ``tp_dealloc`` you don't need to add it." msgstr "" -#: ../../howto/isolating-extensions.rst:427 +#: ../../howto/isolating-extensions.rst:444 msgid "Not overriding ``tp_free``" msgstr "" -#: ../../howto/isolating-extensions.rst:429 +#: ../../howto/isolating-extensions.rst:446 msgid "" "The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set to :c:" "func:`PyObject_GC_Del`. This is the default; do not override it." msgstr "" -#: ../../howto/isolating-extensions.rst:435 +#: ../../howto/isolating-extensions.rst:452 msgid "Avoiding ``PyObject_New``" msgstr "" -#: ../../howto/isolating-extensions.rst:437 +#: ../../howto/isolating-extensions.rst:454 msgid "GC-tracked objects need to be allocated using GC-aware functions." msgstr "" -#: ../../howto/isolating-extensions.rst:439 -msgid "If you use use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:" +#: ../../howto/isolating-extensions.rst:456 +msgid "If you use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:" msgstr "" -#: ../../howto/isolating-extensions.rst:441 +#: ../../howto/isolating-extensions.rst:458 msgid "" "Get and call type's :c:member:`~PyTypeObject.tp_alloc` slot, if possible. " "That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::" msgstr "" -#: ../../howto/isolating-extensions.rst:444 +#: ../../howto/isolating-extensions.rst:461 msgid "TYPE *o = typeobj->tp_alloc(typeobj, 0);" msgstr "TYPE *o = typeobj->tp_alloc(typeobj, 0);" -#: ../../howto/isolating-extensions.rst:446 +#: ../../howto/isolating-extensions.rst:463 msgid "" "Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use " "size instead of the 0." msgstr "" -#: ../../howto/isolating-extensions.rst:449 +#: ../../howto/isolating-extensions.rst:466 msgid "" "If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:" "func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::" msgstr "" -#: ../../howto/isolating-extensions.rst:452 +#: ../../howto/isolating-extensions.rst:469 msgid "" "TYPE *o = PyObject_GC_New(TYPE, typeobj);\n" "\n" @@ -712,24 +735,24 @@ msgstr "" "\n" "TYPE *o = PyObject_GC_NewVar(TYPE, typeobj, size);" -#: ../../howto/isolating-extensions.rst:458 +#: ../../howto/isolating-extensions.rst:475 msgid "Module State Access from Classes" msgstr "" -#: ../../howto/isolating-extensions.rst:460 +#: ../../howto/isolating-extensions.rst:477 msgid "" "If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, " "you can call :c:func:`PyType_GetModule` to get the associated module, and " "then :c:func:`PyModule_GetState` to get the module's state." msgstr "" -#: ../../howto/isolating-extensions.rst:464 +#: ../../howto/isolating-extensions.rst:481 msgid "" "To save a some tedious error-handling boilerplate code, you can combine " "these two steps with :c:func:`PyType_GetModuleState`, resulting in::" msgstr "" -#: ../../howto/isolating-extensions.rst:467 +#: ../../howto/isolating-extensions.rst:484 msgid "" "my_struct *state = (my_struct*)PyType_GetModuleState(type);\n" "if (state == NULL) {\n" @@ -741,11 +764,11 @@ msgstr "" " return NULL;\n" "}" -#: ../../howto/isolating-extensions.rst:474 +#: ../../howto/isolating-extensions.rst:491 msgid "Module State Access from Regular Methods" msgstr "" -#: ../../howto/isolating-extensions.rst:476 +#: ../../howto/isolating-extensions.rst:493 msgid "" "Accessing the module-level state from methods of a class is somewhat more " "complicated, but is possible thanks to API introduced in Python 3.9. To get " @@ -753,27 +776,27 @@ msgid "" "module state from it." msgstr "" -#: ../../howto/isolating-extensions.rst:481 +#: ../../howto/isolating-extensions.rst:498 msgid "" "The largest roadblock is getting *the class a method was defined in*, or " "that method's \"defining class\" for short. The defining class can have a " "reference to the module it is part of." msgstr "" -#: ../../howto/isolating-extensions.rst:485 +#: ../../howto/isolating-extensions.rst:502 msgid "" "Do not confuse the defining class with ``Py_TYPE(self)``. If the method is " "called on a *subclass* of your type, ``Py_TYPE(self)`` will refer to that " "subclass, which may be defined in different module than yours." msgstr "" -#: ../../howto/isolating-extensions.rst:490 +#: ../../howto/isolating-extensions.rst:507 msgid "" "The following Python code can illustrate the concept. ``Base." "get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:" msgstr "" -#: ../../howto/isolating-extensions.rst:494 +#: ../../howto/isolating-extensions.rst:511 msgid "" "class Base:\n" " def get_type_of_self(self):\n" @@ -795,7 +818,7 @@ msgstr "" "class Sub(Base):\n" " pass" -#: ../../howto/isolating-extensions.rst:506 +#: ../../howto/isolating-extensions.rst:523 msgid "" "For a method to get its \"defining class\", it must use the :ref:" "`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `__." msgstr "" -#: ../../howto/isolating-extensions.rst:617 +#: ../../howto/isolating-extensions.rst:634 msgid "Per-Class Scope" msgstr "" -#: ../../howto/isolating-extensions.rst:619 +#: ../../howto/isolating-extensions.rst:636 msgid "" "It is currently (as of Python 3.11) not possible to attach state to " "individual *types* without relying on CPython implementation details (which " @@ -946,11 +969,11 @@ msgid "" "per-class scope)." msgstr "" -#: ../../howto/isolating-extensions.rst:626 +#: ../../howto/isolating-extensions.rst:643 msgid "Lossless Conversion to Heap Types" msgstr "" -#: ../../howto/isolating-extensions.rst:628 +#: ../../howto/isolating-extensions.rst:645 msgid "" "The heap type API was not designed for \"lossless\" conversion from static " "types; that is, creating a type that works exactly like a given static type." diff --git a/howto/regex.po b/howto/regex.po index b261243bd7..782ee533c4 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: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -120,12 +120,12 @@ msgstr "" #: ../../howto/regex.rst:70 msgid "" -"There are exceptions to this rule; some characters are " -"special :dfn:`metacharacters`, and don't match themselves. Instead, they " -"signal that some out-of-the-ordinary thing should be matched, or they affect " -"other portions of the RE by repeating them or changing their meaning. Much " -"of this document is devoted to discussing various metacharacters and what " -"they do." +"There are exceptions to this rule; some characters are special :dfn:" +"`metacharacters`, and don't match themselves. Instead, they signal that " +"some out-of-the-ordinary thing should be matched, or they affect other " +"portions of the RE by repeating them or changing their meaning. Much of " +"this document is devoted to discussing various metacharacters and what they " +"do." msgstr "" #: ../../howto/regex.rst:76 @@ -160,12 +160,12 @@ msgstr "" #: ../../howto/regex.rst:97 msgid "" -"You can match the characters not listed within the class " -"by :dfn:`complementing` the set. This is indicated by including a ``'^'`` " -"as the first character of the class. For example, ``[^5]`` will match any " -"character except ``'5'``. If the caret appears elsewhere in a character " -"class, it does not have special meaning. For example: ``[5^]`` will match " -"either a ``'5'`` or a ``'^'``." +"You can match the characters not listed within the class by :dfn:" +"`complementing` the set. This is indicated by including a ``'^'`` as the " +"first character of the class. For example, ``[^5]`` will match any character " +"except ``'5'``. If the caret appears elsewhere in a character class, it " +"does not have special meaning. For example: ``[5^]`` will match either a " +"``'5'`` or a ``'^'``." msgstr "" #: ../../howto/regex.rst:103 @@ -190,10 +190,10 @@ msgid "" "Let's take an example: ``\\w`` matches any alphanumeric character. If the " "regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-" "Z0-9_]``. If the regex pattern is a string, ``\\w`` will match all the " -"characters marked as letters in the Unicode database provided by " -"the :mod:`unicodedata` module. You can use the more restricted definition " -"of ``\\w`` in a string pattern by supplying the :const:`re.ASCII` flag when " -"compiling the regular expression." +"characters marked as letters in the Unicode database provided by the :mod:" +"`unicodedata` module. You can use the more restricted definition of ``\\w`` " +"in a string pattern by supplying the :const:`re.ASCII` flag when compiling " +"the regular expression." msgstr "" #: ../../howto/regex.rst:123 @@ -272,9 +272,9 @@ msgstr "" #: ../../howto/regex.rst:156 msgid "" "The final metacharacter in this section is ``.``. It matches anything " -"except a newline character, and there's an alternate mode " -"(:const:`re.DOTALL`) where it will match even a newline. ``.`` is often " -"used where you want to match \"any character\"." +"except a newline character, and there's an alternate mode (:const:`re." +"DOTALL`) where it will match even a newline. ``.`` is often used where you " +"want to match \"any character\"." msgstr "" #: ../../howto/regex.rst:163 @@ -524,8 +524,8 @@ msgid "" "and no special syntax was created for expressing them. (There are " "applications that don't need REs at all, so there's no need to bloat the " "language specification by including them.) Instead, the :mod:`re` module is " -"simply a C extension module included with Python, just like " -"the :mod:`socket` or :mod:`zlib` modules." +"simply a C extension module included with Python, just like the :mod:" +"`socket` or :mod:`zlib` modules." msgstr "" #: ../../howto/regex.rst:292 @@ -612,10 +612,10 @@ msgstr "" #: ../../howto/regex.rst:336 msgid "" "In addition, special escape sequences that are valid in regular expressions, " -"but not valid as Python string literals, now result in " -"a :exc:`DeprecationWarning` and will eventually become a :exc:`SyntaxError`, " -"which means the sequences will be invalid if raw string notation or escaping " -"the backslashes isn't used." +"but not valid as Python string literals, now result in a :exc:" +"`DeprecationWarning` and will eventually become a :exc:`SyntaxError`, which " +"means the sequences will be invalid if raw string notation or escaping the " +"backslashes isn't used." msgstr "" #: ../../howto/regex.rst:344 @@ -659,12 +659,12 @@ msgid "" msgstr "" #: ../../howto/regex.rst:363 ../../howto/regex.rst:417 -#: ../../howto/regex.rst:1065 +#: ../../howto/regex.rst:1069 msgid "Method/Attribute" msgstr "方法/屬性" #: ../../howto/regex.rst:363 ../../howto/regex.rst:417 -#: ../../howto/regex.rst:1065 +#: ../../howto/regex.rst:1069 msgid "Purpose" msgstr "" @@ -698,8 +698,8 @@ msgstr "``finditer()``" #: ../../howto/regex.rst:374 msgid "" -"Find all substrings where the RE matches, and returns them as " -"an :term:`iterator`." +"Find all substrings where the RE matches, and returns them as an :term:" +"`iterator`." msgstr "" #: ../../howto/regex.rst:378 @@ -831,11 +831,11 @@ msgstr "" #: ../../howto/regex.rst:438 msgid "" -":meth:`~re.Match.group` returns the substring that was matched by the " -"RE. :meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting " -"and ending index of the match. :meth:`~re.Match.span` returns both start and " -"end indexes in a single tuple. Since the :meth:`~re.Pattern.match` method " -"only checks if the RE matches at the start of a string, :meth:`!start` will " +":meth:`~re.Match.group` returns the substring that was matched by the RE. :" +"meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting and " +"ending index of the match. :meth:`~re.Match.span` returns both start and end " +"indexes in a single tuple. Since the :meth:`~re.Pattern.match` method only " +"checks if the RE matches at the start of a string, :meth:`!start` will " "always be zero. However, the :meth:`~re.Pattern.search` method of patterns " "scans through the string, so the match may not start at zero in that " "case. ::" @@ -886,8 +886,8 @@ msgstr "" #: ../../howto/regex.rst:466 msgid "" -"Two pattern methods return all of the matches for a " -"pattern. :meth:`~re.Pattern.findall` returns a list of matching strings::" +"Two pattern methods return all of the matches for a pattern. :meth:`~re." +"Pattern.findall` returns a list of matching strings::" msgstr "" #: ../../howto/regex.rst:469 @@ -905,16 +905,16 @@ msgid "" "The ``r`` prefix, making the literal a raw string literal, is needed in this " "example because escape sequences in a normal \"cooked\" string literal that " "are not recognized by Python, as opposed to regular expressions, now result " -"in a :exc:`DeprecationWarning` and will eventually become " -"a :exc:`SyntaxError`. See :ref:`the-backslash-plague`." +"in a :exc:`DeprecationWarning` and will eventually become a :exc:" +"`SyntaxError`. See :ref:`the-backslash-plague`." msgstr "" #: ../../howto/regex.rst:479 msgid "" ":meth:`~re.Pattern.findall` has to create the entire list before it can be " "returned as the result. The :meth:`~re.Pattern.finditer` method returns a " -"sequence of :ref:`match object ` instances as " -"an :term:`iterator`::" +"sequence of :ref:`match object ` instances as an :term:" +"`iterator`::" msgstr "" #: ../../howto/regex.rst:483 @@ -945,12 +945,12 @@ msgstr "模組層級函式" #: ../../howto/regex.rst:497 msgid "" -"You don't have to create a pattern object and call its methods; " -"the :mod:`re` module also provides top-level functions " -"called :func:`~re.match`, :func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, " -"and so forth. These functions take the same arguments as the corresponding " -"pattern method with the RE string added as the first argument, and still " -"return either ``None`` or a :ref:`match object ` instance. ::" +"You don't have to create a pattern object and call its methods; the :mod:" +"`re` module also provides top-level functions called :func:`~re.match`, :" +"func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, and so forth. " +"These functions take the same arguments as the corresponding pattern method " +"with the RE string added as the first argument, and still return either " +"``None`` or a :ref:`match object ` instance. ::" msgstr "" #: ../../howto/regex.rst:504 @@ -989,12 +989,12 @@ msgstr "" msgid "" "Compilation flags let you modify some aspects of how regular expressions " "work. Flags are available in the :mod:`re` module under two names, a long " -"name such as :const:`IGNORECASE` and a short, one-letter form such " -"as :const:`I`. (If you're familiar with Perl's pattern modifiers, the one-" -"letter forms use the same letters; the short form of :const:`re.VERBOSE` " -"is :const:`re.X`, for example.) Multiple flags can be specified by bitwise " -"OR-ing them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, " -"for example." +"name such as :const:`IGNORECASE` and a short, one-letter form such as :const:" +"`I`. (If you're familiar with Perl's pattern modifiers, the one-letter " +"forms use the same letters; the short form of :const:`re.VERBOSE` is :const:" +"`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing " +"them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for " +"example." msgstr "" #: ../../howto/regex.rst:534 @@ -1069,13 +1069,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 @@ -1245,9 +1245,9 @@ msgstr "``^``" #: ../../howto/regex.rst:707 msgid "" "Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has " -"been set, this will only match at the beginning of the string. " -"In :const:`MULTILINE` mode, this also matches immediately after each newline " -"within the string." +"been set, this will only match at the beginning of the string. In :const:" +"`MULTILINE` mode, this also matches immediately after each newline within " +"the string." msgstr "" #: ../../howto/regex.rst:711 @@ -1459,12 +1459,12 @@ msgstr "" msgid "" "Groups indicated with ``'('``, ``')'`` also capture the starting and ending " "index of the text that they match; this can be retrieved by passing an " -"argument " -"to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re.Match.end`, " -"and :meth:`~re.Match.span`. Groups are numbered starting with 0. Group 0 " -"is always present; it's the whole RE, so :ref:`match object ` " -"methods all have group 0 as their default argument. Later we'll see how to " -"express groups that don't capture the span of text that they match. ::" +"argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re." +"Match.end`, and :meth:`~re.Match.span`. Groups are numbered starting with " +"0. Group 0 is always present; it's the whole RE, so :ref:`match object " +"` methods all have group 0 as their default argument. Later " +"we'll see how to express groups that don't capture the span of text that " +"they match. ::" msgstr "" #: ../../howto/regex.rst:824 @@ -1693,8 +1693,8 @@ msgstr "" #: ../../howto/regex.rst:946 msgid "" -"Additionally, you can retrieve named groups as a dictionary " -"with :meth:`~re.Match.groupdict`::" +"Additionally, you can retrieve named groups as a dictionary with :meth:`~re." +"Match.groupdict`::" msgstr "" #: ../../howto/regex.rst:949 @@ -1710,8 +1710,8 @@ msgstr "" #: ../../howto/regex.rst:953 msgid "" "Named groups are handy because they let you use easily remembered names, " -"instead of having to remember numbers. Here's an example RE from " -"the :mod:`imaplib` module::" +"instead of having to remember numbers. Here's an example RE from the :mod:" +"`imaplib` module::" msgstr "" #: ../../howto/regex.rst:957 @@ -1743,8 +1743,8 @@ msgid "" "name instead of the number. This is another Python extension: ``(?P=name)`` " "indicates that the contents of the group called *name* should again be " "matched at the current point. The regular expression for finding doubled " -"words, ``\\b(\\w+)\\s+\\1\\b`` can also be written as ``\\b(?P\\w+)\\s+" -"(?P=word)\\b``::" +"words, ``\\b(\\w+)\\s+\\1\\b`` can also be written as ``\\b(?" +"P\\w+)\\s+(?P=word)\\b``::" msgstr "" #: ../../howto/regex.rst:974 @@ -1825,39 +1825,43 @@ msgid "" msgstr "" #: ../../howto/regex.rst:1016 +msgid "``.*[.][^b].*$``" +msgstr "``.*[.][^b].*$``" + +#: ../../howto/regex.rst:1018 msgid "" -"``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by " -"requiring that the first character of the extension is not a ``b``. This is " -"wrong, because the pattern also doesn't match ``foo.bar``." +"The first attempt above tries to exclude ``bat`` by requiring that the first " +"character of the extension is not a ``b``. This is wrong, because the " +"pattern also doesn't match ``foo.bar``." msgstr "" -#: ../../howto/regex.rst:1020 +#: ../../howto/regex.rst:1022 msgid "``.*[.]([^b]..|.[^a].|..[^t])$``" msgstr "``.*[.]([^b]..|.[^a].|..[^t])$``" -#: ../../howto/regex.rst:1022 +#: ../../howto/regex.rst:1024 msgid "" "The expression gets messier when you try to patch up the first solution by " "requiring one of the following cases to match: the first character of the " "extension isn't ``b``; the second character isn't ``a``; or the third " -"character isn't ``t``. This accepts ``foo.bar`` and rejects " -"``autoexec.bat``, but it requires a three-letter extension and won't accept " -"a filename with a two-letter extension such as ``sendmail.cf``. We'll " -"complicate the pattern again in an effort to fix it." +"character isn't ``t``. This accepts ``foo.bar`` and rejects ``autoexec." +"bat``, but it requires a three-letter extension and won't accept a filename " +"with a two-letter extension such as ``sendmail.cf``. We'll complicate the " +"pattern again in an effort to fix it." msgstr "" -#: ../../howto/regex.rst:1030 +#: ../../howto/regex.rst:1032 msgid "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" msgstr "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" -#: ../../howto/regex.rst:1032 +#: ../../howto/regex.rst:1034 msgid "" "In the third attempt, the second and third letters are all made optional in " "order to allow matching extensions shorter than three characters, such as " "``sendmail.cf``." msgstr "" -#: ../../howto/regex.rst:1036 +#: ../../howto/regex.rst:1038 msgid "" "The pattern's getting really complicated now, which makes it hard to read " "and understand. Worse, if the problem changes and you want to exclude both " @@ -1865,75 +1869,79 @@ msgid "" "complicated and confusing." msgstr "" -#: ../../howto/regex.rst:1041 +#: ../../howto/regex.rst:1043 msgid "A negative lookahead cuts through all this confusion:" msgstr "" -#: ../../howto/regex.rst:1043 +#: ../../howto/regex.rst:1045 +msgid "``.*[.](?!bat$)[^.]*$``" +msgstr "``.*[.](?!bat$)[^.]*$``" + +#: ../../howto/regex.rst:1047 msgid "" -"``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression " -"``bat`` doesn't match at this point, try the rest of the pattern; if " -"``bat$`` does match, the whole pattern will fail. The trailing ``$`` is " -"required to ensure that something like ``sample.batch``, where the extension " -"only starts with ``bat``, will be allowed. The ``[^.]*`` makes sure that " -"the pattern works when there are multiple dots in the filename." +"The negative lookahead means: if the expression ``bat`` doesn't match at " +"this point, try the rest of the pattern; if ``bat$`` does match, the whole " +"pattern will fail. The trailing ``$`` is required to ensure that something " +"like ``sample.batch``, where the extension only starts with ``bat``, will be " +"allowed. The ``[^.]*`` makes sure that the pattern works when there are " +"multiple dots in the filename." msgstr "" -#: ../../howto/regex.rst:1050 +#: ../../howto/regex.rst:1054 msgid "" "Excluding another filename extension is now easy; simply add it as an " "alternative inside the assertion. The following pattern excludes filenames " "that end in either ``bat`` or ``exe``:" msgstr "" -#: ../../howto/regex.rst:1054 +#: ../../howto/regex.rst:1058 msgid "``.*[.](?!bat$|exe$)[^.]*$``" msgstr "``.*[.](?!bat$|exe$)[^.]*$``" -#: ../../howto/regex.rst:1058 +#: ../../howto/regex.rst:1062 msgid "Modifying Strings" msgstr "" -#: ../../howto/regex.rst:1060 +#: ../../howto/regex.rst:1064 msgid "" "Up to this point, we've simply performed searches against a static string. " "Regular expressions are also commonly used to modify strings in various " "ways, using the following pattern methods:" msgstr "" -#: ../../howto/regex.rst:1067 +#: ../../howto/regex.rst:1071 msgid "``split()``" msgstr "``split()``" -#: ../../howto/regex.rst:1067 +#: ../../howto/regex.rst:1071 msgid "Split the string into a list, splitting it wherever the RE matches" msgstr "" -#: ../../howto/regex.rst:1070 +#: ../../howto/regex.rst:1074 msgid "``sub()``" msgstr "``sub()``" -#: ../../howto/regex.rst:1070 +#: ../../howto/regex.rst:1074 msgid "" "Find all substrings where the RE matches, and replace them with a different " "string" msgstr "" -#: ../../howto/regex.rst:1073 +#: ../../howto/regex.rst:1077 msgid "``subn()``" msgstr "``subn()``" -#: ../../howto/regex.rst:1073 +#: ../../howto/regex.rst:1077 msgid "" "Does the same thing as :meth:`!sub`, but returns the new string and the " "number of replacements" msgstr "" -#: ../../howto/regex.rst:1080 +#: ../../howto/regex.rst:1084 msgid "Splitting Strings" msgstr "" -#: ../../howto/regex.rst:1082 +#: ../../howto/regex.rst:1086 msgid "" "The :meth:`~re.Pattern.split` method of a pattern splits a string apart " "wherever the RE matches, returning a list of the pieces. It's similar to " @@ -1943,7 +1951,7 @@ msgid "" "module-level :func:`re.split` function, too." msgstr "" -#: ../../howto/regex.rst:1093 +#: ../../howto/regex.rst:1097 msgid "" "Split *string* by the matches of the regular expression. If capturing " "parentheses are used in the RE, then their contents will also be returned as " @@ -1951,7 +1959,7 @@ msgid "" "splits are performed." msgstr "" -#: ../../howto/regex.rst:1098 +#: ../../howto/regex.rst:1102 msgid "" "You can limit the number of splits made, by passing a value for *maxsplit*. " "When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the " @@ -1960,7 +1968,7 @@ msgid "" "characters. ::" msgstr "" -#: ../../howto/regex.rst:1104 +#: ../../howto/regex.rst:1108 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p.split('This is a test, short and sweet, of split().')\n" @@ -1974,7 +1982,7 @@ msgstr "" ">>> p.split('This is a test, short and sweet, of split().', 3)\n" "['This', 'is', 'a', 'test, short and sweet, of split().']" -#: ../../howto/regex.rst:1110 +#: ../../howto/regex.rst:1114 msgid "" "Sometimes you're not only interested in what the text between delimiters is, " "but also need to know what the delimiter was. If capturing parentheses are " @@ -1982,7 +1990,7 @@ msgid "" "Compare the following calls::" msgstr "" -#: ../../howto/regex.rst:1115 +#: ../../howto/regex.rst:1119 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p2 = re.compile(r'(\\W+)')\n" @@ -1998,13 +2006,13 @@ msgstr "" ">>> p2.split('This... is a test.')\n" "['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']" -#: ../../howto/regex.rst:1122 +#: ../../howto/regex.rst:1126 msgid "" "The module-level function :func:`re.split` adds the RE to be used as the " "first argument, but is otherwise the same. ::" msgstr "" -#: ../../howto/regex.rst:1125 +#: ../../howto/regex.rst:1129 msgid "" ">>> re.split(r'[\\W]+', 'Words, words, words.')\n" "['Words', 'words', 'words', '']\n" @@ -2020,11 +2028,11 @@ msgstr "" ">>> re.split(r'[\\W]+', 'Words, words, words.', 1)\n" "['Words', 'words, words.']" -#: ../../howto/regex.rst:1134 +#: ../../howto/regex.rst:1138 msgid "Search and Replace" msgstr "" -#: ../../howto/regex.rst:1136 +#: ../../howto/regex.rst:1140 msgid "" "Another common task is to find all the matches for a pattern, and replace " "them with a different string. The :meth:`~re.Pattern.sub` method takes a " @@ -2032,27 +2040,27 @@ msgid "" "string to be processed." msgstr "" -#: ../../howto/regex.rst:1143 +#: ../../howto/regex.rst:1147 msgid "" "Returns the string obtained by replacing the leftmost non-overlapping " "occurrences of the RE in *string* by the replacement *replacement*. If the " "pattern isn't found, *string* is returned unchanged." msgstr "" -#: ../../howto/regex.rst:1147 +#: ../../howto/regex.rst:1151 msgid "" "The optional argument *count* is the maximum number of pattern occurrences " "to be replaced; *count* must be a non-negative integer. The default value " "of 0 means to replace all occurrences." msgstr "" -#: ../../howto/regex.rst:1151 +#: ../../howto/regex.rst:1155 msgid "" "Here's a simple example of using the :meth:`~re.Pattern.sub` method. It " "replaces colour names with the word ``colour``::" msgstr "" -#: ../../howto/regex.rst:1154 +#: ../../howto/regex.rst:1158 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.sub('colour', 'blue socks and red shoes')\n" @@ -2066,14 +2074,14 @@ msgstr "" ">>> p.sub('colour', 'blue socks and red shoes', count=1)\n" "'colour socks and red shoes'" -#: ../../howto/regex.rst:1160 +#: ../../howto/regex.rst:1164 msgid "" "The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-" "tuple containing the new string value and the number of replacements that " "were performed::" msgstr "" -#: ../../howto/regex.rst:1163 +#: ../../howto/regex.rst:1167 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.subn('colour', 'blue socks and red shoes')\n" @@ -2087,13 +2095,13 @@ msgstr "" ">>> p.subn('colour', 'no colours at all')\n" "('no colours at all', 0)" -#: ../../howto/regex.rst:1169 +#: ../../howto/regex.rst:1173 msgid "" "Empty matches are replaced only when they're not adjacent to a previous " "empty match. ::" msgstr "" -#: ../../howto/regex.rst:1172 +#: ../../howto/regex.rst:1176 msgid "" ">>> p = re.compile('x*')\n" ">>> p.sub('-', 'abxd')\n" @@ -2103,7 +2111,7 @@ msgstr "" ">>> p.sub('-', 'abxd')\n" "'-a-b--d-'" -#: ../../howto/regex.rst:1176 +#: ../../howto/regex.rst:1180 msgid "" "If *replacement* is a string, any backslash escapes in it are processed. " "That is, ``\\n`` is converted to a single newline character, ``\\r`` is " @@ -2114,13 +2122,13 @@ msgid "" "string." msgstr "" -#: ../../howto/regex.rst:1183 +#: ../../howto/regex.rst:1187 msgid "" "This example matches the word ``section`` followed by a string enclosed in " "``{``, ``}``, and changes ``section`` to ``subsection``::" msgstr "" -#: ../../howto/regex.rst:1186 +#: ../../howto/regex.rst:1190 msgid "" ">>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" @@ -2130,7 +2138,7 @@ msgstr "" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" "'subsection{First} subsection{second}'" -#: ../../howto/regex.rst:1190 +#: ../../howto/regex.rst:1194 msgid "" "There's also a syntax for referring to named groups as defined by the ``(?" "P...)`` syntax. ``\\g`` will use the substring matched by the " @@ -2142,7 +2150,7 @@ msgid "" "but use all three variations of the replacement string. ::" msgstr "" -#: ../../howto/regex.rst:1199 +#: ../../howto/regex.rst:1203 msgid "" ">>> p = re.compile('section{ (?P [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First}')\n" @@ -2160,7 +2168,7 @@ msgstr "" ">>> p.sub(r'subsection{\\g}','section{First}')\n" "'subsection{First}'" -#: ../../howto/regex.rst:1207 +#: ../../howto/regex.rst:1211 msgid "" "*replacement* can also be a function, which gives you even more control. If " "*replacement* is a function, the function is called for every non-" @@ -2169,13 +2177,13 @@ msgid "" "this information to compute the desired replacement string and return it." msgstr "" -#: ../../howto/regex.rst:1213 +#: ../../howto/regex.rst:1217 msgid "" "In the following example, the replacement function translates decimals into " "hexadecimal::" msgstr "" -#: ../../howto/regex.rst:1216 +#: ../../howto/regex.rst:1220 msgid "" ">>> def hexrepl(match):\n" "... \"Return the hex string for a decimal number\"\n" @@ -2187,7 +2195,7 @@ msgid "" "'Call 0xffd2 for printing, 0xc000 for user code.'" msgstr "" -#: ../../howto/regex.rst:1225 +#: ../../howto/regex.rst:1229 msgid "" "When using the module-level :func:`re.sub` function, the pattern is passed " "as the first argument. The pattern may be provided as an object or as a " @@ -2197,11 +2205,11 @@ msgid "" "x'``." msgstr "" -#: ../../howto/regex.rst:1233 +#: ../../howto/regex.rst:1237 msgid "Common Problems" msgstr "" -#: ../../howto/regex.rst:1235 +#: ../../howto/regex.rst:1239 msgid "" "Regular expressions are a powerful tool for some applications, but in some " "ways their behaviour isn't intuitive and at times they don't behave the way " @@ -2209,23 +2217,23 @@ msgid "" "pitfalls." msgstr "" -#: ../../howto/regex.rst:1241 +#: ../../howto/regex.rst:1245 msgid "Use String Methods" msgstr "" -#: ../../howto/regex.rst:1243 +#: ../../howto/regex.rst:1247 msgid "" "Sometimes using the :mod:`re` module is a mistake. If you're matching a " -"fixed string, or a single character class, and you're not using " -"any :mod:`re` features such as the :const:`~re.IGNORECASE` flag, then the " -"full power of regular expressions may not be required. Strings have several " -"methods for performing operations with fixed strings and they're usually " -"much faster, because the implementation is a single small C loop that's been " -"optimized for the purpose, instead of the large, more generalized regular " -"expression engine." +"fixed string, or a single character class, and you're not using any :mod:" +"`re` features such as the :const:`~re.IGNORECASE` flag, then the full power " +"of regular expressions may not be required. Strings have several methods for " +"performing operations with fixed strings and they're usually much faster, " +"because the implementation is a single small C loop that's been optimized " +"for the purpose, instead of the large, more generalized regular expression " +"engine." msgstr "" -#: ../../howto/regex.rst:1251 +#: ../../howto/regex.rst:1255 msgid "" "One example might be replacing a single fixed string with another one; for " "example, you might replace ``word`` with ``deed``. :func:`re.sub` seems " @@ -2234,11 +2242,11 @@ msgid "" "turning ``swordfish`` into ``sdeedfish``, but the naive RE ``word`` would " "have done that, too. (To avoid performing the substitution on parts of " "words, the pattern would have to be ``\\bword\\b``, in order to require that " -"``word`` have a word boundary on either side. This takes the job " -"beyond :meth:`!replace`'s abilities.)" +"``word`` have a word boundary on either side. This takes the job beyond :" +"meth:`!replace`'s abilities.)" msgstr "" -#: ../../howto/regex.rst:1260 +#: ../../howto/regex.rst:1264 msgid "" "Another common task is deleting every occurrence of a single character from " "a string or replacing it with another single character. You might do this " @@ -2247,17 +2255,17 @@ msgid "" "operation can be." msgstr "" -#: ../../howto/regex.rst:1266 +#: ../../howto/regex.rst:1270 msgid "" "In short, before turning to the :mod:`re` module, consider whether your " "problem can be solved with a faster and simpler string method." msgstr "" -#: ../../howto/regex.rst:1271 +#: ../../howto/regex.rst:1275 msgid "match() versus search()" msgstr "" -#: ../../howto/regex.rst:1273 +#: ../../howto/regex.rst:1277 msgid "" "The :func:`~re.match` function only checks if the RE matches at the " "beginning of the string while :func:`~re.search` will scan forward through " @@ -2267,7 +2275,7 @@ msgid "" "report it. ::" msgstr "" -#: ../../howto/regex.rst:1279 +#: ../../howto/regex.rst:1283 msgid "" ">>> print(re.match('super', 'superstition').span())\n" "(0, 5)\n" @@ -2279,13 +2287,13 @@ msgstr "" ">>> print(re.match('super', 'insuperable'))\n" "None" -#: ../../howto/regex.rst:1284 +#: ../../howto/regex.rst:1288 msgid "" "On the other hand, :func:`~re.search` will scan forward through the string, " "reporting the first match it finds. ::" msgstr "" -#: ../../howto/regex.rst:1287 +#: ../../howto/regex.rst:1291 msgid "" ">>> print(re.search('super', 'superstition').span())\n" "(0, 5)\n" @@ -2297,31 +2305,30 @@ msgstr "" ">>> print(re.search('super', 'insuperable').span())\n" "(2, 7)" -#: ../../howto/regex.rst:1292 +#: ../../howto/regex.rst:1296 msgid "" -"Sometimes you'll be tempted to keep using :func:`re.match`, and just add " -"``.*`` to the front of your RE. Resist this temptation and " -"use :func:`re.search` instead. The regular expression compiler does some " -"analysis of REs in order to speed up the process of looking for a match. " -"One such analysis figures out what the first character of a match must be; " -"for example, a pattern starting with ``Crow`` must match starting with a " -"``'C'``. The analysis lets the engine quickly scan through the string " -"looking for the starting character, only trying the full match if a ``'C'`` " -"is found." +"Sometimes you'll be tempted to keep using :func:`re.match`, and just add ``." +"*`` to the front of your RE. Resist this temptation and use :func:`re." +"search` instead. The regular expression compiler does some analysis of REs " +"in order to speed up the process of looking for a match. One such analysis " +"figures out what the first character of a match must be; for example, a " +"pattern starting with ``Crow`` must match starting with a ``'C'``. The " +"analysis lets the engine quickly scan through the string looking for the " +"starting character, only trying the full match if a ``'C'`` is found." msgstr "" -#: ../../howto/regex.rst:1301 +#: ../../howto/regex.rst:1305 msgid "" "Adding ``.*`` defeats this optimization, requiring scanning to the end of " "the string and then backtracking to find a match for the rest of the RE. " "Use :func:`re.search` instead." msgstr "" -#: ../../howto/regex.rst:1307 +#: ../../howto/regex.rst:1311 msgid "Greedy versus Non-Greedy" msgstr "" -#: ../../howto/regex.rst:1309 +#: ../../howto/regex.rst:1313 msgid "" "When repeating a regular expression, as in ``a*``, the resulting action is " "to consume as much of the pattern as possible. This fact often bites you " @@ -2330,7 +2337,7 @@ msgid "" "HTML tag doesn't work because of the greedy nature of ``.*``. ::" msgstr "" -#: ../../howto/regex.rst:1315 +#: ../../howto/regex.rst:1319 msgid "" ">>> s = 'Title'\n" ">>> len(s)\n" @@ -2348,7 +2355,7 @@ msgstr "" ">>> print(re.match('<.*>', s).group())\n" "Title" -#: ../../howto/regex.rst:1323 +#: ../../howto/regex.rst:1327 msgid "" "The RE matches the ``'<'`` in ``''``, and the ``.*`` consumes the rest " "of the string. There's still more left in the RE, though, and the ``>`` " @@ -2358,7 +2365,7 @@ msgid "" "``''``, which isn't what you want." msgstr "" -#: ../../howto/regex.rst:1330 +#: ../../howto/regex.rst:1334 msgid "" "In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?" "``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the " @@ -2367,7 +2374,7 @@ msgid "" "retrying the ``'>'`` at every step. This produces just the right result::" msgstr "" -#: ../../howto/regex.rst:1336 +#: ../../howto/regex.rst:1340 msgid "" ">>> print(re.match('<.*?>', s).group())\n" "" @@ -2375,7 +2382,7 @@ msgstr "" ">>> print(re.match('<.*?>', s).group())\n" "" -#: ../../howto/regex.rst:1339 +#: ../../howto/regex.rst:1343 msgid "" "(Note that parsing HTML or XML with regular expressions is painful. Quick-" "and-dirty patterns will handle common cases, but HTML and XML have special " @@ -2385,11 +2392,11 @@ msgid "" "such tasks.)" msgstr "" -#: ../../howto/regex.rst:1347 +#: ../../howto/regex.rst:1351 msgid "Using re.VERBOSE" msgstr "" -#: ../../howto/regex.rst:1349 +#: ../../howto/regex.rst:1353 msgid "" "By now you've probably noticed that regular expressions are a very compact " "notation, but they're not terribly readable. REs of moderate complexity can " @@ -2397,14 +2404,14 @@ msgid "" "making them difficult to read and understand." msgstr "" -#: ../../howto/regex.rst:1354 +#: ../../howto/regex.rst:1358 msgid "" "For such REs, specifying the :const:`re.VERBOSE` flag when compiling the " "regular expression can be helpful, because it allows you to format the " "regular expression more clearly." msgstr "" -#: ../../howto/regex.rst:1358 +#: ../../howto/regex.rst:1362 msgid "" "The ``re.VERBOSE`` flag has several effects. Whitespace in the regular " "expression that *isn't* inside a character class is ignored. This means " @@ -2415,7 +2422,7 @@ msgid "" "quoted strings, this enables REs to be formatted more neatly::" msgstr "" -#: ../../howto/regex.rst:1366 +#: ../../howto/regex.rst:1370 msgid "" "pat = re.compile(r\"\"\"\n" " \\s* # Skip leading whitespace\n" @@ -2427,19 +2434,19 @@ msgid "" "\"\"\", re.VERBOSE)" msgstr "" -#: ../../howto/regex.rst:1375 +#: ../../howto/regex.rst:1379 msgid "This is far more readable than::" msgstr "" -#: ../../howto/regex.rst:1377 +#: ../../howto/regex.rst:1381 msgid "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" msgstr "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" -#: ../../howto/regex.rst:1381 +#: ../../howto/regex.rst:1385 msgid "Feedback" msgstr "" -#: ../../howto/regex.rst:1383 +#: ../../howto/regex.rst:1387 msgid "" "Regular expressions are a complicated topic. Did this document help you " "understand them? Were there parts that were unclear, or Problems you " @@ -2447,7 +2454,7 @@ msgid "" "improvements to the author." msgstr "" -#: ../../howto/regex.rst:1388 +#: ../../howto/regex.rst:1392 msgid "" "The most complete book on regular expressions is almost certainly Jeffrey " "Friedl's Mastering Regular Expressions, published by O'Reilly. " diff --git a/howto/urllib2.po b/howto/urllib2.po index bff4e431ba..5763984962 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: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -43,11 +43,11 @@ msgstr "以下這些與 Python 有關的文章說不定能幫到你::" #: ../../howto/urllib2.rst:18 msgid "" -"`Basic Authentication `_" +"`Basic Authentication `_" msgstr "" -"`Basic Authentication `_" +"`Basic Authentication `_" #: ../../howto/urllib2.rst:20 msgid "A tutorial on *Basic Authentication*, with examples in Python." @@ -114,8 +114,8 @@ msgstr "" #: ../../howto/urllib2.rst:52 msgid "" "If you wish to retrieve a resource via URL and store it in a temporary " -"location, you can do so via the :func:`shutil.copyfileobj` " -"and :func:`tempfile.NamedTemporaryFile` functions::" +"location, you can do so via the :func:`shutil.copyfileobj` and :func:" +"`tempfile.NamedTemporaryFile` functions::" msgstr "" #: ../../howto/urllib2.rst:56 @@ -370,14 +370,14 @@ msgstr "" #: ../../howto/urllib2.rst:197 msgid "" "*urlopen* raises :exc:`~urllib.error.URLError` when it cannot handle a " -"response (though as usual with Python APIs, built-in exceptions such " -"as :exc:`ValueError`, :exc:`TypeError` etc. may also be raised)." +"response (though as usual with Python APIs, built-in exceptions such as :exc:" +"`ValueError`, :exc:`TypeError` etc. may also be raised)." msgstr "" #: ../../howto/urllib2.rst:201 msgid "" -":exc:`~urllib.error.HTTPError` is the subclass " -"of :exc:`~urllib.error.URLError` raised in the specific case of HTTP URLs." +":exc:`~urllib.error.HTTPError` is the subclass of :exc:`~urllib.error." +"URLError` raised in the specific case of HTTP URLs." msgstr "" #: ../../howto/urllib2.rst:204 @@ -427,9 +427,9 @@ msgid "" "request. The default handlers will handle some of these responses for you " "(for example, if the response is a \"redirection\" that requests the client " "fetch the document from a different URL, urllib will handle that for you). " -"For those it can't handle, urlopen will raise " -"an :exc:`~urllib.error.HTTPError`. Typical errors include '404' (page not " -"found), '403' (request forbidden), and '401' (authentication required)." +"For those it can't handle, urlopen will raise an :exc:`~urllib.error." +"HTTPError`. Typical errors include '404' (page not found), '403' (request " +"forbidden), and '401' (authentication required)." msgstr "" #: ../../howto/urllib2.rst:235 @@ -457,82 +457,37 @@ msgstr "" #: ../../howto/urllib2.rst:247 msgid "" ":attr:`http.server.BaseHTTPRequestHandler.responses` is a useful dictionary " -"of response codes in that shows all the response codes used by :rfc:`2616`. " -"The dictionary is reproduced here for convenience ::" +"of response codes that shows all the response codes used by :rfc:`2616`. An " +"excerpt from the dictionary is shown below ::" msgstr "" #: ../../howto/urllib2.rst:251 msgid "" -"# Table mapping response codes to messages; entries have the\n" -"# form {code: (shortmessage, longmessage)}.\n" "responses = {\n" -" 100: ('Continue', 'Request received, please continue'),\n" -" 101: ('Switching Protocols',\n" -" 'Switching to new protocol; obey Upgrade header'),\n" -"\n" -" 200: ('OK', 'Request fulfilled, document follows'),\n" -" 201: ('Created', 'Document created, URL follows'),\n" -" 202: ('Accepted',\n" -" 'Request accepted, processing continues off-line'),\n" -" 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),\n" -" 204: ('No Content', 'Request fulfilled, nothing follows'),\n" -" 205: ('Reset Content', 'Clear input form for further input.'),\n" -" 206: ('Partial Content', 'Partial content follows.'),\n" -"\n" -" 300: ('Multiple Choices',\n" -" 'Object has several resources -- see URI list'),\n" -" 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),\n" -" 302: ('Found', 'Object moved temporarily -- see URI list'),\n" -" 303: ('See Other', 'Object moved -- see Method and URL list'),\n" -" 304: ('Not Modified',\n" -" 'Document has not changed since given time'),\n" -" 305: ('Use Proxy',\n" -" 'You must use proxy specified in Location to access this '\n" -" 'resource.'),\n" -" 307: ('Temporary Redirect',\n" -" 'Object moved temporarily -- see URI list'),\n" -"\n" -" 400: ('Bad Request',\n" -" 'Bad request syntax or unsupported method'),\n" -" 401: ('Unauthorized',\n" -" 'No permission -- see authorization schemes'),\n" -" 402: ('Payment Required',\n" -" 'No payment -- see charging schemes'),\n" -" 403: ('Forbidden',\n" -" 'Request forbidden -- authorization will not help'),\n" -" 404: ('Not Found', 'Nothing matches the given URI'),\n" -" 405: ('Method Not Allowed',\n" -" 'Specified method is invalid for this server.'),\n" -" 406: ('Not Acceptable', 'URI not available in preferred format.'),\n" -" 407: ('Proxy Authentication Required', 'You must authenticate with '\n" -" 'this proxy before proceeding.'),\n" -" 408: ('Request Timeout', 'Request timed out; try again later.'),\n" -" 409: ('Conflict', 'Request conflict.'),\n" -" 410: ('Gone',\n" -" 'URI no longer exists and has been permanently removed.'),\n" -" 411: ('Length Required', 'Client must specify Content-Length.'),\n" -" 412: ('Precondition Failed', 'Precondition in headers is false.'),\n" -" 413: ('Request Entity Too Large', 'Entity is too large.'),\n" -" 414: ('Request-URI Too Long', 'URI is too long.'),\n" -" 415: ('Unsupported Media Type', 'Entity body in unsupported format.'),\n" -" 416: ('Requested Range Not Satisfiable',\n" -" 'Cannot satisfy request range.'),\n" -" 417: ('Expectation Failed',\n" -" 'Expect condition could not be satisfied.'),\n" -"\n" -" 500: ('Internal Server Error', 'Server got itself in trouble'),\n" -" 501: ('Not Implemented',\n" -" 'Server does not support this operation'),\n" -" 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),\n" -" 503: ('Service Unavailable',\n" -" 'The server cannot process the request due to a high load'),\n" -" 504: ('Gateway Timeout',\n" -" 'The gateway server did not receive a timely response'),\n" -" 505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),\n" +" ...\n" +" : ('OK', 'Request fulfilled, document follows'),\n" +" ...\n" +" : ('Forbidden',\n" +" 'Request forbidden -- authorization will " +"'\n" +" 'not help'),\n" +" : ('Not Found',\n" +" 'Nothing matches the given URI'),\n" +" ...\n" +" : (\"I'm a Teapot\",\n" +" 'Server refuses to brew coffee because " +"'\n" +" 'it is a teapot'),\n" +" ...\n" +" : ('Service Unavailable',\n" +" 'The server cannot process the " +"'\n" +" 'request due to a high load'),\n" +" ...\n" " }" msgstr "" -#: ../../howto/urllib2.rst:319 +#: ../../howto/urllib2.rst:271 msgid "" "When an error is raised the server responds by returning an HTTP error code " "*and* an error page. You can use the :exc:`~urllib.error.HTTPError` instance " @@ -541,7 +496,7 @@ msgid "" "``urllib.response`` module::" msgstr "" -#: ../../howto/urllib2.rst:324 +#: ../../howto/urllib2.rst:276 msgid "" ">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" ">>> try:\n" @@ -552,8 +507,8 @@ msgid "" "...\n" "404\n" "b'\\n\\n\\n\\n\\n\\nPage Not Found\\n\n" " ..." @@ -567,28 +522,28 @@ msgstr "" "...\n" "404\n" "b'\\n\\n\\n\\n\\n\\nPage Not Found\\n\n" " ..." -#: ../../howto/urllib2.rst:339 +#: ../../howto/urllib2.rst:291 msgid "Wrapping it Up" msgstr "" -#: ../../howto/urllib2.rst:341 +#: ../../howto/urllib2.rst:293 msgid "" -"So if you want to be prepared for :exc:`~urllib.error.HTTPError` " -"*or* :exc:`~urllib.error.URLError` there are two basic approaches. I prefer " -"the second approach." +"So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:" +"`~urllib.error.URLError` there are two basic approaches. I prefer the second " +"approach." msgstr "" -#: ../../howto/urllib2.rst:345 +#: ../../howto/urllib2.rst:297 msgid "Number 1" msgstr "" -#: ../../howto/urllib2.rst:350 +#: ../../howto/urllib2.rst:302 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError, HTTPError\n" @@ -605,17 +560,17 @@ msgid "" " # everything is fine" msgstr "" -#: ../../howto/urllib2.rst:367 +#: ../../howto/urllib2.rst:319 msgid "" "The ``except HTTPError`` *must* come first, otherwise ``except URLError`` " "will *also* catch an :exc:`~urllib.error.HTTPError`." msgstr "" -#: ../../howto/urllib2.rst:371 +#: ../../howto/urllib2.rst:323 msgid "Number 2" msgstr "" -#: ../../howto/urllib2.rst:375 +#: ../../howto/urllib2.rst:327 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError\n" @@ -633,18 +588,18 @@ msgid "" " # everything is fine" msgstr "" -#: ../../howto/urllib2.rst:392 +#: ../../howto/urllib2.rst:344 msgid "info and geturl" msgstr "" -#: ../../howto/urllib2.rst:394 +#: ../../howto/urllib2.rst:346 msgid "" "The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` " "instance) has two useful methods :meth:`!info` and :meth:`!geturl` and is " "defined in the module :mod:`urllib.response`." msgstr "" -#: ../../howto/urllib2.rst:398 +#: ../../howto/urllib2.rst:350 msgid "" "**geturl** - this returns the real URL of the page fetched. This is useful " "because ``urlopen`` (or the opener object used) may have followed a " @@ -652,14 +607,14 @@ msgid "" "requested." msgstr "" -#: ../../howto/urllib2.rst:402 +#: ../../howto/urllib2.rst:354 msgid "" "**info** - this returns a dictionary-like object that describes the page " -"fetched, particularly the headers sent by the server. It is currently " -"an :class:`http.client.HTTPMessage` instance." +"fetched, particularly the headers sent by the server. It is currently an :" +"class:`http.client.HTTPMessage` instance." msgstr "" -#: ../../howto/urllib2.rst:406 +#: ../../howto/urllib2.rst:358 msgid "" "Typical headers include 'Content-length', 'Content-type', and so on. See the " "`Quick Reference to HTTP Headers `_ for a " @@ -667,11 +622,11 @@ msgid "" "use." msgstr "" -#: ../../howto/urllib2.rst:413 +#: ../../howto/urllib2.rst:365 msgid "Openers and Handlers" msgstr "" -#: ../../howto/urllib2.rst:415 +#: ../../howto/urllib2.rst:367 msgid "" "When you fetch a URL you use an opener (an instance of the perhaps " "confusingly named :class:`urllib.request.OpenerDirector`). Normally we have " @@ -682,20 +637,20 @@ msgid "" "HTTP redirections or HTTP cookies." msgstr "" -#: ../../howto/urllib2.rst:423 +#: ../../howto/urllib2.rst:375 msgid "" "You will want to create openers if you want to fetch URLs with specific " "handlers installed, for example to get an opener that handles cookies, or to " "get an opener that does not handle redirections." msgstr "" -#: ../../howto/urllib2.rst:427 +#: ../../howto/urllib2.rst:379 msgid "" -"To create an opener, instantiate an ``OpenerDirector``, and then call " -"``.add_handler(some_handler_instance)`` repeatedly." +"To create an opener, instantiate an ``OpenerDirector``, and then call ``." +"add_handler(some_handler_instance)`` repeatedly." msgstr "" -#: ../../howto/urllib2.rst:430 +#: ../../howto/urllib2.rst:382 msgid "" "Alternatively, you can use ``build_opener``, which is a convenience function " "for creating opener objects with a single function call. ``build_opener`` " @@ -703,31 +658,31 @@ msgid "" "or override the default handlers." msgstr "" -#: ../../howto/urllib2.rst:435 +#: ../../howto/urllib2.rst:387 msgid "" "Other sorts of handlers you might want to can handle proxies, " "authentication, and other common but slightly specialised situations." msgstr "" -#: ../../howto/urllib2.rst:438 +#: ../../howto/urllib2.rst:390 msgid "" "``install_opener`` can be used to make an ``opener`` object the (global) " "default opener. This means that calls to ``urlopen`` will use the opener you " "have installed." msgstr "" -#: ../../howto/urllib2.rst:442 +#: ../../howto/urllib2.rst:394 msgid "" "Opener objects have an ``open`` method, which can be called directly to " "fetch urls in the same way as the ``urlopen`` function: there's no need to " "call ``install_opener``, except as a convenience." msgstr "" -#: ../../howto/urllib2.rst:448 +#: ../../howto/urllib2.rst:400 msgid "Basic Authentication" msgstr "" -#: ../../howto/urllib2.rst:450 +#: ../../howto/urllib2.rst:402 msgid "" "To illustrate creating and installing a handler we will use the " "``HTTPBasicAuthHandler``. For a more detailed discussion of this subject -- " @@ -736,7 +691,7 @@ msgid "" "www.voidspace.org.uk/python/articles/authentication.shtml>`__." msgstr "" -#: ../../howto/urllib2.rst:456 +#: ../../howto/urllib2.rst:408 msgid "" "When authentication is required, the server sends a header (as well as the " "401 error code) requesting authentication. This specifies the " @@ -744,15 +699,15 @@ msgid "" "Authenticate: SCHEME realm=\"REALM\"``." msgstr "" -#: ../../howto/urllib2.rst:461 +#: ../../howto/urllib2.rst:413 msgid "e.g." msgstr "例如" -#: ../../howto/urllib2.rst:463 +#: ../../howto/urllib2.rst:415 msgid "WWW-Authenticate: Basic realm=\"cPanel Users\"" msgstr "WWW-Authenticate: Basic realm=\"cPanel Users\"" -#: ../../howto/urllib2.rst:468 +#: ../../howto/urllib2.rst:420 msgid "" "The client should then retry the request with the appropriate name and " "password for the realm included as a header in the request. This is 'basic " @@ -760,7 +715,7 @@ msgid "" "of ``HTTPBasicAuthHandler`` and an opener to use this handler." msgstr "" -#: ../../howto/urllib2.rst:473 +#: ../../howto/urllib2.rst:425 msgid "" "The ``HTTPBasicAuthHandler`` uses an object called a password manager to " "handle the mapping of URLs and realms to passwords and usernames. If you " @@ -773,13 +728,13 @@ msgid "" "by providing ``None`` as the realm argument to the ``add_password`` method." msgstr "" -#: ../../howto/urllib2.rst:483 +#: ../../howto/urllib2.rst:435 msgid "" "The top-level URL is the first URL that requires authentication. URLs " "\"deeper\" than the URL you pass to .add_password() will also match. ::" msgstr "" -#: ../../howto/urllib2.rst:486 +#: ../../howto/urllib2.rst:438 msgid "" "# create a password manager\n" "password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()\n" @@ -802,7 +757,7 @@ msgid "" "urllib.request.install_opener(opener)" msgstr "" -#: ../../howto/urllib2.rst:508 +#: ../../howto/urllib2.rst:460 msgid "" "In the above example we only supplied our ``HTTPBasicAuthHandler`` to " "``build_opener``. By default openers have the handlers for normal situations " @@ -812,7 +767,7 @@ msgid "" "``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``." msgstr "" -#: ../../howto/urllib2.rst:515 +#: ../../howto/urllib2.rst:467 msgid "" "``top_level_url`` is in fact *either* a full URL (including the 'http:' " "scheme component and the hostname and optionally the port number) e.g. " @@ -823,11 +778,11 @@ msgid "" "example ``\"joe:password@example.com\"`` is not correct." msgstr "" -#: ../../howto/urllib2.rst:525 +#: ../../howto/urllib2.rst:477 msgid "Proxies" msgstr "" -#: ../../howto/urllib2.rst:527 +#: ../../howto/urllib2.rst:479 msgid "" "**urllib** will auto-detect your proxy settings and use those. This is " "through the ``ProxyHandler``, which is part of the normal handler chain when " @@ -837,7 +792,7 @@ msgid "" "similar steps to setting up a `Basic Authentication`_ handler: ::" msgstr "" -#: ../../howto/urllib2.rst:534 +#: ../../howto/urllib2.rst:486 msgid "" ">>> proxy_support = urllib.request.ProxyHandler({})\n" ">>> opener = urllib.request.build_opener(proxy_support)\n" @@ -847,40 +802,40 @@ msgstr "" ">>> opener = urllib.request.build_opener(proxy_support)\n" ">>> urllib.request.install_opener(opener)" -#: ../../howto/urllib2.rst:540 +#: ../../howto/urllib2.rst:492 msgid "" "Currently ``urllib.request`` *does not* support fetching of ``https`` " -"locations through a proxy. However, this can be enabled by extending " -"urllib.request as shown in the recipe [#]_." +"locations through a proxy. However, this can be enabled by extending urllib." +"request as shown in the recipe [#]_." msgstr "" -#: ../../howto/urllib2.rst:546 +#: ../../howto/urllib2.rst:498 msgid "" "``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see " "the documentation on :func:`~urllib.request.getproxies`." msgstr "" -#: ../../howto/urllib2.rst:551 +#: ../../howto/urllib2.rst:503 msgid "Sockets and Layers" msgstr "" -#: ../../howto/urllib2.rst:553 +#: ../../howto/urllib2.rst:505 msgid "" "The Python support for fetching resources from the web is layered. urllib " "uses the :mod:`http.client` library, which in turn uses the socket library." msgstr "" -#: ../../howto/urllib2.rst:556 +#: ../../howto/urllib2.rst:508 msgid "" "As of Python 2.3 you can specify how long a socket should wait for a " "response before timing out. This can be useful in applications which have to " "fetch web pages. By default the socket module has *no timeout* and can hang. " -"Currently, the socket timeout is not exposed at the http.client or " -"urllib.request levels. However, you can set the default timeout globally for " -"all sockets using ::" +"Currently, the socket timeout is not exposed at the http.client or urllib." +"request levels. However, you can set the default timeout globally for all " +"sockets using ::" msgstr "" -#: ../../howto/urllib2.rst:562 +#: ../../howto/urllib2.rst:514 msgid "" "import socket\n" "import urllib.request\n" @@ -895,38 +850,38 @@ msgid "" "response = urllib.request.urlopen(req)" msgstr "" -#: ../../howto/urllib2.rst:579 +#: ../../howto/urllib2.rst:531 msgid "Footnotes" msgstr "註腳" -#: ../../howto/urllib2.rst:581 +#: ../../howto/urllib2.rst:533 msgid "This document was reviewed and revised by John Lee." msgstr "" -#: ../../howto/urllib2.rst:583 +#: ../../howto/urllib2.rst:535 msgid "Google for example." msgstr "" -#: ../../howto/urllib2.rst:584 +#: ../../howto/urllib2.rst:536 msgid "" "Browser sniffing is a very bad practice for website design - building sites " "using web standards is much more sensible. Unfortunately a lot of sites " "still send different versions to different browsers." msgstr "" -#: ../../howto/urllib2.rst:587 +#: ../../howto/urllib2.rst:539 msgid "" "The user agent for MSIE 6 is *'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT " "5.1; SV1; .NET CLR 1.1.4322)'*" msgstr "" -#: ../../howto/urllib2.rst:589 +#: ../../howto/urllib2.rst:541 msgid "" "For details of more HTTP request headers, see `Quick Reference to HTTP " "Headers`_." msgstr "" -#: ../../howto/urllib2.rst:591 +#: ../../howto/urllib2.rst:543 msgid "" "In my case I have to use a proxy to access the internet at work. If you " "attempt to fetch *localhost* URLs through this proxy it blocks them. IE is " @@ -934,7 +889,7 @@ msgid "" "with a localhost server, I have to prevent urllib from using the proxy." msgstr "" -#: ../../howto/urllib2.rst:596 +#: ../../howto/urllib2.rst:548 msgid "" "urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -47,16 +47,16 @@ msgstr "教學" #: ../../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 `." +"introduction to Python command-line parsing, have a look at the :ref:" +"`argparse tutorial `." msgstr "" #: ../../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 " +"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 "" @@ -116,8 +116,8 @@ msgstr "" #: ../../library/argparse.rst:65 msgid "" -"If you're looking for a guide about how to upgrade :mod:`optparse` code " -"to :mod:`!argparse`, see :ref:`Upgrading Optparse Code `." msgstr "" @@ -420,11 +420,11 @@ msgstr "parents" msgid "" "Sometimes, several parsers share a common set of arguments. Rather than " "repeating the definitions of these arguments, a single parser with all the " -"shared arguments and passed to ``parents=`` argument " -"to :class:`ArgumentParser` can be used. The ``parents=`` argument takes a " -"list of :class:`ArgumentParser` objects, collects all the positional and " -"optional actions from them, and adds these actions to " -"the :class:`ArgumentParser` object being constructed::" +"shared arguments and passed to ``parents=`` argument to :class:" +"`ArgumentParser` can be used. The ``parents=`` argument takes a list of :" +"class:`ArgumentParser` objects, collects all the positional and optional " +"actions from them, and adds these actions to the :class:`ArgumentParser` " +"object being constructed::" msgstr "" #: ../../library/argparse.rst:249 @@ -483,9 +483,9 @@ msgstr "" #: ../../library/argparse.rst:286 msgid "" ":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give " -"more control over how textual descriptions are displayed. By " -"default, :class:`ArgumentParser` objects line-wrap the description_ and " -"epilog_ texts in command-line help messages::" +"more control over how textual descriptions are displayed. By default, :class:" +"`ArgumentParser` objects line-wrap the description_ and epilog_ texts in " +"command-line help messages::" msgstr "" #: ../../library/argparse.rst:291 @@ -717,9 +717,9 @@ msgstr "" #: ../../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 were in the same place as the original file referencing argument on the " +"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 " +"were in the same place as the original file referencing argument on the " "command line. So in the example above, the expression ``['-f', 'foo', " "'@args.txt']`` is considered equivalent to the expression ``['-f', 'foo', '-" "f', 'bar']``." @@ -740,10 +740,10 @@ msgstr "" #: ../../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 the :term:`filesystem " -"encoding and error handler`. Arguments file should be encoded in UTF-8 " -"instead of ANSI Codepage on Windows." +"from default (e.g. :func:`locale.getpreferredencoding(False) ` 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:438 @@ -752,15 +752,14 @@ msgstr "argument_default" #: ../../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.set_defaults` methods with a specific set of name-" -"value pairs. Sometimes however, it may be useful to specify a single parser-" -"wide default for arguments. This can be accomplished by passing the " -"``argument_default=`` keyword argument to :class:`ArgumentParser`. For " -"example, to globally suppress attribute creation " -"on :meth:`~ArgumentParser.parse_args` calls, we supply " -"``argument_default=SUPPRESS``::" +"Generally, argument defaults are specified either by passing a default to :" +"meth:`~ArgumentParser.add_argument` or by calling the :meth:`~ArgumentParser." +"set_defaults` methods with a specific set of name-value pairs. Sometimes " +"however, it may be useful to specify a single parser-wide default for " +"arguments. This can be accomplished by passing the ``argument_default=`` " +"keyword argument to :class:`ArgumentParser`. For example, to globally " +"suppress attribute creation on :meth:`~ArgumentParser.parse_args` calls, we " +"supply ``argument_default=SUPPRESS``::" msgstr "" #: ../../library/argparse.rst:449 @@ -787,9 +786,9 @@ msgstr "allow_abbrev" #: ../../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." +"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:466 @@ -896,8 +895,8 @@ msgstr "" #: ../../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`::" +"This can be achieved by passing ``False`` as the ``add_help=`` argument to :" +"class:`ArgumentParser`::" msgstr "" #: ../../library/argparse.rst:526 @@ -948,10 +947,9 @@ msgstr "exit_on_error" #: ../../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 print a *message* to :data:`sys.stderr` and exit with a status code " -"of 2." +"Normally, when you pass an invalid argument list to the :meth:" +"`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " +"print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" #: ../../library/argparse.rst:555 @@ -1048,8 +1046,8 @@ msgstr "" #: ../../library/argparse.rst:605 msgid "" -"dest_ - The name of the attribute to be added to the object returned " -"by :meth:`parse_args`." +"dest_ - The name of the attribute to be added to the object returned by :" +"meth:`parse_args`." msgstr "" #: ../../library/argparse.rst:608 @@ -1064,9 +1062,9 @@ msgstr "name or flags" msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " -"a list of filenames, is expected. The first arguments passed " -"to :meth:`~ArgumentParser.add_argument` must therefore be either a series of " -"flags, or a simple argument name." +"a list of filenames, is expected. The first arguments passed to :meth:" +"`~ArgumentParser.add_argument` must therefore be either a series of flags, " +"or a simple argument name." msgstr "" #: ../../library/argparse.rst:624 @@ -1281,9 +1279,9 @@ msgstr "" #: ../../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::" +"``'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:741 @@ -1497,9 +1495,9 @@ msgstr "" #: ../../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::" +"``'+'``. Just like ``'*'``, all command-line arguments present are gathered " +"into a list. Additionally, an error message will be generated if there " +"wasn't at least one command-line argument present. For example::" msgstr "" #: ../../library/argparse.rst:869 @@ -1545,11 +1543,10 @@ msgstr "" msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " -"the ``const`` value to one of the attributes of the object returned " -"by :meth:`~ArgumentParser.parse_args`. See the action_ description for " -"examples. If ``const`` is not provided " -"to :meth:`~ArgumentParser.add_argument`, it will receive a default value of " -"``None``." +"the ``const`` value to one of the attributes of the object returned by :meth:" +"`~ArgumentParser.parse_args`. See the action_ description for examples. If " +"``const`` is not provided to :meth:`~ArgumentParser.add_argument`, it will " +"receive a default value of ``None``." msgstr "" #: ../../library/argparse.rst:901 @@ -1575,11 +1572,11 @@ msgstr "default" #: ../../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.add_argument`, whose value defaults to ``None``, " -"specifies what value should be used if the command-line argument is not " -"present. For optional arguments, the ``default`` value is used when the " -"option string was not present at the command line::" +"command line. The ``default`` keyword argument of :meth:`~ArgumentParser." +"add_argument`, whose value defaults to ``None``, specifies what value should " +"be used if the command-line argument is not present. For optional arguments, " +"the ``default`` value is used when the option string was not present at the " +"command line::" msgstr "" #: ../../library/argparse.rst:924 @@ -1620,9 +1617,8 @@ msgstr "" 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_ " -"conversion argument, if provided, before setting the attribute on " -"the :class:`Namespace` return value. Otherwise, the parser uses the value " -"as is::" +"conversion argument, if provided, before setting the attribute on the :class:" +"`Namespace` return value. Otherwise, the parser uses the value as is::" msgstr "" #: ../../library/argparse.rst:944 @@ -1713,9 +1709,9 @@ msgstr "" msgid "" "The argument to ``type`` can be a callable that accepts a single string or " "the name of a registered type (see :meth:`~ArgumentParser.register`) If the " -"function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, " -"or :exc:`ValueError`, the exception is caught and a nicely formatted error " -"message is displayed. Other exception types are not handled." +"function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or :exc:" +"`ValueError`, the exception is caught and a nicely formatted error message " +"is displayed. Other exception types are not handled." msgstr "" #: ../../library/argparse.rst:995 @@ -1788,9 +1784,9 @@ msgstr "" #: ../../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.JSONDecodeError` would not be well formatted and " -"a :exc:`FileNotFoundError` exception would not be handled at all." +"better reporting than can be given by the ``type`` keyword. A :exc:`~json." +"JSONDecodeError` would not be well formatted and a :exc:`FileNotFoundError` " +"exception would not be handled at all." msgstr "" #: ../../library/argparse.rst:1036 @@ -1901,9 +1897,9 @@ msgstr "" #: ../../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." +"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:1107 @@ -1929,8 +1925,8 @@ msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " "available specifiers include the program name, ``%(prog)s`` and most keyword " -"arguments to :meth:`~ArgumentParser.add_argument`, e.g. ``%(default)s``, ``%" -"(type)s``, etc.::" +"arguments to :meth:`~ArgumentParser.add_argument`, e.g. ``%(default)s``, " +"``%(type)s``, etc.::" msgstr "" #: ../../library/argparse.rst:1126 @@ -2119,10 +2115,10 @@ msgstr "dest" msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " -"attribute is determined by the ``dest`` keyword argument " -"of :meth:`~ArgumentParser.add_argument`. For positional argument actions, " -"``dest`` is normally supplied as the first argument " -"to :meth:`~ArgumentParser.add_argument`::" +"attribute is determined by the ``dest`` keyword argument of :meth:" +"`~ArgumentParser.add_argument`. For positional argument actions, ``dest`` " +"is normally supplied as the first argument to :meth:`~ArgumentParser." +"add_argument`::" msgstr "" #: ../../library/argparse.rst:1231 @@ -2226,8 +2222,8 @@ msgstr "Action 類別" msgid "" ":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`." +"follows this API may be passed as the ``action`` parameter to :meth:" +"`~ArgumentParser.add_argument`." msgstr "" #: ../../library/argparse.rst:1300 @@ -2235,8 +2231,8 @@ msgid "" ":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " "the information needed to parse a single argument from one or more strings " "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." +"positional arguments plus any keyword arguments passed to :meth:" +"`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" #: ../../library/argparse.rst:1306 @@ -2261,16 +2257,16 @@ msgstr "" #: ../../library/argparse.rst:1319 msgid "" -"*namespace* - The :class:`Namespace` object that will be returned " -"by :meth:`~ArgumentParser.parse_args`. Most actions add an attribute to " -"this object using :func:`setattr`." +"*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: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`." +"applied. Type conversions are specified with the type_ keyword argument to :" +"meth:`~ArgumentParser.add_argument`." msgstr "" #: ../../library/argparse.rst:1327 @@ -2314,14 +2310,14 @@ msgstr "" #: ../../library/argparse.rst:1353 msgid "" -"args_ - List of strings to parse. The default is taken " -"from :data:`sys.argv`." +"args_ - List of strings to parse. The default is taken from :data:`sys." +"argv`." msgstr "" #: ../../library/argparse.rst:1356 msgid "" -"namespace_ - An object to take the attributes. The default is a new " -"empty :class:`Namespace` object." +"namespace_ - An object to take the attributes. The default is a new empty :" +"class:`Namespace` object." msgstr "" #: ../../library/argparse.rst:1361 @@ -2680,14 +2676,13 @@ msgid "" "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." +"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:1582 @@ -3009,10 +3004,10 @@ msgstr "FileType 物件" #: ../../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:`FileType` objects as their type will open command-line " -"arguments as files with the requested modes, buffer sizes, encodings and " -"error handling (see the :func:`open` function for more details)::" +"argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" +"`FileType` objects as their type will open command-line arguments as files " +"with the requested modes, buffer sizes, encodings and error handling (see " +"the :func:`open` function for more details)::" msgstr "" #: ../../library/argparse.rst:1791 @@ -3096,12 +3091,12 @@ msgstr "" #: ../../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 accepts *title* and *description* arguments which can be used to " -"customize this display::" +"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 " +"accepts *title* and *description* arguments which can be used to customize " +"this display::" msgstr "" #: ../../library/argparse.rst:1841 @@ -3146,9 +3141,9 @@ msgstr "" 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." +"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 @@ -3230,10 +3225,9 @@ msgstr "" #: ../../library/argparse.rst:1907 msgid "" "Note that currently mutually exclusive argument groups do not support the " -"*title* and *description* arguments " -"of :meth:`~ArgumentParser.add_argument_group`. However, a mutually exclusive " -"group can be added to an argument group that has a title and description. " -"For example::" +"*title* and *description* arguments of :meth:`~ArgumentParser." +"add_argument_group`. However, a mutually exclusive group can be added to an " +"argument group that has a title and description. For example::" msgstr "" #: ../../library/argparse.rst:1913 @@ -3286,9 +3280,9 @@ msgstr "" #: ../../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 arguments and the argument actions. :meth:`set_defaults` allows some " +"Most of the time, the attributes of the object returned by :meth:" +"`parse_args` will be fully determined by inspecting the command-line " +"arguments and the argument actions. :meth:`set_defaults` allows some " "additional attributes that are determined without any inspection of the " "command line to be added::" msgstr "" @@ -3335,9 +3329,8 @@ msgstr "" #: ../../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`::" +"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:1972 @@ -3385,8 +3378,8 @@ msgstr "" #: ../../library/argparse.rst:2002 msgid "" -"Return a string containing a brief description of how " -"the :class:`ArgumentParser` should be invoked on the command line." +"Return a string containing a brief description of how the :class:" +"`ArgumentParser` should be invoked on the command line." msgstr "" #: ../../library/argparse.rst:2007 @@ -3401,16 +3394,21 @@ msgstr "" #: ../../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 " -"cases, the :meth:`~ArgumentParser.parse_known_args` method can be useful. " -"It works much like :meth:`~ArgumentParser.parse_args` except that it does " -"not produce an error when extra arguments are present. Instead, it returns " -"a two item tuple containing the populated namespace and the list of " -"remaining argument strings." +"Sometimes a script only needs to handle a specific set of command-line " +"arguments, leaving any unrecognized arguments for another script or program. " +"In these cases, the :meth:`~ArgumentParser.parse_known_args` method can be " +"useful." +msgstr "" + +#: ../../library/argparse.rst:2021 +msgid "" +"This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " +"does not raise an error for extra, unrecognized arguments. Instead, it " +"parses the known arguments and returns a two item tuple that contains the " +"populated namespace and the list of any unrecognized arguments." msgstr "" -#: ../../library/argparse.rst:2025 +#: ../../library/argparse.rst:2028 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3424,19 +3422,19 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2032 +#: ../../library/argparse.rst:2035 msgid "" -":ref:`Prefix matching ` rules apply " -"to :meth:`~ArgumentParser.parse_known_args`. The parser may consume an " -"option even if it's just a prefix of one of its known options, instead of " -"leaving it in the remaining arguments list." +":ref:`Prefix matching ` rules apply to :meth:" +"`~ArgumentParser.parse_known_args`. The parser may consume an option even if " +"it's just a prefix of one of its known options, instead of leaving it in the " +"remaining arguments list." msgstr "" -#: ../../library/argparse.rst:2039 +#: ../../library/argparse.rst:2042 msgid "Customizing file parsing" msgstr "" -#: ../../library/argparse.rst:2043 +#: ../../library/argparse.rst:2046 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -3444,20 +3442,20 @@ msgid "" "reading." msgstr "" -#: ../../library/argparse.rst:2048 +#: ../../library/argparse.rst:2051 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:2052 +#: ../../library/argparse.rst:2055 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:2055 +#: ../../library/argparse.rst:2058 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -3467,18 +3465,18 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2061 +#: ../../library/argparse.rst:2064 msgid "Exiting methods" msgstr "" -#: ../../library/argparse.rst:2065 +#: ../../library/argparse.rst:2068 msgid "" "This method terminates the program, exiting with the specified *status* and, " "if given, it prints a *message* to :data:`sys.stderr` before that. The user " "can override this method to handle these steps differently::" msgstr "" -#: ../../library/argparse.rst:2069 +#: ../../library/argparse.rst:2072 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3492,17 +3490,17 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2077 +#: ../../library/argparse.rst:2080 msgid "" -"This method prints a usage message, including the *message*, " -"to :data:`sys.stderr` 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:2082 +#: ../../library/argparse.rst:2085 msgid "Intermixed parsing" msgstr "" -#: ../../library/argparse.rst:2087 +#: ../../library/argparse.rst:2090 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -3510,7 +3508,7 @@ msgid "" "parsing style." msgstr "" -#: ../../library/argparse.rst:2092 +#: ../../library/argparse.rst:2095 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " @@ -3518,16 +3516,15 @@ msgid "" "positionals are not supported." msgstr "" -#: ../../library/argparse.rst:2097 +#: ../../library/argparse.rst:2100 msgid "" -"The following example shows the difference " -"between :meth:`~ArgumentParser.parse_known_args` " -"and :meth:`~ArgumentParser.parse_intermixed_args`: the former returns " -"``['2', '3']`` as unparsed arguments, while the latter collects all the " -"positionals into ``rest``. ::" +"The following example shows the difference between :meth:`~ArgumentParser." +"parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " +"former returns ``['2', '3']`` as unparsed arguments, while the latter " +"collects all the positionals into ``rest``. ::" msgstr "" -#: ../../library/argparse.rst:2103 +#: ../../library/argparse.rst:2106 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3547,7 +3544,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:2112 +#: ../../library/argparse.rst:2115 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -3555,11 +3552,11 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: ../../library/argparse.rst:2121 +#: ../../library/argparse.rst:2124 msgid "Registering custom types or actions" msgstr "" -#: ../../library/argparse.rst:2125 +#: ../../library/argparse.rst:2128 msgid "" "Sometimes it's desirable to use a custom string in error messages to provide " "more user-friendly output. In these cases, :meth:`!register` can be used to " @@ -3567,7 +3564,7 @@ msgid "" "the type by their registered name instead of their callable name." msgstr "" -#: ../../library/argparse.rst:2130 +#: ../../library/argparse.rst:2133 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " @@ -3575,12 +3572,12 @@ msgid "" "be registered, and object, the callable to be registered." msgstr "" -#: ../../library/argparse.rst:2135 +#: ../../library/argparse.rst:2138 msgid "" "The following example shows how to register a custom type with a parser::" msgstr "" -#: ../../library/argparse.rst:2137 +#: ../../library/argparse.rst:2140 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -3596,26 +3593,26 @@ msgid "" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" -#: ../../library/argparse.rst:2149 +#: ../../library/argparse.rst:2152 msgid "Exceptions" msgstr "例外" -#: ../../library/argparse.rst:2153 +#: ../../library/argparse.rst:2156 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: ../../library/argparse.rst:2155 +#: ../../library/argparse.rst:2158 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: ../../library/argparse.rst:2160 +#: ../../library/argparse.rst:2163 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: ../../library/argparse.rst:2164 +#: ../../library/argparse.rst:2167 msgid "Guides and Tutorials" msgstr "" diff --git a/library/array.po b/library/array.po index d1ee4d39e6..c9aa3ec262 100644 --- a/library/array.po +++ b/library/array.po @@ -223,7 +223,7 @@ msgid "" "``Py_UNICODE`` is alias of :c:type:`wchar_t` since Python 3.3." msgstr "" "目前 ``array('u')`` 使用 :c:type:`wchar_t` 取代已棄用的 ``Py_UNICODE`` 作為 " -"C type。這個異動並沒有影響到它的作用,因爲自從 Python 3.3 開始 " +"C type。這個異動並沒有影響到它的作用,因為自從 Python 3.3 開始 " "``Py_UNICODE`` 即為 :c:type:`wchar_t` 的別名。" #: ../../library/array.rst:60 diff --git a/library/ast.po b/library/ast.po index 8e6a61b972..5d46b5bc4c 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: 2025-04-29 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -38,12 +38,12 @@ msgstr "" #: ../../library/ast.rst:23 msgid "" -"An abstract syntax tree can be generated by " -"passing :data:`ast.PyCF_ONLY_AST` as a flag to the :func:`compile` built-in " -"function, or using the :func:`parse` helper provided in this module. The " -"result will be a tree of objects whose classes all inherit " -"from :class:`ast.AST`. An abstract syntax tree can be compiled into a " -"Python code object using the built-in :func:`compile` function." +"An abstract syntax tree can be generated by passing :data:`ast." +"PyCF_ONLY_AST` as a flag to the :func:`compile` built-in function, or using " +"the :func:`parse` helper provided in this module. The result will be a tree " +"of objects whose classes all inherit from :class:`ast.AST`. An abstract " +"syntax tree can be compiled into a Python code object using the built-in :" +"func:`compile` function." msgstr "" "要生成抽象語法樹,可以透過將 :data:`ast.PyCF_ONLY_AST` 作為旗標傳遞給內建函" "式 :func:`compile` 或使用此模組所提供的 :func:`parse` 輔助函式。結果將會是一" @@ -239,13 +239,13 @@ msgstr "節點 (Node) 類別" #: ../../library/ast.rst:46 msgid "" "This is the base of all AST node classes. The actual node classes are " -"derived from the :file:`Parser/Python.asdl` file, which is " -"reproduced :ref:`above `. They are defined in the :mod:`!" -"_ast` C module and re-exported in :mod:`ast`." +"derived from the :file:`Parser/Python.asdl` file, which is reproduced :ref:" +"`above `. They are defined in the :mod:`!_ast` C module " +"and re-exported in :mod:`ast`." msgstr "" -"這是所有 AST 節點類別的基礎。實際的節點類別是衍生自 :file:`Parser/" -"Python.asdl` 檔案,該檔案在\\ :ref:`上方 ` 重現。它們被定義" -"於 :mod:`!_ast` 的 C 模組中,並於 :mod:`ast` 中重新匯出。" +"這是所有 AST 節點類別的基礎。實際的節點類別是衍生自 :file:`Parser/Python." +"asdl` 檔案,該檔案在\\ :ref:`上方 ` 重現。它們被定義於 :" +"mod:`!_ast` 的 C 模組中,並於 :mod:`ast` 中重新匯出。" #: ../../library/ast.rst:51 msgid "" @@ -257,11 +257,11 @@ msgid "" "rules with alternatives (aka \"sums\"), the left-hand side class is " "abstract: only instances of specific constructor nodes are ever created." msgstr "" -"抽象文法中為每個左側符號定義了一個類別(例如 :class:`ast.stmt` " -"或 :class:`ast.expr`\\ )。此外,也為每個右側的建構函式 (constructor) 定義了" -"一個類別;這些類別繼承自左側樹的類別。例如,:class:`ast.BinOp` 繼承" -"自 :class:`ast.expr`。對於具有替代方案(即為「和 (sums)」)的生產規則,左側類" -"別是抽象的:僅有特定建構函式節點的實例會被建立。" +"抽象文法中為每個左側符號定義了一個類別(例如 :class:`ast.stmt` 或 :class:" +"`ast.expr`\\ )。此外,也為每個右側的建構函式 (constructor) 定義了一個類別;" +"這些類別繼承自左側樹的類別。例如,:class:`ast.BinOp` 繼承自 :class:`ast." +"expr`。對於具有替代方案(即為「和 (sums)」)的生產規則,左側類別是抽象的:僅" +"有特定建構函式節點的實例會被建立。" #: ../../library/ast.rst:64 msgid "" @@ -275,8 +275,8 @@ msgid "" "the type as defined in the grammar. For example, :class:`ast.BinOp` " "instances have an attribute :attr:`left` of type :class:`ast.expr`." msgstr "" -"具體類別的每個實例對於每個子節點都有一個屬性,其型別如文法中所定義。例" -"如,:class:`ast.BinOp` 實例具有型別為 :class:`ast.expr` 的屬性 :attr:`left`。" +"具體類別的每個實例對於每個子節點都有一個屬性,其型別如文法中所定義。例如,:" +"class:`ast.BinOp` 實例具有型別為 :class:`ast.expr` 的屬性 :attr:`left`。" #: ../../library/ast.rst:71 msgid "" @@ -287,16 +287,16 @@ msgid "" "compiling an AST with :func:`compile`." msgstr "" "如果這些屬性在文法中被標記為可選(使用問號),則該值可能為 ``None``。如果屬性" -"可以有零個或多個值(用星號標記),則這些值將表示為 Python 串列。使" -"用 :func:`compile` 編譯 AST 時,所有可能的屬性都必須存在並且具有有效值。" +"可以有零個或多個值(用星號標記),則這些值將表示為 Python 串列。使用 :func:" +"`compile` 編譯 AST 時,所有可能的屬性都必須存在並且具有有效值。" #: ../../library/ast.rst:79 msgid "" "The :attr:`!_field_types` attribute on each concrete class is a dictionary " "mapping field names (as also listed in :attr:`_fields`) to their types." msgstr "" -"每個具體類別上的 :attr:`!_field_types` 屬性是將欄位名稱(也" -"在 :attr:`_fields` 中列出)對映到其型別的字典。" +"每個具體類別上的 :attr:`!_field_types` 屬性是將欄位名稱(也在 :attr:" +"`_fields` 中列出)對映到其型別的字典。" #: ../../library/ast.rst:82 msgid "" @@ -310,22 +310,21 @@ msgstr "" #: ../../library/ast.rst:94 msgid "" -"Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses " -"have :attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`, " -"and :attr:`end_col_offset` attributes. The :attr:`lineno` " -"and :attr:`end_lineno` are the first and last line numbers of source text " -"span (1-indexed so the first line is line 1) and the :attr:`col_offset` " -"and :attr:`end_col_offset` are the corresponding UTF-8 byte offsets of the " -"first and last tokens that generated the node. The UTF-8 offset is recorded " -"because the parser uses UTF-8 internally." -msgstr "" -":class:`ast.expr` 和 :class:`ast.stmt` 子類別的實例具" -"有 :attr:`lineno`、:attr:`col_offset`、:attr:`end_lineno` " -"和 :attr:`end_col_offset` 屬性。:attr:`lineno` 和 :attr:`end_lineno` 是原始文" -"本跨度 (source text span) 的第一個和最後一個列號(1-indexed,因此第一列號是 " -"1)以及 :attr:`col_offset` 和 :attr:`end_col_offset` 是生成節點的第一個和最後" -"一個標記對應的 UTF-8 位元組偏移量。會記錄 UTF-8 偏移量是因為剖析器 (parser) " -"內部使用 UTF-8。" +"Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have :attr:" +"`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and :attr:`end_col_offset` " +"attributes. The :attr:`lineno` and :attr:`end_lineno` are the first and " +"last line numbers of source text span (1-indexed so the first line is line " +"1) and the :attr:`col_offset` and :attr:`end_col_offset` are the " +"corresponding UTF-8 byte offsets of the first and last tokens that generated " +"the node. The UTF-8 offset is recorded because the parser uses UTF-8 " +"internally." +msgstr "" +":class:`ast.expr` 和 :class:`ast.stmt` 子類別的實例具有 :attr:`lineno`、:" +"attr:`col_offset`、:attr:`end_lineno` 和 :attr:`end_col_offset` 屬性。:attr:" +"`lineno` 和 :attr:`end_lineno` 是原始文本跨度 (source text span) 的第一個和最" +"後一個列號(1-indexed,因此第一列號是 1)以及 :attr:`col_offset` 和 :attr:" +"`end_col_offset` 是生成節點的第一個和最後一個標記對應的 UTF-8 位元組偏移量。" +"會記錄 UTF-8 偏移量是因為剖析器 (parser) 內部使用 UTF-8。" #: ../../library/ast.rst:103 msgid "" @@ -377,15 +376,15 @@ msgid "" "If a field that is optional in the grammar is omitted from the constructor, " "it defaults to ``None``. If a list field is omitted, it defaults to the " "empty list. If a field of type :class:`!ast.expr_context` is omitted, it " -"defaults to :class:`Load() `. If any other field is omitted, " -"a :exc:`DeprecationWarning` is raised and the AST node will not have this " +"defaults to :class:`Load() `. If any other field is omitted, a :" +"exc:`DeprecationWarning` is raised and the AST node will not have this " "field. In Python 3.15, this condition will raise an error." msgstr "" "如果建構函式中省略了文法中可選的欄位,則它預設為 ``None``。如果省略串列欄位," -"則預設為空串列。如果省略 :class:`!ast.expr_context` 型別的欄位,則預設" -"為 :class:`Load() `。如果省略任何其他欄位,則會引" -"發 :exc:`DeprecationWarning`,且 AST 節點將沒有此欄位。在 Python 3.15 中,這" -"種情況會引發錯誤。" +"則預設為空串列。如果省略 :class:`!ast.expr_context` 型別的欄位,則預設為 :" +"class:`Load() `。如果省略任何其他欄位,則會引發 :exc:" +"`DeprecationWarning`,且 AST 節點將沒有此欄位。在 Python 3.15 中,這種情況會" +"引發錯誤。" #: ../../library/ast.rst:130 msgid "Class :class:`ast.Constant` is now used for all constants." @@ -399,10 +398,10 @@ msgstr "以它們的值表示簡單索引,擴充切片 (slice) 則以元組 (t #: ../../library/ast.rst:139 msgid "" -"Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!" -"ast.Bytes`, :class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still " -"available, but they will be removed in future Python releases. In the " -"meantime, instantiating them will return an instance of a different class." +"Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`, :" +"class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available, " +"but they will be removed in future Python releases. In the meantime, " +"instantiating them will return an instance of a different class." msgstr "" "舊的類別 :class:`!ast.Num`、:class:`!ast.Str`、:class:`!ast.Bytes`、:class:`!" "ast.NameConstant` 和 :class:`!ast.Ellipsis` 仍然可用,但它們將在未來的 " @@ -432,9 +431,8 @@ msgstr "" #: ../../library/ast.rst:160 msgid "" "The descriptions of the specific node classes displayed here were initially " -"adapted from the fantastic `Green Tree Snakes `__ project and all its " -"contributors." +"adapted from the fantastic `Green Tree Snakes `__ project and all its contributors." msgstr "" "這裡顯示的特定節點類別的描述最初是從出色的 `Green Tree Snakes `__ 專案和所有貢獻者那裡改編而來" @@ -449,8 +447,8 @@ msgid "" "A Python module, as with :ref:`file input `. Node type generated " "by :func:`ast.parse` in the default ``\"exec\"`` *mode*." msgstr "" -"一個 Python 模組,與\\ :ref:`檔案輸入 ` 一樣。" -"由 :func:`ast.parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" +"一個 Python 模組,與\\ :ref:`檔案輸入 ` 一樣。由 :func:`ast." +"parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" #: ../../library/ast.rst:176 msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." @@ -518,8 +516,8 @@ msgstr "" #: ../../library/ast.rst:212 msgid "``body`` is a :class:`list` of :ref:`statement nodes `." msgstr "" -"``body`` 是\\ :ref:`陳述式節點 (statement nodes) ` " -"的 :class:`list`。" +"``body`` 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" +"`list`。" #: ../../library/ast.rst:214 msgid "" @@ -612,13 +610,14 @@ msgstr "文本 (Literals)" msgid "" "A constant value. The ``value`` attribute of the ``Constant`` literal " "contains the Python object it represents. The values represented can be " -"simple types such as a number, string or ``None``, but also immutable " -"container types (tuples and frozensets) if all of their elements are " -"constant." +"instances of :class:`str`, :class:`bytes`, :class:`int`, :class:`float`, :" +"class:`complex`, and :class:`bool`, and the constants :data:`None` and :data:" +"`Ellipsis`." msgstr "" "一個常數值。``Constant`` 文本的 ``value`` 屬性包含它所代表的 Python 物件。表" -"示的值可以是簡單型別,例如數字、字串或 ``None``,但如果它們的所有元素都是常" -"數,也可以是不可變的 (immutable) 容器型別(元組和凍結集合 (frozensets))。" +"示的值可以是 :class:`str`、:class:`bytes`、:class:`int`、:class:`float`、:" +"class:`complex` 和 :class:`bool` 的實例,以及常數 :data:`None` 和 :" +"data:`Ellipsis`。" #: ../../library/ast.rst:279 msgid "" @@ -667,8 +666,8 @@ msgstr "" #: ../../library/ast.rst:299 msgid "" -"An f-string, comprising a series of :class:`FormattedValue` " -"and :class:`Constant` nodes." +"An f-string, comprising a series of :class:`FormattedValue` and :class:" +"`Constant` nodes." msgstr "" "一個 f 字串,包含一系列 :class:`FormattedValue` 和 :class:`Constant` 節點。" @@ -720,8 +719,8 @@ msgid "" "``ctx`` is :class:`Store` if the container is an assignment target (i.e. " "``(x,y)=something``), and :class:`Load` otherwise." msgstr "" -"串列或元組。``elts`` 保存表示元素的節點串列。如果容器是賦值目標(即 " -"``(x,y)=something`` ),則 ``ctx`` 是 :class:`Store`,否則是 :class:`Load`。" +"串列或元組。``elts`` 保存表示元素的節點串列。如果容器是賦值目標(即 ``(x," +"y)=something`` ),則 ``ctx`` 是 :class:`Store`,否則是 :class:`Load`。" #: ../../library/ast.rst:331 msgid "" @@ -887,9 +886,9 @@ msgstr "" #: ../../library/ast.rst:432 msgid "" -"A ``*var`` variable reference. ``value`` holds the variable, typically " -"a :class:`Name` node. This type must be used when building a :class:`Call` " -"node with ``*args``." +"A ``*var`` variable reference. ``value`` holds the variable, typically a :" +"class:`Name` node. This type must be used when building a :class:`Call` node " +"with ``*args``." msgstr "" "一個 ``*var`` 變數參照。``value`` 保存變數,通常是一個 :class:`Name` 節點。在" "使用 ``*args`` 建置 :class:`Call` 節點時必須使用此型別。" @@ -932,14 +931,14 @@ msgstr "運算式" msgid "" "When an expression, such as a function call, appears as a statement by " "itself with its return value not used or stored, it is wrapped in this " -"container. ``value`` holds one of the other nodes in this section, " -"a :class:`Constant`, a :class:`Name`, a :class:`Lambda`, a :class:`Yield` " -"or :class:`YieldFrom` node." +"container. ``value`` holds one of the other nodes in this section, a :class:" +"`Constant`, a :class:`Name`, a :class:`Lambda`, a :class:`Yield` or :class:" +"`YieldFrom` node." msgstr "" "當運算式(例如函式呼叫)本身作為陳述式出現且未使用或儲存其回傳值時,它將被包" -"裝在此容器中。``value`` 保存此區段 (section) 中的一個其他節" -"點::class:`Constant`、:class:`Name`、:class:`Lambda`、:class:`Yield` " -"或 :class:`YieldFrom`" +"裝在此容器中。``value`` 保存此區段 (section) 中的一個其他節點::class:" +"`Constant`、:class:`Name`、:class:`Lambda`、:class:`Yield` 或 :class:" +"`YieldFrom`" #: ../../library/ast.rst:465 msgid "" @@ -1092,11 +1091,11 @@ msgstr "比較運算子 token。" #: ../../library/ast.rst:593 msgid "" -"A function call. ``func`` is the function, which will often be " -"a :class:`Name` or :class:`Attribute` object. Of the arguments:" +"A function call. ``func`` is the function, which will often be a :class:" +"`Name` or :class:`Attribute` object. Of the arguments:" msgstr "" -"一個函式呼叫。``func`` 是該函式,通常是一個 :class:`Name` " -"或 :class:`Attribute` 物件。而在引數中:" +"一個函式呼叫。``func`` 是該函式,通常是一個 :class:`Name` 或 :class:" +"`Attribute` 物件。而在引數中:" #: ../../library/ast.rst:596 msgid "``args`` holds a list of the arguments passed by position." @@ -1185,14 +1184,14 @@ msgstr "" #: ../../library/ast.rst:644 msgid "" -"Attribute access, e.g. ``d.keys``. ``value`` is a node, typically " -"a :class:`Name`. ``attr`` is a bare string giving the name of the attribute, " -"and ``ctx`` is :class:`Load`, :class:`Store` or :class:`Del` according to " -"how the attribute is acted on." +"Attribute access, e.g. ``d.keys``. ``value`` is a node, typically a :class:" +"`Name`. ``attr`` is a bare string giving the name of the attribute, and " +"``ctx`` is :class:`Load`, :class:`Store` or :class:`Del` according to how " +"the attribute is acted on." msgstr "" "屬性的存取,例如 ``d.keys``。``value`` 是一個節點,通常是一個 :class:`Name`。" -"``attr`` 是一個屬性名稱的字串,``ctx`` 根據屬性的作用方式可能" -"是 :class:`Load`、:class:`Store` 或 :class:`Del`。" +"``attr`` 是一個屬性名稱的字串,``ctx`` 根據屬性的作用方式可能是 :class:" +"`Load`、:class:`Store` 或 :class:`Del`。" #: ../../library/ast.rst:649 msgid "" @@ -1213,9 +1212,9 @@ msgstr "" #: ../../library/ast.rst:661 msgid "" "A named expression. This AST node is produced by the assignment expressions " -"operator (also known as the walrus operator). As opposed to " -"the :class:`Assign` node in which the first argument can be multiple nodes, " -"in this case both ``target`` and ``value`` must be single nodes." +"operator (also known as the walrus operator). As opposed to the :class:" +"`Assign` node in which the first argument can be multiple nodes, in this " +"case both ``target`` and ``value`` must be single nodes." msgstr "" "一個附名運算式 (named expression)。該 AST 節點由賦值運算式運算子(也稱為海象" "運算子)產生。相對於 :class:`Assign` 節點之第一個引數可為多個節點,在這種情況" @@ -1242,15 +1241,14 @@ msgstr "下標 (Subscripting)" #: ../../library/ast.rst:681 msgid "" "A subscript, such as ``l[1]``. ``value`` is the subscripted object (usually " -"sequence or mapping). ``slice`` is an index, slice or key. It can be " -"a :class:`Tuple` and contain a :class:`Slice`. ``ctx`` " -"is :class:`Load`, :class:`Store` or :class:`Del` according to the action " -"performed with the subscript." +"sequence or mapping). ``slice`` is an index, slice or key. It can be a :" +"class:`Tuple` and contain a :class:`Slice`. ``ctx`` is :class:`Load`, :class:" +"`Store` or :class:`Del` according to the action performed with the subscript." msgstr "" "一個下標,例如 ``l[1]``。``value`` 是下標物件(通常是序列或對映)。``slice`` " "是索引、切片或鍵。它可以是一個 :class:`Tuple` 並包含一個 :class:`Slice`。根據" -"下標執行的操作不同,``ctx`` 可以是 :class:`Load`、:class:`Store` " -"或 :class:`Del`。" +"下標執行的操作不同,``ctx`` 可以是 :class:`Load`、:class:`Store` 或 :class:" +"`Del`。" #: ../../library/ast.rst:687 msgid "" @@ -1417,9 +1415,9 @@ msgid "" "``iter`` is the object to iterate over. ``ifs`` is a list of test " "expressions: each ``for`` clause can have multiple ``ifs``." msgstr "" -"綜合運算中的一個 ``for`` 子句。``target`` 是用於每個元素的參照 - 通常" -"是 :class:`Name` 或 :class:`Tuple` 節點。``iter`` 是要疊代的物件。``ifs`` 是" -"測試運算式的串列:每個 ``for`` 子句可以有多個 ``ifs``。" +"綜合運算中的一個 ``for`` 子句。``target`` 是用於每個元素的參照 - 通常是 :" +"class:`Name` 或 :class:`Tuple` 節點。``iter`` 是要疊代的物件。``ifs`` 是測試" +"運算式的串列:每個 ``for`` 子句可以有多個 ``ifs``。" #: ../../library/ast.rst:786 msgid "" @@ -1620,26 +1618,25 @@ msgstr "" msgid "" "An assignment with a type annotation. ``target`` is a single node and can be " "a :class:`Name`, an :class:`Attribute` or a :class:`Subscript`. " -"``annotation`` is the annotation, such as a :class:`Constant` " -"or :class:`Name` node. ``value`` is a single optional node." +"``annotation`` is the annotation, such as a :class:`Constant` or :class:" +"`Name` node. ``value`` is a single optional node." msgstr "" -"帶有型別註釋的賦值。``target`` 是單個節點,可以" -"是 :class:`Name`、:class:`Attribute` 或 :class:`Subscript`。``annotation`` 是" -"註釋,例如 :class:`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節" -"點。" +"帶有型別註釋的賦值。``target`` 是單個節點,可以是 :class:`Name`、:class:" +"`Attribute` 或 :class:`Subscript`。``annotation`` 是註釋,例如 :class:" +"`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節點。" #: ../../library/ast.rst:896 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:`~object.__annotations__` dictionary of modules and classes." +"(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:" +"`~object.__annotations__` dictionary of modules and classes." msgstr "" "``simple`` 總會是 0(表示一個「複雜」目標)或 1(表示一個「簡單」目標)。一個" "「簡單」目標僅包含一個 :class:`Name` 節點,且不出現在括號之間;所有其他目標都" -"被視為是複雜的。只有簡單目標會出現在模組和類別" -"的 :attr:`~object.__annotations__` 字典中。" +"被視為是複雜的。只有簡單目標會出現在模組和類別的 :attr:`~object." +"__annotations__` 字典中。" #: ../../library/ast.rst:902 msgid "" @@ -1733,16 +1730,16 @@ msgid "" "value for 1." msgstr "" "增加賦值 (augmented assignment),例如 ``a += 1``。在下面的範例中,``target`` " -"是 ``x`` 的 :class:`Name` 節點(帶有 :class:`Store` 情境),``op`` " -"是 :class:`Add`,``value`` 是一個值為 1 的 :class:`Constant`。" +"是 ``x`` 的 :class:`Name` 節點(帶有 :class:`Store` 情境),``op`` 是 :class:" +"`Add`,``value`` 是一個值為 1 的 :class:`Constant`。" #: ../../library/ast.rst:951 msgid "" "The ``target`` attribute cannot be of class :class:`Tuple` or :class:`List`, " "unlike the targets of :class:`Assign`." msgstr "" -"與 :class:`Assign` 的目標不同,``target`` 屬性不能屬於 :class:`Tuple` " -"或 :class:`List` 類別。" +"與 :class:`Assign` 的目標不同,``target`` 屬性不能屬於 :class:`Tuple` 或 :" +"class:`List` 類別。" #: ../../library/ast.rst:954 msgid "" @@ -1768,8 +1765,8 @@ msgid "" "normally a :class:`Call` or :class:`Name`, or ``None`` for a standalone " "``raise``. ``cause`` is the optional part for ``y`` in ``raise x from y``." msgstr "" -"一個 ``raise`` 陳述式。``exc`` 是要引發的例外物件,通常是 :class:`Call` " -"或 :class:`Name`,若是獨立的 ``raise`` 則為 ``None``。``cause`` 是 ``raise x " +"一個 ``raise`` 陳述式。``exc`` 是要引發的例外物件,通常是 :class:`Call` 或 :" +"class:`Name`,若是獨立的 ``raise`` 則為 ``None``。``cause`` 是 ``raise x " "from y`` 中的可選部分 ``y``。" #: ../../library/ast.rst:971 @@ -1814,11 +1811,11 @@ msgstr "" #: ../../library/ast.rst:998 msgid "" -"Represents a ``del`` statement. ``targets`` is a list of nodes, such " -"as :class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." +"Represents a ``del`` statement. ``targets`` is a list of nodes, such as :" +"class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." msgstr "" -"代表一個 ``del`` 陳述式。``targets`` 是節點串列,例" -"如 :class:`Name`、:class:`Attribute` 或 :class:`Subscript` 節點。" +"代表一個 ``del`` 陳述式。``targets`` 是節點串列,例如 :class:`Name`、:class:" +"`Attribute` 或 :class:`Subscript` 節點。" #: ../../library/ast.rst:1001 msgid "" @@ -1859,9 +1856,9 @@ msgstr "" #: ../../library/ast.rst:1027 msgid "" "A :ref:`type alias ` created through the :keyword:`type` " -"statement. ``name`` is the name of the alias, ``type_params`` is a list " -"of :ref:`type parameters `, and ``value`` is the value of " -"the type alias." +"statement. ``name`` is the name of the alias, ``type_params`` is a list of :" +"ref:`type parameters `, and ``value`` is the value of the " +"type alias." msgstr "" "透過 :keyword:`type` 陳述式建立的\\ :ref:`型別別名 (type alias) `。``name`` 是別名的名稱、``type_params`` 是\\ :ref:`型別參數 (type " @@ -1994,8 +1991,8 @@ msgstr "諸如 ``else`` 之類的可選子句如果不存在,則將被儲存 #: ../../library/ast.rst:1112 msgid "" -"An ``if`` statement. ``test`` holds a single node, such as " -"a :class:`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." +"An ``if`` statement. ``test`` holds a single node, such as a :class:" +"`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." msgstr "" "一個 ``if`` 陳述式。``test`` 保存單個節點,例如 :class:`Compare` 節點。" "``body`` 和 ``orelse`` 各自保存一個節點串列。" @@ -2064,17 +2061,17 @@ msgstr "" #: ../../library/ast.rst:1149 msgid "" "A ``for`` loop. ``target`` holds the variable(s) the loop assigns to, as a " -"single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` " -"or :class:`Subscript` node. ``iter`` holds the item to be looped over, again " -"as a single node. ``body`` and ``orelse`` contain lists of nodes to execute. " +"single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` or :" +"class:`Subscript` node. ``iter`` holds the item to be looped over, again as " +"a single node. ``body`` and ``orelse`` contain lists of nodes to execute. " "Those in ``orelse`` are executed if the loop finishes normally, rather than " "via a ``break`` statement." msgstr "" -"一個 ``for`` 迴圈。 ``target`` 保存迴圈賦予的變數,為單" -"個 :class:`Name`、:class:`Tuple`、:class:`List`、:class:`Attribute` " -"或 :class:`Subscript` 節點。``iter`` 保存要迴圈跑過的項目,也為單個節點。" -"``body`` 和 ``orelse`` 包含要執行的節點串列。如果迴圈正常完成,則執行 " -"``orelse`` 中的內容,而不是透過 ``break`` 陳述式執行。" +"一個 ``for`` 迴圈。 ``target`` 保存迴圈賦予的變數,為單個 :class:`Name`、:" +"class:`Tuple`、:class:`List`、:class:`Attribute` 或 :class:`Subscript` 節點。" +"``iter`` 保存要迴圈跑過的項目,也為單個節點。``body`` 和 ``orelse`` 包含要執" +"行的節點串列。如果迴圈正常完成,則執行 ``orelse`` 中的內容,而不是透過 " +"``break`` 陳述式執行。" #: ../../library/ast.rst:1160 msgid "" @@ -2355,10 +2352,10 @@ msgid "" "clause). ``name`` is a raw string for the name to hold the exception, or " "``None`` if the clause doesn't have ``as foo``. ``body`` is a list of nodes." msgstr "" -"單個 ``except`` 子句。``type`` 是會被匹配的例外型別,通常是一" -"個 :class:`Name` 節點(或者 ``None`` 表示會捕捉到所有例外的 ``except:`` 子" -"句)。``name`` 是用於保存例外的名稱之原始字串,如果子句沒有 ``as foo`` ,則" -"為 ``None``。``body`` 是節點串列。" +"單個 ``except`` 子句。``type`` 是會被匹配的例外型別,通常是一個 :class:" +"`Name` 節點(或者 ``None`` 表示會捕捉到所有例外的 ``except:`` 子句)。" +"``name`` 是用於保存例外的名稱之原始字串,如果子句沒有 ``as foo`` ,則為 " +"``None``。``body`` 是節點串列。" #: ../../library/ast.rst:1321 msgid "" @@ -2416,14 +2413,13 @@ msgstr "" #: ../../library/ast.rst:1357 msgid "" "A single context manager in a ``with`` block. ``context_expr`` is the " -"context manager, often a :class:`Call` node. ``optional_vars`` is " -"a :class:`Name`, :class:`Tuple` or :class:`List` for the ``as foo`` part, or " -"``None`` if that isn't used." +"context manager, often a :class:`Call` node. ``optional_vars`` is a :class:" +"`Name`, :class:`Tuple` or :class:`List` for the ``as foo`` part, or ``None`` " +"if that isn't used." msgstr "" -"``with`` 區塊中的單個情境管理器。``context_expr`` 是情境管理器,通常是一" -"個 :class:`Call` 節點。``Optional_vars`` 是 ``as foo`` 部分" -"的 :class:`Name`、:class:`Tuple` 或 :class:`List`,或者如果不使用則為 " -"``None`` 。" +"``with`` 區塊中的單個情境管理器。``context_expr`` 是情境管理器,通常是一個 :" +"class:`Call` 節點。``Optional_vars`` 是 ``as foo`` 部分的 :class:`Name`、:" +"class:`Tuple` 或 :class:`List`,或者如果不使用則為 ``None`` 。" #: ../../library/ast.rst:1362 msgid "" @@ -2487,8 +2483,8 @@ msgstr "" #: ../../library/ast.rst:1401 msgid "" "A single case pattern in a ``match`` statement. ``pattern`` contains the " -"match pattern that the subject will be matched against. Note that " -"the :class:`AST` nodes produced for patterns differ from those produced for " +"match pattern that the subject will be matched against. Note that the :class:" +"`AST` nodes produced for patterns differ from those produced for " "expressions, even when they share the same syntax." msgstr "" "``match`` 陳述式中的單個案例模式。``pattern`` 包含主題將與之匹配的匹配模式。" @@ -3202,15 +3198,15 @@ msgstr ":ref:`型別參數 `\\ 可以存在於類別、函式和型 #: ../../library/ast.rst:1806 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``." +"``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`,它代表約束;否則它代表界限。``default_value`` 為預設值;如" -"果 :class:`!TypeVar` 沒有預設值,那此屬性會被設為 ``None``。" +"存在的)界限 (bound) 或約束 (constraint)。如果 ``bound`` 是一個 :class:" +"`Tuple`,它代表約束;否則它代表界限。``default_value`` 為預設值;如果 :class:" +"`!TypeVar` 沒有預設值,那此屬性會被設為 ``None``。" #: ../../library/ast.rst:1812 msgid "" @@ -3670,8 +3666,8 @@ msgstr "``bases`` 是被顯式指定的基底類別節點串列。" #: ../../library/ast.rst:2072 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。" @@ -3740,8 +3736,8 @@ msgstr "async 和 await" #: ../../library/ast.rst:2112 msgid "" -"An ``async def`` function definition. Has the same fields " -"as :class:`FunctionDef`." +"An ``async def`` function definition. Has the same fields as :class:" +"`FunctionDef`." msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" #: ../../library/ast.rst:2121 @@ -3749,8 +3745,8 @@ msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." msgstr "" -"一個 ``await`` 運算式。``value`` 是它等待的東西。僅" -"在 :class:`AsyncFunctionDef` 主體 (body) 中有效。" +"一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" +"`AsyncFunctionDef` 主體 (body) 中有效。" #: ../../library/ast.rst:2124 msgid "" @@ -3795,16 +3791,16 @@ msgstr "" #: ../../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.boolop` " -"and :class:`ast.expr_context`) on the returned tree will be singletons. " -"Changes to one will be reflected in all other occurrences of the same value " -"(e.g. :class:`ast.Add`)." +"When a string is parsed by :func:`ast.parse`, operator nodes (subclasses of :" +"class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast." +"boolop` and :class:`ast.expr_context`) on the returned tree will be " +"singletons. Changes to one will be reflected in all other occurrences of the " +"same value (e.g. :class:`ast.Add`)." msgstr "" -"當字串被 :func:`ast.parse` 剖析時,回傳樹的運算子節點" -"(\\ :class:`ast.operator`、:class:`ast.unaryop`、:class:`ast.cmpop`、:class: :class:`ast.boolop` " -"和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所有其他出" -"現的相同值中(例如 :class:`ast.Add`\\ )。" +"當字串被 :func:`ast.parse` 剖析時,回傳樹的運算子節點(\\ :class:`ast." +"operator`、:class:`ast.unaryop`、:class:`ast.cmpop`、:class: :class:`ast." +"boolop` 和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所" +"有其他出現的相同值中(例如 :class:`ast.Add`\\ )。" #: ../../library/ast.rst:2158 msgid ":mod:`ast` Helpers" @@ -3822,8 +3818,8 @@ msgstr "" msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " "filename, mode, flags=FLAGS_VALUE, optimize=optimize)``, where " -"``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0`` and " -"``ast.PyCF_OPTIMIZED_AST`` otherwise." +"``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0`` and ``ast." +"PyCF_OPTIMIZED_AST`` otherwise." msgstr "" "將原始碼剖析為 AST 節點,相當於 ``compile(source, filename, mode, " "flags=FLAGS_VALUE, optimize=optimize)``,其中 ``FLAGS_VALUE`` 在 ``optimize " @@ -3833,18 +3829,18 @@ msgstr "" 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 " -"equivalent to adding :data:`ast.PyCF_TYPE_COMMENTS` to the flags passed " -"to :func:`compile`. This will report syntax errors for misplaced type " +"equivalent to adding :data:`ast.PyCF_TYPE_COMMENTS` to the flags passed to :" +"func:`compile`. This will report syntax errors for misplaced type " "comments. Without this flag, type comments will be ignored, and the " "``type_comment`` field on selected AST nodes will always be ``None``. In " "addition, the locations of ``# type: ignore`` comments will be returned as " "the ``type_ignores`` attribute of :class:`Module` (otherwise it is always an " "empty list)." msgstr "" -"如果給定 ``type_comments=True``,剖析器將被修改為檢查並回傳 :pep:`484` " -"和 :pep:`526` 指定的型別註釋。這相當於將 :data:`ast.PyCF_TYPE_COMMENTS` 新增" -"到傳遞給 :func:`compile` 的旗標中。這將報告錯誤型別註釋的語法錯誤。如果沒有此" -"旗標,型別註釋將被忽略,並且所選 AST 節點上的 ``type_comment`` 欄位將始終為 " +"如果給定 ``type_comments=True``,剖析器將被修改為檢查並回傳 :pep:`484` 和 :" +"pep:`526` 指定的型別註釋。這相當於將 :data:`ast.PyCF_TYPE_COMMENTS` 新增到傳" +"遞給 :func:`compile` 的旗標中。這將報告錯誤型別註釋的語法錯誤。如果沒有此旗" +"標,型別註釋將被忽略,並且所選 AST 節點上的 ``type_comment`` 欄位將始終為 " "``None``。此外,``# type: ignore`` 註釋的位置將作為 :class:`Module` 的 " "``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" @@ -3927,11 +3923,11 @@ msgstr "" #: ../../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 :func:`ast.parse`." +"would produce an equivalent :class:`ast.AST` object if parsed back with :" +"func:`ast.parse`." msgstr "" -"反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使" -"用 :func:`ast.parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" +"反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使用 :func:`ast." +"parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" #: ../../library/ast.rst:2227 msgid "" @@ -3944,8 +3940,8 @@ msgstr "" #: ../../library/ast.rst:2232 msgid "" -"Trying to unparse a highly complex expression would result " -"with :exc:`RecursionError`." +"Trying to unparse a highly complex expression would result with :exc:" +"`RecursionError`." msgstr "嘗試剖析高度複雜的運算式會導致 :exc:`RecursionError`。" #: ../../library/ast.rst:2240 @@ -3993,13 +3989,11 @@ msgstr "由於 Python AST 編譯器的堆疊深度限制,Python 直譯器可 #: ../../library/ast.rst:2263 msgid "" -"It can " -"raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:`MemoryError` " -"and :exc:`RecursionError` depending on the malformed input." +"It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" +"`MemoryError` and :exc:`RecursionError` depending on the malformed input." msgstr "" -"它可能會引" -"發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:`MemoryError` " -"和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" +"它可能會引發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:" +"`MemoryError` 和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" #: ../../library/ast.rst:2267 msgid "Now allows bytes and set literals." @@ -4015,15 +4009,15 @@ msgstr "對於字串輸入,前導空格和定位字元 (tab) 現在已被去 #: ../../library/ast.rst:2279 msgid "" -"Return the docstring of the given *node* (which must be " -"a :class:`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, " -"or :class:`Module` node), or ``None`` if it has no docstring. If *clean* is " -"true, clean up the docstring's indentation with :func:`inspect.cleandoc`." +"Return the docstring of the given *node* (which must be a :class:" +"`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or :class:" +"`Module` node), or ``None`` if it has no docstring. If *clean* is true, " +"clean up the docstring's indentation with :func:`inspect.cleandoc`." msgstr "" -"回傳給定 *node* 的文件字串 (docstring)(必須" -"是 :class:`FunctionDef`、:class:`AsyncFunctionDef`、:class:`ClassDef` " -"或 :class:`Module` 節點)或如果它沒有文件字串則為 ``None``。如果 *clean* 為 " -"true,則使用 :func:`inspect.cleandoc` 清理文件字串的縮排。" +"回傳給定 *node* 的文件字串 (docstring)(必須是 :class:`FunctionDef`、:class:" +"`AsyncFunctionDef`、:class:`ClassDef` 或 :class:`Module` 節點)或如果它沒有文" +"件字串則為 ``None``。如果 *clean* 為 true,則使用 :func:`inspect.cleandoc` 清" +"理文件字串的縮排。" #: ../../library/ast.rst:2285 msgid ":class:`AsyncFunctionDef` is now supported." @@ -4032,13 +4026,13 @@ msgstr "目前已支援 :class:`AsyncFunctionDef`。" #: ../../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`, :attr:`~ast.AST.col_offset`, " -"or :attr:`~ast.AST.end_col_offset`) is missing, return ``None``." +"location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" +"attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, " +"return ``None``." msgstr "" -"取得生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊" -"(:attr:`~ast.AST.lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` " -"或 :attr:`~ast.AST.end_col_offset`\\ )遺漏,則回傳 ``None``。" +"取得生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`~ast.AST." +"lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` 或 :attr:" +"`~ast.AST.end_col_offset`\\ )遺漏,則回傳 ``None``。" #: ../../library/ast.rst:2295 msgid "" @@ -4050,18 +4044,17 @@ msgstr "" #: ../../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 node that supports them. This is rather tedious to fill in for " -"generated nodes, so this helper adds these attributes recursively where not " -"already set, by setting them to the values of the parent node. It works " -"recursively starting at *node*." +"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 " +"node that supports them. This is rather tedious to fill in for generated " +"nodes, so this helper adds these attributes recursively where not already " +"set, by setting them to the values of the parent node. It works recursively " +"starting at *node*." msgstr "" -"當你使用 :func:`compile` 編譯節點樹時,對於每個有支" -"援 :attr:`~ast.AST.lineno` 和 :attr:`~ast.AST.col_offset` 屬性之節點,編譯器" -"預期他們的這些屬性都要存在。填入生成的節點相當繁瑣,因此該輔助工具透過將這些" -"屬性設定為父節點的值,在尚未設定的地方遞迴地新增這些屬性。它從 *node* 開始遞" -"迴地作用。" +"當你使用 :func:`compile` 編譯節點樹時,對於每個有支援 :attr:`~ast.AST." +"lineno` 和 :attr:`~ast.AST.col_offset` 屬性之節點,編譯器預期他們的這些屬性都" +"要存在。填入生成的節點相當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的" +"值,在尚未設定的地方遞迴地新增這些屬性。它從 *node* 開始遞迴地作用。" #: ../../library/ast.rst:2312 msgid "" @@ -4074,15 +4067,13 @@ msgstr "" #: ../../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 *old_node* to *new_node* if " -"possible, and return *new_node*." +"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 " +"*old_node* to *new_node* if possible, and return *new_node*." msgstr "" -"如果可行,將原始位置" -"(:attr:`~ast.AST.lineno`、:attr:`~ast.AST.col_offset`、:attr:`~ast.AST.end_lineno` " -"和 :attr:`~ast.AST.end_col_offset` )從 *old_node* 複製到 *new_node*,並回傳 " -"*new_node* 。" +"如果可行,將原始位置(:attr:`~ast.AST.lineno`、:attr:`~ast.AST.col_offset`、:" +"attr:`~ast.AST.end_lineno` 和 :attr:`~ast.AST.end_col_offset` )從 " +"*old_node* 複製到 *new_node*,並回傳 *new_node* 。" #: ../../library/ast.rst:2326 msgid "" @@ -4126,13 +4117,13 @@ msgstr "這個類別應該被子類別化,子類別新增瀏覽者方法。" #: ../../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, or :meth:`generic_visit` if that method doesn't exist." +"Visit a node. The default implementation calls the method called :samp:" +"`self.visit_{classname}` where *classname* is the name of the node class, " +"or :meth:`generic_visit` if that method doesn't exist." msgstr "" "瀏覽一個節點。預設實作呼叫名為 :samp:`self.visit_{classname}` 的方法,其中 " -"*classname* 是節點類別的名稱,或者在該方法不存在時呼" -"叫 :meth:`generic_visit`。" +"*classname* 是節點類別的名稱,或者在該方法不存在時呼叫 :meth:" +"`generic_visit`。" #: ../../library/ast.rst:2360 msgid "This visitor calls :meth:`visit` on all children of the node." @@ -4153,19 +4144,19 @@ msgstr "處理所有常數節點。" #: ../../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:`NodeTransformer`) that allows modifications." +"during traversal. For this a special visitor exists (:class:" +"`NodeTransformer`) that allows modifications." msgstr "" -"如果你想在遍歷期間將變更應用 (apply) 於節點,請不要使" -"用 :class:`NodeVisitor`。為此,有個允許修改的特殊遍歷瀏覽者工" -"具 :class:`NodeTransformer`。" +"如果你想在遍歷期間將變更應用 (apply) 於節點,請不要使用 :class:" +"`NodeVisitor`。為此,有個允許修改的特殊遍歷瀏覽者工具 :class:" +"`NodeTransformer`。" #: ../../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 will not be called in future Python versions. Add " -"the :meth:`visit_Constant` method to handle all constant nodes." +"Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" +"`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated now and " +"will not be called in future Python versions. Add the :meth:" +"`visit_Constant` method to handle all constant nodes." msgstr "" ":meth:`!visit_Num`、:meth:`!visit_Str`、:meth:`!visit_Bytes`、:meth:`!" "visit_NameConstant` 和 :meth:`!visit_Ellipsis` 方法現已棄用,並且不會在未來的" @@ -4220,11 +4211,11 @@ msgstr "" #: ../../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.NodeVisitor.generic_visit` method for the node first." +"either transform the child nodes yourself or call the :meth:`~ast." +"NodeVisitor.generic_visit` method for the node first." msgstr "" -"請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或先呼叫該節點" -"的 :meth:`~ast.NodeVisitor.generic_visit` 方法。" +"請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或先呼叫該節點的 :" +"meth:`~ast.NodeVisitor.generic_visit` 方法。" #: ../../library/ast.rst:2409 msgid "" @@ -4238,13 +4229,13 @@ msgstr "" #: ../../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.AST.lineno`), :func:`fix_missing_locations` should be called " -"with the new sub-tree to recalculate the location information::" +"original tree) without giving them location information (such as :attr:`~ast." +"AST.lineno`), :func:`fix_missing_locations` should be called with the new " +"sub-tree to recalculate the location information::" msgstr "" "如果 :class:`NodeTransformer` 引進了新節點(不屬於原始樹的一部分),但沒有給" -"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子樹呼" -"叫 :func:`fix_missing_locations` 以重新計算位置資訊: ::" +"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子樹呼叫 :" +"func:`fix_missing_locations` 以重新計算位置資訊: ::" #: ../../library/ast.rst:2418 msgid "" @@ -4294,21 +4285,21 @@ msgstr "" #: ../../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." +"If *show_empty* is false (the default), optional empty lists will be omitted " +"from the output. Optional ``None`` values are always omitted." msgstr "" -"如果 *show_empty* 為 ``False`` (預設值),則輸出中將省略 ``False`` 的空串列" -"和欄位。" +"如果 *show_empty* 為 false(預設值),則輸出中將省略可選的空串列。" +"可選的 ``None`` 值總是會被省略。" -#: ../../library/ast.rst:2446 +#: ../../library/ast.rst:2447 msgid "Added the *indent* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2449 +#: ../../library/ast.rst:2450 msgid "Added the *show_empty* option." msgstr "新增 *show_empty* 選項。" -#: ../../library/ast.rst:2452 +#: ../../library/ast.rst:2453 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -4360,17 +4351,17 @@ msgstr "" " type_params=[])],\n" " type_ignores=[])" -#: ../../library/ast.rst:2483 +#: ../../library/ast.rst:2484 msgid "Compiler Flags" msgstr "編譯器旗標" -#: ../../library/ast.rst:2485 +#: ../../library/ast.rst:2486 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:2490 +#: ../../library/ast.rst:2491 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." @@ -4378,21 +4369,21 @@ msgstr "" "啟用對最高階 ``await``、``async for``、``async with`` 和非同步綜合運算的支" "援。" -#: ../../library/ast.rst:2497 +#: ../../library/ast.rst:2498 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." msgstr "生成並回傳抽象語法樹,而不是回傳已編譯的程式碼物件。" -#: ../../library/ast.rst:2502 +#: ../../library/ast.rst:2503 msgid "" -"The returned AST is optimized according to the *optimize* argument " -"in :func:`compile` or :func:`ast.parse`." +"The returned AST is optimized according to the *optimize* argument in :func:" +"`compile` or :func:`ast.parse`." msgstr "" "回傳的 AST 會根據 :func:`compile` 或 :func:`ast.parse` 中的 *optimize* 引數進" "行最佳化。" -#: ../../library/ast.rst:2509 +#: ../../library/ast.rst:2510 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." @@ -4400,47 +4391,47 @@ msgstr "" "啟用對 :pep:`484` 和 :pep:`526` 樣式型別註釋的支援 (``# type: ``, ``# " "type: ignore ``)。" -#: ../../library/ast.rst:2518 +#: ../../library/ast.rst:2519 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/ast.rst:2522 +#: ../../library/ast.rst:2523 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:2525 +#: ../../library/ast.rst:2526 msgid "python -m ast [-m ] [-a] [infile]" msgstr "python -m ast [-m ] [-a] [infile]" -#: ../../library/ast.rst:2529 +#: ../../library/ast.rst:2530 msgid "The following options are accepted:" msgstr "以下選項可被接受:" -#: ../../library/ast.rst:2535 +#: ../../library/ast.rst:2536 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/ast.rst:2540 +#: ../../library/ast.rst:2541 msgid "" -"Specify what kind of code must be compiled, like the *mode* argument " -"in :func:`parse`." +"Specify what kind of code must be compiled, like the *mode* argument in :" +"func:`parse`." msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" -#: ../../library/ast.rst:2545 +#: ../../library/ast.rst:2546 msgid "Don't parse type comments." msgstr "不要剖析型別註解。" -#: ../../library/ast.rst:2549 +#: ../../library/ast.rst:2550 msgid "Include attributes such as line numbers and column offsets." msgstr "包括列號和行偏移量等屬性。" -#: ../../library/ast.rst:2554 +#: ../../library/ast.rst:2555 msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST 中節點的縮進(空格數)。" -#: ../../library/ast.rst:2556 +#: ../../library/ast.rst:2557 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." @@ -4448,7 +4439,7 @@ msgstr "" "如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" "則會從 stdin 讀取內容。" -#: ../../library/ast.rst:2562 +#: ../../library/ast.rst:2563 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." @@ -4456,7 +4447,7 @@ msgstr "" "`Green Tree Snakes `_ 是一個外部文件" "資源,提供了有關使用 Python AST 的詳細資訊。" -#: ../../library/ast.rst:2565 +#: ../../library/ast.rst:2566 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -4467,7 +4458,7 @@ msgstr "" "用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" "的工具很有幫助。" -#: ../../library/ast.rst:2570 +#: ../../library/ast.rst:2571 msgid "" "`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " @@ -4477,7 +4468,7 @@ msgstr "" "py>`_ 透過在 token 和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 " "token 和基於剖析樹的視圖。" -#: ../../library/ast.rst:2575 +#: ../../library/ast.rst:2576 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " @@ -4487,7 +4478,7 @@ msgstr "" "(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" "重構 (codemod) 應用程式和 linter 非常有用。" -#: ../../library/ast.rst:2580 +#: ../../library/ast.rst:2581 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " diff --git a/library/asyncio-dev.po b/library/asyncio-dev.po index ad5c2a8c28..ca430f7225 100644 --- a/library/asyncio-dev.po +++ b/library/asyncio-dev.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-06-27 07:36+0000\n" "PO-Revision-Date: 2023-02-18 14:17+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -101,15 +101,6 @@ msgstr "啟用除錯模式時:" #: ../../library/asyncio-dev.rst:49 msgid "" -"asyncio checks for :ref:`coroutines that were not awaited ` and logs them; this mitigates the \"forgotten await\" " -"pitfall." -msgstr "" -"asyncio 會檢查\\ :ref:`未被等待的協程 `\\ 並" -"記錄他們;這會減輕\"被遺忘的等待 (forgotten await)\" 問題。" - -#: ../../library/asyncio-dev.rst:53 -msgid "" "Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` and :meth:" "`loop.call_at` methods) raise an exception if they are called from a wrong " "thread." @@ -118,7 +109,7 @@ msgstr "" "call_soon` 和 :meth:`loop.call_at` 方法),如果從錯誤的執行緒呼叫就會引發例" "外。" -#: ../../library/asyncio-dev.rst:57 +#: ../../library/asyncio-dev.rst:53 msgid "" "The execution time of the I/O selector is logged if it takes too long to " "perform an I/O operation." @@ -126,7 +117,7 @@ msgstr "" "如果執行一個 I/O 操作花費的時間太長,則將 I/O 選擇器 (selector) 的執行時間記" "錄到日誌中。" -#: ../../library/asyncio-dev.rst:60 +#: ../../library/asyncio-dev.rst:56 msgid "" "Callbacks taking longer than 100 milliseconds are logged. The :attr:`loop." "slow_callback_duration` attribute can be used to set the minimum execution " @@ -136,11 +127,11 @@ msgstr "" "slow_callback_duration` 可用於設定以秒為單位的最小執行持續時間,超過這個值執" "行時間就會被視為\"緩慢\"。" -#: ../../library/asyncio-dev.rst:68 +#: ../../library/asyncio-dev.rst:64 msgid "Concurrency and Multithreading" msgstr "並行性和多執行緒 (Concurrency and Multithreading)" -#: ../../library/asyncio-dev.rst:70 +#: ../../library/asyncio-dev.rst:66 msgid "" "An event loop runs in a thread (typically the main thread) and executes all " "callbacks and Tasks in its thread. While a Task is running in the event " @@ -153,7 +144,7 @@ msgstr "" "運行。當一個 Task 執行一個 ``await`` 運算式時,正在執行的 Task 會被暫停,而事" "件迴圈會執行下一個 Task。" -#: ../../library/asyncio-dev.rst:76 +#: ../../library/asyncio-dev.rst:72 msgid "" "To schedule a :term:`callback` from another OS thread, the :meth:`loop." "call_soon_threadsafe` method should be used. Example::" @@ -161,11 +152,11 @@ msgstr "" "要從不同的 OS 執行緒為一個 :term:`callback` 排程,應該使用 :meth:`loop." "call_soon_threadsafe` 方法。例如: ::" -#: ../../library/asyncio-dev.rst:79 +#: ../../library/asyncio-dev.rst:75 msgid "loop.call_soon_threadsafe(callback, *args)" msgstr "loop.call_soon_threadsafe(callback, *args)" -#: ../../library/asyncio-dev.rst:81 +#: ../../library/asyncio-dev.rst:77 msgid "" "Almost all asyncio objects are not thread safe, which is typically not a " "problem unless there is code that works with them from outside of a Task or " @@ -176,11 +167,11 @@ msgstr "" "在 Task 或回呼函式之外有程式需要和它們一起運作。如果需要這樣的程式來呼叫低階 " "asyncio API,應該使用 :meth:`loop.call_soon_threadsafe` 方法,例如: ::" -#: ../../library/asyncio-dev.rst:87 +#: ../../library/asyncio-dev.rst:83 msgid "loop.call_soon_threadsafe(fut.cancel)" msgstr "loop.call_soon_threadsafe(fut.cancel)" -#: ../../library/asyncio-dev.rst:89 +#: ../../library/asyncio-dev.rst:85 msgid "" "To schedule a coroutine object from a different OS thread, the :func:" "`run_coroutine_threadsafe` function should be used. It returns a :class:" @@ -190,7 +181,7 @@ msgstr "" "`run_coroutine_threadsafe` 函式。它會回傳一個 :class:`concurrent.futures." "Future` 以存取結果: ::" -#: ../../library/asyncio-dev.rst:93 +#: ../../library/asyncio-dev.rst:89 msgid "" "async def coro_func():\n" " return await asyncio.sleep(1, 42)\n" @@ -202,11 +193,11 @@ msgid "" "result = future.result()" msgstr "" -#: ../../library/asyncio-dev.rst:102 +#: ../../library/asyncio-dev.rst:98 msgid "To handle signals the event loop must be run in the main thread." msgstr "為了能夠處理訊號,事件迴圈必須於主執行緒中運行。" -#: ../../library/asyncio-dev.rst:105 +#: ../../library/asyncio-dev.rst:101 msgid "" "The :meth:`loop.run_in_executor` method can be used with a :class:" "`concurrent.futures.ThreadPoolExecutor` to execute blocking code in a " @@ -217,7 +208,7 @@ msgstr "" "ThreadPoolExecutor` 一起使用,這能夠在作業系統上另一個不同的執行緒中執行阻塞" "程式,且避免阻塞執行事件迴圈的執行緒。" -#: ../../library/asyncio-dev.rst:110 +#: ../../library/asyncio-dev.rst:106 msgid "" "There is currently no way to schedule coroutines or callbacks directly from " "a different process (such as one started with :mod:`multiprocessing`). The :" @@ -237,11 +228,11 @@ msgstr "" "run_in_executor` 方法也可和 :class:`concurrent.futures.ProcessPoolExecutor` " "搭配使用,以在另一個行程中執行程式。" -#: ../../library/asyncio-dev.rst:124 +#: ../../library/asyncio-dev.rst:120 msgid "Running Blocking Code" msgstr "執行阻塞的程式" -#: ../../library/asyncio-dev.rst:126 +#: ../../library/asyncio-dev.rst:122 msgid "" "Blocking (CPU-bound) code should not be called directly. For example, if a " "function performs a CPU-intensive calculation for 1 second, all concurrent " @@ -250,7 +241,7 @@ msgstr "" "不應該直接呼叫阻塞(CPU 密集型)程式。例如一個執行 1 秒 CPU 密集型計算的函" "式,那麼所有並行非同步 Tasks 和 IO 操作都會被延遲 1 秒。" -#: ../../library/asyncio-dev.rst:131 +#: ../../library/asyncio-dev.rst:127 msgid "" "An executor can be used to run a task in a different thread or even in a " "different process to avoid blocking the OS thread with the event loop. See " @@ -260,11 +251,11 @@ msgstr "" "以避免使用事件迴圈阻塞 OS 執行緒。詳情請見 :meth:`loop.run_in_executor` 方" "法。" -#: ../../library/asyncio-dev.rst:140 +#: ../../library/asyncio-dev.rst:136 msgid "Logging" msgstr "日誌記錄" -#: ../../library/asyncio-dev.rst:142 +#: ../../library/asyncio-dev.rst:138 msgid "" "asyncio uses the :mod:`logging` module and all logging is performed via the " "``\"asyncio\"`` logger." @@ -272,17 +263,17 @@ msgstr "" "asyncio 使用 :mod:`logging` 模組,所有日誌記錄都是透過 ``\"asyncio\"`` " "logger 執行的。" -#: ../../library/asyncio-dev.rst:145 +#: ../../library/asyncio-dev.rst:141 msgid "" "The default log level is :py:const:`logging.INFO`, which can be easily " "adjusted::" msgstr "日誌級別被預設為 :py:const:`logging.INFO`,它可以很容易地被調整: ::" -#: ../../library/asyncio-dev.rst:148 +#: ../../library/asyncio-dev.rst:144 msgid "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" msgstr "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" -#: ../../library/asyncio-dev.rst:151 +#: ../../library/asyncio-dev.rst:147 msgid "" "Network logging can block the event loop. It is recommended to use a " "separate thread for handling logs or use non-blocking IO. For example, see :" @@ -291,11 +282,11 @@ msgstr "" "網路日誌記錄可能會阻塞事件迴圈。建議使用獨立的執行緒來處理日誌或使用非阻塞 " "IO,範例請參見 :ref:`blocking-handlers`。" -#: ../../library/asyncio-dev.rst:159 +#: ../../library/asyncio-dev.rst:155 msgid "Detect never-awaited coroutines" msgstr "偵測從未被等待的 (never-awaited) 協程" -#: ../../library/asyncio-dev.rst:161 +#: ../../library/asyncio-dev.rst:157 msgid "" "When a coroutine function is called, but not awaited (e.g. ``coro()`` " "instead of ``await coro()``) or the coroutine is not scheduled with :meth:" @@ -305,7 +296,7 @@ msgstr "" "者協程沒有透過 :meth:`asyncio.create_task` 被排程,asyncio 將會發出 :exc:" "`RuntimeWarning`: ::" -#: ../../library/asyncio-dev.rst:166 +#: ../../library/asyncio-dev.rst:162 msgid "" "import asyncio\n" "\n" @@ -318,11 +309,11 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-dev.rst:176 ../../library/asyncio-dev.rst:221 +#: ../../library/asyncio-dev.rst:172 ../../library/asyncio-dev.rst:217 msgid "Output::" msgstr "輸出: ::" -#: ../../library/asyncio-dev.rst:178 +#: ../../library/asyncio-dev.rst:174 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" @@ -330,11 +321,11 @@ msgstr "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" -#: ../../library/asyncio-dev.rst:181 ../../library/asyncio-dev.rst:237 +#: ../../library/asyncio-dev.rst:177 ../../library/asyncio-dev.rst:233 msgid "Output in debug mode::" msgstr "除錯模式中的輸出: ::" -#: ../../library/asyncio-dev.rst:183 +#: ../../library/asyncio-dev.rst:179 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" "Coroutine created at (most recent call last)\n" @@ -358,14 +349,14 @@ msgstr "" " test()\n" " test()" -#: ../../library/asyncio-dev.rst:194 +#: ../../library/asyncio-dev.rst:190 msgid "" "The usual fix is to either await the coroutine or call the :meth:`asyncio." "create_task` function::" msgstr "" "常用的修復方法是去等待協程或者呼叫 :meth:`asyncio.create_task` 函式: ::" -#: ../../library/asyncio-dev.rst:197 +#: ../../library/asyncio-dev.rst:193 msgid "" "async def main():\n" " await test()" @@ -373,11 +364,11 @@ msgstr "" "async def main():\n" " await test()" -#: ../../library/asyncio-dev.rst:202 +#: ../../library/asyncio-dev.rst:198 msgid "Detect never-retrieved exceptions" msgstr "偵測從未被取得的 (never-retrieved) 例外" -#: ../../library/asyncio-dev.rst:204 +#: ../../library/asyncio-dev.rst:200 msgid "" "If a :meth:`Future.set_exception` is called but the Future object is never " "awaited on, the exception would never be propagated to the user code. In " @@ -388,11 +379,11 @@ msgstr "" "傳播 (propagate) 到使用者程式。在這種情況下,當 Future 物件被垃圾回收 " "(garbage collected) 時,asyncio 將發出一則日誌訊息。" -#: ../../library/asyncio-dev.rst:209 +#: ../../library/asyncio-dev.rst:205 msgid "Example of an unhandled exception::" msgstr "未處理例外的例子: ::" -#: ../../library/asyncio-dev.rst:211 +#: ../../library/asyncio-dev.rst:207 msgid "" "import asyncio\n" "\n" @@ -414,7 +405,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-dev.rst:223 +#: ../../library/asyncio-dev.rst:219 msgid "" "Task exception was never retrieved\n" "future: \n" @@ -434,7 +425,7 @@ msgstr "" " raise Exception(\"not consumed\")\n" "Exception: not consumed" -#: ../../library/asyncio-dev.rst:232 +#: ../../library/asyncio-dev.rst:228 msgid "" ":ref:`Enable the debug mode ` to get the traceback where " "the task was created::" @@ -442,11 +433,11 @@ msgstr "" ":ref:`啟用除錯模式 `\\ 以取得任務建立處的追蹤資訊 " "(traceback): ::" -#: ../../library/asyncio-dev.rst:235 +#: ../../library/asyncio-dev.rst:231 msgid "asyncio.run(main(), debug=True)" msgstr "asyncio.run(main(), debug=True)" -#: ../../library/asyncio-dev.rst:239 +#: ../../library/asyncio-dev.rst:235 msgid "" "Task exception was never retrieved\n" "future: \n" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index fe2e0e3861..e946d14bce 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-15 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-02-20 12:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -295,8 +295,8 @@ msgid "" msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" #: ../../library/asyncio-eventloop.rst:177 -#: ../../library/asyncio-eventloop.rst:1301 -#: ../../library/asyncio-eventloop.rst:1750 +#: ../../library/asyncio-eventloop.rst:1320 +#: ../../library/asyncio-eventloop.rst:1769 msgid "Example::" msgstr "範例: ::" @@ -587,13 +587,21 @@ msgstr "" #: ../../library/asyncio-eventloop.rst:367 msgid "" +"The full function signature is largely the same as that of the :class:`Task` " +"constructor (or factory) - all of the keyword arguments to this function are " +"passed through to that interface, except *name*, or *context* if it is " +"``None``." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:372 +msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." msgstr "" "如果提供了 *name* 引數且不為 ``None``,則將其設置為任務的名稱,使用 :meth:" "`Task.set_name`。" -#: ../../library/asyncio-eventloop.rst:370 +#: ../../library/asyncio-eventloop.rst:375 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. The current context " @@ -603,19 +611,32 @@ msgstr "" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立目前情境的副" "本。" -#: ../../library/asyncio-eventloop.rst:374 +#: ../../library/asyncio-eventloop.rst:379 msgid "Added the *name* parameter." msgstr "加入 *name* 參數。" -#: ../../library/asyncio-eventloop.rst:377 +#: ../../library/asyncio-eventloop.rst:382 msgid "Added the *context* parameter." msgstr "加入 *context* 參數。" -#: ../../library/asyncio-eventloop.rst:382 +#: ../../library/asyncio-eventloop.rst:385 +msgid "" +"Added ``kwargs`` which passes on arbitrary extra parameters, including " +"``name`` and ``context``." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:388 +msgid "" +"Rolled back the change that passes on *name* and *context* (if it is None), " +"while still passing on other arbitrary keyword arguments (to avoid breaking " +"backwards compatibility with 3.13.3)." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:394 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr "設置將由 :meth:`loop.create_task` 使用的任務工廠。" -#: ../../library/asyncio-eventloop.rst:385 +#: ../../library/asyncio-eventloop.rst:397 msgid "" "If *factory* is ``None`` the default task factory will be set. Otherwise, " "*factory* must be a *callable* with the signature matching ``(loop, coro, " @@ -628,21 +649,31 @@ msgstr "" "迴圈的參照、*coro* 是一個協程物件。該可呼叫物件必須傳遞所有 *kwargs* 並回傳一" "個與 :class:`asyncio.Task` 相容的物件。" -#: ../../library/asyncio-eventloop.rst:393 +#: ../../library/asyncio-eventloop.rst:403 +msgid "Required that all *kwargs* are passed on to :class:`asyncio.Task`." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:406 +msgid "" +"*name* is no longer passed to task factories. *context* is no longer passed " +"to task factories if it is ``None``." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:412 msgid "Return a task factory or ``None`` if the default one is in use." msgstr "回傳任務工廠,如果使用預設任務工廠則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:397 +#: ../../library/asyncio-eventloop.rst:416 msgid "Opening network connections" msgstr "打開網路連線" -#: ../../library/asyncio-eventloop.rst:409 +#: ../../library/asyncio-eventloop.rst:428 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." msgstr "打開以 *host* 和 *port* 指定之給定地址的串流傳輸連線。" -#: ../../library/asyncio-eventloop.rst:412 +#: ../../library/asyncio-eventloop.rst:431 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 " @@ -651,13 +682,13 @@ msgstr "" "根據 *host*(或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" "`~socket.AF_INET` 或 :py:const:`~socket.AF_INET6`。" -#: ../../library/asyncio-eventloop.rst:416 +#: ../../library/asyncio-eventloop.rst:435 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" -#: ../../library/asyncio-eventloop.rst:418 -#: ../../library/asyncio-eventloop.rst:1211 -#: ../../library/asyncio-eventloop.rst:1228 +#: ../../library/asyncio-eventloop.rst:437 +#: ../../library/asyncio-eventloop.rst:1230 +#: ../../library/asyncio-eventloop.rst:1247 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -665,24 +696,24 @@ msgstr "" "*protocol_factory* 必須是一個回傳 :ref:`asyncio protocol ` " "實作的可呼叫函式。" -#: ../../library/asyncio-eventloop.rst:421 +#: ../../library/asyncio-eventloop.rst:440 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:424 +#: ../../library/asyncio-eventloop.rst:443 msgid "The chronological synopsis of the underlying operation is as follows:" msgstr "底層操作的時間軸簡介如下:" -#: ../../library/asyncio-eventloop.rst:426 +#: ../../library/asyncio-eventloop.rst:445 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." msgstr "建立連線並為其建立\\ :ref:`傳輸 `。" -#: ../../library/asyncio-eventloop.rst:429 +#: ../../library/asyncio-eventloop.rst:448 msgid "" "*protocol_factory* is called without arguments and is expected to return a :" "ref:`protocol ` instance." @@ -690,7 +721,7 @@ msgstr "" "*protocol_factory* 在無引數的情況下被呼叫,並且預計回傳一個 :ref:`協定 " "` 實例。" -#: ../../library/asyncio-eventloop.rst:432 +#: ../../library/asyncio-eventloop.rst:451 msgid "" "The protocol instance is coupled with the transport by calling its :meth:" "`~BaseProtocol.connection_made` method." @@ -698,21 +729,21 @@ msgstr "" "通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協議實例與傳輸連線在" "一起。" -#: ../../library/asyncio-eventloop.rst:435 +#: ../../library/asyncio-eventloop.rst:454 msgid "A ``(transport, protocol)`` tuple is returned on success." msgstr "成功時回傳一個 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:437 +#: ../../library/asyncio-eventloop.rst:456 msgid "" "The created transport is an implementation-dependent bidirectional stream." msgstr "建立的傳輸是一個依賴實作的雙向串流。" -#: ../../library/asyncio-eventloop.rst:440 -#: ../../library/asyncio-eventloop.rst:573 +#: ../../library/asyncio-eventloop.rst:459 +#: ../../library/asyncio-eventloop.rst:592 msgid "Other arguments:" msgstr "其他引數:" -#: ../../library/asyncio-eventloop.rst:442 +#: ../../library/asyncio-eventloop.rst:461 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` " @@ -724,11 +755,11 @@ msgstr "" "果 *ssl* 為 :class:`ssl.SSLContext` 物件,則使用該情境來建立傳輸;如果 *ssl* " "為 :const:`True`,則使用 :func:`ssl.create_default_context` 回傳的預設情境。" -#: ../../library/asyncio-eventloop.rst:448 +#: ../../library/asyncio-eventloop.rst:467 msgid ":ref:`SSL/TLS security considerations `" msgstr ":ref:`SSL/TLS 安全考量 `" -#: ../../library/asyncio-eventloop.rst:450 +#: ../../library/asyncio-eventloop.rst:469 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 " @@ -743,7 +774,7 @@ msgstr "" "預設值,必須傳遞 *server_hostname* 的值。若 *server_hostname* 為空字串,將停" "用主機名稱匹配(這是一個嚴重的安全風險,可能導致中間人攻擊)。" -#: ../../library/asyncio-eventloop.rst:458 +#: ../../library/asyncio-eventloop.rst:477 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " @@ -754,7 +785,7 @@ msgstr "" "getaddrinfo() 進行 *host* 解析。若有給定這些應該都是相應 :mod:`socket` 模組常" "數的整數。" -#: ../../library/asyncio-eventloop.rst:463 +#: ../../library/asyncio-eventloop.rst:482 msgid "" "*happy_eyeballs_delay*, if given, enables Happy Eyeballs for this " "connection. It should be a floating-point number representing the amount of " @@ -768,7 +799,7 @@ msgstr "" "`8305` 中定義的「連線嘗試延遲」。RFC 建議的合理預設值為 ``0.25`` 秒(250 毫" "秒)。" -#: ../../library/asyncio-eventloop.rst:471 +#: ../../library/asyncio-eventloop.rst:490 msgid "" "*interleave* controls address reordering when a host name resolves to " "multiple IP addresses. If ``0`` or unspecified, no reordering is done, and " @@ -784,7 +815,7 @@ msgstr "" "族計數」。如果未指定 *happy_eyeballs_delay*,則預設值為 ``0``,如果指定則為 " "``1``。" -#: ../../library/asyncio-eventloop.rst:480 +#: ../../library/asyncio-eventloop.rst:499 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 " @@ -795,9 +826,9 @@ msgstr "" "輸使用。如果提供了 *sock*,則不應指定 *host*、*port*、*family*、*proto*、" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" -#: ../../library/asyncio-eventloop.rst:488 -#: ../../library/asyncio-eventloop.rst:604 -#: ../../library/asyncio-eventloop.rst:852 +#: ../../library/asyncio-eventloop.rst:507 +#: ../../library/asyncio-eventloop.rst:623 +#: ../../library/asyncio-eventloop.rst:871 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -806,7 +837,7 @@ msgstr "" "引數 *sock* 將 socket 所有權轉移給所建立的傳輸 socket,請呼叫傳輸的 :meth:" "`~asyncio.BaseTransport.close` 方法。" -#: ../../library/asyncio-eventloop.rst:492 +#: ../../library/asyncio-eventloop.rst:511 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 " @@ -816,8 +847,8 @@ msgstr "" "地綁定 socket。將使用 ``getaddrinfo()`` 查找 *local_host* 和 *local_port*,方" "式類似於 *host* 和 *port*。" -#: ../../library/asyncio-eventloop.rst:496 -#: ../../library/asyncio-eventloop.rst:948 +#: ../../library/asyncio-eventloop.rst:515 +#: ../../library/asyncio-eventloop.rst:967 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. " @@ -827,10 +858,10 @@ msgstr "" "在那之前若未完成則會中斷連線。如果為 ``None`` (預設值),則會等待 ``60.0`` " "秒。" -#: ../../library/asyncio-eventloop.rst:500 -#: ../../library/asyncio-eventloop.rst:759 -#: ../../library/asyncio-eventloop.rst:863 -#: ../../library/asyncio-eventloop.rst:952 +#: ../../library/asyncio-eventloop.rst:519 +#: ../../library/asyncio-eventloop.rst:778 +#: ../../library/asyncio-eventloop.rst:882 +#: ../../library/asyncio-eventloop.rst:971 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`` " @@ -839,7 +870,7 @@ msgstr "" "*ssl_shutdown_timeout* 是等待 SSL 關閉完成以前中斷連線的時間,以秒為單位。如" "果為 ``None`` (預設值),則會等待 ``30.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:504 +#: ../../library/asyncio-eventloop.rst:523 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -853,12 +884,12 @@ msgstr "" "包含所有錯誤訊息的單一 ``OSError``。當 ``all_errors`` 為 ``True`` 時,將引發" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" -#: ../../library/asyncio-eventloop.rst:514 -#: ../../library/asyncio-eventloop.rst:771 +#: ../../library/asyncio-eventloop.rst:533 +#: ../../library/asyncio-eventloop.rst:790 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" -#: ../../library/asyncio-eventloop.rst:518 +#: ../../library/asyncio-eventloop.rst:537 msgid "" "The socket option :ref:`socket.TCP_NODELAY ` is set " "by default for all TCP connections." @@ -866,16 +897,16 @@ msgstr "" "所有 TCP 連線都預設有 :ref:`socket.TCP_NODELAY ` " "socket 選項。" -#: ../../library/asyncio-eventloop.rst:523 -#: ../../library/asyncio-eventloop.rst:873 +#: ../../library/asyncio-eventloop.rst:542 +#: ../../library/asyncio-eventloop.rst:892 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:527 +#: ../../library/asyncio-eventloop.rst:546 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "加入 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-eventloop.rst:529 +#: ../../library/asyncio-eventloop.rst:548 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 " @@ -891,24 +922,24 @@ msgstr "" "用戶端的使用者體驗變差。本文件具體說明了減少此用戶可見延遲的演算法要求並提供" "了一種演算法。" -#: ../../library/asyncio-eventloop.rst:538 +#: ../../library/asyncio-eventloop.rst:557 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" -#: ../../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 +#: ../../library/asyncio-eventloop.rst:561 +#: ../../library/asyncio-eventloop.rst:687 +#: ../../library/asyncio-eventloop.rst:804 +#: ../../library/asyncio-eventloop.rst:844 +#: ../../library/asyncio-eventloop.rst:896 +#: ../../library/asyncio-eventloop.rst:979 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:544 +#: ../../library/asyncio-eventloop.rst:563 msgid "*all_errors* was added." msgstr "已新增 *all_errors*。" -#: ../../library/asyncio-eventloop.rst:549 +#: ../../library/asyncio-eventloop.rst:568 msgid "" "The :func:`open_connection` function is a high-level alternative API. It " "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " @@ -917,11 +948,11 @@ msgstr "" "函式 :func:`open_connection` 是高階的替代 API。它回傳一對 (:class:" "`StreamReader`, :class:`StreamWriter`) 可直接在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:560 +#: ../../library/asyncio-eventloop.rst:579 msgid "Create a datagram connection." msgstr "建立一個資料報連線。" -#: ../../library/asyncio-eventloop.rst:562 +#: ../../library/asyncio-eventloop.rst:581 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 " @@ -931,13 +962,13 @@ msgstr "" "或 :py:const:`~socket.AF_UNIX`,視乎 *host*\\ (或提供的 *family* 引數)而" "定。" -#: ../../library/asyncio-eventloop.rst:566 +#: ../../library/asyncio-eventloop.rst:585 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" -#: ../../library/asyncio-eventloop.rst:568 -#: ../../library/asyncio-eventloop.rst:695 -#: ../../library/asyncio-eventloop.rst:844 +#: ../../library/asyncio-eventloop.rst:587 +#: ../../library/asyncio-eventloop.rst:714 +#: ../../library/asyncio-eventloop.rst:863 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -945,12 +976,12 @@ msgstr "" "*protocol_factory* 必須是可呼叫的函式,回傳 :ref:`protocol ` 實作。" -#: ../../library/asyncio-eventloop.rst:571 -#: ../../library/asyncio-eventloop.rst:650 +#: ../../library/asyncio-eventloop.rst:590 +#: ../../library/asyncio-eventloop.rst:669 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:575 +#: ../../library/asyncio-eventloop.rst:594 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 :" @@ -959,7 +990,7 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:579 +#: ../../library/asyncio-eventloop.rst:598 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* " @@ -969,7 +1000,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:583 +#: ../../library/asyncio-eventloop.rst:602 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -980,7 +1011,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:588 +#: ../../library/asyncio-eventloop.rst:607 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 " @@ -992,13 +1023,13 @@ msgstr "" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" "const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:594 +#: ../../library/asyncio-eventloop.rst:613 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:597 +#: ../../library/asyncio-eventloop.rst:616 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 " @@ -1009,7 +1040,7 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:608 +#: ../../library/asyncio-eventloop.rst:627 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." @@ -1017,7 +1048,7 @@ msgstr "" "請參閱 :ref:`UDP 回應用戶端協議 ` 和 :ref:" "`UDP 回應伺服器協議 ` 範例。" -#: ../../library/asyncio-eventloop.rst:611 +#: ../../library/asyncio-eventloop.rst:630 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1025,11 +1056,11 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:615 +#: ../../library/asyncio-eventloop.rst:634 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:618 +#: ../../library/asyncio-eventloop.rst:637 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " @@ -1038,7 +1069,7 @@ msgstr "" "不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:624 +#: ../../library/asyncio-eventloop.rst:643 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1047,7 +1078,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:628 +#: ../../library/asyncio-eventloop.rst:647 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT ` is set by default " @@ -1273,7 +1304,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:789 +#: ../../library/asyncio-eventloop.rst:808 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1282,7 +1313,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:801 +#: ../../library/asyncio-eventloop.rst:820 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1290,7 +1321,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:804 +#: ../../library/asyncio-eventloop.rst:823 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`, " @@ -1300,7 +1331,7 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:809 +#: ../../library/asyncio-eventloop.rst:828 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 " @@ -1309,13 +1340,13 @@ msgstr "" "如果 *cleanup_socket* 為真,則 Unix socket 將在伺服器關閉時自動從檔案系統中刪" "除,除非在建立伺服器後替換了 socket。" -#: ../../library/asyncio-eventloop.rst:813 +#: ../../library/asyncio-eventloop.rst:832 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:820 +#: ../../library/asyncio-eventloop.rst:839 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1323,26 +1354,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:829 +#: ../../library/asyncio-eventloop.rst:848 msgid "Added the *cleanup_socket* parameter." msgstr "加入 *cleanup_socket* 參數。" -#: ../../library/asyncio-eventloop.rst:837 +#: ../../library/asyncio-eventloop.rst:856 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "將已接受的連線包裝成傳輸層/協議對。" -#: ../../library/asyncio-eventloop.rst:839 +#: ../../library/asyncio-eventloop.rst:858 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:842 -#: ../../library/asyncio-eventloop.rst:934 +#: ../../library/asyncio-eventloop.rst:861 +#: ../../library/asyncio-eventloop.rst:953 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:847 +#: ../../library/asyncio-eventloop.rst:866 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1350,13 +1381,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:856 +#: ../../library/asyncio-eventloop.rst:875 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:859 +#: ../../library/asyncio-eventloop.rst:878 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. " @@ -1365,29 +1396,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:867 +#: ../../library/asyncio-eventloop.rst:886 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:881 +#: ../../library/asyncio-eventloop.rst:900 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:887 +#: ../../library/asyncio-eventloop.rst:906 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:890 +#: ../../library/asyncio-eventloop.rst:909 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:892 +#: ../../library/asyncio-eventloop.rst:911 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:894 -#: ../../library/asyncio-eventloop.rst:1155 +#: ../../library/asyncio-eventloop.rst:913 +#: ../../library/asyncio-eventloop.rst:1174 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 " @@ -1399,7 +1430,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:901 +#: ../../library/asyncio-eventloop.rst:920 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 " @@ -1408,7 +1439,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:905 +#: ../../library/asyncio-eventloop.rst:924 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1416,15 +1447,15 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:912 +#: ../../library/asyncio-eventloop.rst:931 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:920 +#: ../../library/asyncio-eventloop.rst:939 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:922 +#: ../../library/asyncio-eventloop.rst:941 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " @@ -1433,7 +1464,7 @@ msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" "作了對於 *transport* 的協議,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:926 +#: ../../library/asyncio-eventloop.rst:945 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1444,13 +1475,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:931 +#: ../../library/asyncio-eventloop.rst:950 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:936 +#: ../../library/asyncio-eventloop.rst:955 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1458,11 +1489,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:940 +#: ../../library/asyncio-eventloop.rst:959 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:942 +#: ../../library/asyncio-eventloop.rst:961 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1470,17 +1501,17 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:945 +#: ../../library/asyncio-eventloop.rst:964 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:965 +#: ../../library/asyncio-eventloop.rst:984 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:969 +#: ../../library/asyncio-eventloop.rst:988 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." @@ -1488,14 +1519,14 @@ msgstr "" "開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:973 -#: ../../library/asyncio-eventloop.rst:987 +#: ../../library/asyncio-eventloop.rst:992 +#: ../../library/asyncio-eventloop.rst:1006 msgid "" "Any preexisting callback registered for *fd* is cancelled and replaced by " "*callback*." msgstr "任何預先存在、為 *fd* 註冊的回呼函式將被取消並替換為 *callback*。" -#: ../../library/asyncio-eventloop.rst:978 +#: ../../library/asyncio-eventloop.rst:997 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1503,7 +1534,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:983 +#: ../../library/asyncio-eventloop.rst:1002 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." @@ -1511,8 +1542,8 @@ msgstr "" "開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:990 -#: ../../library/asyncio-eventloop.rst:1268 +#: ../../library/asyncio-eventloop.rst:1009 +#: ../../library/asyncio-eventloop.rst:1287 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1520,7 +1551,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:995 +#: ../../library/asyncio-eventloop.rst:1014 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1528,7 +1559,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:998 +#: ../../library/asyncio-eventloop.rst:1017 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1536,11 +1567,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:1003 +#: ../../library/asyncio-eventloop.rst:1022 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:1005 +#: ../../library/asyncio-eventloop.rst:1024 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1552,7 +1583,7 @@ msgstr "" "`loop.create_server`\\ )的協議實作比直接使用 socket 的實作更快。然而在某些情" "況下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:1015 +#: ../../library/asyncio-eventloop.rst:1034 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1560,23 +1591,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:1018 +#: ../../library/asyncio-eventloop.rst:1037 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../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:1130 -#: ../../library/asyncio-eventloop.rst:1169 +#: ../../library/asyncio-eventloop.rst:1039 +#: ../../library/asyncio-eventloop.rst:1054 +#: ../../library/asyncio-eventloop.rst:1066 +#: ../../library/asyncio-eventloop.rst:1079 +#: ../../library/asyncio-eventloop.rst:1095 +#: ../../library/asyncio-eventloop.rst:1111 +#: ../../library/asyncio-eventloop.rst:1122 +#: ../../library/asyncio-eventloop.rst:1149 +#: ../../library/asyncio-eventloop.rst:1188 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:1022 +#: ../../library/asyncio-eventloop.rst:1041 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 " @@ -1585,7 +1616,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1030 +#: ../../library/asyncio-eventloop.rst:1049 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1593,11 +1624,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:1033 +#: ../../library/asyncio-eventloop.rst:1052 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1042 +#: ../../library/asyncio-eventloop.rst:1061 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1605,11 +1636,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1045 +#: ../../library/asyncio-eventloop.rst:1064 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1054 +#: ../../library/asyncio-eventloop.rst:1073 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1617,11 +1648,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1058 +#: ../../library/asyncio-eventloop.rst:1077 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1067 +#: ../../library/asyncio-eventloop.rst:1086 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1629,7 +1660,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1070 +#: ../../library/asyncio-eventloop.rst:1089 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 " @@ -1641,8 +1672,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1078 -#: ../../library/asyncio-eventloop.rst:1132 +#: ../../library/asyncio-eventloop.rst:1097 +#: ../../library/asyncio-eventloop.rst:1151 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 " @@ -1651,7 +1682,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1086 +#: ../../library/asyncio-eventloop.rst:1105 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1659,20 +1690,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1090 +#: ../../library/asyncio-eventloop.rst:1109 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1099 +#: ../../library/asyncio-eventloop.rst:1118 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1101 +#: ../../library/asyncio-eventloop.rst:1120 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1105 +#: ../../library/asyncio-eventloop.rst:1124 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1683,7 +1714,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1114 +#: ../../library/asyncio-eventloop.rst:1133 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1691,7 +1722,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1121 +#: ../../library/asyncio-eventloop.rst:1140 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1699,7 +1730,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1124 +#: ../../library/asyncio-eventloop.rst:1143 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 " @@ -1710,34 +1741,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1139 +#: ../../library/asyncio-eventloop.rst:1158 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1145 +#: ../../library/asyncio-eventloop.rst:1164 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:1148 +#: ../../library/asyncio-eventloop.rst:1167 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1150 +#: ../../library/asyncio-eventloop.rst:1169 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:1153 +#: ../../library/asyncio-eventloop.rst:1172 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1162 +#: ../../library/asyncio-eventloop.rst:1181 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 " @@ -1746,7 +1777,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1166 +#: ../../library/asyncio-eventloop.rst:1185 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1754,19 +1785,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1175 +#: ../../library/asyncio-eventloop.rst:1194 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1181 +#: ../../library/asyncio-eventloop.rst:1200 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1186 +#: ../../library/asyncio-eventloop.rst:1205 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1189 +#: ../../library/asyncio-eventloop.rst:1208 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1776,7 +1807,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1196 +#: ../../library/asyncio-eventloop.rst:1215 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1787,19 +1818,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1204 +#: ../../library/asyncio-eventloop.rst:1223 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1209 +#: ../../library/asyncio-eventloop.rst:1228 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1214 +#: ../../library/asyncio-eventloop.rst:1233 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1216 +#: ../../library/asyncio-eventloop.rst:1235 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1808,22 +1839,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1220 -#: ../../library/asyncio-eventloop.rst:1237 +#: ../../library/asyncio-eventloop.rst:1239 +#: ../../library/asyncio-eventloop.rst:1256 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1226 +#: ../../library/asyncio-eventloop.rst:1245 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1231 +#: ../../library/asyncio-eventloop.rst:1250 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1233 +#: ../../library/asyncio-eventloop.rst:1252 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1832,7 +1863,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1242 +#: ../../library/asyncio-eventloop.rst:1261 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1840,20 +1871,20 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1247 +#: ../../library/asyncio-eventloop.rst:1266 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:1252 +#: ../../library/asyncio-eventloop.rst:1271 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1258 +#: ../../library/asyncio-eventloop.rst:1277 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1260 +#: ../../library/asyncio-eventloop.rst:1279 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1864,7 +1895,7 @@ msgstr "" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1265 +#: ../../library/asyncio-eventloop.rst:1284 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1872,16 +1903,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1271 +#: ../../library/asyncio-eventloop.rst:1290 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中叫用。" -#: ../../library/asyncio-eventloop.rst:1276 +#: ../../library/asyncio-eventloop.rst:1295 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1278 +#: ../../library/asyncio-eventloop.rst:1297 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1889,19 +1920,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1285 +#: ../../library/asyncio-eventloop.rst:1304 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1289 +#: ../../library/asyncio-eventloop.rst:1308 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1293 +#: ../../library/asyncio-eventloop.rst:1312 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1295 +#: ../../library/asyncio-eventloop.rst:1314 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1910,7 +1941,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1303 +#: ../../library/asyncio-eventloop.rst:1322 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -1953,7 +1984,7 @@ msgid "" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1343 +#: ../../library/asyncio-eventloop.rst:1362 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -1965,11 +1996,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1348 +#: ../../library/asyncio-eventloop.rst:1367 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1350 +#: ../../library/asyncio-eventloop.rst:1369 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -1977,7 +2008,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1353 +#: ../../library/asyncio-eventloop.rst:1372 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 " @@ -1988,7 +2019,7 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1362 +#: ../../library/asyncio-eventloop.rst:1381 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." @@ -1997,26 +2028,26 @@ msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" "須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1366 +#: ../../library/asyncio-eventloop.rst:1385 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1372 +#: ../../library/asyncio-eventloop.rst:1391 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1374 +#: ../../library/asyncio-eventloop.rst:1393 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1378 +#: ../../library/asyncio-eventloop.rst:1397 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1380 +#: ../../library/asyncio-eventloop.rst:1399 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -2029,7 +2060,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1388 +#: ../../library/asyncio-eventloop.rst:1407 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 " @@ -2038,7 +2069,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1394 +#: ../../library/asyncio-eventloop.rst:1413 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2046,18 +2077,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1399 +#: ../../library/asyncio-eventloop.rst:1418 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" "回傳目前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1406 +#: ../../library/asyncio-eventloop.rst:1425 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1408 +#: ../../library/asyncio-eventloop.rst:1427 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 " @@ -2066,17 +2097,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1412 +#: ../../library/asyncio-eventloop.rst:1431 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1417 +#: ../../library/asyncio-eventloop.rst:1436 msgid "Call the current event loop exception handler." msgstr "呼叫目前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1419 +#: ../../library/asyncio-eventloop.rst:1438 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2084,55 +2115,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1422 +#: ../../library/asyncio-eventloop.rst:1441 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1423 +#: ../../library/asyncio-eventloop.rst:1442 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1424 +#: ../../library/asyncio-eventloop.rst:1443 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1425 +#: ../../library/asyncio-eventloop.rst:1444 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1426 +#: ../../library/asyncio-eventloop.rst:1445 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1427 +#: ../../library/asyncio-eventloop.rst:1446 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1428 +#: ../../library/asyncio-eventloop.rst:1447 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1429 +#: ../../library/asyncio-eventloop.rst:1448 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1430 +#: ../../library/asyncio-eventloop.rst:1449 msgid "'source_traceback' (optional): Traceback of the source;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1431 +#: ../../library/asyncio-eventloop.rst:1450 msgid "'handle_traceback' (optional): Traceback of the handle;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1432 +#: ../../library/asyncio-eventloop.rst:1451 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1433 +#: ../../library/asyncio-eventloop.rst:1452 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1437 +#: ../../library/asyncio-eventloop.rst:1456 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2140,15 +2171,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1442 +#: ../../library/asyncio-eventloop.rst:1461 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1446 +#: ../../library/asyncio-eventloop.rst:1465 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1448 +#: ../../library/asyncio-eventloop.rst:1467 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2156,17 +2187,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1454 +#: ../../library/asyncio-eventloop.rst:1473 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1458 +#: ../../library/asyncio-eventloop.rst:1477 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1463 +#: ../../library/asyncio-eventloop.rst:1482 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 " @@ -2175,19 +2206,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1486 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1471 +#: ../../library/asyncio-eventloop.rst:1490 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1475 +#: ../../library/asyncio-eventloop.rst:1494 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1477 +#: ../../library/asyncio-eventloop.rst:1496 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2197,7 +2228,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1484 +#: ../../library/asyncio-eventloop.rst:1503 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2207,26 +2238,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1496 +#: ../../library/asyncio-eventloop.rst:1515 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1499 +#: ../../library/asyncio-eventloop.rst:1518 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1501 +#: ../../library/asyncio-eventloop.rst:1520 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1502 +#: ../../library/asyncio-eventloop.rst:1521 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1505 +#: ../../library/asyncio-eventloop.rst:1524 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2235,7 +2266,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1509 +#: ../../library/asyncio-eventloop.rst:1528 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 " @@ -2246,7 +2277,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1515 +#: ../../library/asyncio-eventloop.rst:1534 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2254,67 +2285,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1518 +#: ../../library/asyncio-eventloop.rst:1537 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1520 +#: ../../library/asyncio-eventloop.rst:1539 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1522 -#: ../../library/asyncio-eventloop.rst:1533 -#: ../../library/asyncio-eventloop.rst:1543 +#: ../../library/asyncio-eventloop.rst:1541 +#: ../../library/asyncio-eventloop.rst:1552 +#: ../../library/asyncio-eventloop.rst:1562 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1523 +#: ../../library/asyncio-eventloop.rst:1542 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1524 -#: ../../library/asyncio-eventloop.rst:1534 -#: ../../library/asyncio-eventloop.rst:1544 +#: ../../library/asyncio-eventloop.rst:1543 +#: ../../library/asyncio-eventloop.rst:1553 +#: ../../library/asyncio-eventloop.rst:1563 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1526 -#: ../../library/asyncio-eventloop.rst:1536 -#: ../../library/asyncio-eventloop.rst:1546 +#: ../../library/asyncio-eventloop.rst:1545 +#: ../../library/asyncio-eventloop.rst:1555 +#: ../../library/asyncio-eventloop.rst:1565 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1528 -#: ../../library/asyncio-eventloop.rst:1538 -#: ../../library/asyncio-eventloop.rst:1548 +#: ../../library/asyncio-eventloop.rst:1547 +#: ../../library/asyncio-eventloop.rst:1557 +#: ../../library/asyncio-eventloop.rst:1567 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:1531 +#: ../../library/asyncio-eventloop.rst:1550 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1541 +#: ../../library/asyncio-eventloop.rst:1560 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1550 +#: ../../library/asyncio-eventloop.rst:1569 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:1553 +#: ../../library/asyncio-eventloop.rst:1572 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2324,7 +2355,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1558 +#: ../../library/asyncio-eventloop.rst:1577 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 " @@ -2333,7 +2364,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1562 +#: ../../library/asyncio-eventloop.rst:1581 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:" @@ -2344,13 +2375,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1567 +#: ../../library/asyncio-eventloop.rst:1586 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1570 +#: ../../library/asyncio-eventloop.rst:1589 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2360,7 +2391,7 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1579 +#: ../../library/asyncio-eventloop.rst:1598 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:1584 +#: ../../library/asyncio-eventloop.rst:1603 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2377,7 +2408,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1587 +#: ../../library/asyncio-eventloop.rst:1606 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2385,13 +2416,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1590 +#: ../../library/asyncio-eventloop.rst:1609 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1593 +#: ../../library/asyncio-eventloop.rst:1612 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2401,7 +2432,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1598 +#: ../../library/asyncio-eventloop.rst:1617 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2414,11 +2445,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1607 +#: ../../library/asyncio-eventloop.rst:1626 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1611 +#: ../../library/asyncio-eventloop.rst:1630 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2426,46 +2457,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1616 +#: ../../library/asyncio-eventloop.rst:1635 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1623 +#: ../../library/asyncio-eventloop.rst:1642 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1628 +#: ../../library/asyncio-eventloop.rst:1647 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1634 +#: ../../library/asyncio-eventloop.rst:1653 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:1637 +#: ../../library/asyncio-eventloop.rst:1656 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1641 +#: ../../library/asyncio-eventloop.rst:1660 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1643 +#: ../../library/asyncio-eventloop.rst:1662 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1650 +#: ../../library/asyncio-eventloop.rst:1669 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1652 +#: ../../library/asyncio-eventloop.rst:1671 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2475,11 +2506,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1656 +#: ../../library/asyncio-eventloop.rst:1675 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1660 +#: ../../library/asyncio-eventloop.rst:1679 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 " @@ -2488,7 +2519,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1665 +#: ../../library/asyncio-eventloop.rst:1684 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2504,30 +2535,30 @@ msgstr "" "\n" "# 此時 srv 已關閉,不再接受新的連線。" -#: ../../library/asyncio-eventloop.rst:1673 +#: ../../library/asyncio-eventloop.rst:1692 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1676 +#: ../../library/asyncio-eventloop.rst:1695 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:1681 +#: ../../library/asyncio-eventloop.rst:1700 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1684 +#: ../../library/asyncio-eventloop.rst:1703 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1687 +#: ../../library/asyncio-eventloop.rst:1706 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)." @@ -2535,53 +2566,53 @@ msgstr "" "伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1693 +#: ../../library/asyncio-eventloop.rst:1712 msgid "Close all existing incoming client connections." msgstr "關閉所有現有的傳入客戶端連線。" -#: ../../library/asyncio-eventloop.rst:1695 +#: ../../library/asyncio-eventloop.rst:1714 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1698 +#: ../../library/asyncio-eventloop.rst:1717 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:1705 +#: ../../library/asyncio-eventloop.rst:1724 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "立即關閉所有現有的傳入客戶端連線,而不等待待定操作完成。" -#: ../../library/asyncio-eventloop.rst:1708 +#: ../../library/asyncio-eventloop.rst:1727 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1711 +#: ../../library/asyncio-eventloop.rst:1730 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:1718 +#: ../../library/asyncio-eventloop.rst:1737 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1725 +#: ../../library/asyncio-eventloop.rst:1744 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1727 +#: ../../library/asyncio-eventloop.rst:1746 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1749 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 " @@ -2594,14 +2625,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1742 +#: ../../library/asyncio-eventloop.rst:1761 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:1746 +#: ../../library/asyncio-eventloop.rst:1765 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2609,7 +2640,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1752 +#: ../../library/asyncio-eventloop.rst:1771 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2635,24 +2666,24 @@ msgstr "" "\n" "asyncio.run(main('127.0.0.1', 0))" -#: ../../library/asyncio-eventloop.rst:1768 +#: ../../library/asyncio-eventloop.rst:1787 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1775 +#: ../../library/asyncio-eventloop.rst:1794 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1780 +#: ../../library/asyncio-eventloop.rst:1799 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1783 +#: ../../library/asyncio-eventloop.rst:1802 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." @@ -2660,11 +2691,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1793 +#: ../../library/asyncio-eventloop.rst:1812 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1795 +#: ../../library/asyncio-eventloop.rst:1814 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2672,17 +2703,17 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1798 +#: ../../library/asyncio-eventloop.rst:1817 msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "預設情況下,asyncio 被配置為要使用 :class:`EventLoop`。" -#: ../../library/asyncio-eventloop.rst:1803 +#: ../../library/asyncio-eventloop.rst:1822 msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "基於 :mod:`selectors` 模組的一個 :class:`AbstractEventLoop` 子類別。" -#: ../../library/asyncio-eventloop.rst:1806 +#: ../../library/asyncio-eventloop.rst:1825 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2691,7 +2722,7 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1810 +#: ../../library/asyncio-eventloop.rst:1829 msgid "" "import asyncio\n" "import selectors\n" @@ -2713,7 +2744,7 @@ msgstr "" "\n" "asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1826 +#: ../../library/asyncio-eventloop.rst:1845 msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." @@ -2721,7 +2752,7 @@ msgstr "" "用於 Windows 的 :class:`AbstractEventLoop` 子類別,使用「I/O 完成埠 (IOCP, I/" "O Completion Ports)」。" -#: ../../library/asyncio-eventloop.rst:1832 +#: ../../library/asyncio-eventloop.rst:1851 msgid "" "`MSDN documentation on I/O Completion Ports `_." @@ -2729,13 +2760,13 @@ msgstr "" "`I/O 完成埠的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1837 +#: ../../library/asyncio-eventloop.rst:1856 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" -#: ../../library/asyncio-eventloop.rst:1840 +#: ../../library/asyncio-eventloop.rst:1859 msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" "`ProactorEventLoop` on Windows." @@ -2743,11 +2774,11 @@ msgstr "" "在 Unix 上是 :class:`SelectorEventLoop` 的別名,在 Windows 上是 :class:" "`ProactorEventLoop` 的別名。" -#: ../../library/asyncio-eventloop.rst:1846 +#: ../../library/asyncio-eventloop.rst:1865 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1848 +#: ../../library/asyncio-eventloop.rst:1867 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2755,11 +2786,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1854 +#: ../../library/asyncio-eventloop.rst:1873 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1856 +#: ../../library/asyncio-eventloop.rst:1875 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." @@ -2770,11 +2801,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1866 +#: ../../library/asyncio-eventloop.rst:1885 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1868 +#: ../../library/asyncio-eventloop.rst:1887 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::" @@ -2782,7 +2813,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1872 +#: ../../library/asyncio-eventloop.rst:1891 msgid "" "import asyncio\n" "\n" @@ -2820,18 +2851,18 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1892 +#: ../../library/asyncio-eventloop.rst:1911 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:1899 +#: ../../library/asyncio-eventloop.rst:1918 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1901 +#: ../../library/asyncio-eventloop.rst:1920 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 " @@ -2840,7 +2871,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1905 +#: ../../library/asyncio-eventloop.rst:1924 msgid "" "import asyncio\n" "import datetime\n" @@ -2886,7 +2917,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1929 +#: ../../library/asyncio-eventloop.rst:1948 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2894,11 +2925,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1936 +#: ../../library/asyncio-eventloop.rst:1955 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1938 +#: ../../library/asyncio-eventloop.rst:1957 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2906,7 +2937,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1941 +#: ../../library/asyncio-eventloop.rst:1960 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -2974,7 +3005,7 @@ msgstr "" " wsock.close()\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1976 +#: ../../library/asyncio-eventloop.rst:1995 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -2982,7 +3013,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1980 +#: ../../library/asyncio-eventloop.rst:1999 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -2990,15 +3021,15 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1988 +#: ../../library/asyncio-eventloop.rst:2007 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:1990 +#: ../../library/asyncio-eventloop.rst:2009 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:1992 +#: ../../library/asyncio-eventloop.rst:2011 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" @@ -3006,7 +3037,7 @@ msgstr "" "使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" "data:`SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:1995 +#: ../../library/asyncio-eventloop.rst:2014 msgid "" "import asyncio\n" "import functools\n" diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index 6858c444a2..fea78a7148 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-23 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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:430 +#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:437 msgid "" "import asyncio\n" "\n" @@ -140,13 +140,13 @@ msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "新增 *happy_eyeballs_delay* 和 *interleave* 參數。" #: ../../library/asyncio-stream.rst:84 ../../library/asyncio-stream.rst:128 -#: ../../library/asyncio-stream.rst:164 ../../library/asyncio-stream.rst:195 +#: ../../library/asyncio-stream.rst:164 ../../library/asyncio-stream.rst:199 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" #: ../../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 +#: ../../library/asyncio-stream.rst:167 ../../library/asyncio-stream.rst:202 +#: ../../library/asyncio-stream.rst:404 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "新增 *ssl_shutdown_timeout* 參數。" @@ -180,7 +180,7 @@ msgid "" "The rest of the arguments are passed directly to :meth:`loop.create_server`." msgstr "剩下的引數將會直接傳遞給 :meth:`loop.create_server`。" -#: ../../library/asyncio-stream.rst:121 ../../library/asyncio-stream.rst:185 +#: ../../library/asyncio-stream.rst:121 ../../library/asyncio-stream.rst:189 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." @@ -211,7 +211,7 @@ msgstr "與 :func:`open_connection` 相似,但是是操作 Unix sockets。" msgid "See also the documentation of :meth:`loop.create_unix_connection`." msgstr "另請參閱 :meth:`loop.create_unix_connection` 文件。" -#: ../../library/asyncio-stream.rst:158 ../../library/asyncio-stream.rst:189 +#: ../../library/asyncio-stream.rst:158 ../../library/asyncio-stream.rst:193 msgid "Availability" msgstr "" @@ -232,10 +232,17 @@ msgid "Similar to :func:`start_server` but works with Unix sockets." msgstr "與 :func:`start_server` 相似,但會是操作 Unix sockets。" #: ../../library/asyncio-stream.rst:181 +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-stream.rst:185 msgid "See also the documentation of :meth:`loop.create_unix_server`." msgstr "另請參閱 :meth:`loop.create_unix_server` 文件。" -#: ../../library/asyncio-stream.rst:191 +#: ../../library/asyncio-stream.rst:195 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :term:`path-like object`." @@ -243,11 +250,15 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可以是" "個 :term:`path-like object`。" -#: ../../library/asyncio-stream.rst:203 +#: ../../library/asyncio-stream.rst:205 +msgid "Added the *cleanup_socket* parameter." +msgstr "新增 *cleanup_socket* 參數。" + +#: ../../library/asyncio-stream.rst:210 msgid "StreamReader" msgstr "StreamReader" -#: ../../library/asyncio-stream.rst:207 +#: ../../library/asyncio-stream.rst:214 msgid "" "Represents a reader object that provides APIs to read data from the IO " "stream. As an :term:`asynchronous iterable`, the object supports the :" @@ -256,7 +267,7 @@ msgstr "" "表示一個有提供 API 來從 IO 串流中讀取資料的 reader 物件。作為一個 :term:" "`asynchronous iterable`,此物件支援 :keyword:`async for` 陳述式。" -#: ../../library/asyncio-stream.rst:211 +#: ../../library/asyncio-stream.rst:218 msgid "" "It is not recommended to instantiate *StreamReader* objects directly; use :" "func:`open_connection` and :func:`start_server` instead." @@ -264,15 +275,15 @@ msgstr "" "不建議直接實例化 *StreamReader* 物件;使用 :func:`open_connection` 和 :func:" "`start_server` 會是較好的做法。" -#: ../../library/asyncio-stream.rst:217 +#: ../../library/asyncio-stream.rst:224 msgid "Acknowledge the EOF." msgstr "" -#: ../../library/asyncio-stream.rst:222 +#: ../../library/asyncio-stream.rst:229 msgid "Read up to *n* bytes from the stream." msgstr "從串流中讀取至多 *n* 個位元組的資料。" -#: ../../library/asyncio-stream.rst:224 +#: ../../library/asyncio-stream.rst:231 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, " @@ -282,39 +293,39 @@ msgstr "" "的 :class:`bytes`。讀取到 EOF 且內部緩衝區是空的,則回傳一個空的 ``bytes`` 物" "件。" -#: ../../library/asyncio-stream.rst:229 +#: ../../library/asyncio-stream.rst:236 msgid "If *n* is ``0``, return an empty ``bytes`` object immediately." msgstr "如果 *n* 為 ``0``,則立即回傳一個空的 ``bytes`` 物件。" -#: ../../library/asyncio-stream.rst:231 +#: ../../library/asyncio-stream.rst:238 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:239 +#: ../../library/asyncio-stream.rst:246 msgid "" "Read one line, where \"line\" is a sequence of bytes ending with ``\\n``." msgstr "讀取一行,其中\"行\"指的是以 ``\\n`` 結尾的位元組序列。" -#: ../../library/asyncio-stream.rst:242 +#: ../../library/asyncio-stream.rst:249 msgid "" "If EOF is received and ``\\n`` was not found, the method returns partially " "read data." msgstr "如果讀取到 EOF 而沒有找到 ``\\n``,該方法會回傳部分的已讀取資料。" -#: ../../library/asyncio-stream.rst:245 +#: ../../library/asyncio-stream.rst:252 msgid "" "If EOF is received and the internal buffer is empty, return an empty " "``bytes`` object." msgstr "如果讀取到 EOF 且內部緩衝區是空的,則回傳一個空的 ``bytes`` 物件。" -#: ../../library/asyncio-stream.rst:251 +#: ../../library/asyncio-stream.rst:258 msgid "Read exactly *n* bytes." msgstr "讀取剛好 *n* 個位元組。" -#: ../../library/asyncio-stream.rst:253 +#: ../../library/asyncio-stream.rst:260 msgid "" "Raise an :exc:`IncompleteReadError` if EOF is reached before *n* can be " "read. Use the :attr:`IncompleteReadError.partial` attribute to get the " @@ -324,11 +335,11 @@ msgstr "" "`IncompleteReadError`。使用 :attr:`IncompleteReadError.partial` 屬性來取得串" "流結束前已讀取的部分資料。" -#: ../../library/asyncio-stream.rst:260 +#: ../../library/asyncio-stream.rst:267 msgid "Read data from the stream until *separator* is found." msgstr "從串流中持續讀取資料直到出現 *separator*。" -#: ../../library/asyncio-stream.rst:262 +#: ../../library/asyncio-stream.rst:269 msgid "" "On success, the data and separator will be removed from the internal buffer " "(consumed). Returned data will include the separator at the end." @@ -336,7 +347,7 @@ msgstr "" "成功後,資料和 separator(分隔符號)會從內部緩衝區中刪除(或者說是被消費掉 " "(consumed))。回傳的資料在末尾會有一個 separator。" -#: ../../library/asyncio-stream.rst:266 +#: ../../library/asyncio-stream.rst:273 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 " @@ -345,7 +356,7 @@ msgstr "" "如果讀取的資料量超過了設定的串流限制,將會引發 :exc:`LimitOverrunError` 例" "外,資料將被留在內部緩衝區中,並可以再次被讀取。" -#: ../../library/asyncio-stream.rst:270 +#: ../../library/asyncio-stream.rst:277 msgid "" "If EOF is reached before the complete separator is found, an :exc:" "`IncompleteReadError` exception is raised, and the internal buffer is " @@ -356,7 +367,7 @@ msgstr "" "`IncompleteReadError` 例外,且內部緩衝區會被重置。:attr:`IncompleteReadError." "partial` 屬性可能包含一部分的 separator。" -#: ../../library/asyncio-stream.rst:275 +#: ../../library/asyncio-stream.rst:282 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. " @@ -364,24 +375,24 @@ msgid "" "separator is considered to be the one that matched." msgstr "" -#: ../../library/asyncio-stream.rst:285 +#: ../../library/asyncio-stream.rst:292 msgid "The *separator* parameter may now be a :class:`tuple` of separators." msgstr "現在 *separator* 參數可以是一個分隔符號的 :class:`tuple`。" -#: ../../library/asyncio-stream.rst:290 +#: ../../library/asyncio-stream.rst:297 msgid "Return ``True`` if the buffer is empty and :meth:`feed_eof` was called." msgstr "如果緩衝區是空的且 :meth:`feed_eof` 曾被呼叫則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:295 +#: ../../library/asyncio-stream.rst:302 msgid "StreamWriter" msgstr "StreamWriter" -#: ../../library/asyncio-stream.rst:299 +#: ../../library/asyncio-stream.rst:306 msgid "" "Represents a writer object that provides APIs to write data to the IO stream." msgstr "表示一個有提供 API 來將資料寫入 IO 串流的 writer 物件。" -#: ../../library/asyncio-stream.rst:302 +#: ../../library/asyncio-stream.rst:309 msgid "" "It is not recommended to instantiate *StreamWriter* objects directly; use :" "func:`open_connection` and :func:`start_server` instead." @@ -389,7 +400,7 @@ msgstr "" "不建議直接實例化 *StreamWriter* 物件;使用 :func:`open_connection` 和 :func:" "`start_server` 會是較好的做法。" -#: ../../library/asyncio-stream.rst:308 +#: ../../library/asyncio-stream.rst:315 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 " @@ -398,11 +409,11 @@ msgstr "" "此方法會嘗試立即將 *data* 寫入到底層的 socket。如果失敗,資料會被放到內部寫入" "緩衝中排隊等待 (queue),直到它可被發送。" -#: ../../library/asyncio-stream.rst:312 ../../library/asyncio-stream.rst:324 +#: ../../library/asyncio-stream.rst:319 ../../library/asyncio-stream.rst:331 msgid "The method should be used along with the ``drain()`` method::" msgstr "此方法應當與 ``drain()`` 方法一起使用: ::" -#: ../../library/asyncio-stream.rst:314 +#: ../../library/asyncio-stream.rst:321 msgid "" "stream.write(data)\n" "await stream.drain()" @@ -410,7 +421,7 @@ msgstr "" "stream.write(data)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:319 +#: ../../library/asyncio-stream.rst:326 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 " @@ -419,7 +430,7 @@ msgstr "" "此方法會立即嘗試將一個位元組 list(或任何可疊代物件 (iterable))寫入到底層的 " "socket。如果失敗,資料會被放到內部寫入緩衝中排隊等待,直到它可被發送。" -#: ../../library/asyncio-stream.rst:326 +#: ../../library/asyncio-stream.rst:333 msgid "" "stream.writelines(lines)\n" "await stream.drain()" @@ -427,17 +438,17 @@ msgstr "" "stream.writelines(lines)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:331 +#: ../../library/asyncio-stream.rst:338 msgid "The method closes the stream and the underlying socket." msgstr "此方法會關閉串流以及底層的 socket。" -#: ../../library/asyncio-stream.rst:333 +#: ../../library/asyncio-stream.rst:340 msgid "" "The method should be used, though not mandatory, along with the " "``wait_closed()`` method::" msgstr "此方法應與 ``wait_closed()`` 方法一起使用,但並非強制: ::" -#: ../../library/asyncio-stream.rst:336 +#: ../../library/asyncio-stream.rst:343 msgid "" "stream.close()\n" "await stream.wait_closed()" @@ -445,7 +456,7 @@ msgstr "" "stream.close()\n" "await stream.wait_closed()" -#: ../../library/asyncio-stream.rst:341 +#: ../../library/asyncio-stream.rst:348 msgid "" "Return ``True`` if the underlying transport supports the :meth:`write_eof` " "method, ``False`` otherwise." @@ -453,26 +464,26 @@ msgstr "" "如果底層的傳輸支援 :meth:`write_eof` 方法就回傳 ``True``,否則回傳 " "``False``。" -#: ../../library/asyncio-stream.rst:346 +#: ../../library/asyncio-stream.rst:353 msgid "" "Close the write end of the stream after the buffered write data is flushed." msgstr "在已緩衝的寫入資料被清理 (flush) 後關閉串流的寫入端。" -#: ../../library/asyncio-stream.rst:351 +#: ../../library/asyncio-stream.rst:358 msgid "Return the underlying asyncio transport." msgstr "回傳底層的 asyncio 傳輸。" -#: ../../library/asyncio-stream.rst:355 +#: ../../library/asyncio-stream.rst:362 msgid "" "Access optional transport information; see :meth:`BaseTransport." "get_extra_info` for details." msgstr "存取可選的傳輸資訊;詳情請見 :meth:`BaseTransport.get_extra_info`。" -#: ../../library/asyncio-stream.rst:361 +#: ../../library/asyncio-stream.rst:368 msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "等待直到可以繼續寫入到串流。範例: ::" -#: ../../library/asyncio-stream.rst:364 +#: ../../library/asyncio-stream.rst:371 msgid "" "writer.write(data)\n" "await writer.drain()" @@ -480,7 +491,7 @@ msgstr "" "writer.write(data)\n" "await writer.drain()" -#: ../../library/asyncio-stream.rst:367 +#: ../../library/asyncio-stream.rst:374 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()* " @@ -492,48 +503,48 @@ msgstr "" "(high watermark) 時,*drain()* 會阻塞直到緩衝區大小減少至最低標記位 (low " "watermark) 以便繼續寫入。當沒有要等待的資料時,:meth:`drain` 會立即回傳。" -#: ../../library/asyncio-stream.rst:378 +#: ../../library/asyncio-stream.rst:385 msgid "Upgrade an existing stream-based connection to TLS." msgstr "將現有的基於串流的連線升級到 TLS。" -#: ../../library/asyncio-stream.rst:380 +#: ../../library/asyncio-stream.rst:387 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-stream.rst:382 +#: ../../library/asyncio-stream.rst:389 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:一個 :class:`~ssl.SSLContext` 的已配置實例。" -#: ../../library/asyncio-stream.rst:384 +#: ../../library/asyncio-stream.rst:391 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設定或覆寫將會被目標伺服器憑證比對的主機名稱。" -#: ../../library/asyncio-stream.rst:387 +#: ../../library/asyncio-stream.rst:394 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:391 +#: ../../library/asyncio-stream.rst:398 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:403 +#: ../../library/asyncio-stream.rst:410 msgid "" "Return ``True`` if the stream is closed or in the process of being closed." msgstr "如果串流已被關閉或正在被關閉則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:411 +#: ../../library/asyncio-stream.rst:418 msgid "Wait until the stream is closed." msgstr "等待直到串流被關閉。" -#: ../../library/asyncio-stream.rst:413 +#: ../../library/asyncio-stream.rst:420 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 " @@ -542,19 +553,19 @@ msgstr "" "應當在 :meth:`close` 之後才被呼叫,這會持續等待直到底層的連線被關閉,以確保在" "這之前(例如在程式退出前)所有資料都已經被清空" -#: ../../library/asyncio-stream.rst:421 +#: ../../library/asyncio-stream.rst:428 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-stream.rst:426 +#: ../../library/asyncio-stream.rst:433 msgid "TCP echo client using streams" msgstr "使用串流的 TCP echo 客戶端" -#: ../../library/asyncio-stream.rst:428 +#: ../../library/asyncio-stream.rst:435 msgid "TCP echo client using the :func:`asyncio.open_connection` function::" msgstr "使用 :func:`asyncio.open_connection` 函式的 TCP echo 客戶端: ::" -#: ../../library/asyncio-stream.rst:452 +#: ../../library/asyncio-stream.rst:459 msgid "" "The :ref:`TCP echo client protocol " "` example uses the low-level :meth:" @@ -563,15 +574,15 @@ msgstr "" "使用低階 :meth:`loop.create_connection` 方法的 :ref:`TCP echo 客戶端協定 " "`\\ 範例。" -#: ../../library/asyncio-stream.rst:459 +#: ../../library/asyncio-stream.rst:466 msgid "TCP echo server using streams" msgstr "使用串流的 TCP echo 伺服器" -#: ../../library/asyncio-stream.rst:461 +#: ../../library/asyncio-stream.rst:468 msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr "TCP echo 伺服器使用 :func:`asyncio.start_server` 函式: ::" -#: ../../library/asyncio-stream.rst:463 +#: ../../library/asyncio-stream.rst:470 msgid "" "import asyncio\n" "\n" @@ -631,7 +642,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-stream.rst:495 +#: ../../library/asyncio-stream.rst:502 msgid "" "The :ref:`TCP echo server protocol " "` example uses the :meth:`loop." @@ -640,16 +651,16 @@ msgstr "" "使用 :meth:`loop.create_server` 方法的 :ref:`TCP echo 伺服器協定 " "` 範例。" -#: ../../library/asyncio-stream.rst:500 +#: ../../library/asyncio-stream.rst:507 msgid "Get HTTP headers" msgstr "取得 HTTP 標頭" -#: ../../library/asyncio-stream.rst:502 +#: ../../library/asyncio-stream.rst:509 msgid "" "Simple example querying HTTP headers of the URL passed on the command line::" msgstr "查詢自命令列傳入之 URL 所帶有 HTTP 標頭的簡單範例: ::" -#: ../../library/asyncio-stream.rst:504 +#: ../../library/asyncio-stream.rst:511 msgid "" "import asyncio\n" "import urllib.parse\n" @@ -688,34 +699,34 @@ msgid "" "asyncio.run(print_http_headers(url))" msgstr "" -#: ../../library/asyncio-stream.rst:541 +#: ../../library/asyncio-stream.rst:548 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-stream.rst:543 +#: ../../library/asyncio-stream.rst:550 msgid "python example.py http://example.com/path/page.html" msgstr "python example.py http://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:545 +#: ../../library/asyncio-stream.rst:552 msgid "or with HTTPS::" msgstr "或使用 HTTPS: ::" -#: ../../library/asyncio-stream.rst:547 +#: ../../library/asyncio-stream.rst:554 msgid "python example.py https://example.com/path/page.html" msgstr "python example.py https://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:553 +#: ../../library/asyncio-stream.rst:560 msgid "Register an open socket to wait for data using streams" msgstr "註冊一個使用串流來等待資料的開放 socket" -#: ../../library/asyncio-stream.rst:555 +#: ../../library/asyncio-stream.rst:562 msgid "" "Coroutine waiting until a socket receives data using the :func:" "`open_connection` function::" msgstr "" "等待直到 socket 透過使用 :func:`open_connection` 函式接收到資料的協程: ::" -#: ../../library/asyncio-stream.rst:558 +#: ../../library/asyncio-stream.rst:565 msgid "" "import asyncio\n" "import socket\n" @@ -748,7 +759,7 @@ msgid "" "asyncio.run(wait_for_data())" msgstr "" -#: ../../library/asyncio-stream.rst:590 +#: ../../library/asyncio-stream.rst:597 msgid "" "The :ref:`register an open socket to wait for data using a protocol " "` example uses a low-level protocol and " @@ -758,7 +769,7 @@ msgstr "" "`\\ 範例中,有使用了低階協定以及 :meth:" "`loop.create_connection` 方法。" -#: ../../library/asyncio-stream.rst:594 +#: ../../library/asyncio-stream.rst:601 msgid "" "The :ref:`watch a file descriptor for read events " "` example uses the low-level :meth:`loop." diff --git a/library/base64.po b/library/base64.po index 6a500d7382..59e5ded526 100644 --- a/library/base64.po +++ b/library/base64.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-06-27 07:36+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-" @@ -30,27 +30,17 @@ msgstr "**原始碼:** :source:`Lib/base64.py`" #: ../../library/base64.rst:16 msgid "" "This module provides functions for encoding binary data to printable ASCII " -"characters and decoding such encodings back to binary data. It provides " -"encoding and decoding functions for the encodings specified in :rfc:`4648`, " -"which defines the Base16, Base32, and Base64 algorithms, and for the de-" -"facto standard Ascii85 and Base85 encodings." +"characters and decoding such encodings back to binary data. This includes " +"the :ref:`encodings specified in ` :rfc:`4648` (Base64, " +"Base32 and Base16) and the non-standard :ref:`Base85 encodings `." msgstr "" -"這個模組提供將二進位資料編碼成可顯示 ASCII 字元以及解碼回原始資料的功能,包括" -"了 :rfc:`4648` 中的 Base16、Base32、Base64 等編碼方式,以及標準 Ascii85、" -"Base85 編碼等。" +"這個模組提供將二進位資料編碼成可顯示 ASCII 字元以及解碼回原始資料的功能。這包括" +"了 :rfc:`4648` 中\\ :ref:`指定的編碼 `\\ (Base64、Base32 " +"和 Base16)和非標準的 :ref:`Base85 編碼 `。" #: ../../library/base64.rst:22 msgid "" -"The :rfc:`4648` encodings are suitable for encoding binary data so that it " -"can be safely sent by email, used as parts of URLs, or included as part of " -"an HTTP POST request. The encoding algorithm is not the same as the :" -"program:`uuencode` program." -msgstr "" -":rfc:`4648` 編碼適合對二進位資料進行編碼來使得電子郵件、URL 或是 HTTP POST 內" -"容等傳輸管道安全地傳遞資料。這些編碼演算法與 :program:`uuencode` 並不相同。" - -#: ../../library/base64.rst:27 -msgid "" "There are two interfaces provided by this module. The modern interface " "supports encoding :term:`bytes-like objects ` to ASCII :" "class:`bytes`, and decoding :term:`bytes-like objects ` " @@ -63,27 +53,27 @@ msgstr "" "義的兩種 base-64 字母表(常見和 URL 安全 (URL-safe) 及檔案系統安全 " "(filesystem-safe) 字母表)。" -#: ../../library/base64.rst:33 +#: ../../library/base64.rst:28 msgid "" -"The legacy interface does not support decoding from strings, but it does " -"provide functions for encoding and decoding to and from :term:`file objects " -"`. It only supports the Base64 standard alphabet, and it adds " -"newlines every 76 characters as per :rfc:`2045`. Note that if you are " -"looking for :rfc:`2045` support you probably want to be looking at the :mod:" -"`email` package instead." +"The :ref:`legacy interface ` does not support decoding from " +"strings, but it does provide functions for encoding and decoding to and " +"from :term:`file objects `. It only supports the Base64 " +"standard alphabet, and it adds newlines every 76 characters as per :rfc:" +"`2045`. Note that if you are looking for :rfc:`2045` support you probably " +"want to be looking at the :mod:`email` package instead." msgstr "" -"舊版介面不支援從字串解碼,但它提供對\\ :term:`檔案物件 `\\ 進行" +":ref:`舊版介面 `\\ 不支援從字串解碼,但它提供對\\ :term:`檔案物件 `\\ 進行" "編碼和解碼的函式。它僅支援 Base64 標準字母表,並且按照 :rfc:`2045` 每 76 個字" "元添加換行字元。請注意,如果你需要 :rfc:`2045` 的支援,你可能會需要 :mod:" "`email` 函式庫。" -#: ../../library/base64.rst:41 +#: ../../library/base64.rst:36 msgid "" "ASCII-only Unicode strings are now accepted by the decoding functions of the " "modern interface." msgstr "新介面的解碼功能現在接受 ASCII-only 的 Unicode 字串。" -#: ../../library/base64.rst:45 +#: ../../library/base64.rst:40 msgid "" "Any :term:`bytes-like objects ` are now accepted by all " "encoding and decoding functions in this module. Ascii85/Base85 support " @@ -92,11 +82,20 @@ msgstr "" "任何\\ :term:`類位元組物件 `\\ 現在被該模組中的所有編碼和" "解碼函式接受。新增了對 Ascii85/Base85 的支援。" -#: ../../library/base64.rst:49 -msgid "The modern interface provides:" -msgstr "新介面提供:" +#: ../../library/base64.rst:48 +msgid "RFC 4648 Encodings" +msgstr "RFC 4648 編碼" + +#: ../../library/base64.rst:50 +msgid "" +"The :rfc:`4648` encodings are suitable for encoding binary data so that it " +"can be safely sent by email, used as parts of URLs, or included as part of " +"an HTTP POST request." +msgstr "" +":rfc:`4648` 編碼適合對二進位資料進行編碼來使得電子郵件、URL 或是 HTTP POST 內" +"容等傳輸管道能夠安全地傳遞資料。" -#: ../../library/base64.rst:53 +#: ../../library/base64.rst:56 msgid "" "Encode the :term:`bytes-like object` *s* using Base64 and return the " "encoded :class:`bytes`." @@ -104,7 +103,7 @@ msgstr "" "使用 Base64 對\\ :term:`類位元組物件 ` *s* 進行編碼並回傳" "編碼過的 :class:`bytes`。" -#: ../../library/base64.rst:56 +#: ../../library/base64.rst:59 msgid "" "Optional *altchars* must be a :term:`bytes-like object` of length 2 which " "specifies an alternative alphabet for the ``+`` and ``/`` characters. This " @@ -117,7 +116,7 @@ msgstr "" "以生成對 URL 或檔案系統安全的 Base64 字串。預設值為 ``None``,即使用標準的 " "Base64 字母表。" -#: ../../library/base64.rst:61 +#: ../../library/base64.rst:64 msgid "" "May assert or raise a :exc:`ValueError` if the length of *altchars* is not " "2. Raises a :exc:`TypeError` if *altchars* is not a :term:`bytes-like " @@ -127,7 +126,7 @@ msgstr "" "*altchars* 不是\\ :term:`類位元組物件 `,則會引發 :exc:" "`TypeError`。" -#: ../../library/base64.rst:67 +#: ../../library/base64.rst:70 msgid "" "Decode the Base64 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -135,7 +134,7 @@ msgstr "" "將經過 Base64 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII 字" "串 *s* 解碼,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:70 +#: ../../library/base64.rst:73 msgid "" "Optional *altchars* must be a :term:`bytes-like object` or ASCII string of " "length 2 which specifies the alternative alphabet used instead of the ``+`` " @@ -144,12 +143,12 @@ msgstr "" "可選的 *altchars* 必須是長度為 2 的\\ :term:`類位元組物件 `\\ 或 ASCII 字串,用於指定替代字母表,取代 ``+`` 和 ``/`` 字元。" -#: ../../library/base64.rst:74 +#: ../../library/base64.rst:77 msgid "" "A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded." msgstr "如果 *s* 填充 (pad) 不正確,將引發 :exc:`binascii.Error` 例外。" -#: ../../library/base64.rst:77 +#: ../../library/base64.rst:80 msgid "" "If *validate* is ``False`` (the default), characters that are neither in the " "normal base-64 alphabet nor the alternative alphabet are discarded prior to " @@ -160,18 +159,18 @@ msgstr "" "不屬於標準 base-64 字母表和替代字母表的字元將被丟棄。如果 *validate* 為 " "``True``,輸入中的這些非字母表字元將導致引發 :exc:`binascii.Error`。" -#: ../../library/base64.rst:83 +#: ../../library/base64.rst:86 msgid "" "For more information about the strict base64 check, see :func:`binascii." "a2b_base64`" msgstr "有關嚴格的 base64 檢查的更多資訊,請參閱 :func:`binascii.a2b_base64`。" -#: ../../library/base64.rst:85 +#: ../../library/base64.rst:88 msgid "" "May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2." msgstr "如果 *altchars* 的長度不是 2,可能會斷言或引發 :exc:`ValueError`。" -#: ../../library/base64.rst:89 +#: ../../library/base64.rst:92 msgid "" "Encode :term:`bytes-like object` *s* using the standard Base64 alphabet and " "return the encoded :class:`bytes`." @@ -179,7 +178,7 @@ msgstr "" "使用標準 Base64 字母表對\\ :term:`類位元組物件 ` *s* 進行" "編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:95 +#: ../../library/base64.rst:98 msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the standard " "Base64 alphabet and return the decoded :class:`bytes`." @@ -187,7 +186,7 @@ msgstr "" "使用標準 Base64 字母表對\\ :term:`類位元組物件 `\\ 或 " "ASCII 字串 *s* 進行解碼,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:101 +#: ../../library/base64.rst:104 msgid "" "Encode :term:`bytes-like object` *s* using the URL- and filesystem-safe " "alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/" @@ -198,7 +197,7 @@ msgstr "" "object>` *s* 進行編碼,該字母表將標準 Base64 字母表中的 ``+`` 替換為 ``-``," "``/`` 替換為 ``_``,並回傳編碼後的 :class:`bytes`。結果仍可能包含 ``=``。" -#: ../../library/base64.rst:110 +#: ../../library/base64.rst:113 msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the URL- and " "filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` " @@ -209,7 +208,7 @@ msgstr "" "object>`\\ 或 ASCII 字串 *s* 進行解碼,該字母表將標準 Base64 字母表中的 " "``+`` 替換為 ``-``,``/`` 替換為 ``_``,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:119 +#: ../../library/base64.rst:122 msgid "" "Encode the :term:`bytes-like object` *s* using Base32 and return the " "encoded :class:`bytes`." @@ -217,7 +216,7 @@ msgstr "" "使用 Base32 對\\ :term:`類位元組物件 ` *s* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:125 +#: ../../library/base64.rst:128 msgid "" "Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -225,7 +224,7 @@ msgstr "" "解碼經過 Base32 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:128 ../../library/base64.rst:176 +#: ../../library/base64.rst:131 ../../library/base64.rst:179 msgid "" "Optional *casefold* is a flag specifying whether a lowercase alphabet is " "acceptable as input. For security purposes, the default is ``False``." @@ -233,7 +232,7 @@ msgstr "" "可選的 *casefold* 是一個是否接受小寫字母表作為輸入的旗標。出於安全性考量,預" "設值為 ``False``。" -#: ../../library/base64.rst:132 +#: ../../library/base64.rst:135 msgid "" ":rfc:`4648` allows for optional mapping of the digit 0 (zero) to the letter " "O (oh), and for optional mapping of the digit 1 (one) to either the letter I " @@ -248,14 +247,14 @@ msgstr "" "對映為哪個字母(當 *map01* 不為 ``None`` 時,數字 0 總是對映為字母 O)。出於" "安全性考量,預設值為 ``None``,因此不允許在輸入中使用數字 0 和 1。" -#: ../../library/base64.rst:139 ../../library/base64.rst:180 +#: ../../library/base64.rst:142 ../../library/base64.rst:183 msgid "" "A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there " "are non-alphabet characters present in the input." msgstr "" "如果 *s* 的填充不正確或輸入中存在非字母表字元,將引發 :exc:`binascii.Error`。" -#: ../../library/base64.rst:146 +#: ../../library/base64.rst:149 msgid "" "Similar to :func:`b32encode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." @@ -263,14 +262,14 @@ msgstr "" "類似於 :func:`b32encode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表 " "(Extended Hex Alphabet)。" -#: ../../library/base64.rst:154 +#: ../../library/base64.rst:157 msgid "" "Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." msgstr "" "類似於 :func:`b32encode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表。" -#: ../../library/base64.rst:157 +#: ../../library/base64.rst:160 msgid "" "This version does not allow the digit 0 (zero) to the letter O (oh) and " "digit 1 (one) to either the letter I (eye) or letter L (el) mappings, all " @@ -280,7 +279,7 @@ msgstr "" "這個版本不允許將數字 0 對映為字母 O ,以及將數字 1 對映為字母 I 或字母 L,所" "有這些字元都包含在擴展十六進位字母表中,並且不能互換使用。" -#: ../../library/base64.rst:167 +#: ../../library/base64.rst:170 msgid "" "Encode the :term:`bytes-like object` *s* using Base16 and return the " "encoded :class:`bytes`." @@ -288,7 +287,7 @@ msgstr "" "使用 Base16 對\\ :term:`類位元組物件 ` *s* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:173 +#: ../../library/base64.rst:176 msgid "" "Decode the Base16 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -296,7 +295,51 @@ msgstr "" "解碼經過 Base16 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:187 +#: ../../library/base64.rst:190 +msgid "Base85 Encodings" +msgstr "Base85 編碼" + +#: ../../library/base64.rst:192 +msgid "" +"Base85 encoding is not formally specified but rather a de facto standard, " +"thus different systems perform the encoding differently." +msgstr "" + +#: ../../library/base64.rst:195 +msgid "" +"The :func:`a85encode` and :func:`b85encode` functions in this module are two " +"implementations of the de facto standard. You should call the function with " +"the Base85 implementation used by the software you intend to work with." +msgstr "" + +#: ../../library/base64.rst:199 +msgid "" +"The two functions present in this module differ in how they handle the " +"following:" +msgstr "" + +#: ../../library/base64.rst:201 +msgid "Whether to include enclosing ``<~`` and ``~>`` markers" +msgstr "" + +#: ../../library/base64.rst:202 +msgid "Whether to include newline characters" +msgstr "" + +#: ../../library/base64.rst:203 +msgid "The set of ASCII characters used for encoding" +msgstr "" + +#: ../../library/base64.rst:204 +msgid "Handling of null bytes" +msgstr "" + +#: ../../library/base64.rst:206 +msgid "" +"Refer to the documentation of the individual functions for more information." +msgstr "" + +#: ../../library/base64.rst:210 msgid "" "Encode the :term:`bytes-like object` *b* using Ascii85 and return the " "encoded :class:`bytes`." @@ -304,7 +347,7 @@ msgstr "" "使用 Ascii85 對\\ :term:`類位元組物件 ` *b* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:190 +#: ../../library/base64.rst:213 msgid "" "*foldspaces* is an optional flag that uses the special short sequence 'y' " "instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This " @@ -314,7 +357,7 @@ msgstr "" "(ASCII 0x20),這是由 'btoa' 支援的功能。這個特性不被「標準」的 Ascii85 編碼所" "支援。" -#: ../../library/base64.rst:194 +#: ../../library/base64.rst:217 msgid "" "*wrapcol* controls whether the output should have newline (``b'\\n'``) " "characters added to it. If this is non-zero, each output line will be at " @@ -323,7 +366,7 @@ msgstr "" "*wrapcol* 控制輸出是否應該包含換行字元 (``b'\\n'``) 。如果這個值不為零,每行" "輸出的長度將不超過這個字元長度(不包含後面的換行符號)。" -#: ../../library/base64.rst:198 +#: ../../library/base64.rst:221 msgid "" "*pad* controls whether the input is padded to a multiple of 4 before " "encoding. Note that the ``btoa`` implementation always pads." @@ -331,7 +374,7 @@ msgstr "" "*pad* 控制是否在編碼之前將輸入填充為 4 的倍數。請注意,``btoa`` 實作始終會填" "充。" -#: ../../library/base64.rst:201 +#: ../../library/base64.rst:224 msgid "" "*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " "``~>``, which is used by the Adobe implementation." @@ -339,7 +382,7 @@ msgstr "" "*adobe* 控制編碼的位元組序列前後是否加上 ``<~`` 和 ``~>``,這是 Adobe 實作中" "使用的。" -#: ../../library/base64.rst:209 +#: ../../library/base64.rst:232 msgid "" "Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`." @@ -347,7 +390,7 @@ msgstr "" "解碼經過 Ascii85 編碼的\\ :term:`類位元組物件 `\\ 或 " "ASCII 字串 *b*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:212 +#: ../../library/base64.rst:235 msgid "" "*foldspaces* is a flag that specifies whether the 'y' short sequence should " "be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature " @@ -356,7 +399,7 @@ msgstr "" "*foldspaces* 是一個旗標,指定是否應該將短序列 'y' 視為 4 個連續的空格 (ASCII " "0x20) 的簡寫。這個功能不受「標準」Ascii85 編碼的支援。" -#: ../../library/base64.rst:216 +#: ../../library/base64.rst:239 msgid "" "*adobe* controls whether the input sequence is in Adobe Ascii85 format (i.e. " "is framed with <~ and ~>)." @@ -364,7 +407,7 @@ msgstr "" "*adobe* 控制輸入序列是否符合 Adobe Ascii85 格式(即前後加上 ``<~`` 和 " "``~>``)。" -#: ../../library/base64.rst:219 +#: ../../library/base64.rst:242 msgid "" "*ignorechars* should be a :term:`bytes-like object` or ASCII string " "containing characters to ignore from the input. This should only contain " @@ -375,7 +418,7 @@ msgstr "" "like object>`\\ 或 ASCII 字串。這只包含空格字元,預設情況下包含 ASCII 中的所" "有空格字元。" -#: ../../library/base64.rst:229 +#: ../../library/base64.rst:252 msgid "" "Encode the :term:`bytes-like object` *b* using base85 (as used in e.g. git-" "style binary diffs) and return the encoded :class:`bytes`." @@ -383,7 +426,7 @@ msgstr "" "使用 Base85(例如,git 風格的二進位差異 (binary diff))對\\ :term:`類位元組物" "件 ` *b* 進行編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:232 +#: ../../library/base64.rst:255 msgid "" "If *pad* is true, the input is padded with ``b'\\0'`` so its length is a " "multiple of 4 bytes before encoding." @@ -391,7 +434,7 @@ msgstr "" "如果 *pad* 為 true,則在編碼之前,輸入將使用 ``b'\\0'`` 進行填充,以使其長度" "為 4 的倍數。" -#: ../../library/base64.rst:240 +#: ../../library/base64.rst:263 msgid "" "Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`. Padding is implicitly removed, if " @@ -400,31 +443,29 @@ msgstr "" "解碼經過 base85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *b*,並回傳解碼後的 :class:`bytes`。必要時會隱式移除填充。" -#: ../../library/base64.rst:249 -#, fuzzy +#: ../../library/base64.rst:272 msgid "" "Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ) and " "return the encoded :class:`bytes`. See `Z85 specification `_ for more information." msgstr "" -"使用 Base85(例如,git 風格的二進位差異 (binary diff))對\\ :term:`類位元組物" -"件 ` *b* 進行編碼,並回傳編碼後的 :class:`bytes`。" +"使用 Z85(如用於 ZeroMQ)對\\ :term:`類位元組物件 ` *s* 進行編碼,並回傳" +"編碼後的 :class:`bytes`。有關更多資訊,請參閱 `Z85 規格 `_。" -#: ../../library/base64.rst:258 -#, fuzzy +#: ../../library/base64.rst:281 msgid "" "Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`. See `Z85 specification `_ for more information." msgstr "" -"解碼經過 base85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " -"字串 *b*,並回傳解碼後的 :class:`bytes`。必要時會隱式移除填充。" +"解碼經 Z85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " +"字串 *s*,並回傳解碼後的 :class:`bytes`。有關更多資訊,請參閱 `Z85 規格 `_。" -#: ../../library/base64.rst:265 -msgid "The legacy interface:" -msgstr "舊版介面:" +#: ../../library/base64.rst:291 +msgid "Legacy Interface" +msgstr "舊版介面" -#: ../../library/base64.rst:269 +#: ../../library/base64.rst:295 msgid "" "Decode the contents of the binary *input* file and write the resulting " "binary data to the *output* file. *input* and *output* must be :term:`file " @@ -435,7 +476,7 @@ msgstr "" "*input* 和 *output* 必須是\\ :term:`檔案物件 `。*input* 將被讀" "取,直到 ``input.readline()`` 回傳一個空的 bytes 物件為止。" -#: ../../library/base64.rst:277 +#: ../../library/base64.rst:303 msgid "" "Decode the :term:`bytes-like object` *s*, which must contain one or more " "lines of base64 encoded data, and return the decoded :class:`bytes`." @@ -443,7 +484,7 @@ msgstr "" "解碼必須包含一行或多行的 base64 編碼資料\\ :term:`類位元組物件 ` *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:285 +#: ../../library/base64.rst:311 msgid "" "Encode the contents of the binary *input* file and write the resulting " "base64 encoded data to the *output* file. *input* and *output* must be :term:" @@ -458,7 +499,7 @@ msgstr "" "出的每 76 個位元組之後插入一個換行字元 (``b'\\n'``),並確保輸出始終以換行字元" "結尾,符合 :rfc:`2045` (MIME) 的規定。" -#: ../../library/base64.rst:295 +#: ../../library/base64.rst:321 msgid "" "Encode the :term:`bytes-like object` *s*, which can contain arbitrary binary " "data, and return :class:`bytes` containing the base64-encoded data, with " @@ -469,15 +510,15 @@ msgstr "" "碼,並回傳包含 base64 編碼資料 :class:`bytes`,在每 76 個輸出位元組後插入換行" "字元 (``b'\\n'``) ,並確保有尾隨換行字元,符合 :rfc:`2045` (MIME) 的規定。" -#: ../../library/base64.rst:303 +#: ../../library/base64.rst:329 msgid "An example usage of the module:" msgstr "模組的一個範例用法:" -#: ../../library/base64.rst:316 +#: ../../library/base64.rst:342 msgid "Security Considerations" msgstr "安全性注意事項" -#: ../../library/base64.rst:318 +#: ../../library/base64.rst:344 msgid "" "A new security considerations section was added to :rfc:`4648` (section 12); " "it's recommended to review the security section for any code deployed to " @@ -486,18 +527,18 @@ msgstr "" ":rfc:`4648`\\ (第 12 節)中添加了一個新的安全性考量部分;建議對部署到正式環" "境的任何程式碼進行安全性部分的審查。" -#: ../../library/base64.rst:323 +#: ../../library/base64.rst:349 msgid "Module :mod:`binascii`" msgstr ":mod:`binascii` 模組" -#: ../../library/base64.rst:324 +#: ../../library/base64.rst:350 msgid "" "Support module containing ASCII-to-binary and binary-to-ASCII conversions." msgstr "" "支援模組中包含 ASCII 到二進位 (ASCII-to-binary) 和二進位到 ASCII (binary-to-" "ASCII) 的轉換功能。" -#: ../../library/base64.rst:326 +#: ../../library/base64.rst:352 msgid "" ":rfc:`1521` - MIME (Multipurpose Internet Mail Extensions) Part One: " "Mechanisms for Specifying and Describing the Format of Internet Message " @@ -506,7 +547,7 @@ msgstr "" ":rfc:`1521` - MIME(多用途網際網路郵件擴展)第一部分:指定和描述網際網路主體" "格式的機制。" -#: ../../library/base64.rst:327 +#: ../../library/base64.rst:353 msgid "" "Section 5.2, \"Base64 Content-Transfer-Encoding,\" provides the definition " "of the base64 encoding." diff --git a/library/code.po b/library/code.po index 3d680b5ea3..c8693449e1 100644 --- a/library/code.po +++ b/library/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: 2025-06-27 07:36+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-" @@ -43,37 +43,45 @@ msgid "" "``'__console__'`` and key ``'__doc__'`` set to ``None``." msgstr "" -#: ../../library/code.rst:28 +#: ../../library/code.rst:25 +msgid "" +"Note that functions and classes objects created under an :class:`!" +"InteractiveInterpreter` instance will belong to the namespace specified by " +"*locals*. They are only pickleable if *locals* is the namespace of an " +"existing module." +msgstr "" + +#: ../../library/code.rst:34 msgid "" "Closely emulate the behavior of the interactive Python interpreter. This " "class builds on :class:`InteractiveInterpreter` and adds prompting using the " "familiar ``sys.ps1`` and ``sys.ps2``, and input buffering. If *local_exit* " -"is true, ``exit()`` and ``quit()`` in the console will not " -"raise :exc:`SystemExit`, but instead return to the calling code." +"is true, ``exit()`` and ``quit()`` in the console will not raise :exc:" +"`SystemExit`, but instead return to the calling code." msgstr "" -#: ../../library/code.rst:34 ../../library/code.rst:52 +#: ../../library/code.rst:40 ../../library/code.rst:58 msgid "Added *local_exit* parameter." msgstr "新增 *local_exit* 參數。" -#: ../../library/code.rst:39 +#: ../../library/code.rst:45 msgid "" "Convenience function to run a read-eval-print loop. This creates a new " "instance of :class:`InteractiveConsole` and sets *readfunc* to be used as " "the :meth:`InteractiveConsole.raw_input` method, if provided. If *local* is " "provided, it is passed to the :class:`InteractiveConsole` constructor for " "use as the default namespace for the interpreter loop. If *local_exit* is " -"provided, it is passed to the :class:`InteractiveConsole` constructor. " -"The :meth:`~InteractiveConsole.interact` method of the instance is then run " -"with *banner* and *exitmsg* passed as the banner and exit message to use, if " +"provided, it is passed to the :class:`InteractiveConsole` constructor. The :" +"meth:`~InteractiveConsole.interact` method of the instance is then run with " +"*banner* and *exitmsg* passed as the banner and exit message to use, if " "provided. The console object is discarded after use." msgstr "" -#: ../../library/code.rst:49 +#: ../../library/code.rst:55 msgid "Added *exitmsg* parameter." msgstr "新增 *exitmsg* 參數。" -#: ../../library/code.rst:57 +#: ../../library/code.rst:63 msgid "" "This function is useful for programs that want to emulate Python's " "interpreter main loop (a.k.a. the read-eval-print loop). The tricky part is " @@ -83,7 +91,7 @@ msgid "" "real interpreter main loop." msgstr "" -#: ../../library/code.rst:64 +#: ../../library/code.rst:70 msgid "" "*source* is the source string; *filename* is the optional filename from " "which source was read, defaulting to ``''``; and *symbol* is the " @@ -91,7 +99,7 @@ msgid "" "``'eval'`` or ``'exec'``." msgstr "" -#: ../../library/code.rst:69 +#: ../../library/code.rst:75 msgid "" "Returns a code object (the same as ``compile(source, filename, symbol)``) if " "the command is complete and valid; ``None`` if the command is incomplete; " @@ -100,32 +108,32 @@ msgid "" "contains an invalid literal." msgstr "" -#: ../../library/code.rst:79 +#: ../../library/code.rst:85 msgid "Interactive Interpreter Objects" msgstr "" -#: ../../library/code.rst:84 +#: ../../library/code.rst:90 msgid "" "Compile and run some source in the interpreter. Arguments are the same as " "for :func:`compile_command`; the default for *filename* is ``''``, " "and for *symbol* is ``'single'``. One of several things can happen:" msgstr "" -#: ../../library/code.rst:88 +#: ../../library/code.rst:94 msgid "" -"The input is incorrect; :func:`compile_command` raised an exception " -"(:exc:`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be " -"printed by calling the :meth:`showsyntaxerror` method. :meth:`runsource` " -"returns ``False``." +"The input is incorrect; :func:`compile_command` raised an exception (:exc:" +"`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be printed " +"by calling the :meth:`showsyntaxerror` method. :meth:`runsource` returns " +"``False``." msgstr "" -#: ../../library/code.rst:93 +#: ../../library/code.rst:99 msgid "" "The input is incomplete, and more input is required; :func:`compile_command` " "returned ``None``. :meth:`runsource` returns ``True``." msgstr "" -#: ../../library/code.rst:96 +#: ../../library/code.rst:102 msgid "" "The input is complete; :func:`compile_command` returned a code object. The " "code is executed by calling the :meth:`runcode` (which also handles run-time " @@ -133,27 +141,27 @@ msgid "" "``False``." msgstr "" -#: ../../library/code.rst:100 +#: ../../library/code.rst:106 msgid "" -"The return value can be used to decide whether to use ``sys.ps1`` or " -"``sys.ps2`` to prompt the next line." +"The return value can be used to decide whether to use ``sys.ps1`` or ``sys." +"ps2`` to prompt the next line." msgstr "" -#: ../../library/code.rst:106 +#: ../../library/code.rst:112 msgid "" "Execute a code object. When an exception occurs, :meth:`showtraceback` is " -"called to display a traceback. All exceptions are caught " -"except :exc:`SystemExit`, which is allowed to propagate." +"called to display a traceback. All exceptions are caught except :exc:" +"`SystemExit`, which is allowed to propagate." msgstr "" -#: ../../library/code.rst:110 +#: ../../library/code.rst:116 msgid "" "A note about :exc:`KeyboardInterrupt`: this exception may occur elsewhere in " "this code, and may not always be caught. The caller should be prepared to " "deal with it." msgstr "" -#: ../../library/code.rst:117 +#: ../../library/code.rst:123 msgid "" "Display the syntax error that just occurred. This does not display a stack " "trace because there isn't one for syntax errors. If *filename* is given, it " @@ -162,38 +170,38 @@ msgid "" "string. The output is written by the :meth:`write` method." msgstr "" -#: ../../library/code.rst:126 +#: ../../library/code.rst:132 msgid "" "Display the exception that just occurred. We remove the first stack item " "because it is within the interpreter object implementation. The output is " "written by the :meth:`write` method." msgstr "" -#: ../../library/code.rst:130 +#: ../../library/code.rst:136 msgid "" "The full chained traceback is displayed instead of just the primary " "traceback." msgstr "" -#: ../../library/code.rst:136 +#: ../../library/code.rst:142 msgid "" "Write a string to the standard error stream (``sys.stderr``). Derived " "classes should override this to provide the appropriate output handling as " "needed." msgstr "" -#: ../../library/code.rst:143 +#: ../../library/code.rst:149 msgid "Interactive Console Objects" msgstr "" -#: ../../library/code.rst:145 +#: ../../library/code.rst:151 msgid "" -"The :class:`InteractiveConsole` class is a subclass " -"of :class:`InteractiveInterpreter`, and so offers all the methods of the " -"interpreter objects as well as the following additions." +"The :class:`InteractiveConsole` class is a subclass of :class:" +"`InteractiveInterpreter`, and so offers all the methods of the interpreter " +"objects as well as the following additions." msgstr "" -#: ../../library/code.rst:152 +#: ../../library/code.rst:158 msgid "" "Closely emulate the interactive Python console. The optional *banner* " "argument specify the banner to print before the first interaction; by " @@ -203,22 +211,22 @@ msgid "" "close!)." msgstr "" -#: ../../library/code.rst:158 +#: ../../library/code.rst:164 msgid "" "The optional *exitmsg* argument specifies an exit message printed when " "exiting. Pass the empty string to suppress the exit message. If *exitmsg* is " "not given or ``None``, a default message is printed." msgstr "" -#: ../../library/code.rst:162 +#: ../../library/code.rst:168 msgid "To suppress printing any banner, pass an empty string." msgstr "" -#: ../../library/code.rst:165 +#: ../../library/code.rst:171 msgid "Print an exit message when exiting." msgstr "" -#: ../../library/code.rst:171 +#: ../../library/code.rst:177 msgid "" "Push a line of source text to the interpreter. The line should not have a " "trailing newline; it may have internal newlines. The line is appended to a " @@ -231,14 +239,14 @@ msgid "" "same as :meth:`!runsource`)." msgstr "" -#: ../../library/code.rst:183 +#: ../../library/code.rst:189 msgid "Remove any unhandled source text from the input buffer." msgstr "" -#: ../../library/code.rst:188 +#: ../../library/code.rst:194 msgid "" "Write a prompt and read a line. The returned line does not include the " -"trailing newline. When the user enters the EOF key " -"sequence, :exc:`EOFError` is raised. The base implementation reads from " -"``sys.stdin``; a subclass may replace this with a different implementation." +"trailing newline. When the user enters the EOF key sequence, :exc:" +"`EOFError` is raised. The base implementation reads from ``sys.stdin``; a " +"subclass may replace this with a different implementation." msgstr "" diff --git a/library/compileall.po b/library/compileall.po index da2c078c4b..6830bf371b 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-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -89,26 +89,40 @@ msgid "" "executed." msgstr "" -#: ../../library/compileall.rst:61 +#: ../../library/compileall.rst:60 msgid "" -"Remove (``-s``) or append (``-p``) the given prefix of paths recorded in the " -"``.pyc`` files. Cannot be combined with ``-d``." +"Remove the given prefix from paths recorded in the ``.pyc`` files. Paths are " +"made relative to the prefix." +msgstr "" + +#: ../../library/compileall.rst:63 +msgid "This option can be used with ``-p`` but not with ``-d``." msgstr "" #: ../../library/compileall.rst:67 msgid "" +"Prepend the given prefix to paths recorded in the ``.pyc`` files. Use ``-p /" +"`` to make the paths absolute." +msgstr "" + +#: ../../library/compileall.rst:70 +msgid "This option can be used with ``-s`` but not with ``-d``." +msgstr "" + +#: ../../library/compileall.rst:74 +msgid "" "regex is used to search the full path to each file considered for " "compilation, and if the regex produces a match, the file is skipped." msgstr "" -#: ../../library/compileall.rst:72 +#: ../../library/compileall.rst:79 msgid "" "Read the file ``list`` and add each line that it contains to the list of " "files and directories to compile. If ``list`` is ``-``, read lines from " "``stdin``." msgstr "" -#: ../../library/compileall.rst:78 +#: ../../library/compileall.rst:85 msgid "" "Write the byte-code files to their legacy locations and names, which may " "overwrite byte-code files created by another version of Python. The default " @@ -116,7 +130,7 @@ msgid "" "byte-code files from multiple versions of Python to coexist." msgstr "" -#: ../../library/compileall.rst:85 +#: ../../library/compileall.rst:92 msgid "" "Control the maximum recursion level for subdirectories. If this is given, " "then ``-l`` option will not be taken into account. :program:`python -m " @@ -124,13 +138,13 @@ msgid "" " -l`." msgstr "" -#: ../../library/compileall.rst:92 +#: ../../library/compileall.rst:99 msgid "" "Use *N* workers to compile the files within the given directory. If ``0`` is " "used, then the result of :func:`os.process_cpu_count` will be used." msgstr "" -#: ../../library/compileall.rst:98 +#: ../../library/compileall.rst:105 msgid "" "Control how the generated byte-code files are invalidated at runtime. The " "``timestamp`` value, means that ``.pyc`` files with the source timestamp and " @@ -143,53 +157,53 @@ msgid "" "the ``SOURCE_DATE_EPOCH`` environment variable is set." msgstr "" -#: ../../library/compileall.rst:111 +#: ../../library/compileall.rst:118 msgid "" "Compile with the given optimization level. May be used multiple times to " "compile for multiple levels at a time (for example, ``compileall -o 1 -o " "2``)." msgstr "" -#: ../../library/compileall.rst:117 +#: ../../library/compileall.rst:124 msgid "Ignore symlinks pointing outside the given directory." msgstr "" -#: ../../library/compileall.rst:121 +#: ../../library/compileall.rst:128 msgid "" "If two ``.pyc`` files with different optimization level have the same " "content, use hard links to consolidate duplicate files." msgstr "" -#: ../../library/compileall.rst:124 +#: ../../library/compileall.rst:131 msgid "Added the ``-i``, ``-b`` and ``-h`` options." msgstr "新增選項 ``-i``、``-b`` 與 ``-h``。" -#: ../../library/compileall.rst:127 +#: ../../library/compileall.rst:134 msgid "" "Added the ``-j``, ``-r``, and ``-qq`` options. ``-q`` option was changed " "to a multilevel value. ``-b`` will always produce a byte-code file ending " "in ``.pyc``, never ``.pyo``." msgstr "" -#: ../../library/compileall.rst:132 +#: ../../library/compileall.rst:139 msgid "Added the ``--invalidation-mode`` option." msgstr "新增選項 ``--invalidation-mode``。" -#: ../../library/compileall.rst:135 +#: ../../library/compileall.rst:142 msgid "" "Added the ``-s``, ``-p``, ``-e`` and ``--hardlink-dupes`` options. Raised " "the default recursion limit from 10 to :py:func:`sys.getrecursionlimit()`. " "Added the possibility to specify the ``-o`` option multiple times." msgstr "" -#: ../../library/compileall.rst:142 +#: ../../library/compileall.rst:149 msgid "" "There is no command-line option to control the optimization level used by " "the :func:`compile` function, because the Python interpreter itself already " "provides the option: :program:`python -O -m compileall`." msgstr "" -#: ../../library/compileall.rst:146 +#: ../../library/compileall.rst:153 msgid "" "Similarly, the :func:`compile` function respects the :data:`sys." "pycache_prefix` setting. The generated bytecode cache will only be useful " @@ -197,24 +211,24 @@ msgid "" "that will be used at runtime." msgstr "" -#: ../../library/compileall.rst:152 +#: ../../library/compileall.rst:159 msgid "Public functions" msgstr "" -#: ../../library/compileall.rst:156 +#: ../../library/compileall.rst:163 msgid "" "Recursively descend the directory tree named by *dir*, compiling all :file:`." "py` files along the way. Return a true value if all the files compiled " "successfully, and a false value otherwise." msgstr "" -#: ../../library/compileall.rst:160 +#: ../../library/compileall.rst:167 msgid "" "The *maxlevels* parameter is used to limit the depth of the recursion; it " "defaults to ``sys.getrecursionlimit()``." msgstr "" -#: ../../library/compileall.rst:163 +#: ../../library/compileall.rst:170 msgid "" "If *ddir* is given, it is prepended to the path to each file being compiled " "for use in compilation time tracebacks, and is also compiled in to the byte-" @@ -223,13 +237,13 @@ msgid "" "executed." msgstr "" -#: ../../library/compileall.rst:169 +#: ../../library/compileall.rst:176 msgid "" "If *force* is true, modules are re-compiled even if the timestamps are up to " "date." msgstr "" -#: ../../library/compileall.rst:172 +#: ../../library/compileall.rst:179 msgid "" "If *rx* is given, its ``search`` method is called on the complete path to " "each file considered for compilation, and if it returns a true value, the " @@ -237,14 +251,14 @@ msgid "" "expression, given as a :ref:`re.Pattern ` object." msgstr "" -#: ../../library/compileall.rst:177 ../../library/compileall.rst:254 +#: ../../library/compileall.rst:184 ../../library/compileall.rst:261 msgid "" "If *quiet* is ``False`` or ``0`` (the default), the filenames and other " "information are printed to standard out. Set to ``1``, only errors are " "printed. Set to ``2``, all output is suppressed." msgstr "" -#: ../../library/compileall.rst:181 ../../library/compileall.rst:258 +#: ../../library/compileall.rst:188 ../../library/compileall.rst:265 msgid "" "If *legacy* is true, byte-code files are written to their legacy locations " "and names, which may overwrite byte-code files created by another version of " @@ -253,7 +267,7 @@ msgid "" "coexist." msgstr "" -#: ../../library/compileall.rst:187 ../../library/compileall.rst:264 +#: ../../library/compileall.rst:194 ../../library/compileall.rst:271 msgid "" "*optimize* specifies the optimization level for the compiler. It is passed " "to the built-in :func:`compile` function. Accepts also a sequence of " @@ -261,7 +275,7 @@ msgid "" "file in one call." msgstr "" -#: ../../library/compileall.rst:191 +#: ../../library/compileall.rst:198 msgid "" "The argument *workers* specifies how many workers are used to compile files " "in parallel. The default is to not use multiple workers. If the platform " @@ -271,80 +285,80 @@ msgid "" "`ValueError` will be raised." msgstr "" -#: ../../library/compileall.rst:198 ../../library/compileall.rst:268 +#: ../../library/compileall.rst:205 ../../library/compileall.rst:275 msgid "" "*invalidation_mode* should be a member of the :class:`py_compile." "PycInvalidationMode` enum and controls how the generated pycs are " "invalidated at runtime." msgstr "" -#: ../../library/compileall.rst:202 ../../library/compileall.rst:272 +#: ../../library/compileall.rst:209 ../../library/compileall.rst:279 msgid "" "The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to the " "``-s``, ``-p`` and ``-e`` options described above. They may be specified as " "``str`` or :py:class:`os.PathLike`." msgstr "" -#: ../../library/compileall.rst:206 ../../library/compileall.rst:276 +#: ../../library/compileall.rst:213 ../../library/compileall.rst:283 msgid "" "If *hardlink_dupes* is true and two ``.pyc`` files with different " "optimization level have the same content, use hard links to consolidate " "duplicate files." msgstr "" -#: ../../library/compileall.rst:209 ../../library/compileall.rst:307 +#: ../../library/compileall.rst:216 ../../library/compileall.rst:314 msgid "Added the *legacy* and *optimize* parameter." msgstr "新增 *legacy* 與 *optimize* 參數。" -#: ../../library/compileall.rst:212 +#: ../../library/compileall.rst:219 msgid "Added the *workers* parameter." msgstr "新增 *workers* 參數。" -#: ../../library/compileall.rst:215 ../../library/compileall.rst:281 -#: ../../library/compileall.rst:310 +#: ../../library/compileall.rst:222 ../../library/compileall.rst:288 +#: ../../library/compileall.rst:317 msgid "*quiet* parameter was changed to a multilevel value." msgstr "" -#: ../../library/compileall.rst:218 ../../library/compileall.rst:284 -#: ../../library/compileall.rst:313 +#: ../../library/compileall.rst:225 ../../library/compileall.rst:291 +#: ../../library/compileall.rst:320 msgid "" "The *legacy* parameter only writes out ``.pyc`` files, not ``.pyo`` files no " "matter what the value of *optimize* is." msgstr "" -#: ../../library/compileall.rst:222 +#: ../../library/compileall.rst:229 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../library/compileall.rst:225 ../../library/compileall.rst:288 -#: ../../library/compileall.rst:317 +#: ../../library/compileall.rst:232 ../../library/compileall.rst:295 +#: ../../library/compileall.rst:324 msgid "The *invalidation_mode* parameter was added." msgstr "新增 *invalidation_mode* 參數。" -#: ../../library/compileall.rst:228 ../../library/compileall.rst:291 -#: ../../library/compileall.rst:320 +#: ../../library/compileall.rst:235 ../../library/compileall.rst:298 +#: ../../library/compileall.rst:327 msgid "" "The *invalidation_mode* parameter's default value is updated to ``None``." msgstr "新增 *invalidation_mode* 參數的預設值被更新為 ``None``。" -#: ../../library/compileall.rst:231 +#: ../../library/compileall.rst:238 msgid "Setting *workers* to 0 now chooses the optimal number of cores." msgstr "" -#: ../../library/compileall.rst:234 +#: ../../library/compileall.rst:241 msgid "" "Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* " "arguments. Default value of *maxlevels* was changed from ``10`` to ``sys." "getrecursionlimit()``" msgstr "" -#: ../../library/compileall.rst:240 +#: ../../library/compileall.rst:247 msgid "" "Compile the file with path *fullname*. Return a true value if the file " "compiled successfully, and a false value otherwise." msgstr "" -#: ../../library/compileall.rst:243 +#: ../../library/compileall.rst:250 msgid "" "If *ddir* is given, it is prepended to the path to the file being compiled " "for use in compilation time tracebacks, and is also compiled in to the byte-" @@ -353,7 +367,7 @@ msgid "" "executed." msgstr "" -#: ../../library/compileall.rst:249 +#: ../../library/compileall.rst:256 msgid "" "If *rx* is given, its ``search`` method is passed the full path name to the " "file being compiled, and if it returns a true value, the file is not " @@ -362,20 +376,20 @@ msgid "" "object." msgstr "" -#: ../../library/compileall.rst:294 +#: ../../library/compileall.rst:301 msgid "" "Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* " "arguments." msgstr "" -#: ../../library/compileall.rst:299 +#: ../../library/compileall.rst:306 msgid "" "Byte-compile all the :file:`.py` files found along ``sys.path``. Return a " "true value if all the files compiled successfully, and a false value " "otherwise." msgstr "" -#: ../../library/compileall.rst:302 +#: ../../library/compileall.rst:309 msgid "" "If *skip_curdir* is true (the default), the current directory is not " "included in the search. All other parameters are passed to the :func:" @@ -383,13 +397,13 @@ msgid "" "``maxlevels`` defaults to ``0``." msgstr "" -#: ../../library/compileall.rst:323 +#: ../../library/compileall.rst:330 msgid "" "To force a recompile of all the :file:`.py` files in the :file:`Lib/` " "subdirectory and all its subdirectories::" msgstr "" -#: ../../library/compileall.rst:326 +#: ../../library/compileall.rst:333 msgid "" "import compileall\n" "\n" @@ -404,10 +418,10 @@ msgid "" "compileall.compile_dir(pathlib.Path('Lib/'), force=True)" msgstr "" -#: ../../library/compileall.rst:340 +#: ../../library/compileall.rst:347 msgid "Module :mod:`py_compile`" msgstr ":mod:`py_compile` 模組" -#: ../../library/compileall.rst:341 +#: ../../library/compileall.rst:348 msgid "Byte-compile a single source file." msgstr "" diff --git a/library/copy.po b/library/copy.po index b0b7a3ac26..d3d49fd63f 100644 --- a/library/copy.po +++ b/library/copy.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-06-27 07:36+0000\n" "PO-Revision-Date: 2022-01-20 18:49+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -129,8 +129,8 @@ msgid "" "This module does not copy types like module, method, stack trace, stack " "frame, file, socket, window, or any similar types. It does \"copy\" " "functions and classes (shallow and deeply), by returning the original object " -"unchanged; this is compatible with the way these are treated by " -"the :mod:`pickle` module." +"unchanged; this is compatible with the way these are treated by the :mod:" +"`pickle` module." msgstr "" "該模組不複製模組、方法、堆疊追蹤(stack trace)、堆疊框(stack frame)、檔" "案、socket、視窗、陣列以及任何類似的型別。它透過不變更原始物件並將其回傳來" @@ -170,7 +170,6 @@ msgid "" msgstr "" #: ../../library/copy.rst:104 -#, fuzzy msgid "" "Called to implement the deep copy operation; it is passed one argument, the " "*memo* dictionary. If the ``__deepcopy__`` implementation needs to make a " @@ -178,19 +177,17 @@ msgid "" "with the component as first argument and the *memo* dictionary as second " "argument. The *memo* dictionary should be treated as an opaque object." msgstr "" -"想要為一個類別定義它自己的複製操作實作,可以透過定義特殊方" -"法 :meth:`__copy__` 和 :meth:`__deepcopy__`。呼叫前者以實現淺層複製操作;不必" -"傳入額外引數。呼叫後者以實現深層複製操作;它應傳入一個引數,即 ``memo`` 字" -"典。如果 :meth:`__deepcopy__` 實現需要建立一個元件的深層複製,它應當呼" -"叫 :func:`~copy.deepcopy` 函式並以該元件作為第一個引數、以該 *memo* 字典作為" -"第二個引數。*memo* 字典應當被當作不透明物件 (opaque object) 來處理。" +"用來實作深層複製操作;它會傳遞一個引數,即 *memo* 字典。如果 " +"``__deepcopy__`` 實現需要建立一個元件的深層複製,它應當呼叫 :func:`~copy." +"deepcopy` 函式並以該元件作為第一個引數、以該 *memo* 字典作為第二個引數。*memo* " +"字典應當被當作不透明物件 (opaque object) 來處理" #: ../../library/copy.rst:114 msgid "" -"Function :func:`!copy.replace` is more limited than :func:`~copy.copy` " -"and :func:`~copy.deepcopy`, and only supports named tuples created " -"by :func:`~collections.namedtuple`, :mod:`dataclasses`, and other classes " -"which define method :meth:`~object.__replace__`." +"Function :func:`!copy.replace` is more limited than :func:`~copy.copy` and :" +"func:`~copy.deepcopy`, and only supports named tuples created by :func:" +"`~collections.namedtuple`, :mod:`dataclasses`, and other classes which " +"define method :meth:`~object.__replace__`." msgstr "" #: ../../library/copy.rst:122 @@ -199,11 +196,11 @@ msgid "" "with values from *changes*." msgstr "" -#: ../../library/copy.rst:128 +#: ../../library/copy.rst:130 msgid "Module :mod:`pickle`" msgstr ":mod:`pickle` 模組" -#: ../../library/copy.rst:129 +#: ../../library/copy.rst:131 msgid "" "Discussion of the special methods used to support object state retrieval and " "restoration." diff --git a/library/csv.po b/library/csv.po index 106f364d77..ca8bece800 100644 --- a/library/csv.po +++ b/library/csv.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-06-27 07:36+0000\n" "PO-Revision-Date: 2023-11-08 15:06+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -114,12 +114,12 @@ msgstr "" #: ../../library/csv.rst:72 msgid "" "Each row read from the csv file is returned as a list of strings. No " -"automatic data type conversion is performed unless the ``QUOTE_NONNUMERIC`` " -"format option is specified (in which case unquoted fields are transformed " -"into floats)." +"automatic data type conversion is performed unless the :data:" +"`QUOTE_NONNUMERIC` format option is specified (in which case unquoted fields " +"are transformed into floats)." msgstr "" "從 CSV 檔案讀取的每一列會回傳為一個字串列表。除非格式選項 " -"``QUOTE_NONNUMERIC`` 有被指定(在這個情況之下,沒有引號的欄位都會被轉換成浮點" +":data:`QUOTE_NONNUMERIC` 有被指定(在這個情況之下,沒有引號的欄位都會被轉換成浮點" "數),否則不會進行自動資料型別轉換。" #: ../../library/csv.rst:76 ../../library/csv.rst:106 ../../library/csv.rst:181 @@ -538,11 +538,19 @@ msgstr "引導 :class:`writer` 物件引用所有非數字的欄位。" #: ../../library/csv.rst:334 msgid "" -"Instructs :class:`reader` objects to convert all non-quoted fields to type " -"*float*." -msgstr "引導 :class:`reader` 物件轉換所有非引用的欄位為 *float*。" +"Instructs :class:`reader` objects to convert all non-quoted fields to type :" +"class:`float`." +msgstr "引導 :class:`reader` 物件轉換所有非引用的欄位為 :class:`float`。" -#: ../../library/csv.rst:339 +#: ../../library/csv.rst:337 +msgid "" +"Some numeric types, such as :class:`bool`, :class:`~fractions.Fraction`, or :" +"class:`~enum.IntEnum`, have a string representation that cannot be converted " +"to :class:`float`. They cannot be read in the :data:`QUOTE_NONNUMERIC` and :" +"data:`QUOTE_STRINGS` modes." +msgstr "" + +#: ../../library/csv.rst:345 msgid "" "Instructs :class:`writer` objects to never quote fields. When the current " "*delimiter* occurs in output data it is preceded by the current *escapechar* " @@ -553,13 +561,13 @@ msgstr "" "他之前的字元是目前的\\*逸出字元 (escape character)*。如果沒有設定\\*逸出字元" "*\\,若遇到任何字元需要逸出,寫入器則會引發 :exc:`Error` 。" -#: ../../library/csv.rst:344 +#: ../../library/csv.rst:350 msgid "" "Instructs :class:`reader` objects to perform no special processing of quote " "characters." msgstr "引導 :class:`reader` 物件不對引號進行特別處理。" -#: ../../library/csv.rst:348 +#: ../../library/csv.rst:354 msgid "" "Instructs :class:`writer` objects to quote all fields which are not " "``None``. This is similar to :data:`QUOTE_ALL`, except that if a field " @@ -568,7 +576,7 @@ msgstr "" "引導 :class:`writer` 物件引用所有非 ``None`` 的欄位。這與 :data:`QUOTE_ALL` " "相似,除非如果欄位值為 ``None``,該欄位則被寫成空(沒有引號)字串。" -#: ../../library/csv.rst:352 +#: ../../library/csv.rst:358 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) field as " "``None`` and to otherwise behave as :data:`QUOTE_ALL`." @@ -576,7 +584,7 @@ msgstr "" "引導 :class:`reader` 物件將空(沒有引號)欄位直譯 (interpret) 為 ``None``,否" "則會和 :data:`QUOTE_ALL` 有相同的表現方式。" -#: ../../library/csv.rst:359 +#: ../../library/csv.rst:365 msgid "" "Instructs :class:`writer` objects to always place quotes around fields which " "are strings. This is similar to :data:`QUOTE_NONNUMERIC`, except that if a " @@ -586,7 +594,7 @@ msgstr "" "`QUOTE_NONNUMERIC` 相似,除非如果欄位值為 ``None``,該欄位則被寫成空(沒有引" "號)字串。" -#: ../../library/csv.rst:363 +#: ../../library/csv.rst:369 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) string as " "``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`." @@ -594,19 +602,19 @@ msgstr "" "引導 :class:`reader` 物件將空(沒有引號)字串直譯為 ``None``,否則會和 :data:" "`QUOTE_ALL` 有相同的表現方式。" -#: ../../library/csv.rst:368 +#: ../../library/csv.rst:374 msgid "The :mod:`csv` module defines the following exception:" msgstr ":mod:`csv` 模組定義下列例外:" -#: ../../library/csv.rst:373 +#: ../../library/csv.rst:379 msgid "Raised by any of the functions when an error is detected." msgstr "當偵測到錯誤時,任何函式都可以引發。" -#: ../../library/csv.rst:378 +#: ../../library/csv.rst:384 msgid "Dialects and Formatting Parameters" msgstr "Dialect 與格式參數" -#: ../../library/csv.rst:380 +#: ../../library/csv.rst:386 msgid "" "To make it easier to specify the format of input and output records, " "specific formatting parameters are grouped together into dialects. A " @@ -625,16 +633,16 @@ msgstr "" "代,在\\ *dialect*\\ 參數中,程式設計師可以指定個別的格式化參數,其與 :class:" "`Dialect` 類別定義的屬性具有相同的名字。" -#: ../../library/csv.rst:390 +#: ../../library/csv.rst:396 msgid "Dialects support the following attributes:" msgstr "Dialect 支援下列屬性:" -#: ../../library/csv.rst:395 +#: ../../library/csv.rst:401 msgid "" "A one-character string used to separate fields. It defaults to ``','``." msgstr "一個單一字元 (one-character) 的字串可已用來分割欄位。預設為 ``','``。" -#: ../../library/csv.rst:400 +#: ../../library/csv.rst:406 msgid "" "Controls how instances of *quotechar* appearing inside a field should " "themselves be quoted. When :const:`True`, the character is doubled. When :" @@ -645,7 +653,7 @@ msgstr "" "為 :const:`True`,字元會是雙引號。若為 :const:`False`,在 *quotechar* 之前會" "先使用 *escapechar* 作為前綴字。預設為 :const:`True`。" -#: ../../library/csv.rst:405 +#: ../../library/csv.rst:411 msgid "" "On output, if *doublequote* is :const:`False` and no *escapechar* is set, :" "exc:`Error` is raised if a *quotechar* is found in a field." @@ -653,7 +661,7 @@ msgstr "" "在輸出時,若 *doublequote* 是 :const:`False` 且\\ *逸出字元*\\ 沒有被設定,當" "一個\\ *引號*\\ 在欄位中被發現時,:exc:`Error` 會被引發。" -#: ../../library/csv.rst:411 +#: ../../library/csv.rst:417 msgid "" "A one-character string used by the writer to escape the *delimiter* if " "*quoting* is set to :const:`QUOTE_NONE` and the *quotechar* if *doublequote* " @@ -666,17 +674,17 @@ msgstr "" "在讀取時,*逸出字元*\\ 會移除後面的字元以及任何特殊意義。預設為 :const:" "`None`,表示禁止逸出。" -#: ../../library/csv.rst:416 +#: ../../library/csv.rst:422 msgid "An empty *escapechar* is not allowed." msgstr "*escapechar* 為空是不被接受的。" -#: ../../library/csv.rst:421 +#: ../../library/csv.rst:427 msgid "" "The string used to terminate lines produced by the :class:`writer`. It " "defaults to ``'\\r\\n'``." msgstr "由 :class:`writer` 產生被用來分行的字串。預設為 ``'\\r\\n'``。" -#: ../../library/csv.rst:426 +#: ../../library/csv.rst:432 msgid "" "The :class:`reader` is hard-coded to recognise either ``'\\r'`` or ``'\\n'`` " "as end-of-line, and ignores *lineterminator*. This behavior may change in " @@ -685,7 +693,7 @@ msgstr "" ":class:`reader` 是 hard-coded 辨別 ``'\\r'`` or ``'\\n'`` 作為行尾 (end-of-" "line),並忽略\\ *分行符號*。未來可能會改變這個行為。" -#: ../../library/csv.rst:433 +#: ../../library/csv.rst:439 msgid "" "A one-character string used to quote fields containing special characters, " "such as the *delimiter* or *quotechar*, or which contain new-line " @@ -694,11 +702,11 @@ msgstr "" "一個單一字元的字串被用於引用包含特殊字元的欄位,像是 *delimiter*、" "*quotechar* 或是換行字元。預設為 ``'\"'``。" -#: ../../library/csv.rst:437 +#: ../../library/csv.rst:443 msgid "An empty *quotechar* is not allowed." msgstr "*quotechar* 為空是不被允許的。" -#: ../../library/csv.rst:442 +#: ../../library/csv.rst:448 msgid "" "Controls when quotes should be generated by the writer and recognised by the " "reader. It can take on any of the :ref:`QUOTE_\\* constants `\\ 且預設為 :const:`QUOTE_MINIMAL`。" -#: ../../library/csv.rst:449 +#: ../../library/csv.rst:455 msgid "" "When :const:`True`, spaces immediately following the *delimiter* are " "ignored. The default is :const:`False`." @@ -715,18 +723,18 @@ msgstr "" "若為 :const:`True`,在緊接著\\ *分隔符號*\\ 後的空格會被忽略。預設為 :const:" "`False`。" -#: ../../library/csv.rst:455 +#: ../../library/csv.rst:461 msgid "" "When ``True``, raise exception :exc:`Error` on bad CSV input. The default is " "``False``." msgstr "" "若為 ``True``,若有錯誤的 CSV 輸入則會引發 :exc:`Error`。預設為 ``False``。" -#: ../../library/csv.rst:461 +#: ../../library/csv.rst:467 msgid "Reader Objects" msgstr "讀取器物件" -#: ../../library/csv.rst:463 +#: ../../library/csv.rst:469 msgid "" "Reader objects (:class:`DictReader` instances and objects returned by the :" "func:`reader` function) have the following public methods:" @@ -734,7 +742,7 @@ msgstr "" "讀取器物件(:func:`reader` 函式回傳的 :class:`DictReader` 實例與物件)有下列" "公用方法 (public method):" -#: ../../library/csv.rst:468 +#: ../../library/csv.rst:474 msgid "" "Return the next row of the reader's iterable object as a list (if the object " "was returned from :func:`reader`) or a dict (if it is a :class:`DictReader` " @@ -745,25 +753,25 @@ msgstr "" "傳)或是一個 dict(若為 :class:`DictReader` 實例),會依據目前的 :class:" "`Dialect` 進行剖析。通常會用 ``next(reader)`` 來進行呼叫。" -#: ../../library/csv.rst:474 +#: ../../library/csv.rst:480 msgid "Reader objects have the following public attributes:" msgstr "讀取器物件有下列公用屬性 (public attributes):" -#: ../../library/csv.rst:478 +#: ../../library/csv.rst:484 msgid "A read-only description of the dialect in use by the parser." msgstr "dialect 的唯讀敘述,會被剖析器使用。" -#: ../../library/csv.rst:483 +#: ../../library/csv.rst:489 msgid "" "The number of lines read from the source iterator. This is not the same as " "the number of records returned, as records can span multiple lines." msgstr "來源疊代器所讀取的行數。這與回傳的紀錄數不同,因為可以進行跨行紀錄。" -#: ../../library/csv.rst:487 +#: ../../library/csv.rst:493 msgid "DictReader objects have the following public attribute:" msgstr "DictReader 物件有下列公用屬性:" -#: ../../library/csv.rst:491 +#: ../../library/csv.rst:497 msgid "" "If not passed as a parameter when creating the object, this attribute is " "initialized upon first access or when the first record is read from the file." @@ -771,11 +779,11 @@ msgstr "" "若在建立物件時沒有作為參數傳遞,這個屬性會在第一次存取之前或是第一筆資料被讀" "取之前進行初始化 (initialize)。" -#: ../../library/csv.rst:498 +#: ../../library/csv.rst:504 msgid "Writer Objects" msgstr "寫入器物件" -#: ../../library/csv.rst:500 +#: ../../library/csv.rst:506 msgid "" ":class:`writer` objects (:class:`DictWriter` instances and objects returned " "by the :func:`writer` function) have the following public methods. A *row* " @@ -793,7 +801,7 @@ msgstr "" "遞)。請注意,在寫入複數 (complex number) 時會用小括號 (parens) 包起來。這可" "能在其他程式讀取 CSV 檔案時導致某些問題(假設他們完全支援複雜數字)。" -#: ../../library/csv.rst:511 +#: ../../library/csv.rst:517 msgid "" "Write the *row* parameter to the writer's file object, formatted according " "to the current :class:`Dialect`. Return the return value of the call to the " @@ -802,11 +810,11 @@ msgstr "" "將參數 *row* 寫入至寫入器的檔案物件中,並依照目前的 :class:`Dialect` 進行格式" "化。回傳下層檔案物件 *write* 方法的回傳值。" -#: ../../library/csv.rst:515 +#: ../../library/csv.rst:521 msgid "Added support of arbitrary iterables." msgstr "新增對任意可疊代物件 (arbitrary iterables) 的支援。" -#: ../../library/csv.rst:520 +#: ../../library/csv.rst:526 msgid "" "Write all elements in *rows* (an iterable of *row* objects as described " "above) to the writer's file object, formatted according to the current " @@ -815,19 +823,19 @@ msgstr "" "將 *rows* 中所有元素(為上述的一個可疊代的 *row* 物件)寫入至寫入器的檔案物件" "中,並依照目前的 dialect 進行格式化。" -#: ../../library/csv.rst:524 +#: ../../library/csv.rst:530 msgid "Writer objects have the following public attribute:" msgstr "寫入器物件有下列公用屬性:" -#: ../../library/csv.rst:529 +#: ../../library/csv.rst:535 msgid "A read-only description of the dialect in use by the writer." msgstr "dialect 的唯讀敘述,會被寫入器使用。" -#: ../../library/csv.rst:532 +#: ../../library/csv.rst:538 msgid "DictWriter objects have the following public method:" msgstr "DictWriter 物件有下列公用方法:" -#: ../../library/csv.rst:537 +#: ../../library/csv.rst:543 msgid "" "Write a row with the field names (as specified in the constructor) to the " "writer's file object, formatted according to the current dialect. Return the " @@ -837,7 +845,7 @@ msgstr "" "中,並依照目前的 dialect 進行格式化。回傳內部呼叫 :meth:`csvwriter.writerow` " "的回傳值。" -#: ../../library/csv.rst:542 +#: ../../library/csv.rst:548 msgid "" ":meth:`writeheader` now also returns the value returned by the :meth:" "`csvwriter.writerow` method it uses internally." @@ -845,15 +853,15 @@ msgstr "" ":meth:`writeheader` 現在也會回傳內部呼叫 :meth:`csvwriter.writerow` 的回傳" "值。" -#: ../../library/csv.rst:550 +#: ../../library/csv.rst:556 msgid "Examples" msgstr "範例" -#: ../../library/csv.rst:552 +#: ../../library/csv.rst:558 msgid "The simplest example of reading a CSV file::" msgstr "最簡單的讀取 CSV 檔案範例: ::" -#: ../../library/csv.rst:554 +#: ../../library/csv.rst:560 msgid "" "import csv\n" "with open('some.csv', newline='') as f:\n" @@ -867,11 +875,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:560 +#: ../../library/csv.rst:566 msgid "Reading a file with an alternate format::" msgstr "讀取一個其他格式的檔案: ::" -#: ../../library/csv.rst:562 +#: ../../library/csv.rst:568 msgid "" "import csv\n" "with open('passwd', newline='') as f:\n" @@ -885,11 +893,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:568 +#: ../../library/csv.rst:574 msgid "The corresponding simplest possible writing example is::" msgstr "相對最簡單、可行的寫入範例為: ::" -#: ../../library/csv.rst:570 +#: ../../library/csv.rst:576 msgid "" "import csv\n" "with open('some.csv', 'w', newline='') as f:\n" @@ -897,7 +905,7 @@ msgid "" " writer.writerows(someiterable)" msgstr "" -#: ../../library/csv.rst:575 +#: ../../library/csv.rst:581 msgid "" "Since :func:`open` is used to open a CSV file for reading, the file will by " "default be decoded into unicode using the system default encoding (see :func:" @@ -908,7 +916,7 @@ msgstr "" "碼格式(請見 :func:`locale.getencoding`),並解碼為 unicode。若要使用不同編碼" "格式進行檔案解碼,請使用 open 函式的 ``encoding`` 引數: ::" -#: ../../library/csv.rst:580 +#: ../../library/csv.rst:586 msgid "" "import csv\n" "with open('some.csv', newline='', encoding='utf-8') as f:\n" @@ -922,7 +930,7 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:586 +#: ../../library/csv.rst:592 msgid "" "The same applies to writing in something other than the system default " "encoding: specify the encoding argument when opening the output file." @@ -930,11 +938,11 @@ msgstr "" "同理可以應用到使用不同編碼格式進行寫入:當開啟輸出檔案時,指定 ``encoding`` " "引數。" -#: ../../library/csv.rst:589 +#: ../../library/csv.rst:595 msgid "Registering a new dialect::" msgstr "註冊一個新的 dialect : ::" -#: ../../library/csv.rst:591 +#: ../../library/csv.rst:597 msgid "" "import csv\n" "csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" @@ -946,13 +954,13 @@ msgstr "" "with open('passwd', newline='') as f:\n" " reader = csv.reader(f, 'unixpwd')" -#: ../../library/csv.rst:596 +#: ../../library/csv.rst:602 msgid "" "A slightly more advanced use of the reader --- catching and reporting " "errors::" msgstr "稍微進階的讀取器用法 -- 擷取及回報錯誤: ::" -#: ../../library/csv.rst:598 +#: ../../library/csv.rst:604 msgid "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -962,7 +970,7 @@ msgid "" " for row in reader:\n" " print(row)\n" " except csv.Error as e:\n" -" sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))" +" sys.exit(f'file {filename}, line {reader.line_num}: {e}')" msgstr "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -972,15 +980,15 @@ msgstr "" " for row in reader:\n" " print(row)\n" " except csv.Error as e:\n" -" sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))" +" sys.exit(f'file {filename}, line {reader.line_num}: {e}')" -#: ../../library/csv.rst:608 +#: ../../library/csv.rst:614 msgid "" "And while the module doesn't directly support parsing strings, it can easily " "be done::" msgstr "而當模組無法直接支援剖析字串時,仍可以輕鬆的解決: ::" -#: ../../library/csv.rst:611 +#: ../../library/csv.rst:617 msgid "" "import csv\n" "for row in csv.reader(['one,two,three']):\n" @@ -990,11 +998,11 @@ msgstr "" "for row in csv.reader(['one,two,three']):\n" " print(row)" -#: ../../library/csv.rst:617 +#: ../../library/csv.rst:623 msgid "Footnotes" msgstr "註解" -#: ../../library/csv.rst:618 +#: ../../library/csv.rst:624 msgid "" "If ``newline=''`` is not specified, newlines embedded inside quoted fields " "will not be interpreted correctly, and on platforms that use ``\\r\\n`` " diff --git a/library/ctypes.po b/library/ctypes.po index 86164ffb4f..176c2ec266 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-21 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -47,10 +47,9 @@ msgstr "" #: ../../library/ctypes.rst:27 msgid "" "Note: Some code samples reference the ctypes :class:`c_int` type. On " -"platforms where ``sizeof(long) == sizeof(int)`` it is an alias " -"to :class:`c_long`. So, you should not be confused if :class:`c_long` is " -"printed if you would expect :class:`c_int` --- they are actually the same " -"type." +"platforms where ``sizeof(long) == sizeof(int)`` it is an alias to :class:" +"`c_long`. So, you should not be confused if :class:`c_long` is printed if " +"you would expect :class:`c_int` --- they are actually the same type." msgstr "" #: ../../library/ctypes.rst:35 @@ -76,8 +75,8 @@ msgstr "" #: ../../library/ctypes.rst:48 msgid "" -"Windows errors used to raise :exc:`WindowsError`, which is now an alias " -"of :exc:`OSError`." +"Windows errors used to raise :exc:`WindowsError`, which is now an alias of :" +"exc:`OSError`." msgstr "" #: ../../library/ctypes.rst:53 @@ -209,8 +208,8 @@ msgstr "" #: ../../library/ctypes.rst:125 msgid "" "Sometimes, dlls export functions with names which aren't valid Python " -"identifiers, like ``\"??2@YAPAXI@Z\"``. In this case you have to " -"use :func:`getattr` to retrieve the function::" +"identifiers, like ``\"??2@YAPAXI@Z\"``. In this case you have to use :func:" +"`getattr` to retrieve the function::" msgstr "" #: ../../library/ctypes.rst:129 @@ -364,10 +363,10 @@ msgid "" "``None``, integers, bytes objects and (unicode) strings are the only native " "Python objects that can directly be used as parameters in these function " "calls. ``None`` is passed as a C ``NULL`` pointer, bytes objects and strings " -"are passed as pointer to the memory block that contains their data " -"(:c:expr:`char *` or :c:expr:`wchar_t *`). Python integers are passed as " -"the platform's default C :c:expr:`int` type, their value is masked to fit " -"into the C type." +"are passed as pointer to the memory block that contains their data (:c:expr:" +"`char *` or :c:expr:`wchar_t *`). Python integers are passed as the " +"platform's default C :c:expr:`int` type, their value is masked to fit into " +"the C type." msgstr "" #: ../../library/ctypes.rst:205 @@ -376,7 +375,7 @@ msgid "" "learn more about :mod:`ctypes` data types." msgstr "" -#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2242 +#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2262 msgid "Fundamental data types" msgstr "" @@ -664,10 +663,10 @@ msgstr "" #: ../../library/ctypes.rst:292 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 string objects are immutable)::" +"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 string objects are immutable)::" msgstr "" #: ../../library/ctypes.rst:297 @@ -691,11 +690,11 @@ msgstr "" #: ../../library/ctypes.rst:312 msgid "" "You should be careful, however, not to pass them to functions expecting " -"pointers to mutable memory. If you need mutable memory blocks, ctypes has " -"a :func:`create_string_buffer` function which creates these in various " -"ways. The current memory block contents can be accessed (or changed) with " -"the ``raw`` property; if you want to access it as NUL terminated string, use " -"the ``value`` property::" +"pointers to mutable memory. If you need mutable memory blocks, ctypes has a :" +"func:`create_string_buffer` function which creates these in various ways. " +"The current memory block contents can be accessed (or changed) with the " +"``raw`` property; if you want to access it as NUL terminated string, use the " +"``value`` property::" msgstr "" #: ../../library/ctypes.rst:319 @@ -734,9 +733,9 @@ msgstr "" #: ../../library/ctypes.rst:347 msgid "" -"Note that printf prints to the real standard output channel, *not* " -"to :data:`sys.stdout`, so these examples will only work at the console " -"prompt, not from within *IDLE* or *PythonWin*::" +"Note that printf prints to the real standard output channel, *not* to :data:" +"`sys.stdout`, so these examples will only work at the console prompt, not " +"from within *IDLE* or *PythonWin*::" msgstr "" #: ../../library/ctypes.rst:351 @@ -931,13 +930,13 @@ 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:`~_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:`!_as_parameter_` attribute, or whatever you want to pass as the C " -"function argument in this case. Again, the result should be an integer, " -"string, bytes, a :mod:`ctypes` instance, or an object with an :attr:`!" +"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:`!" +"_as_parameter_` attribute, or whatever you want to pass as the C function " +"argument in this case. Again, the result should be an integer, string, " +"bytes, a :mod:`ctypes` instance, or an object with an :attr:`!" "_as_parameter_` attribute." msgstr "" @@ -954,10 +953,9 @@ msgstr "" #: ../../library/ctypes.rst:482 msgid "" -"The C prototype of :c:func:`time` is ``time_t time(time_t *)``. " -"Because :c:type:`time_t` might be of a different type than the default " -"return type :c:expr:`int`, you should specify the :attr:`!restype` " -"attribute::" +"The C prototype of :c:func:`time` is ``time_t time(time_t *)``. Because :c:" +"type:`time_t` might be of a different type than the default return type :c:" +"expr:`int`, you should specify the :attr:`!restype` attribute::" msgstr "" #: ../../library/ctypes.rst:486 @@ -1127,10 +1125,10 @@ msgstr "" #: ../../library/ctypes.rst:571 msgid "" ":mod:`ctypes` exports the :func:`byref` function which is used to pass " -"parameters by reference. The same effect can be achieved with " -"the :func:`pointer` function, although :func:`pointer` does a lot more work " -"since it constructs a real pointer object, so it is faster to " -"use :func:`byref` if you don't need the pointer object in Python itself::" +"parameters by reference. The same effect can be achieved with the :func:" +"`pointer` function, although :func:`pointer` does a lot more work since it " +"constructs a real pointer object, so it is faster to use :func:`byref` if " +"you don't need the pointer object in Python itself::" msgstr "" #: ../../library/ctypes.rst:577 @@ -1165,11 +1163,11 @@ msgstr "" #: ../../library/ctypes.rst:595 msgid "" -"Structures and unions must derive from the :class:`Structure` " -"and :class:`Union` base classes which are defined in the :mod:`ctypes` " -"module. Each subclass must define a :attr:`~Structure._fields_` " -"attribute. :attr:`!_fields_` must be a list of *2-tuples*, containing a " -"*field name* and a *field type*." +"Structures and unions must derive from the :class:`Structure` and :class:" +"`Union` base classes which are defined in the :mod:`ctypes` module. Each " +"subclass must define a :attr:`~Structure._fields_` attribute. :attr:`!" +"_fields_` must be a list of *2-tuples*, containing a *field name* and a " +"*field type*." msgstr "" #: ../../library/ctypes.rst:600 @@ -1306,8 +1304,8 @@ msgstr "" #: ../../library/ctypes.rst:667 msgid "" "By default, Structure and Union fields are aligned in the same way the C " -"compiler does it. It is possible to override this behavior by specifying " -"a :attr:`~Structure._pack_` class attribute in the subclass definition. This " +"compiler does it. It is possible to override this behavior by specifying a :" +"attr:`~Structure._pack_` class attribute in the subclass definition. This " "must be set to a positive integer and specifies the maximum alignment for " "the fields. This is what ``#pragma pack(n)`` also does in MSVC. It is also " "possible to set a minimum alignment for how the subclass itself is packed in " @@ -1319,10 +1317,10 @@ msgstr "" #: ../../library/ctypes.rst:677 msgid "" ":mod:`ctypes` uses the native byte order for Structures and Unions. To " -"build structures with non-native byte order, you can use one of " -"the :class:`BigEndianStructure`, :class:`LittleEndianStructure`, :class:`BigEndianUnion`, " -"and :class:`LittleEndianUnion` base classes. These classes cannot contain " -"pointer fields." +"build structures with non-native byte order, you can use one of the :class:" +"`BigEndianStructure`, :class:`LittleEndianStructure`, :class:" +"`BigEndianUnion`, and :class:`LittleEndianUnion` base classes. These " +"classes cannot contain pointer fields." msgstr "" #: ../../library/ctypes.rst:687 @@ -1461,8 +1459,8 @@ msgstr "" #: ../../library/ctypes.rst:759 msgid "" -"Pointer instances are created by calling the :func:`pointer` function on " -"a :mod:`ctypes` type::" +"Pointer instances are created by calling the :func:`pointer` function on a :" +"mod:`ctypes` type::" msgstr "" #: ../../library/ctypes.rst:762 @@ -1847,8 +1845,8 @@ msgstr "" #: ../../library/ctypes.rst:958 msgid "" "because the new ``class cell`` is not available in the class statement " -"itself. In :mod:`ctypes`, we can define the ``cell`` class and set " -"the :attr:`~Structure._fields_` attribute later, after the class statement::" +"itself. In :mod:`ctypes`, we can define the ``cell`` class and set the :attr:" +"`~Structure._fields_` attribute later, after the class statement::" msgstr "" #: ../../library/ctypes.rst:962 @@ -2498,7 +2496,7 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1316 ../../library/ctypes.rst:2002 +#: ../../library/ctypes.rst:1316 ../../library/ctypes.rst:2022 msgid "The exact functionality is system dependent." msgstr "" @@ -2607,14 +2605,13 @@ msgstr "" #: ../../library/ctypes.rst:1376 msgid "" "On Windows creating a :class:`CDLL` instance may fail even if the DLL name " -"exists. When a dependent DLL of the loaded DLL is not found, " -"a :exc:`OSError` error is raised with the message *\"[WinError 126] The " -"specified module could not be found\".* This error message does not contain " -"the name of the missing DLL because the Windows API does not return this " -"information making this error hard to diagnose. To resolve this error and " -"determine which DLL is not found, you need to find the list of dependent " -"DLLs and determine which one is not found using Windows debugging and " -"tracing tools." +"exists. When a dependent DLL of the loaded DLL is not found, a :exc:" +"`OSError` error is raised with the message *\"[WinError 126] The specified " +"module could not be found\".* This error message does not contain the name " +"of the missing DLL because the Windows API does not return this information " +"making this error hard to diagnose. To resolve this error and determine " +"which DLL is not found, you need to find the list of dependent DLLs and " +"determine which one is not found using Windows debugging and tracing tools." msgstr "" #: ../../library/ctypes.rst:1388 ../../library/ctypes.rst:1413 @@ -2640,18 +2637,18 @@ 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 +#: ../../library/ctypes.rst:1751 ../../library/ctypes.rst:2002 +#: ../../library/ctypes.rst:2011 ../../library/ctypes.rst:2036 +#: ../../library/ctypes.rst:2045 ../../library/ctypes.rst:2054 +#: ../../library/ctypes.rst:2069 ../../library/ctypes.rst:2126 +#: ../../library/ctypes.rst:2154 ../../library/ctypes.rst:2498 msgid "Availability" msgstr "" #: ../../library/ctypes.rst:1407 msgid "" -":exc:`WindowsError` used to be raised, which is now an alias " -"of :exc:`OSError`." +":exc:`WindowsError` used to be raised, which is now an alias of :exc:" +"`OSError`." msgstr "" #: ../../library/ctypes.rst:1418 @@ -2700,12 +2697,11 @@ msgstr "" #: ../../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:`ctypes` maintains a thread-local copy of the " -"system's :data:`errno` variable; if you call foreign functions created with " -"``use_errno=True`` then the :data:`errno` value before the function call is " -"swapped with the ctypes private copy, the same happens immediately after the " -"function call." +"allows accessing the system :data:`errno` error number in a safe way. :mod:" +"`ctypes` maintains a thread-local copy of the system's :data:`errno` " +"variable; if you call foreign functions created with ``use_errno=True`` then " +"the :data:`errno` value before the function call is swapped with the ctypes " +"private copy, the same happens immediately after the function call." msgstr "" #: ../../library/ctypes.rst:1465 @@ -2718,11 +2714,10 @@ msgstr "" #: ../../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 :func:`!SetLastError` Windows API " -"functions; :func:`ctypes.get_last_error` and :func:`ctypes.set_last_error` " -"are used to request and change the ctypes private copy of the windows error " -"code." +"for the Windows error code which is managed by the :func:`GetLastError` and :" +"func:`!SetLastError` Windows API functions; :func:`ctypes.get_last_error` " +"and :func:`ctypes.set_last_error` are used to request and change the ctypes " +"private copy of the windows error code." msgstr "" #: ../../library/ctypes.rst:1475 @@ -2806,8 +2801,8 @@ msgstr "" #: ../../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." +"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:1543 @@ -2853,9 +2848,9 @@ msgstr "" #: ../../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:`int`, which is of course not always the truth, so you have to " -"assign the correct :attr:`!restype` attribute to use these functions." +"attributes. Note that all these functions are assumed to return C :c:expr:" +"`int`, which is of course not always the truth, so you have to assign the " +"correct :attr:`!restype` attribute to use these functions." msgstr "" #: ../../library/ctypes.rst:1594 ../../library/ctypes.rst:1596 @@ -2867,9 +2862,9 @@ msgstr "" #: ../../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)." +"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:1606 ../../library/ctypes.rst:1608 @@ -2951,12 +2946,12 @@ msgstr "" #: ../../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` tuple, this method allows adapting the actual argument " -"to an object that the foreign function accepts. For example, " -"a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string " -"passed as argument into a bytes object using ctypes conversion rules." +"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` " +"tuple, this method allows adapting the actual argument to an object that the " +"foreign function accepts. For example, a :class:`c_char_p` item in the :" +"attr:`argtypes` tuple will convert a string passed as argument into a bytes " +"object using ctypes conversion rules." msgstr "" #: ../../library/ctypes.rst:1671 @@ -3008,9 +3003,9 @@ msgstr "" 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 " -"a suitable Python exception. Further, an auditing event " -"``ctypes.set_exception`` with argument ``code`` will be raised, allowing an " -"audit hook to replace the exception with its own." +"a suitable Python exception. Further, an auditing event ``ctypes." +"set_exception`` with argument ``code`` will be raised, allowing an audit " +"hook to replace the exception with its own." msgstr "" #: ../../library/ctypes.rst:1715 ../../library/ctypes.rst:1717 @@ -3039,10 +3034,9 @@ msgstr "" msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " -"*use_errno* is set to true, the ctypes private copy of the " -"system :data:`errno` variable is exchanged with the real :data:`errno` value " -"before and after the call; *use_last_error* does the same for the Windows " -"error code." +"*use_errno* is set to true, the ctypes private copy of the system :data:" +"`errno` variable is exchanged with the real :data:`errno` value before and " +"after the call; *use_last_error* does the same for the Windows error code." msgstr "" #: ../../library/ctypes.rst:1746 @@ -3106,8 +3100,8 @@ msgstr "" #: ../../library/ctypes.rst:1802 msgid "" -"*paramflags* must be a tuple of the same length " -"as :attr:`~_CFuncPtr.argtypes`." +"*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." +"argtypes`." msgstr "" #: ../../library/ctypes.rst:1804 @@ -3330,8 +3324,8 @@ msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." msgstr "" -"引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` " -"``ctypes.addressof``。" +"引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` ``ctypes." +"addressof``。" #: ../../library/ctypes.rst:1917 msgid "" @@ -3368,57 +3362,83 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:1945 +#: ../../library/ctypes.rst:1946 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:1948 +#: ../../library/ctypes.rst:1949 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." +"If *size* is given (and not ``None``), it must be an :class:`int`. It " +"specifies the size of the returned array." msgstr "" -#: ../../library/ctypes.rst:1951 +#: ../../library/ctypes.rst:1952 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 " -"termination character. An integer can be passed as second argument which " -"allows specifying the size of the array if the length of the bytes should " -"not be used." +"If the *init* argument is given, it must be :class:`bytes`. It is used to " +"initialize the array items. Bytes not initialized this way are set to zero " +"(NUL)." msgstr "" #: ../../library/ctypes.rst:1956 msgid "" +"If *size* is not given (or if it is ``None``), the buffer is made one " +"element larger than *init*, effectively adding a NUL terminator." +msgstr "" + +#: ../../library/ctypes.rst:1959 +msgid "" +"If both arguments are given, *size* must not be less than ``len(init)``." +msgstr "" + +#: ../../library/ctypes.rst:1963 +msgid "" +"If *size* is equal to ``len(init)``, a NUL terminator is not added. Do not " +"treat such a buffer as a C string." +msgstr "" + +#: ../../library/ctypes.rst:1966 +msgid "For example::" +msgstr "" + +#: ../../library/ctypes.rst:1968 +msgid "" +">>> bytes(create_string_buffer(2))\n" +"b'\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'ab'))\n" +"b'ab\\x00'\n" +">>> bytes(create_string_buffer(b'ab', 2))\n" +"b'ab'\n" +">>> bytes(create_string_buffer(b'ab', 4))\n" +"b'ab\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'abcdef', 2))\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: byte string too long" +msgstr "" + +#: ../../library/ctypes.rst:1981 +msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_string_buffer``。" -#: ../../library/ctypes.rst:1961 +#: ../../library/ctypes.rst:1987 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../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:1967 +#: ../../library/ctypes.rst:1990 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 " -"is a NUL termination character. An integer can be passed as second argument " -"which allows specifying the size of the array if the length of the string " -"should not be used." +"The function takes the same arguments as :func:`~create_string_buffer` " +"except *init* must be a string and *size* counts :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1973 +#: ../../library/ctypes.rst:1993 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." @@ -3426,21 +3446,21 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_unicode_buffer``。" -#: ../../library/ctypes.rst:1978 +#: ../../library/ctypes.rst:1998 msgid "" "This function is a hook which allows implementing in-process COM servers " "with ctypes. It is called from the DllCanUnloadNow function that the " "_ctypes extension dll exports." msgstr "" -#: ../../library/ctypes.rst:1987 +#: ../../library/ctypes.rst:2007 msgid "" "This function is a hook which allows implementing in-process COM servers " "with ctypes. It is called from the DllGetClassObject function that the " "``_ctypes`` extension dll exports." msgstr "" -#: ../../library/ctypes.rst:1997 +#: ../../library/ctypes.rst:2017 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 " @@ -3448,94 +3468,94 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:2008 +#: ../../library/ctypes.rst:2028 msgid "" "Returns the filename of the VC runtime library used by Python, and by the " "extension modules. If the name of the library cannot be determined, " "``None`` is returned." msgstr "" -#: ../../library/ctypes.rst:2012 +#: ../../library/ctypes.rst:2032 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:2021 +#: ../../library/ctypes.rst:2041 msgid "" "Returns a textual description of the error code *code*. If no error code is " "specified, the last error code is used by calling the Windows api function " "GetLastError." msgstr "" -#: ../../library/ctypes.rst:2030 +#: ../../library/ctypes.rst:2050 msgid "" "Returns the last error code set by Windows in the calling thread. This " "function calls the Windows ``GetLastError()`` function directly, it does not " "return the ctypes-private copy of the error code." msgstr "" -#: ../../library/ctypes.rst:2039 +#: ../../library/ctypes.rst:2059 msgid "" -"Returns the current value of the ctypes-private copy of the " -"system :data:`errno` variable in the calling thread." +"Returns the current value of the ctypes-private copy of the system :data:" +"`errno` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2042 +#: ../../library/ctypes.rst:2062 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_errno``。" -#: ../../library/ctypes.rst:2046 +#: ../../library/ctypes.rst:2066 msgid "" "Returns the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2051 +#: ../../library/ctypes.rst:2071 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_last_error``。" -#: ../../library/ctypes.rst:2056 +#: ../../library/ctypes.rst:2076 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:2063 +#: ../../library/ctypes.rst:2083 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:2070 +#: ../../library/ctypes.rst:2090 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:2077 +#: ../../library/ctypes.rst:2097 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:2080 +#: ../../library/ctypes.rst:2100 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:2086 +#: ../../library/ctypes.rst:2106 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 " @@ -3543,115 +3563,114 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:2094 +#: ../../library/ctypes.rst:2114 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:2097 +#: ../../library/ctypes.rst:2117 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." msgstr "" -"引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` " -"``ctypes.set_errno``。" +"引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` ``ctypes." +"set_errno``。" -#: ../../library/ctypes.rst:2102 +#: ../../library/ctypes.rst:2122 msgid "" "Sets the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread to *value* and return the previous " "value." msgstr "" -#: ../../library/ctypes.rst:2108 +#: ../../library/ctypes.rst:2128 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." msgstr "" -"引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` " -"``ctypes.set_last_error``。" +"引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` ``ctypes." +"set_last_error``。" -#: ../../library/ctypes.rst:2113 +#: ../../library/ctypes.rst:2133 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:2119 +#: ../../library/ctypes.rst:2139 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:2123 +#: ../../library/ctypes.rst:2143 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." msgstr "" -"引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` " -"``ctypes.string_at``。" +"引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." +"string_at``。" -#: ../../library/ctypes.rst:2128 +#: ../../library/ctypes.rst:2148 msgid "" "This function is probably the worst-named thing in ctypes. It creates an " "instance of :exc:`OSError`. If *code* is not specified, ``GetLastError`` is " -"called to determine the error code. If *descr* is not " -"specified, :func:`FormatError` is called to get a textual description of the " -"error." +"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:2136 +#: ../../library/ctypes.rst:2156 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:2143 +#: ../../library/ctypes.rst:2163 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:2148 +#: ../../library/ctypes.rst:2168 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." msgstr "" -"引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` " -"``ctypes.wstring_at``。" +"引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." +"wstring_at``。" -#: ../../library/ctypes.rst:2154 +#: ../../library/ctypes.rst:2174 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2159 +#: ../../library/ctypes.rst:2179 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 " -"hold C compatible data; the address of the memory block is returned by " -"the :func:`addressof` helper function. Another instance variable is exposed " -"as :attr:`_objects`; this contains other Python objects that need to be kept " +"hold C compatible data; the address of the memory block is returned by the :" +"func:`addressof` helper function. Another instance variable is exposed as :" +"attr:`_objects`; this contains other Python objects that need to be kept " "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2166 +#: ../../library/ctypes.rst:2186 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:2171 +#: ../../library/ctypes.rst:2191 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " "The optional *offset* parameter specifies an offset into the source buffer " -"in bytes; the default is zero. If the source buffer is not large enough " -"a :exc:`ValueError` is raised." +"in bytes; the default is zero. If the source buffer is not large enough a :" +"exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2177 ../../library/ctypes.rst:2187 +#: ../../library/ctypes.rst:2197 ../../library/ctypes.rst:2207 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." @@ -3659,7 +3678,7 @@ msgstr "" "引發一個附帶引數 ``pointer``、``size``、``offset`` 的\\ :ref:`稽核事件 " "` ``ctypes.cdata/buffer``。" -#: ../../library/ctypes.rst:2181 +#: ../../library/ctypes.rst:2201 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -3667,20 +3686,19 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2191 +#: ../../library/ctypes.rst:2211 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: ../../library/ctypes.rst:2194 ../../library/ctypes.rst:2196 +#: ../../library/ctypes.rst:2214 ../../library/ctypes.rst:2216 msgid "" -"This method, and others that indirectly call this method, raises " -"an :ref:`auditing event ` ``ctypes.cdata`` with argument " -"``address``." +"This method, and others that indirectly call this method, raises an :ref:" +"`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2202 +#: ../../library/ctypes.rst:2222 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 " @@ -3688,39 +3706,39 @@ msgid "" "object that can be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2207 +#: ../../library/ctypes.rst:2227 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:2213 +#: ../../library/ctypes.rst:2233 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:2217 +#: ../../library/ctypes.rst:2237 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2221 +#: ../../library/ctypes.rst:2241 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:`_b_base_` read-only member is the root ctypes object that owns " -"the memory block." +"instead they share part of the memory block of a base object. The :attr:" +"`_b_base_` read-only member is the root ctypes object that owns the memory " +"block." msgstr "" -#: ../../library/ctypes.rst:2228 +#: ../../library/ctypes.rst:2248 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2233 +#: ../../library/ctypes.rst:2253 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. " @@ -3728,20 +3746,20 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2246 +#: ../../library/ctypes.rst:2266 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 " -"fundamental ctypes data types. :class:`_SimpleCData` is a subclass " -"of :class:`_CData`, so it inherits their methods and attributes. ctypes data " +"fundamental ctypes data types. :class:`_SimpleCData` is a subclass of :" +"class:`_CData`, so it inherits their methods and attributes. ctypes data " "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2252 +#: ../../library/ctypes.rst:2272 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2256 +#: ../../library/ctypes.rst:2276 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 " @@ -3749,7 +3767,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2261 +#: ../../library/ctypes.rst:2281 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -3757,7 +3775,7 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2267 +#: ../../library/ctypes.rst:2287 msgid "" "Fundamental data types, when returned as foreign function call results, or, " "for example, by retrieving structure field members or array items, are " @@ -3767,7 +3785,7 @@ msgid "" "instance." msgstr "" -#: ../../library/ctypes.rst:2275 +#: ../../library/ctypes.rst:2295 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 " @@ -3775,25 +3793,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: ../../library/ctypes.rst:2280 +#: ../../library/ctypes.rst:2300 msgid "These are the fundamental ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2284 +#: ../../library/ctypes.rst:2304 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:2291 +#: ../../library/ctypes.rst:2311 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:2298 +#: ../../library/ctypes.rst:2318 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 " @@ -3801,259 +3819,259 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: ../../library/ctypes.rst:2306 +#: ../../library/ctypes.rst:2326 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2312 +#: ../../library/ctypes.rst:2332 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:2318 +#: ../../library/ctypes.rst:2338 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2324 +#: ../../library/ctypes.rst:2344 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:2331 +#: ../../library/ctypes.rst:2351 msgid "" -"Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias " -"for :class:`c_byte`." +"Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for :" +"class:`c_byte`." msgstr "" -#: ../../library/ctypes.rst:2337 +#: ../../library/ctypes.rst:2357 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: ../../library/ctypes.rst:2343 +#: ../../library/ctypes.rst:2363 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: ../../library/ctypes.rst:2349 +#: ../../library/ctypes.rst:2369 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: ../../library/ctypes.rst:2355 +#: ../../library/ctypes.rst:2375 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:2361 +#: ../../library/ctypes.rst:2381 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:2367 +#: ../../library/ctypes.rst:2387 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:2373 +#: ../../library/ctypes.rst:2393 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2378 +#: ../../library/ctypes.rst:2398 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2385 +#: ../../library/ctypes.rst:2405 msgid "Represents the C :c:type:`time_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2392 +#: ../../library/ctypes.rst:2412 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:2399 +#: ../../library/ctypes.rst:2419 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:2406 +#: ../../library/ctypes.rst:2426 msgid "" "Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ubyte`." msgstr "" -#: ../../library/ctypes.rst:2412 +#: ../../library/ctypes.rst:2432 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: ../../library/ctypes.rst:2418 +#: ../../library/ctypes.rst:2438 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: ../../library/ctypes.rst:2424 +#: ../../library/ctypes.rst:2444 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: ../../library/ctypes.rst:2430 +#: ../../library/ctypes.rst:2450 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:2436 +#: ../../library/ctypes.rst:2456 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:2442 +#: ../../library/ctypes.rst:2462 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:2448 +#: ../../library/ctypes.rst:2468 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:2454 +#: ../../library/ctypes.rst:2474 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:2461 +#: ../../library/ctypes.rst:2481 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:2468 +#: ../../library/ctypes.rst:2488 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:2475 +#: ../../library/ctypes.rst:2495 msgid "" "Represents a :c:type:`!HRESULT` value, which contains success or error " "information for a function or method call." msgstr "" -#: ../../library/ctypes.rst:2483 +#: ../../library/ctypes.rst:2503 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: ../../library/ctypes.rst:2486 +#: ../../library/ctypes.rst:2506 msgid "" "The :mod:`!ctypes.wintypes` module provides quite some other Windows " -"specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, " -"or :c:type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!" -"RECT` are also defined." +"specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:" +"type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!RECT` " +"are also defined." msgstr "" -#: ../../library/ctypes.rst:2494 +#: ../../library/ctypes.rst:2514 msgid "Structured data types" msgstr "" -#: ../../library/ctypes.rst:2499 +#: ../../library/ctypes.rst:2519 msgid "Abstract base class for unions in native byte order." msgstr "" -#: ../../library/ctypes.rst:2504 +#: ../../library/ctypes.rst:2524 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2510 +#: ../../library/ctypes.rst:2530 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2516 +#: ../../library/ctypes.rst:2536 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2521 +#: ../../library/ctypes.rst:2541 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2523 +#: ../../library/ctypes.rst:2543 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:2529 +#: ../../library/ctypes.rst:2549 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: ../../library/ctypes.rst:2531 +#: ../../library/ctypes.rst:2551 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:`ctypes` will create :term:`descriptor`\\s which allow " -"reading and writing the fields by direct attribute accesses. These are the" +"these types, and at least define a :attr:`_fields_` class variable. :mod:" +"`ctypes` will create :term:`descriptor`\\s which allow reading and writing " +"the fields by direct attribute accesses. These are the" msgstr "" -#: ../../library/ctypes.rst:2539 +#: ../../library/ctypes.rst:2559 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:2543 +#: ../../library/ctypes.rst:2563 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:2547 +#: ../../library/ctypes.rst:2567 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:2550 +#: ../../library/ctypes.rst:2570 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:2554 +#: ../../library/ctypes.rst:2574 msgid "" "class List(Structure):\n" " pass\n" @@ -4067,7 +4085,7 @@ msgstr "" " ...\n" " ]" -#: ../../library/ctypes.rst:2560 +#: ../../library/ctypes.rst:2580 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, " @@ -4075,48 +4093,48 @@ msgid "" "raise an AttributeError." msgstr "" -#: ../../library/ctypes.rst:2565 +#: ../../library/ctypes.rst:2585 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:2572 +#: ../../library/ctypes.rst:2592 msgid "" "An optional small integer that allows overriding the alignment of structure " -"fields in the instance. :attr:`_pack_` must already be defined " -"when :attr:`_fields_` is assigned, otherwise it will have no effect. Setting " -"this attribute to 0 is the same as not setting it at all." +"fields in the instance. :attr:`_pack_` must already be defined when :attr:" +"`_fields_` is assigned, otherwise it will have no effect. Setting this " +"attribute to 0 is the same as not setting it at all." msgstr "" -#: ../../library/ctypes.rst:2580 +#: ../../library/ctypes.rst:2600 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:2588 +#: ../../library/ctypes.rst:2608 msgid "" -"An optional sequence that lists the names of unnamed (anonymous) " -"fields. :attr:`_anonymous_` must be already defined when :attr:`_fields_` is " +"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:2592 +#: ../../library/ctypes.rst:2612 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 accessing the nested fields directly, without the need to create the " +"The fields listed in this variable must be structure or union type fields. :" +"mod:`ctypes` will create descriptors in the structure type that allows " +"accessing the nested fields directly, without the need to create the " "structure or union field." msgstr "" -#: ../../library/ctypes.rst:2597 +#: ../../library/ctypes.rst:2617 msgid "Here is an example type (Windows)::" msgstr "" -#: ../../library/ctypes.rst:2599 +#: ../../library/ctypes.rst:2619 msgid "" "class _U(Union):\n" " _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" @@ -4138,7 +4156,7 @@ msgstr "" " _fields_ = [(\"u\", _U),\n" " (\"vt\", VARTYPE)]" -#: ../../library/ctypes.rst:2610 +#: ../../library/ctypes.rst:2630 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 " @@ -4148,7 +4166,7 @@ msgid "" "temporary union instance::" msgstr "" -#: ../../library/ctypes.rst:2617 +#: ../../library/ctypes.rst:2637 msgid "" "td = TYPEDESC()\n" "td.vt = VT_PTR\n" @@ -4160,15 +4178,15 @@ msgstr "" "td.lptdesc = POINTER(some_type)\n" "td.u.lptdesc = POINTER(some_type)" -#: ../../library/ctypes.rst:2622 +#: ../../library/ctypes.rst:2642 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:`_fields_` variable, the fields specified in this are " -"appended to the fields of the base class." +"fields of the base class. If the subclass definition has a separate :attr:" +"`_fields_` variable, the fields specified in this are appended to the fields " +"of the base class." msgstr "" -#: ../../library/ctypes.rst:2627 +#: ../../library/ctypes.rst:2647 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -4178,77 +4196,77 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: ../../library/ctypes.rst:2638 +#: ../../library/ctypes.rst:2658 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:2642 +#: ../../library/ctypes.rst:2662 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:2644 +#: ../../library/ctypes.rst:2664 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 subclass this type and define :attr:`_length_` and :attr:`_type_` class " +"The recommended way to create concrete array types is by multiplying any :" +"mod:`ctypes` data type with a non-negative integer. Alternatively, you can " +"subclass this type and define :attr:`_length_` and :attr:`_type_` class " "variables. Array elements can be read and written using standard subscript " "and slice accesses; for slice reads, the resulting object is *not* itself " "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:2654 +#: ../../library/ctypes.rst:2674 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`." +"range subscripts result in an :exc:`IndexError`. Will be returned by :func:" +"`len`." msgstr "" -#: ../../library/ctypes.rst:2661 +#: ../../library/ctypes.rst:2681 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:2664 +#: ../../library/ctypes.rst:2684 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:2669 +#: ../../library/ctypes.rst:2689 msgid "" -"Create an array. Equivalent to ``type * length``, where *type* is " -"a :mod:`ctypes` data type and *length* an integer." +"Create an array. Equivalent to ``type * length``, where *type* is a :mod:" +"`ctypes` data type and *length* an integer." msgstr "" -#: ../../library/ctypes.rst:2673 +#: ../../library/ctypes.rst:2693 msgid "" "This function is :term:`soft deprecated` in favor of multiplication. There " "are no plans to remove it." msgstr "" -#: ../../library/ctypes.rst:2679 +#: ../../library/ctypes.rst:2699 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:2681 +#: ../../library/ctypes.rst:2701 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:2685 +#: ../../library/ctypes.rst:2705 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 :func:`len` will raise :exc:`TypeError`. Negative subscripts will read " -"from the memory *before* the pointer (as in C), and out-of-range subscripts " -"will probably crash with an access violation (if you're lucky)." +"standard subscript and slice accesses. Pointer objects have no size, so :" +"func:`len` will raise :exc:`TypeError`. Negative subscripts will read from " +"the memory *before* the pointer (as in C), and out-of-range subscripts will " +"probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:2695 +#: ../../library/ctypes.rst:2715 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:2699 +#: ../../library/ctypes.rst:2719 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/dataclasses.po b/library/dataclasses.po index 4cf5400e32..2b181acb28 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-14 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -244,13 +244,15 @@ msgstr "" #: ../../library/dataclasses.rst:124 #, fuzzy msgid "" -"*unsafe_hash*: If ``False`` (the default), a :meth:`~object.__hash__` method " -"is generated according to how *eq* and *frozen* are set." +"*unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object." +"__hash__` method, even though it may not be safe to do so. Otherwise, " +"generate a :meth:`~object.__hash__` method according to how *eq* and " +"*frozen* are set. The default value is ``False``." msgstr "" "*unsafe_hash*:如果 ``False``(預設值),將根據 *eq* 和 *frozen* 的設定生成一" "個 :meth:`~object.__hash__` 方法。" -#: ../../library/dataclasses.rst:127 +#: ../../library/dataclasses.rst:130 #, fuzzy msgid "" ":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are " @@ -265,7 +267,7 @@ msgstr "" "複雜的屬性,它取決於程序員的意圖 :meth:`!__eq__` 的存在和行為,以及 " "dataclass 裝飾器中的 *eq* 和 *frozen* 旗標的值." -#: ../../library/dataclasses.rst:134 +#: ../../library/dataclasses.rst:137 #, fuzzy msgid "" "By default, ``@dataclass`` will not implicitly add a :meth:`~object." @@ -279,7 +281,7 @@ msgstr "" "類別屬性 ``__hash__ = None`` 對 Python 具有特定含義,如 :meth:`!__hash__` 文" "件中所述。" -#: ../../library/dataclasses.rst:140 +#: ../../library/dataclasses.rst:143 #, fuzzy msgid "" "If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, " @@ -295,7 +297,7 @@ msgstr "" "方法。如果你的類別在邏輯上是不可變的但仍然可以改變,則可能是這種情況。這是一" "個特殊的用例,應該仔細考慮。" -#: ../../library/dataclasses.rst:147 +#: ../../library/dataclasses.rst:150 #, fuzzy msgid "" "Here are the rules governing implicit creation of a :meth:`!__hash__` " @@ -307,7 +309,7 @@ msgstr "" "有顯式的 :meth:`!__hash__` 方法又設定 ``unsafe_hash=True``;這將導致 :exc:" "`TypeError`。" -#: ../../library/dataclasses.rst:152 +#: ../../library/dataclasses.rst:155 #, fuzzy msgid "" "If *eq* and *frozen* are both true, by default ``@dataclass`` will generate " @@ -325,7 +327,7 @@ msgstr "" "__hash__` 方法(如果超類別是 :class:`object`,這意味著它將回退到基於 id 的散" "列)。" -#: ../../library/dataclasses.rst:160 +#: ../../library/dataclasses.rst:163 #, fuzzy msgid "" "*frozen*: If true (the default is ``False``), assigning to fields will " @@ -337,7 +339,7 @@ msgstr "" "凍結實例。如果 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` 在" "類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" -#: ../../library/dataclasses.rst:165 +#: ../../library/dataclasses.rst:168 #, fuzzy msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." @@ -352,7 +354,7 @@ msgstr "" "成,見上文)。如果為 false,或者類別中已經定義了 :attr:`!__match_args__`,則" "不會生成 :attr:`!__match_args__`。" -#: ../../library/dataclasses.rst:174 +#: ../../library/dataclasses.rst:177 #, fuzzy msgid "" "*kw_only*: If true (the default value is ``False``), then all fields will be " @@ -368,11 +370,11 @@ msgstr "" "類別的任何其他方面都沒有影響。有關詳細資訊,請參閱 :term:`parameter` 詞彙表條" "目。另請參閱 :const:`KW_ONLY` 部分。" -#: ../../library/dataclasses.rst:182 +#: ../../library/dataclasses.rst:185 msgid "Keyword-only fields are not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:186 +#: ../../library/dataclasses.rst:189 #, fuzzy msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " @@ -384,7 +386,7 @@ msgstr "" "屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," "則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:192 +#: ../../library/dataclasses.rst:195 #, fuzzy msgid "" "Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result " @@ -396,7 +398,7 @@ msgstr "" "屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," "則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:199 +#: ../../library/dataclasses.rst:202 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " @@ -404,7 +406,7 @@ msgid "" "workaround. See :gh:`91126` for full details." msgstr "" -#: ../../library/dataclasses.rst:207 +#: ../../library/dataclasses.rst:210 #, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " @@ -420,7 +422,7 @@ msgstr "" "夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" "代器。" -#: ../../library/dataclasses.rst:217 +#: ../../library/dataclasses.rst:220 #, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " @@ -432,14 +434,14 @@ msgstr "" "插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " "``weakref_slot=True`` 是錯誤的。" -#: ../../library/dataclasses.rst:225 +#: ../../library/dataclasses.rst:228 #, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::" -#: ../../library/dataclasses.rst:228 +#: ../../library/dataclasses.rst:231 msgid "" "@dataclass\n" "class C:\n" @@ -447,7 +449,7 @@ msgid "" " b: int = 0 # assign a default value for 'b'" msgstr "" -#: ../../library/dataclasses.rst:233 +#: ../../library/dataclasses.rst:236 #, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " @@ -456,11 +458,11 @@ msgstr "" "在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object." "__init__` 方法中,該方法將定義為: ::" -#: ../../library/dataclasses.rst:236 +#: ../../library/dataclasses.rst:239 msgid "def __init__(self, a: int, b: int = 0):" msgstr "def __init__(self, a: int, b: int = 0):" -#: ../../library/dataclasses.rst:238 +#: ../../library/dataclasses.rst:241 #, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " @@ -470,7 +472,7 @@ msgstr "" ":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" "發生在單個類別中還是作為類別繼承的結果,都是如此。" -#: ../../library/dataclasses.rst:244 +#: ../../library/dataclasses.rst:247 #, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " @@ -483,7 +485,7 @@ msgstr "" "位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函" "式來替換預設欄位值。例如: ::" -#: ../../library/dataclasses.rst:250 +#: ../../library/dataclasses.rst:253 msgid "" "@dataclass\n" "class C:\n" @@ -499,7 +501,7 @@ msgstr "" "c = C()\n" "c.mylist += [1, 2, 3]" -#: ../../library/dataclasses.rst:257 +#: ../../library/dataclasses.rst:260 #, fuzzy msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " @@ -511,11 +513,11 @@ msgstr "" "供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效值。任何程式碼" "都不應直接使用 :const:`MISSING` 值。" -#: ../../library/dataclasses.rst:262 +#: ../../library/dataclasses.rst:265 msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" -#: ../../library/dataclasses.rst:264 +#: ../../library/dataclasses.rst:267 #, fuzzy msgid "" "*default*: If provided, this will be the default value for this field. This " @@ -525,7 +527,7 @@ msgstr "" "*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" "叫本身會替換預設值的正常位置。" -#: ../../library/dataclasses.rst:268 +#: ../../library/dataclasses.rst:271 #, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " @@ -538,7 +540,7 @@ msgstr "" "時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指" "定 *default* 和 *default_factory* 是錯誤的。" -#: ../../library/dataclasses.rst:274 +#: ../../library/dataclasses.rst:277 #, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " @@ -547,7 +549,7 @@ msgstr "" "*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` " "方法的參數包含在內。" -#: ../../library/dataclasses.rst:277 +#: ../../library/dataclasses.rst:280 #, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " @@ -556,7 +558,7 @@ msgstr "" "*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方" "法回傳的字串中。" -#: ../../library/dataclasses.rst:280 +#: ../../library/dataclasses.rst:283 #, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " @@ -572,7 +574,7 @@ msgstr "" "是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定" "為 ``None`` 以外的任何值。" -#: ../../library/dataclasses.rst:288 +#: ../../library/dataclasses.rst:291 #, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " @@ -585,7 +587,7 @@ msgstr "" "湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" -#: ../../library/dataclasses.rst:294 +#: ../../library/dataclasses.rst:297 #, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " @@ -595,7 +597,7 @@ msgstr "" "*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" -#: ../../library/dataclasses.rst:298 +#: ../../library/dataclasses.rst:301 #, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " @@ -610,7 +612,7 @@ msgstr "" "不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" "密鑰,用作元資料中的命名空間。" -#: ../../library/dataclasses.rst:306 +#: ../../library/dataclasses.rst:309 #, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " @@ -619,11 +621,11 @@ msgstr "" "*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:" "`~object.__init__` 方法的參數時使用。" -#: ../../library/dataclasses.rst:310 +#: ../../library/dataclasses.rst:313 msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:314 +#: ../../library/dataclasses.rst:317 #, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " @@ -639,7 +641,7 @@ msgstr "" "在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" "值,就像預設值本身已指定一樣。例如,在: ::" -#: ../../library/dataclasses.rst:323 +#: ../../library/dataclasses.rst:326 msgid "" "@dataclass\n" "class C:\n" @@ -655,7 +657,7 @@ msgstr "" " z: int = field(repr=False, default=10)\n" " t: int = 20" -#: ../../library/dataclasses.rst:330 +#: ../../library/dataclasses.rst:333 #, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" @@ -665,7 +667,7 @@ msgstr "" "類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" "性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" -#: ../../library/dataclasses.rst:336 +#: ../../library/dataclasses.rst:339 #, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " @@ -677,15 +679,15 @@ msgstr "" "`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物" "件。它記錄的屬性是:" -#: ../../library/dataclasses.rst:341 +#: ../../library/dataclasses.rst:344 msgid ":attr:`!name`: The name of the field." msgstr ":attr:`!name`:欄位的名稱。" -#: ../../library/dataclasses.rst:342 +#: ../../library/dataclasses.rst:345 msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" -#: ../../library/dataclasses.rst:343 +#: ../../library/dataclasses.rst:346 #, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" @@ -696,14 +698,14 @@ msgstr "" "attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它" "們在 :func:`field` 函式中的含義和值相同。" -#: ../../library/dataclasses.rst:347 +#: ../../library/dataclasses.rst:350 #, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。" -#: ../../library/dataclasses.rst:352 +#: ../../library/dataclasses.rst:355 msgid "" "``InitVar[T]`` type annotations describe variables that are :ref:`init-only " "`. Fields annotated with :class:`!InitVar` " @@ -712,7 +714,7 @@ msgid "" "meth:`~object.__init__` and an optional :meth:`__post_init__`." msgstr "" -#: ../../library/dataclasses.rst:361 +#: ../../library/dataclasses.rst:364 #, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " @@ -724,7 +726,7 @@ msgstr "" "實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 " "``ClassVar`` 或 ``InitVar`` 的偽欄位。" -#: ../../library/dataclasses.rst:368 +#: ../../library/dataclasses.rst:371 #, fuzzy msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " @@ -736,12 +738,12 @@ msgstr "" "都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被" "遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:374 +#: ../../library/dataclasses.rst:377 #, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" -#: ../../library/dataclasses.rst:376 +#: ../../library/dataclasses.rst:379 msgid "" "@dataclass\n" "class Point:\n" @@ -773,22 +775,22 @@ msgstr "" "c = C([Point(0, 0), Point(10, 4)])\n" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" -#: ../../library/dataclasses.rst:391 ../../library/dataclasses.rst:411 +#: ../../library/dataclasses.rst:394 ../../library/dataclasses.rst:414 #, fuzzy msgid "To create a shallow copy, the following workaround may be used::" msgstr "要建立淺複製,可以使用以下解決方法:" -#: ../../library/dataclasses.rst:393 +#: ../../library/dataclasses.rst:396 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" msgstr "" -#: ../../library/dataclasses.rst:395 +#: ../../library/dataclasses.rst:398 #, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:400 +#: ../../library/dataclasses.rst:403 #, fuzzy msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " @@ -800,11 +802,11 @@ msgstr "" "都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :" "func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:406 +#: ../../library/dataclasses.rst:409 msgid "Continuing from the previous example::" msgstr "從前面的例子繼續: ::" -#: ../../library/dataclasses.rst:408 +#: ../../library/dataclasses.rst:411 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" @@ -812,11 +814,11 @@ msgstr "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" -#: ../../library/dataclasses.rst:413 +#: ../../library/dataclasses.rst:416 msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" msgstr "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" -#: ../../library/dataclasses.rst:415 +#: ../../library/dataclasses.rst:418 #, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " @@ -824,7 +826,7 @@ msgid "" msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:420 +#: ../../library/dataclasses.rst:423 #, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " @@ -844,13 +846,13 @@ msgstr "" "``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" "的含義相同。" -#: ../../library/dataclasses.rst:430 +#: ../../library/dataclasses.rst:433 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:434 +#: ../../library/dataclasses.rst:437 #, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " @@ -862,7 +864,7 @@ msgstr "" "機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供此功能是為了" "方便。例如: ::" -#: ../../library/dataclasses.rst:440 +#: ../../library/dataclasses.rst:443 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -876,11 +878,11 @@ msgstr "" " ('z', int, field(default=5))],\n" " namespace={'add_one': lambda self: self.x + 1})" -#: ../../library/dataclasses.rst:446 +#: ../../library/dataclasses.rst:449 msgid "Is equivalent to::" msgstr "相當於: ::" -#: ../../library/dataclasses.rst:448 +#: ../../library/dataclasses.rst:451 msgid "" "@dataclass\n" "class C:\n" @@ -892,7 +894,7 @@ msgid "" " return self.x + 1" msgstr "" -#: ../../library/dataclasses.rst:459 +#: ../../library/dataclasses.rst:462 #, fuzzy msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " @@ -904,7 +906,7 @@ msgstr "" "``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定" "欄位,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:464 +#: ../../library/dataclasses.rst:467 #, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " @@ -914,7 +916,7 @@ msgstr "" "新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" "保 :meth:`__post_init__`(如果存在)也被呼叫。" -#: ../../library/dataclasses.rst:468 +#: ../../library/dataclasses.rst:471 #, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " @@ -924,7 +926,7 @@ msgstr "" "沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" "們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" -#: ../../library/dataclasses.rst:472 +#: ../../library/dataclasses.rst:475 #, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " @@ -933,7 +935,7 @@ msgstr "" "*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引" "發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:476 +#: ../../library/dataclasses.rst:479 #, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" @@ -950,13 +952,13 @@ msgstr "" "建構函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似" "命名的)方法。" -#: ../../library/dataclasses.rst:485 +#: ../../library/dataclasses.rst:488 msgid "" "Dataclass instances are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/dataclasses.rst:489 +#: ../../library/dataclasses.rst:492 #, fuzzy msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " @@ -964,7 +966,7 @@ msgid "" msgstr "" "如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/dataclasses.rst:492 +#: ../../library/dataclasses.rst:495 #, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " @@ -974,18 +976,18 @@ msgstr "" "如果你需要知道一個類別是否是資料類別的實例(而不是資料類別本身),那麼新增一" "個進一步的檢查 ``not isinstance(obj, type)``: ::" -#: ../../library/dataclasses.rst:496 +#: ../../library/dataclasses.rst:499 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" msgstr "" -#: ../../library/dataclasses.rst:501 +#: ../../library/dataclasses.rst:504 #, fuzzy msgid "A sentinel value signifying a missing default or default_factory." msgstr "表示缺少 default 或 default_factory 的標記值。" -#: ../../library/dataclasses.rst:505 +#: ../../library/dataclasses.rst:508 #, fuzzy msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " @@ -1001,14 +1003,14 @@ msgstr "" "類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位" "表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其指定為關鍵字。" -#: ../../library/dataclasses.rst:514 +#: ../../library/dataclasses.rst:517 #, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::" -#: ../../library/dataclasses.rst:516 +#: ../../library/dataclasses.rst:519 msgid "" "@dataclass\n" "class Point:\n" @@ -1028,14 +1030,14 @@ msgstr "" "\n" "p = Point(0, y=1.5, z=2.0)" -#: ../../library/dataclasses.rst:525 +#: ../../library/dataclasses.rst:528 #, 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:532 +#: ../../library/dataclasses.rst:535 #, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" @@ -1045,12 +1047,12 @@ msgstr "" "當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" "meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" -#: ../../library/dataclasses.rst:539 +#: ../../library/dataclasses.rst:542 #, fuzzy msgid "Post-init processing" msgstr "初始化後處理" -#: ../../library/dataclasses.rst:543 +#: ../../library/dataclasses.rst:546 #, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." @@ -1066,14 +1068,14 @@ msgstr "" "將按照它們在類別中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :" "meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" -#: ../../library/dataclasses.rst:550 +#: ../../library/dataclasses.rst:553 #, 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:553 +#: ../../library/dataclasses.rst:556 msgid "" "@dataclass\n" "class C:\n" @@ -1093,7 +1095,7 @@ msgstr "" " def __post_init__(self):\n" " self.c = self.a + self.b" -#: ../../library/dataclasses.rst:562 +#: ../../library/dataclasses.rst:565 #, fuzzy msgid "" "The :meth:`~object.__init__` method generated by :func:`@dataclass " @@ -1105,7 +1107,7 @@ msgstr "" "類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " "方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" -#: ../../library/dataclasses.rst:567 +#: ../../library/dataclasses.rst:570 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" @@ -1131,7 +1133,7 @@ msgstr "" " def __post_init__(self):\n" " super().__init__(self.side, self.side)" -#: ../../library/dataclasses.rst:579 +#: ../../library/dataclasses.rst:582 #, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " @@ -1141,7 +1143,7 @@ msgstr "" "但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為衍生資料" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" -#: ../../library/dataclasses.rst:583 +#: ../../library/dataclasses.rst:586 #, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" @@ -1151,11 +1153,11 @@ msgstr "" "請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的" "方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。" -#: ../../library/dataclasses.rst:590 +#: ../../library/dataclasses.rst:593 msgid "Class variables" msgstr "類別變數" -#: ../../library/dataclasses.rst:592 +#: ../../library/dataclasses.rst:595 #, fuzzy msgid "" "One of the few places where :func:`@dataclass ` actually inspects " @@ -1172,12 +1174,12 @@ msgstr "" "外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " "``ClassVar`` 偽欄位。" -#: ../../library/dataclasses.rst:603 +#: ../../library/dataclasses.rst:606 #, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" -#: ../../library/dataclasses.rst:605 +#: ../../library/dataclasses.rst:608 #, fuzzy msgid "" "Another place where :func:`@dataclass ` inspects a type " @@ -1197,14 +1199,14 @@ msgstr "" "的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" "它們不被資料類別使用。" -#: ../../library/dataclasses.rst:615 +#: ../../library/dataclasses.rst:618 #, 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:618 +#: ../../library/dataclasses.rst:621 msgid "" "@dataclass\n" "class C:\n" @@ -1230,7 +1232,7 @@ msgstr "" "\n" "c = C(10, database=my_database)" -#: ../../library/dataclasses.rst:630 +#: ../../library/dataclasses.rst:633 #, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" @@ -1239,11 +1241,11 @@ msgstr "" "在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:" "`Field` 物件,但不會為 :attr:`!database` 回傳。" -#: ../../library/dataclasses.rst:636 +#: ../../library/dataclasses.rst:639 msgid "Frozen instances" msgstr "凍結實例" -#: ../../library/dataclasses.rst:638 +#: ../../library/dataclasses.rst:641 #, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " @@ -1257,7 +1259,7 @@ msgstr "" "別將向類別新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" "法。這些方法在叫用時會引發 :exc:`FrozenInstanceError`。" -#: ../../library/dataclasses.rst:644 +#: ../../library/dataclasses.rst:647 #, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" @@ -1267,11 +1269,11 @@ msgstr "" "使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" "用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" -#: ../../library/dataclasses.rst:653 +#: ../../library/dataclasses.rst:656 msgid "Inheritance" msgstr "繼承" -#: ../../library/dataclasses.rst:655 +#: ../../library/dataclasses.rst:658 #, fuzzy msgid "" "When the dataclass is being created by the :func:`@dataclass ` " @@ -1289,7 +1291,7 @@ msgstr "" "將自己的欄位新增到有序對映中。所有生成的方法都將使用這種組合的、計算的有序欄" "位對映。因為欄位是按插入順序排列的,所以衍生類別會覆蓋基底類別。一個例子: ::" -#: ../../library/dataclasses.rst:665 +#: ../../library/dataclasses.rst:668 msgid "" "@dataclass\n" "class Base:\n" @@ -1311,7 +1313,7 @@ msgstr "" " z: int = 10\n" " x: int = 15" -#: ../../library/dataclasses.rst:675 +#: ../../library/dataclasses.rst:678 #, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " @@ -1321,23 +1323,23 @@ msgstr "" "最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" -#: ../../library/dataclasses.rst:678 +#: ../../library/dataclasses.rst:681 #, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:680 +#: ../../library/dataclasses.rst:683 msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" msgstr "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" -#: ../../library/dataclasses.rst:683 +#: ../../library/dataclasses.rst:686 #, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" -#: ../../library/dataclasses.rst:685 +#: ../../library/dataclasses.rst:688 #, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " @@ -1349,7 +1351,7 @@ msgstr "" "僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" "非僅關鍵字參數之後。" -#: ../../library/dataclasses.rst:691 +#: ../../library/dataclasses.rst:694 #, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " @@ -1359,7 +1361,7 @@ msgstr "" "在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄" "位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::" -#: ../../library/dataclasses.rst:694 +#: ../../library/dataclasses.rst:697 msgid "" "@dataclass\n" "class Base:\n" @@ -1385,12 +1387,12 @@ msgstr "" " z: int = 10\n" " t: int = field(kw_only=True, default=0)" -#: ../../library/dataclasses.rst:706 +#: ../../library/dataclasses.rst:709 #, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:708 +#: ../../library/dataclasses.rst:711 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" @@ -1398,7 +1400,7 @@ msgstr "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" -#: ../../library/dataclasses.rst:710 +#: ../../library/dataclasses.rst:713 #, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " @@ -1408,18 +1410,18 @@ msgstr "" "請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位衍生的參數後" "跟從僅關鍵字欄位衍生的參數。" -#: ../../library/dataclasses.rst:714 +#: ../../library/dataclasses.rst:717 #, 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:719 +#: ../../library/dataclasses.rst:722 msgid "Default factory functions" msgstr "預設工廠函式" -#: ../../library/dataclasses.rst:721 +#: ../../library/dataclasses.rst:724 #, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " @@ -1429,11 +1431,11 @@ msgstr "" "如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" "引數呼叫。例如,要建立列表的新實例,請使用: ::" -#: ../../library/dataclasses.rst:725 +#: ../../library/dataclasses.rst:728 msgid "mylist: list = field(default_factory=list)" msgstr "mylist: list = field(default_factory=list)" -#: ../../library/dataclasses.rst:727 +#: ../../library/dataclasses.rst:730 #, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " @@ -1446,11 +1448,11 @@ msgstr "" "位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" "`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" -#: ../../library/dataclasses.rst:734 +#: ../../library/dataclasses.rst:737 msgid "Mutable default values" msgstr "可變預設值" -#: ../../library/dataclasses.rst:736 +#: ../../library/dataclasses.rst:739 #, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " @@ -1458,7 +1460,7 @@ msgid "" msgstr "" "Python 將預設成員變數值存儲在類別屬性中。考慮這個例子,不使用資料類別: ::" -#: ../../library/dataclasses.rst:739 +#: ../../library/dataclasses.rst:742 msgid "" "class C:\n" " x = []\n" @@ -1484,7 +1486,7 @@ msgstr "" "assert o1.x == [1, 2]\n" "assert o1.x is o2.x" -#: ../../library/dataclasses.rst:751 +#: ../../library/dataclasses.rst:754 #, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " @@ -1493,12 +1495,12 @@ msgstr "" "請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的" "那樣。" -#: ../../library/dataclasses.rst:754 +#: ../../library/dataclasses.rst:757 #, fuzzy msgid "Using dataclasses, *if* this code was valid::" msgstr "使用資料類別,*如果*此程式碼有效: ::" -#: ../../library/dataclasses.rst:756 +#: ../../library/dataclasses.rst:759 msgid "" "@dataclass\n" "class D:\n" @@ -1512,11 +1514,11 @@ msgstr "" " def add(self, element):\n" " self.x.append(element)" -#: ../../library/dataclasses.rst:762 +#: ../../library/dataclasses.rst:765 msgid "it would generate code similar to::" msgstr "它會生成類似的程式碼: ::" -#: ../../library/dataclasses.rst:764 +#: ../../library/dataclasses.rst:767 msgid "" "class D:\n" " x = []\n" @@ -1536,7 +1538,7 @@ msgstr "" "\n" "assert D().x is D().x" -#: ../../library/dataclasses.rst:773 +#: ../../library/dataclasses.rst:776 #, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " @@ -1556,14 +1558,14 @@ msgstr "" "檢測到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" "列的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" -#: ../../library/dataclasses.rst:784 +#: ../../library/dataclasses.rst:787 #, 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:787 +#: ../../library/dataclasses.rst:790 msgid "" "@dataclass\n" "class D:\n" @@ -1577,7 +1579,7 @@ msgstr "" "\n" "assert D().x is not D().x" -#: ../../library/dataclasses.rst:793 +#: ../../library/dataclasses.rst:796 #, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" @@ -1587,12 +1589,12 @@ msgstr "" "不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現" "在不允許使用不可散列的對像作為預設值。不可散列性用於近似可變性。" -#: ../../library/dataclasses.rst:800 +#: ../../library/dataclasses.rst:803 #, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" -#: ../../library/dataclasses.rst:802 +#: ../../library/dataclasses.rst:805 #, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " @@ -1600,7 +1602,7 @@ msgid "" msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" -#: ../../library/dataclasses.rst:805 +#: ../../library/dataclasses.rst:808 #, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " @@ -1610,7 +1612,7 @@ msgstr "" "傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:" "`~object.__set__` 方法,而不是覆蓋描述器物件。" -#: ../../library/dataclasses.rst:809 +#: ../../library/dataclasses.rst:812 #, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" @@ -1620,7 +1622,7 @@ msgstr "" "同樣,在取得或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" "__set__` 方法,而不是回傳或覆蓋描述器物件。" -#: ../../library/dataclasses.rst:813 +#: ../../library/dataclasses.rst:816 #, fuzzy msgid "" "To determine whether a field contains a default value, :func:`@dataclass " @@ -1636,7 +1638,7 @@ msgstr "" "面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" "值。" -#: ../../library/dataclasses.rst:823 +#: ../../library/dataclasses.rst:826 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1690,7 +1692,7 @@ msgstr "" "i.quantity_on_hand = 2.5 # 以 2.5 呼叫 __set__\n" "print(i.quantity_on_hand) # 2" -#: ../../library/dataclasses.rst:848 +#: ../../library/dataclasses.rst:851 #, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " diff --git a/library/decimal.po b/library/decimal.po index b2f4740813..384c9f1508 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: 2025-04-25 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -146,7 +146,7 @@ msgid "" msgstr "" #: ../../library/decimal.rst:125 -msgid "Quick-start Tutorial" +msgid "Quick-start tutorial" msgstr "" #: ../../library/decimal.rst:127 @@ -1192,12 +1192,12 @@ msgstr "" msgid "Return the square root of the argument to full precision." msgstr "" -#: ../../library/decimal.rst:875 ../../library/decimal.rst:1512 +#: ../../library/decimal.rst:875 ../../library/decimal.rst:1524 msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "" -#: ../../library/decimal.rst:877 ../../library/decimal.rst:1514 +#: ../../library/decimal.rst:877 ../../library/decimal.rst:1526 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 " @@ -1469,53 +1469,50 @@ msgid "" "field is not specified or is :const:`None`, all flags are cleared." msgstr "" -#: ../../library/decimal.rst:1074 +#: ../../library/decimal.rst:1076 msgid "" -"*prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets the " -"precision for arithmetic operations in the context." +"An integer in the range [``1``, :const:`MAX_PREC`] that sets the precision " +"for arithmetic operations in the context." msgstr "" -#: ../../library/decimal.rst:1077 -msgid "" -"The *rounding* option is one of the constants listed in the section " -"`Rounding Modes`_." +#: ../../library/decimal.rst:1081 +msgid "One of the constants listed in the section `Rounding Modes`_." msgstr "" -#: ../../library/decimal.rst:1080 +#: ../../library/decimal.rst:1086 msgid "" -"The *traps* and *flags* fields list any signals to be set. Generally, new " -"contexts should only set traps and leave the flags clear." +"Lists of any signals to be set. Generally, new contexts should only set " +"traps and leave the flags clear." msgstr "" -#: ../../library/decimal.rst:1083 +#: ../../library/decimal.rst:1092 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`]." +"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:1087 +#: ../../library/decimal.rst:1098 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')``." +"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:1091 +#: ../../library/decimal.rst:1104 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 " -"context is strictly limited to the range ``Emin - prec + 1 <= e <= Emax - " -"prec + 1``. If *clamp* is ``0`` then a weaker condition holds: the adjusted " -"exponent of the :class:`Decimal` instance is at most :attr:`~Context.Emax`. " -"When *clamp* is ``1``, a large normal number will, where possible, have its " -"exponent reduced and a corresponding number of zeros added to its " -"coefficient, in order to fit the exponent constraints; this preserves the " -"value of the number but loses information about significant trailing zeros. " -"For example::" +"Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of " +"a :class:`Decimal` instance representable in this context is strictly " +"limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* " +"is ``0`` then a weaker condition holds: the adjusted exponent of the :class:" +"`Decimal` instance is at most :attr:`~Context.Emax`. When *clamp* is ``1``, " +"a large normal number will, where possible, have its exponent reduced and a " +"corresponding number of zeros added to its coefficient, in order to fit the " +"exponent constraints; this preserves the value of the number but loses " +"information about significant trailing zeros. For example::" msgstr "" -#: ../../library/decimal.rst:1103 +#: ../../library/decimal.rst:1115 msgid "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" @@ -1523,13 +1520,13 @@ msgstr "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" -#: ../../library/decimal.rst:1106 +#: ../../library/decimal.rst:1118 msgid "" "A *clamp* value of ``1`` allows compatibility with the fixed-width decimal " "interchange formats specified in IEEE 754." msgstr "" -#: ../../library/decimal.rst:1109 +#: ../../library/decimal.rst:1121 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 " @@ -1542,30 +1539,30 @@ msgid "" "instance of :class:`int`) anywhere that a Decimal instance is accepted." msgstr "" -#: ../../library/decimal.rst:1122 +#: ../../library/decimal.rst:1134 msgid "Resets all of the flags to ``0``." msgstr "" -#: ../../library/decimal.rst:1126 +#: ../../library/decimal.rst:1138 msgid "Resets all of the traps to ``0``." msgstr "" -#: ../../library/decimal.rst:1132 +#: ../../library/decimal.rst:1144 msgid "Return a duplicate of the context." msgstr "" -#: ../../library/decimal.rst:1136 +#: ../../library/decimal.rst:1148 msgid "Return a copy of the Decimal instance num." msgstr "" -#: ../../library/decimal.rst:1140 +#: ../../library/decimal.rst:1152 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:1144 +#: ../../library/decimal.rst:1156 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 " @@ -1574,7 +1571,7 @@ msgid "" "sum can change the result:" msgstr "" -#: ../../library/decimal.rst:1150 +#: ../../library/decimal.rst:1162 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.4445') + Decimal('1.0023')\n" @@ -1588,14 +1585,14 @@ msgstr "" ">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" "Decimal('4.44')" -#: ../../library/decimal.rst:1158 +#: ../../library/decimal.rst:1170 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:1164 +#: ../../library/decimal.rst:1176 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 " @@ -1603,7 +1600,7 @@ msgid "" "conversion." msgstr "" -#: ../../library/decimal.rst:1169 +#: ../../library/decimal.rst:1181 msgid "" ">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" ">>> context.create_decimal_from_float(math.pi)\n" @@ -1623,18 +1620,18 @@ msgstr "" " ...\n" "decimal.Inexact: None" -#: ../../library/decimal.rst:1184 +#: ../../library/decimal.rst:1196 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:1190 +#: ../../library/decimal.rst:1202 msgid "Returns a value equal to ``Emax - prec + 1``." msgstr "" -#: ../../library/decimal.rst:1192 +#: ../../library/decimal.rst:1204 msgid "" "The usual approach to working with decimals is to create :class:`Decimal` " "instances and then apply arithmetic operations which take place within the " @@ -1644,189 +1641,189 @@ msgid "" "recounted here." msgstr "" -#: ../../library/decimal.rst:1202 +#: ../../library/decimal.rst:1214 msgid "Returns the absolute value of *x*." msgstr "" -#: ../../library/decimal.rst:1207 +#: ../../library/decimal.rst:1219 msgid "Return the sum of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1212 +#: ../../library/decimal.rst:1224 msgid "Returns the same Decimal object *x*." msgstr "" -#: ../../library/decimal.rst:1217 +#: ../../library/decimal.rst:1229 msgid "Compares *x* and *y* numerically." msgstr "" -#: ../../library/decimal.rst:1222 +#: ../../library/decimal.rst:1234 msgid "Compares the values of the two operands numerically." msgstr "" -#: ../../library/decimal.rst:1227 +#: ../../library/decimal.rst:1239 msgid "Compares two operands using their abstract representation." msgstr "" -#: ../../library/decimal.rst:1232 +#: ../../library/decimal.rst:1244 msgid "" "Compares two operands using their abstract representation, ignoring sign." msgstr "" -#: ../../library/decimal.rst:1237 +#: ../../library/decimal.rst:1249 msgid "Returns a copy of *x* with the sign set to 0." msgstr "" -#: ../../library/decimal.rst:1242 +#: ../../library/decimal.rst:1254 msgid "Returns a copy of *x* with the sign inverted." msgstr "" -#: ../../library/decimal.rst:1247 +#: ../../library/decimal.rst:1259 msgid "Copies the sign from *y* to *x*." msgstr "" -#: ../../library/decimal.rst:1252 +#: ../../library/decimal.rst:1264 msgid "Return *x* divided by *y*." msgstr "" -#: ../../library/decimal.rst:1257 +#: ../../library/decimal.rst:1269 msgid "Return *x* divided by *y*, truncated to an integer." msgstr "" -#: ../../library/decimal.rst:1262 +#: ../../library/decimal.rst:1274 msgid "Divides two numbers and returns the integer part of the result." msgstr "" -#: ../../library/decimal.rst:1267 +#: ../../library/decimal.rst:1279 msgid "Returns ``e ** x``." msgstr "" -#: ../../library/decimal.rst:1272 +#: ../../library/decimal.rst:1284 msgid "Returns *x* multiplied by *y*, plus *z*." msgstr "" -#: ../../library/decimal.rst:1277 +#: ../../library/decimal.rst:1289 msgid "Returns ``True`` if *x* is canonical; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1282 +#: ../../library/decimal.rst:1294 msgid "Returns ``True`` if *x* is finite; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1287 +#: ../../library/decimal.rst:1299 msgid "Returns ``True`` if *x* is infinite; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1292 +#: ../../library/decimal.rst:1304 msgid "Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1297 +#: ../../library/decimal.rst:1309 msgid "" "Returns ``True`` if *x* is a normal number; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1302 +#: ../../library/decimal.rst:1314 msgid "Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1307 +#: ../../library/decimal.rst:1319 msgid "Returns ``True`` if *x* is negative; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1312 +#: ../../library/decimal.rst:1324 msgid "" "Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1317 +#: ../../library/decimal.rst:1329 msgid "Returns ``True`` if *x* is subnormal; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1322 +#: ../../library/decimal.rst:1334 msgid "Returns ``True`` if *x* is a zero; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1327 +#: ../../library/decimal.rst:1339 msgid "Returns the natural (base e) logarithm of *x*." msgstr "" -#: ../../library/decimal.rst:1332 +#: ../../library/decimal.rst:1344 msgid "Returns the base 10 logarithm of *x*." msgstr "" -#: ../../library/decimal.rst:1337 +#: ../../library/decimal.rst:1349 msgid "Returns the exponent of the magnitude of the operand's MSD." msgstr "" -#: ../../library/decimal.rst:1342 +#: ../../library/decimal.rst:1354 msgid "Applies the logical operation *and* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1347 +#: ../../library/decimal.rst:1359 msgid "Invert all the digits in *x*." msgstr "" -#: ../../library/decimal.rst:1352 +#: ../../library/decimal.rst:1364 msgid "Applies the logical operation *or* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1357 +#: ../../library/decimal.rst:1369 msgid "Applies the logical operation *xor* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1362 +#: ../../library/decimal.rst:1374 msgid "Compares two values numerically and returns the maximum." msgstr "" -#: ../../library/decimal.rst:1367 ../../library/decimal.rst:1377 +#: ../../library/decimal.rst:1379 ../../library/decimal.rst:1389 msgid "Compares the values numerically with their sign ignored." msgstr "" -#: ../../library/decimal.rst:1372 +#: ../../library/decimal.rst:1384 msgid "Compares two values numerically and returns the minimum." msgstr "" -#: ../../library/decimal.rst:1382 +#: ../../library/decimal.rst:1394 msgid "Minus corresponds to the unary prefix minus operator in Python." msgstr "" -#: ../../library/decimal.rst:1387 +#: ../../library/decimal.rst:1399 msgid "Return the product of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1392 +#: ../../library/decimal.rst:1404 msgid "Returns the largest representable number smaller than *x*." msgstr "" -#: ../../library/decimal.rst:1397 +#: ../../library/decimal.rst:1409 msgid "Returns the smallest representable number larger than *x*." msgstr "" -#: ../../library/decimal.rst:1402 +#: ../../library/decimal.rst:1414 msgid "Returns the number closest to *x*, in direction towards *y*." msgstr "" -#: ../../library/decimal.rst:1407 +#: ../../library/decimal.rst:1419 msgid "Reduces *x* to its simplest form." msgstr "" -#: ../../library/decimal.rst:1412 +#: ../../library/decimal.rst:1424 msgid "Returns an indication of the class of *x*." msgstr "" -#: ../../library/decimal.rst:1417 +#: ../../library/decimal.rst:1429 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:1424 +#: ../../library/decimal.rst:1436 msgid "Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given." msgstr "" -#: ../../library/decimal.rst:1426 +#: ../../library/decimal.rst:1438 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 " @@ -1835,42 +1832,42 @@ msgid "" "in the Python version." msgstr "" -#: ../../library/decimal.rst:1432 +#: ../../library/decimal.rst:1444 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." msgstr "" -#: ../../library/decimal.rst:1435 +#: ../../library/decimal.rst:1447 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:1440 +#: ../../library/decimal.rst:1452 msgid "" "With three arguments, compute ``(x**y) % modulo``. For the three argument " "form, the following restrictions on the arguments hold:" msgstr "" -#: ../../library/decimal.rst:1443 +#: ../../library/decimal.rst:1455 msgid "all three arguments must be integral" msgstr "" -#: ../../library/decimal.rst:1444 +#: ../../library/decimal.rst:1456 msgid "``y`` must be nonnegative" msgstr "" -#: ../../library/decimal.rst:1445 +#: ../../library/decimal.rst:1457 msgid "at least one of ``x`` or ``y`` must be nonzero" msgstr "" -#: ../../library/decimal.rst:1446 +#: ../../library/decimal.rst:1458 msgid "``modulo`` must be nonzero and have at most 'precision' digits" msgstr "" -#: ../../library/decimal.rst:1448 +#: ../../library/decimal.rst:1460 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 " @@ -1879,110 +1876,110 @@ msgid "" "result is always exact." msgstr "" -#: ../../library/decimal.rst:1458 +#: ../../library/decimal.rst:1470 msgid "Returns a value equal to *x* (rounded), having the exponent of *y*." msgstr "" -#: ../../library/decimal.rst:1463 +#: ../../library/decimal.rst:1475 msgid "Just returns 10, as this is Decimal, :)" msgstr "" -#: ../../library/decimal.rst:1468 +#: ../../library/decimal.rst:1480 msgid "Returns the remainder from integer division." msgstr "" -#: ../../library/decimal.rst:1470 +#: ../../library/decimal.rst:1482 msgid "" "The sign of the result, if non-zero, is the same as that of the original " "dividend." msgstr "" -#: ../../library/decimal.rst:1476 +#: ../../library/decimal.rst:1488 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:1482 +#: ../../library/decimal.rst:1494 msgid "Returns a rotated copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1487 +#: ../../library/decimal.rst:1499 msgid "Returns ``True`` if the two operands have the same exponent." msgstr "" -#: ../../library/decimal.rst:1492 +#: ../../library/decimal.rst:1504 msgid "Returns the first operand after adding the second value its exp." msgstr "" -#: ../../library/decimal.rst:1497 +#: ../../library/decimal.rst:1509 msgid "Returns a shifted copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1502 +#: ../../library/decimal.rst:1514 msgid "Square root of a non-negative number to context precision." msgstr "" -#: ../../library/decimal.rst:1507 +#: ../../library/decimal.rst:1519 msgid "Return the difference between *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1521 +#: ../../library/decimal.rst:1533 msgid "Rounds to an integer." msgstr "" -#: ../../library/decimal.rst:1526 +#: ../../library/decimal.rst:1538 msgid "Converts a number to a string using scientific notation." msgstr "" -#: ../../library/decimal.rst:1533 +#: ../../library/decimal.rst:1545 msgid "Constants" msgstr "常數" -#: ../../library/decimal.rst:1535 +#: ../../library/decimal.rst:1547 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:1539 +#: ../../library/decimal.rst:1551 msgid "32-bit" msgstr "32 位元" -#: ../../library/decimal.rst:1539 +#: ../../library/decimal.rst:1551 msgid "64-bit" msgstr "64 位元" -#: ../../library/decimal.rst:1541 ../../library/decimal.rst:1543 +#: ../../library/decimal.rst:1553 ../../library/decimal.rst:1555 msgid "``425000000``" msgstr "``425000000``" -#: ../../library/decimal.rst:1541 ../../library/decimal.rst:1543 +#: ../../library/decimal.rst:1553 ../../library/decimal.rst:1555 msgid "``999999999999999999``" msgstr "``999999999999999999``" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1557 msgid "``-425000000``" msgstr "``-425000000``" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1557 msgid "``-999999999999999999``" msgstr "``-999999999999999999``" -#: ../../library/decimal.rst:1547 +#: ../../library/decimal.rst:1559 msgid "``-849999999``" msgstr "``-849999999``" -#: ../../library/decimal.rst:1547 +#: ../../library/decimal.rst:1559 msgid "``-1999999999999999997``" msgstr "``-1999999999999999997``" -#: ../../library/decimal.rst:1553 +#: ../../library/decimal.rst:1565 msgid "" "The value is ``True``. Deprecated, because Python now always has threads." msgstr "" -#: ../../library/decimal.rst:1559 +#: ../../library/decimal.rst:1571 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -1991,55 +1988,55 @@ msgid "" "scenarios." msgstr "" -#: ../../library/decimal.rst:1568 +#: ../../library/decimal.rst:1580 msgid "Rounding modes" msgstr "" -#: ../../library/decimal.rst:1572 +#: ../../library/decimal.rst:1584 msgid "Round towards ``Infinity``." msgstr "" -#: ../../library/decimal.rst:1576 +#: ../../library/decimal.rst:1588 msgid "Round towards zero." msgstr "" -#: ../../library/decimal.rst:1580 +#: ../../library/decimal.rst:1592 msgid "Round towards ``-Infinity``." msgstr "" -#: ../../library/decimal.rst:1584 +#: ../../library/decimal.rst:1596 msgid "Round to nearest with ties going towards zero." msgstr "" -#: ../../library/decimal.rst:1588 +#: ../../library/decimal.rst:1600 msgid "Round to nearest with ties going to nearest even integer." msgstr "" -#: ../../library/decimal.rst:1592 +#: ../../library/decimal.rst:1604 msgid "Round to nearest with ties going away from zero." msgstr "" -#: ../../library/decimal.rst:1596 +#: ../../library/decimal.rst:1608 msgid "Round away from zero." msgstr "" -#: ../../library/decimal.rst:1600 +#: ../../library/decimal.rst:1612 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:1607 +#: ../../library/decimal.rst:1619 msgid "Signals" msgstr "" -#: ../../library/decimal.rst:1609 +#: ../../library/decimal.rst:1621 msgid "" "Signals represent conditions that arise during computation. Each corresponds " "to one context flag and one context trap enabler." msgstr "" -#: ../../library/decimal.rst:1612 +#: ../../library/decimal.rst:1624 msgid "" "The context flag is set whenever the condition is encountered. After the " "computation, flags may be checked for informational purposes (for instance, " @@ -2047,7 +2044,7 @@ msgid "" "sure to clear all flags before starting the next computation." msgstr "" -#: ../../library/decimal.rst:1617 +#: ../../library/decimal.rst:1629 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:" @@ -2055,54 +2052,54 @@ msgid "" "raised upon encountering the condition." msgstr "" -#: ../../library/decimal.rst:1625 +#: ../../library/decimal.rst:1637 msgid "Altered an exponent to fit representation constraints." msgstr "" -#: ../../library/decimal.rst:1627 +#: ../../library/decimal.rst:1639 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:1634 +#: ../../library/decimal.rst:1646 msgid "Base class for other signals and a subclass of :exc:`ArithmeticError`." msgstr "" -#: ../../library/decimal.rst:1639 +#: ../../library/decimal.rst:1651 msgid "Signals the division of a non-infinite number by zero." msgstr "" -#: ../../library/decimal.rst:1641 +#: ../../library/decimal.rst:1653 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:1648 +#: ../../library/decimal.rst:1660 msgid "Indicates that rounding occurred and the result is not exact." msgstr "" -#: ../../library/decimal.rst:1650 +#: ../../library/decimal.rst:1662 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:1657 +#: ../../library/decimal.rst:1669 msgid "An invalid operation was performed." msgstr "" -#: ../../library/decimal.rst:1659 +#: ../../library/decimal.rst:1671 msgid "" "Indicates that an operation was requested that does not make sense. If not " "trapped, returns ``NaN``. Possible causes include::" msgstr "" -#: ../../library/decimal.rst:1662 +#: ../../library/decimal.rst:1674 msgid "" "Infinity - Infinity\n" "0 * Infinity\n" @@ -2124,11 +2121,11 @@ msgstr "" "x ** (non-integer)\n" "x ** Infinity" -#: ../../library/decimal.rst:1675 +#: ../../library/decimal.rst:1687 msgid "Numerical overflow." msgstr "" -#: ../../library/decimal.rst:1677 +#: ../../library/decimal.rst:1689 msgid "" "Indicates the exponent is larger than :attr:`Context.Emax` after rounding " "has occurred. If not trapped, the result depends on the rounding mode, " @@ -2137,42 +2134,42 @@ msgid "" "`Rounded` are also signaled." msgstr "" -#: ../../library/decimal.rst:1686 +#: ../../library/decimal.rst:1698 msgid "Rounding occurred though possibly no information was lost." msgstr "" -#: ../../library/decimal.rst:1688 +#: ../../library/decimal.rst:1700 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:1696 +#: ../../library/decimal.rst:1708 msgid "Exponent was lower than :attr:`~Context.Emin` prior to rounding." msgstr "" -#: ../../library/decimal.rst:1698 +#: ../../library/decimal.rst:1710 msgid "" "Occurs when an operation result is subnormal (the exponent is too small). If " "not trapped, returns the result unchanged." msgstr "" -#: ../../library/decimal.rst:1704 +#: ../../library/decimal.rst:1716 msgid "Numerical underflow with result rounded to zero." msgstr "" -#: ../../library/decimal.rst:1706 +#: ../../library/decimal.rst:1718 msgid "" "Occurs when a subnormal result is pushed to zero by rounding. :class:" "`Inexact` and :class:`Subnormal` are also signaled." msgstr "" -#: ../../library/decimal.rst:1712 +#: ../../library/decimal.rst:1724 msgid "Enable stricter semantics for mixing floats and Decimals." msgstr "" -#: ../../library/decimal.rst:1714 +#: ../../library/decimal.rst:1726 msgid "" "If the signal is not trapped (default), mixing floats and Decimals is " "permitted in the :class:`~decimal.Decimal` constructor, :meth:`~decimal." @@ -2183,18 +2180,18 @@ msgid "" "Context.create_decimal_from_float` do not set the flag." msgstr "" -#: ../../library/decimal.rst:1722 +#: ../../library/decimal.rst:1734 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:1726 +#: ../../library/decimal.rst:1738 msgid "The following table summarizes the hierarchy of signals::" msgstr "" -#: ../../library/decimal.rst:1728 +#: ../../library/decimal.rst:1740 msgid "" "exceptions.ArithmeticError(exceptions.Exception)\n" " DecimalException\n" @@ -2220,15 +2217,15 @@ msgstr "" " Subnormal\n" " FloatOperation(DecimalException, exceptions.TypeError)" -#: ../../library/decimal.rst:1747 -msgid "Floating-Point Notes" +#: ../../library/decimal.rst:1759 +msgid "Floating-point notes" msgstr "" -#: ../../library/decimal.rst:1751 +#: ../../library/decimal.rst:1763 msgid "Mitigating round-off error with increased precision" msgstr "" -#: ../../library/decimal.rst:1753 +#: ../../library/decimal.rst:1765 msgid "" "The use of decimal floating point eliminates decimal representation error " "(making it possible to represent ``0.1`` exactly); however, some operations " @@ -2236,7 +2233,7 @@ msgid "" "precision." msgstr "" -#: ../../library/decimal.rst:1757 +#: ../../library/decimal.rst:1769 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " @@ -2245,7 +2242,7 @@ msgid "" "of the associative and distributive properties of addition:" msgstr "" -#: ../../library/decimal.rst:1763 +#: ../../library/decimal.rst:1775 msgid "" "# Examples from Seminumerical Algorithms, Section 4.2.2.\n" ">>> from decimal import Decimal, getcontext\n" @@ -2264,13 +2261,13 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1781 +#: ../../library/decimal.rst:1793 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:1784 +#: ../../library/decimal.rst:1796 msgid "" ">>> getcontext().prec = 20\n" ">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" @@ -2286,18 +2283,18 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1801 +#: ../../library/decimal.rst:1813 msgid "Special values" msgstr "特殊值" -#: ../../library/decimal.rst:1803 +#: ../../library/decimal.rst:1815 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:1807 +#: ../../library/decimal.rst:1819 msgid "" "Infinities can be constructed directly with: ``Decimal('Infinity')``. Also, " "they can arise from dividing by zero when the :exc:`DivisionByZero` signal " @@ -2306,14 +2303,14 @@ msgid "" "representable number." msgstr "" -#: ../../library/decimal.rst:1812 +#: ../../library/decimal.rst:1824 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:1816 +#: ../../library/decimal.rst:1828 msgid "" "Some operations are indeterminate and return ``NaN``, or if the :exc:" "`InvalidOperation` signal is trapped, raise an exception. For example, " @@ -2324,14 +2321,14 @@ msgid "" "the calculation to proceed while flagging specific results as invalid." msgstr "" -#: ../../library/decimal.rst:1824 +#: ../../library/decimal.rst:1836 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:1828 +#: ../../library/decimal.rst:1840 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 " @@ -2348,7 +2345,7 @@ msgid "" "compare_signal` methods instead." msgstr "" -#: ../../library/decimal.rst:1841 +#: ../../library/decimal.rst:1853 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 " @@ -2356,7 +2353,7 @@ msgid "" "negative zeros are treated as equal and their sign is informational." msgstr "" -#: ../../library/decimal.rst:1846 +#: ../../library/decimal.rst:1858 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 " @@ -2365,11 +2362,11 @@ msgid "" "that the following calculation returns a value equal to zero:" msgstr "" -#: ../../library/decimal.rst:1861 +#: ../../library/decimal.rst:1873 msgid "Working with threads" msgstr "" -#: ../../library/decimal.rst:1863 +#: ../../library/decimal.rst:1875 msgid "" "The :func:`getcontext` function accesses a different :class:`Context` object " "for each thread. Having separate thread contexts means that threads may " @@ -2377,20 +2374,20 @@ msgid "" "other threads." msgstr "" -#: ../../library/decimal.rst:1867 +#: ../../library/decimal.rst:1879 msgid "" "Likewise, the :func:`setcontext` function automatically assigns its target " "to the current thread." msgstr "" -#: ../../library/decimal.rst:1870 +#: ../../library/decimal.rst:1882 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:1874 +#: ../../library/decimal.rst:1886 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 " @@ -2399,7 +2396,7 @@ msgid "" "a race condition between threads calling :func:`getcontext`. For example::" msgstr "" -#: ../../library/decimal.rst:1880 +#: ../../library/decimal.rst:1892 msgid "" "# Set applicationwide defaults for all threads about to be launched\n" "DefaultContext.prec = 12\n" @@ -2415,17 +2412,17 @@ msgid "" " . . ." msgstr "" -#: ../../library/decimal.rst:1899 +#: ../../library/decimal.rst:1911 msgid "Recipes" msgstr "" -#: ../../library/decimal.rst:1901 +#: ../../library/decimal.rst:1913 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:1904 +#: ../../library/decimal.rst:1916 msgid "" "def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n" " pos='', neg='-', trailneg=''):\n" @@ -2574,41 +2571,41 @@ msgid "" " return +s" msgstr "" -#: ../../library/decimal.rst:2056 +#: ../../library/decimal.rst:2068 msgid "Decimal FAQ" msgstr "" -#: ../../library/decimal.rst:2058 +#: ../../library/decimal.rst:2070 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:2061 +#: ../../library/decimal.rst:2073 msgid "A. Some users abbreviate the constructor to just a single letter:" msgstr "" -#: ../../library/decimal.rst:2067 +#: ../../library/decimal.rst:2079 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:2071 +#: ../../library/decimal.rst:2083 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:2089 +#: ../../library/decimal.rst:2101 msgid "" "Q. Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "" -#: ../../library/decimal.rst:2092 +#: ../../library/decimal.rst:2104 msgid "" "A. Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " @@ -2616,13 +2613,13 @@ msgid "" "places and need to be followed-up with a :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2110 +#: ../../library/decimal.rst:2122 msgid "" "In developing fixed-point applications, it is convenient to define functions " "to handle the :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2124 +#: ../../library/decimal.rst:2136 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 " @@ -2630,17 +2627,17 @@ msgid "" "canonical value?" msgstr "" -#: ../../library/decimal.rst:2129 +#: ../../library/decimal.rst:2141 msgid "" "A. The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "" -#: ../../library/decimal.rst:2136 +#: ../../library/decimal.rst:2148 msgid "Q. When does rounding occur in a computation?" msgstr "" -#: ../../library/decimal.rst:2138 +#: ../../library/decimal.rst:2150 msgid "" "A. It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " @@ -2650,7 +2647,7 @@ msgid "" "computation::" msgstr "" -#: ../../library/decimal.rst:2145 +#: ../../library/decimal.rst:2157 msgid "" ">>> getcontext().prec = 5\n" ">>> pi = Decimal('3.1415926535') # More than 5 digits\n" @@ -2664,13 +2661,13 @@ msgid "" "Decimal('3.1416')" msgstr "" -#: ../../library/decimal.rst:2156 +#: ../../library/decimal.rst:2168 msgid "" "Q. Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "" -#: ../../library/decimal.rst:2159 +#: ../../library/decimal.rst:2171 msgid "" "A. For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " @@ -2678,25 +2675,25 @@ msgid "" "original's two-place significance." msgstr "" -#: ../../library/decimal.rst:2164 +#: ../../library/decimal.rst:2176 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:2174 +#: ../../library/decimal.rst:2186 msgid "Q. Is there a way to convert a regular float to a :class:`Decimal`?" msgstr "" -#: ../../library/decimal.rst:2176 +#: ../../library/decimal.rst:2188 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:2180 +#: ../../library/decimal.rst:2192 msgid "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" @@ -2704,13 +2701,13 @@ msgstr "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" -#: ../../library/decimal.rst:2185 +#: ../../library/decimal.rst:2197 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:2188 +#: ../../library/decimal.rst:2200 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. " @@ -2718,14 +2715,14 @@ msgid "" "issues, ill-conditioned inputs, or a numerically unstable algorithm." msgstr "" -#: ../../library/decimal.rst:2193 +#: ../../library/decimal.rst:2205 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:2197 +#: ../../library/decimal.rst:2209 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 " @@ -2734,7 +2731,7 @@ msgid "" "haven't been rounded:" msgstr "" -#: ../../library/decimal.rst:2202 +#: ../../library/decimal.rst:2214 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.104') + Decimal('2.104')\n" @@ -2748,30 +2745,30 @@ msgstr "" ">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" "Decimal('5.20')" -#: ../../library/decimal.rst:2210 +#: ../../library/decimal.rst:2222 msgid "" "The solution is either to increase precision or to force rounding of inputs " "using the unary plus operation:" msgstr "" -#: ../../library/decimal.rst:2213 +#: ../../library/decimal.rst:2225 msgid "" ">>> getcontext().prec = 3\n" ">>> +Decimal('1.23456789') # unary plus triggers rounding\n" "Decimal('1.23')" msgstr "" -#: ../../library/decimal.rst:2219 +#: ../../library/decimal.rst:2231 msgid "" "Alternatively, inputs can be rounded upon creation using the :meth:`Context." "create_decimal` method:" msgstr "" -#: ../../library/decimal.rst:2225 +#: ../../library/decimal.rst:2237 msgid "Q. Is the CPython implementation fast for large numbers?" msgstr "" -#: ../../library/decimal.rst:2227 +#: ../../library/decimal.rst:2239 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" @@ -2810,13 +2807,13 @@ msgstr "" ">>> x / 128\n" "Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" -#: ../../library/decimal.rst:2250 +#: ../../library/decimal.rst:2262 msgid "" "For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms " "and the available memory will be insufficient::" msgstr "" -#: ../../library/decimal.rst:2253 +#: ../../library/decimal.rst:2265 msgid "" ">>> Decimal(1) / 3\n" "Traceback (most recent call last):\n" @@ -2828,7 +2825,7 @@ msgstr "" " File \"\", line 1, in \n" "MemoryError" -#: ../../library/decimal.rst:2258 +#: ../../library/decimal.rst:2270 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 " @@ -2836,7 +2833,7 @@ msgid "" "of 500MB each::" msgstr "" -#: ../../library/decimal.rst:2262 +#: ../../library/decimal.rst:2274 msgid "" ">>> import sys\n" ">>>\n" @@ -2860,14 +2857,14 @@ msgid "" " decimal.Inexact: []" msgstr "" -#: ../../library/decimal.rst:2282 +#: ../../library/decimal.rst:2294 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:2291 +#: ../../library/decimal.rst:2303 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "" diff --git a/library/doctest.po b/library/doctest.po index fb18a89516..e23645d07a 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-17 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -265,8 +265,8 @@ msgstr "" #: ../../library/doctest.rst:171 msgid "" "You can force verbose mode by passing ``verbose=True`` to :func:`testmod`, " -"or prohibit it by passing ``verbose=False``. In either of those cases, " -"``sys.argv`` is not examined by :func:`testmod` (so passing ``-v`` or not " +"or prohibit it by passing ``verbose=False``. In either of those cases, :" +"data:`sys.argv` is not examined by :func:`testmod` (so passing ``-v`` or not " "has no effect)." msgstr "" @@ -371,7 +371,7 @@ msgid "" "As with :func:`testmod`, :func:`testfile` won't display anything unless an " "example fails. If an example does fail, then the failing example(s) and the " "cause(s) of the failure(s) are printed to stdout, using the same format as :" -"func:`testmod`." +"func:`!testmod`." msgstr "" #: ../../library/doctest.rst:232 @@ -474,7 +474,7 @@ msgid "" "searched. Objects imported into the module are not searched." msgstr "" -#: ../../library/doctest.rst:310 +#: ../../library/doctest.rst:313 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 " @@ -487,11 +487,11 @@ msgid "" "__test__.K``." msgstr "" -#: ../../library/doctest.rst:319 +#: ../../library/doctest.rst:322 msgid "For example, place this block of code at the top of :file:`example.py`:" msgstr "" -#: ../../library/doctest.rst:321 +#: ../../library/doctest.rst:324 msgid "" "__test__ = {\n" " 'numbers': \"\"\"\n" @@ -513,7 +513,7 @@ msgstr "" "\"\"\"\n" "}" -#: ../../library/doctest.rst:333 +#: ../../library/doctest.rst:336 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 " @@ -522,24 +522,24 @@ msgid "" "scanned for tests." msgstr "" -#: ../../library/doctest.rst:339 +#: ../../library/doctest.rst:342 msgid "" "Any classes found are recursively searched similarly, to test docstrings in " "their contained methods and nested classes." msgstr "" -#: ../../library/doctest.rst:346 +#: ../../library/doctest.rst:349 msgid "How are Docstring Examples Recognized?" msgstr "" -#: ../../library/doctest.rst:348 +#: ../../library/doctest.rst:351 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:353 +#: ../../library/doctest.rst:356 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -573,18 +573,18 @@ msgstr "" "NO!!!\n" ">>>" -#: ../../library/doctest.rst:373 +#: ../../library/doctest.rst:376 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:377 +#: ../../library/doctest.rst:380 msgid "The fine print:" msgstr "" -#: ../../library/doctest.rst:379 +#: ../../library/doctest.rst:382 msgid "" "Expected output cannot contain an all-whitespace line, since such a line is " "taken to signal the end of expected output. If expected output does contain " @@ -592,7 +592,7 @@ msgid "" "line is expected." msgstr "" -#: ../../library/doctest.rst:384 +#: ../../library/doctest.rst:387 msgid "" "All hard tab characters are expanded to spaces, using 8-column tab stops. " "Tabs in output generated by the tested code are not modified. Because any " @@ -607,20 +607,20 @@ msgid "" "`DocTestParser` class." msgstr "" -#: ../../library/doctest.rst:396 +#: ../../library/doctest.rst:399 msgid "" "Output to stdout is captured, but not output to stderr (exception tracebacks " "are captured via a different means)." msgstr "" -#: ../../library/doctest.rst:399 +#: ../../library/doctest.rst:402 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:403 +#: ../../library/doctest.rst:406 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -629,7 +629,7 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:409 +#: ../../library/doctest.rst:412 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " "example, the ``\\n`` above would be interpreted as a newline character. " @@ -637,7 +637,7 @@ msgid "" "use a raw string)::" msgstr "" -#: ../../library/doctest.rst:413 +#: ../../library/doctest.rst:416 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -646,11 +646,11 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:419 +#: ../../library/doctest.rst:422 msgid "The starting column doesn't matter::" msgstr "" -#: ../../library/doctest.rst:421 +#: ../../library/doctest.rst:424 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" @@ -662,17 +662,17 @@ msgstr "" " >>> math.floor(1.9)\n" " 1" -#: ../../library/doctest.rst:426 +#: ../../library/doctest.rst:429 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:433 +#: ../../library/doctest.rst:436 msgid "What's the Execution Context?" msgstr "" -#: ../../library/doctest.rst:435 +#: ../../library/doctest.rst:438 msgid "" "By default, each time :mod:`doctest` finds a docstring to test, it uses a " "*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change " @@ -683,17 +683,17 @@ msgid "" "defined in other docstrings." msgstr "" -#: ../../library/doctest.rst:443 +#: ../../library/doctest.rst:446 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:450 +#: ../../library/doctest.rst:453 msgid "What About Exceptions?" msgstr "" -#: ../../library/doctest.rst:452 +#: ../../library/doctest.rst:455 msgid "" "No problem, provided that the traceback is the only output produced by the " "example: just paste in the traceback. [#]_ Since tracebacks contain details " @@ -702,11 +702,11 @@ msgid "" "it accepts." msgstr "" -#: ../../library/doctest.rst:458 +#: ../../library/doctest.rst:461 msgid "Simple example::" msgstr "簡單範例: ::" -#: ../../library/doctest.rst:460 +#: ../../library/doctest.rst:463 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" @@ -718,20 +718,20 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" -#: ../../library/doctest.rst:465 +#: ../../library/doctest.rst:468 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:468 +#: ../../library/doctest.rst:471 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:472 +#: ../../library/doctest.rst:475 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" @@ -739,14 +739,14 @@ msgstr "" "Traceback (most recent call last):\n" "Traceback (innermost last):" -#: ../../library/doctest.rst:475 +#: ../../library/doctest.rst:478 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:479 +#: ../../library/doctest.rst:482 msgid "" "The traceback stack is followed by the most interesting part: the line(s) " "containing the exception type and detail. This is usually the last line of " @@ -754,7 +754,7 @@ msgid "" "multi-line detail::" msgstr "" -#: ../../library/doctest.rst:484 +#: ../../library/doctest.rst:487 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -770,20 +770,20 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:491 +#: ../../library/doctest.rst:494 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:494 +#: ../../library/doctest.rst:497 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:497 +#: ../../library/doctest.rst:500 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -799,7 +799,7 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:504 +#: ../../library/doctest.rst:507 msgid "" "Note that tracebacks are treated very specially. In particular, in the " "rewritten example, the use of ``...`` is independent of doctest's :const:" @@ -808,11 +808,11 @@ msgid "" "transcript of a Monty Python skit." msgstr "" -#: ../../library/doctest.rst:510 +#: ../../library/doctest.rst:513 msgid "Some details you should read once, but won't need to remember:" msgstr "" -#: ../../library/doctest.rst:512 +#: ../../library/doctest.rst:515 msgid "" "Doctest can't guess whether your expected output came from an exception " "traceback or from ordinary printing. So, e.g., an example that expects " @@ -822,7 +822,7 @@ msgid "" "create real problems." msgstr "" -#: ../../library/doctest.rst:519 +#: ../../library/doctest.rst:522 msgid "" "Each line of the traceback stack (if present) must be indented further than " "the first line of the example, *or* start with a non-alphanumeric character. " @@ -831,29 +831,29 @@ msgid "" "course this does the right thing for genuine tracebacks." msgstr "" -#: ../../library/doctest.rst:525 +#: ../../library/doctest.rst:528 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:529 +#: ../../library/doctest.rst:532 msgid "" "The interactive shell omits the traceback header line for some :exc:" "`SyntaxError`\\ s. But doctest uses the traceback header line to " "distinguish exceptions from non-exceptions. So in the rare case where you " -"need to test a :exc:`SyntaxError` that omits the traceback header, you will " +"need to test a :exc:`!SyntaxError` that omits the traceback header, you will " "need to manually add the traceback header line to your test example." msgstr "" -#: ../../library/doctest.rst:537 +#: ../../library/doctest.rst:540 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" -#: ../../library/doctest.rst:540 +#: ../../library/doctest.rst:543 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -867,7 +867,7 @@ msgstr "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:546 +#: ../../library/doctest.rst:549 msgid "" "Since the lines showing the position of the error come before the exception " "type and detail, they are not checked by doctest. For example, the " @@ -875,7 +875,7 @@ msgid "" "location::" msgstr "" -#: ../../library/doctest.rst:550 +#: ../../library/doctest.rst:553 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -889,11 +889,11 @@ msgstr "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:561 +#: ../../library/doctest.rst:564 msgid "Option Flags" msgstr "可選旗標" -#: ../../library/doctest.rst:563 +#: ../../library/doctest.rst:566 msgid "" "A number of option flags control various aspects of doctest's behavior. " "Symbolic names for the flags are supplied as module constants, which can be :" @@ -903,13 +903,13 @@ msgid "" "option." msgstr "" -#: ../../library/doctest.rst:569 +#: ../../library/doctest.rst:572 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:575 +#: ../../library/doctest.rst:578 msgid "" "By default, if an expected output block contains just ``1``, an actual " "output block containing just ``1`` or just ``True`` is considered to be a " @@ -921,7 +921,7 @@ msgid "" "not for several years." msgstr "" -#: ../../library/doctest.rst:587 +#: ../../library/doctest.rst:590 msgid "" "By default, if an expected output block contains a line containing only the " "string ````, then that line will match a blank line in the actual " @@ -930,7 +930,7 @@ msgid "" "`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." msgstr "" -#: ../../library/doctest.rst:596 +#: ../../library/doctest.rst:599 msgid "" "When specified, all sequences of whitespace (blanks and newlines) are " "treated as equal. Any sequence of whitespace within the expected output " @@ -940,7 +940,7 @@ msgid "" "across multiple lines in your source." msgstr "" -#: ../../library/doctest.rst:607 +#: ../../library/doctest.rst:610 msgid "" "When specified, an ellipsis marker (``...``) in the expected output can " "match any substring in the actual output. This includes substrings that " @@ -949,14 +949,14 @@ msgid "" "matched too much!\" surprises that ``.*`` is prone to in regular expressions." msgstr "" -#: ../../library/doctest.rst:616 +#: ../../library/doctest.rst:619 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:620 +#: ../../library/doctest.rst:623 msgid "" "For example, an example expecting ``ValueError: 42`` will pass if the actual " "exception raised is ``ValueError: 3*14``, but will fail if, say, a :exc:" @@ -966,7 +966,7 @@ msgid "" "these variations will work with the flag specified:" msgstr "" -#: ../../library/doctest.rst:628 +#: ../../library/doctest.rst:631 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -992,20 +992,20 @@ msgstr "" "Traceback (most recent call last):\n" "__main__.Exception: message" -#: ../../library/doctest.rst:642 +#: ../../library/doctest.rst:645 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:646 +#: ../../library/doctest.rst:649 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -#: ../../library/doctest.rst:653 +#: ../../library/doctest.rst:656 msgid "" "When specified, do not run the example at all. This can be useful in " "contexts where doctest examples serve as both documentation and test cases, " @@ -1014,32 +1014,32 @@ msgid "" "might depend on resources which would be unavailable to the test driver." msgstr "" -#: ../../library/doctest.rst:659 +#: ../../library/doctest.rst:662 msgid "" "The SKIP flag can also be used for temporarily \"commenting out\" examples." msgstr "" -#: ../../library/doctest.rst:664 +#: ../../library/doctest.rst:667 msgid "A bitmask or'ing together all the comparison flags above." msgstr "" -#: ../../library/doctest.rst:666 +#: ../../library/doctest.rst:669 msgid "The second group of options controls how test failures are reported:" msgstr "" -#: ../../library/doctest.rst:671 +#: ../../library/doctest.rst:674 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "are displayed using a unified diff." msgstr "" -#: ../../library/doctest.rst:677 +#: ../../library/doctest.rst:680 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "will be displayed using a context diff." msgstr "" -#: ../../library/doctest.rst:683 +#: ../../library/doctest.rst:686 msgid "" "When specified, differences are computed by ``difflib.Differ``, using the " "same algorithm as the popular :file:`ndiff.py` utility. This is the only " @@ -1049,7 +1049,7 @@ msgid "" "mismatching column positions." msgstr "" -#: ../../library/doctest.rst:692 +#: ../../library/doctest.rst:695 msgid "" "When specified, display the first failing example in each doctest, but " "suppress output for all remaining examples. This will prevent doctest from " @@ -1060,7 +1060,7 @@ msgid "" "of failures reported; only the output is suppressed." msgstr "" -#: ../../library/doctest.rst:703 +#: ../../library/doctest.rst:706 msgid "" "When specified, exit after the first failing example and don't attempt to " "run the remaining examples. Thus, the number of failures reported will be at " @@ -1068,17 +1068,17 @@ msgid "" "first failure won't even produce debugging output." msgstr "" -#: ../../library/doctest.rst:711 +#: ../../library/doctest.rst:714 msgid "A bitmask or'ing together all the reporting flags above." msgstr "" -#: ../../library/doctest.rst:714 +#: ../../library/doctest.rst:717 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:720 +#: ../../library/doctest.rst:723 msgid "" "Create a new option flag with a given name, and return the new flag's " "integer value. :func:`register_optionflag` can be used when subclassing :" @@ -1087,39 +1087,39 @@ msgid "" "be called using the following idiom::" msgstr "" -#: ../../library/doctest.rst:726 +#: ../../library/doctest.rst:729 msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "MY_FLAG = register_optionflag('MY_FLAG')" -#: ../../library/doctest.rst:736 +#: ../../library/doctest.rst:739 msgid "Directives" msgstr "" -#: ../../library/doctest.rst:738 +#: ../../library/doctest.rst:741 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:749 +#: ../../library/doctest.rst:752 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:753 +#: ../../library/doctest.rst:756 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:756 +#: ../../library/doctest.rst:759 msgid "For example, this test passes:" msgstr "" -#: ../../library/doctest.rst:758 +#: ../../library/doctest.rst:761 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" @@ -1129,7 +1129,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:765 +#: ../../library/doctest.rst:768 msgid "" "Without the directive it would fail, both because the actual output doesn't " "have two blanks before the single-digit list elements, and because the " @@ -1137,7 +1137,7 @@ msgid "" "a directive to do so:" msgstr "" -#: ../../library/doctest.rst:770 +#: ../../library/doctest.rst:773 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" @@ -1145,13 +1145,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:776 +#: ../../library/doctest.rst:779 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" -#: ../../library/doctest.rst:779 +#: ../../library/doctest.rst:782 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" @@ -1159,13 +1159,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:785 +#: ../../library/doctest.rst:788 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" -#: ../../library/doctest.rst:788 +#: ../../library/doctest.rst:791 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" @@ -1175,14 +1175,14 @@ msgstr "" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:795 +#: ../../library/doctest.rst:798 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:799 +#: ../../library/doctest.rst:802 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" @@ -1192,7 +1192,7 @@ msgstr "" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" -#: ../../library/doctest.rst:806 +#: ../../library/doctest.rst:809 msgid "" "Note that since all options are disabled by default, and directives apply " "only to the example they appear in, enabling options (via ``+`` in a " @@ -1202,11 +1202,11 @@ msgid "" "be useful." msgstr "" -#: ../../library/doctest.rst:816 +#: ../../library/doctest.rst:819 msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:818 +#: ../../library/doctest.rst:821 msgid "" ":mod:`doctest` is serious about requiring exact matches in expected output. " "If even a single character doesn't match, the test fails. This will " @@ -1216,7 +1216,7 @@ msgid "" "test like ::" msgstr "" -#: ../../library/doctest.rst:824 +#: ../../library/doctest.rst:827 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" @@ -1224,11 +1224,11 @@ msgstr "" ">>> foo()\n" "{\"spam\", \"eggs\"}" -#: ../../library/doctest.rst:827 +#: ../../library/doctest.rst:830 msgid "is vulnerable! One workaround is to do ::" msgstr "" -#: ../../library/doctest.rst:829 +#: ../../library/doctest.rst:832 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" @@ -1236,11 +1236,11 @@ msgstr "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" -#: ../../library/doctest.rst:832 +#: ../../library/doctest.rst:835 msgid "instead. Another is to do ::" msgstr "" -#: ../../library/doctest.rst:834 +#: ../../library/doctest.rst:837 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" @@ -1250,15 +1250,15 @@ msgstr "" ">>> d\n" "['eggs', 'spam']" -#: ../../library/doctest.rst:838 +#: ../../library/doctest.rst:841 msgid "There are others, but you get the idea." msgstr "" -#: ../../library/doctest.rst:840 +#: ../../library/doctest.rst:843 msgid "Another bad idea is to print things that embed an object address, like" msgstr "" -#: ../../library/doctest.rst:842 +#: ../../library/doctest.rst:845 msgid "" ">>> id(1.0) # certain to fail some of the time\n" "7948648\n" @@ -1267,12 +1267,12 @@ msgid "" "" msgstr "" -#: ../../library/doctest.rst:850 +#: ../../library/doctest.rst:853 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" -#: ../../library/doctest.rst:852 +#: ../../library/doctest.rst:855 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" @@ -1280,46 +1280,46 @@ msgstr "" ">>> C() # doctest: +ELLIPSIS\n" "" -#: ../../library/doctest.rst:858 +#: ../../library/doctest.rst:861 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. ::" +"platforms, because Python defers to the platform C library for some floating-" +"point calculations, and C libraries vary widely in quality here. ::" msgstr "" -#: ../../library/doctest.rst:862 +#: ../../library/doctest.rst:865 msgid "" -">>> 1./7 # risky\n" -"0.14285714285714285\n" -">>> print(1./7) # safer\n" -"0.142857142857\n" -">>> print(round(1./7, 6)) # much safer\n" -"0.142857" +">>> 1000**0.1 # risky\n" +"1.9952623149688797\n" +">>> round(1000**0.1, 9) # safer\n" +"1.995262315\n" +">>> print(f'{1000**0.1:.4f}') # much safer\n" +"1.9953" msgstr "" -#: ../../library/doctest.rst:869 +#: ../../library/doctest.rst:872 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:872 +#: ../../library/doctest.rst:875 msgid "" ">>> 3./4 # utterly safe\n" "0.75" msgstr "" -#: ../../library/doctest.rst:875 +#: ../../library/doctest.rst:878 msgid "" "Simple fractions are also easier for people to understand, and that makes " "for better documentation." msgstr "" -#: ../../library/doctest.rst:882 +#: ../../library/doctest.rst:885 msgid "Basic API" msgstr "基礎 API" -#: ../../library/doctest.rst:884 +#: ../../library/doctest.rst:887 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " @@ -1327,25 +1327,25 @@ msgid "" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -#: ../../library/doctest.rst:892 +#: ../../library/doctest.rst:895 msgid "" "All arguments except *filename* are optional, and should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:895 +#: ../../library/doctest.rst:898 msgid "" "Test examples in the file named *filename*. Return ``(failure_count, " "test_count)``." msgstr "" -#: ../../library/doctest.rst:898 +#: ../../library/doctest.rst:901 msgid "" "Optional argument *module_relative* specifies how the filename should be " "interpreted:" msgstr "" -#: ../../library/doctest.rst:901 +#: ../../library/doctest.rst:904 msgid "" "If *module_relative* is ``True`` (the default), then *filename* specifies an " "OS-independent module-relative path. By default, this path is relative to " @@ -1355,20 +1355,20 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" -#: ../../library/doctest.rst:908 +#: ../../library/doctest.rst:911 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:912 +#: ../../library/doctest.rst:915 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:915 +#: ../../library/doctest.rst:918 msgid "" "Optional argument *package* is a Python package or the name of a Python " "package whose directory should be used as the base directory for a module-" @@ -1377,7 +1377,7 @@ msgid "" "is an error to specify *package* if *module_relative* is ``False``." msgstr "" -#: ../../library/doctest.rst:921 +#: ../../library/doctest.rst:924 msgid "" "Optional argument *globs* gives a dict to be used as the globals when " "executing examples. A new shallow copy of this dict is created for the " @@ -1385,7 +1385,7 @@ msgid "" "``None``, a new empty dict is used." msgstr "" -#: ../../library/doctest.rst:926 +#: ../../library/doctest.rst:929 msgid "" "Optional argument *extraglobs* gives a dict merged into the globals used to " "execute examples. This works like :meth:`dict.update`: if *globs* and " @@ -1398,27 +1398,27 @@ msgid "" "tested." msgstr "" -#: ../../library/doctest.rst:935 +#: ../../library/doctest.rst:938 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``." +"v'`` is in :data:`sys.argv`." msgstr "" -#: ../../library/doctest.rst:939 +#: ../../library/doctest.rst:942 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:943 +#: ../../library/doctest.rst:946 msgid "" -"Optional argument *optionflags* (default value 0) takes the :ref:`bitwise OR " -"` of option flags. See section :ref:`doctest-options`." +"Optional argument *optionflags* (default value ``0``) takes the :ref:" +"`bitwise OR ` of option flags. See section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:947 +#: ../../library/doctest.rst:950 msgid "" "Optional argument *raise_on_error* defaults to false. If true, an exception " "is raised upon the first failure or unexpected exception in an example. " @@ -1426,33 +1426,33 @@ msgid "" "continue running examples." msgstr "" -#: ../../library/doctest.rst:952 ../../library/doctest.rst:1094 +#: ../../library/doctest.rst:955 ../../library/doctest.rst:1098 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:956 ../../library/doctest.rst:1098 +#: ../../library/doctest.rst:959 ../../library/doctest.rst:1102 msgid "" "Optional argument *encoding* specifies an encoding that should be used to " "convert the file to unicode." msgstr "" -#: ../../library/doctest.rst:962 +#: ../../library/doctest.rst:965 msgid "" "All arguments are optional, and all except for *m* should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:965 +#: ../../library/doctest.rst:968 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:969 +#: ../../library/doctest.rst:972 msgid "" "Also test examples reachable from dict ``m.__test__``, if it exists. ``m." "__test__`` maps names (strings) to functions, classes and strings; function " @@ -1460,22 +1460,22 @@ msgid "" "directly, as if they were docstrings." msgstr "" -#: ../../library/doctest.rst:974 +#: ../../library/doctest.rst:977 msgid "" "Only docstrings attached to objects belonging to module *m* are searched." msgstr "" -#: ../../library/doctest.rst:976 +#: ../../library/doctest.rst:979 msgid "Return ``(failure_count, test_count)``." msgstr "" -#: ../../library/doctest.rst:978 +#: ../../library/doctest.rst:981 msgid "" "Optional argument *name* gives the name of the module; by default, or if " "``None``, ``m.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:981 +#: ../../library/doctest.rst:984 msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " @@ -1486,39 +1486,39 @@ msgid "" "defaults to true." msgstr "" -#: ../../library/doctest.rst:989 +#: ../../library/doctest.rst:992 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:996 +#: ../../library/doctest.rst:999 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:999 +#: ../../library/doctest.rst:1002 msgid "" "A shallow copy of dictionary argument *globs* is used for the execution " "context." msgstr "" -#: ../../library/doctest.rst:1001 +#: ../../library/doctest.rst:1004 msgid "" "Optional argument *name* is used in failure messages, and defaults to " "``\"NoName\"``." msgstr "" -#: ../../library/doctest.rst:1004 +#: ../../library/doctest.rst:1007 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:1007 +#: ../../library/doctest.rst:1010 msgid "" "Optional argument *compileflags* gives the set of flags that should be used " "by the Python compiler when running the examples. By default, or if " @@ -1526,16 +1526,16 @@ msgid "" "found in *globs*." msgstr "" -#: ../../library/doctest.rst:1011 +#: ../../library/doctest.rst:1014 msgid "" "Optional argument *optionflags* works as for function :func:`testfile` above." msgstr "" -#: ../../library/doctest.rst:1017 +#: ../../library/doctest.rst:1020 msgid "Unittest API" msgstr "" -#: ../../library/doctest.rst:1019 +#: ../../library/doctest.rst:1022 msgid "" "As your collection of doctest'ed modules grows, you'll want a way to run all " "their doctests systematically. :mod:`doctest` provides two functions that " @@ -1545,7 +1545,7 @@ msgid "" "your test module::" msgstr "" -#: ../../library/doctest.rst:1025 +#: ../../library/doctest.rst:1028 msgid "" "import unittest\n" "import doctest\n" @@ -1563,44 +1563,44 @@ msgstr "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" -#: ../../library/doctest.rst:1033 +#: ../../library/doctest.rst:1036 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " "instances from text files and modules with doctests:" msgstr "" -#: ../../library/doctest.rst:1039 +#: ../../library/doctest.rst:1042 msgid "" "Convert doctest tests from one or more text files to a :class:`unittest." "TestSuite`." msgstr "" -#: ../../library/doctest.rst:1042 +#: ../../library/doctest.rst:1045 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs the interactive examples in each file. If an example in " -"any file fails, then the synthesized unit test fails, and a :exc:" -"`failureException` exception is raised showing the name of the file " +"any file fails, then the synthesized unit test fails, and a :exc:`~unittest." +"TestCase.failureException` exception is raised showing the name of the file " "containing the test and a (sometimes approximate) line number. If all the " "examples in a file are skipped, then the synthesized unit test is also " "marked as skipped." msgstr "" -#: ../../library/doctest.rst:1049 +#: ../../library/doctest.rst:1052 msgid "Pass one or more paths (as strings) to text files to be examined." msgstr "" -#: ../../library/doctest.rst:1051 +#: ../../library/doctest.rst:1054 msgid "Options may be provided as keyword arguments:" msgstr "" -#: ../../library/doctest.rst:1053 +#: ../../library/doctest.rst:1056 msgid "" "Optional argument *module_relative* specifies how the filenames in *paths* " "should be interpreted:" msgstr "" -#: ../../library/doctest.rst:1056 +#: ../../library/doctest.rst:1059 msgid "" "If *module_relative* is ``True`` (the default), then each filename in " "*paths* specifies an OS-independent module-relative path. By default, this " @@ -1611,14 +1611,14 @@ msgid "" "``)." msgstr "" -#: ../../library/doctest.rst:1064 +#: ../../library/doctest.rst:1067 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:1068 +#: ../../library/doctest.rst:1071 msgid "" "Optional argument *package* is a Python package or the name of a Python " "package whose directory should be used as the base directory for module-" @@ -1628,30 +1628,31 @@ msgid "" "``False``." msgstr "" -#: ../../library/doctest.rst:1075 +#: ../../library/doctest.rst:1078 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 " -"will be passed a :class:`DocTest` object. The setUp function can access the " -"test globals as the *globs* attribute of the test passed." +"will be passed a :class:`DocTest` object. The *setUp* function can access " +"the test globals as the :attr:`~DocTest.globs` attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1080 +#: ../../library/doctest.rst:1083 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* " -"function will be passed a :class:`DocTest` object. The setUp function can " -"access the test globals as the *globs* attribute of the test passed." +"function will be passed a :class:`DocTest` object. The *tearDown* function " +"can access the test globals as the :attr:`~DocTest.globs` attribute of the " +"test passed." msgstr "" -#: ../../library/doctest.rst:1085 ../../library/doctest.rst:1120 +#: ../../library/doctest.rst:1089 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:1089 +#: ../../library/doctest.rst:1093 msgid "" "Optional argument *optionflags* specifies the default doctest options for " "the tests, created by or-ing together individual option flags. See section :" @@ -1659,70 +1660,71 @@ msgid "" "for a better way to set reporting options." msgstr "" -#: ../../library/doctest.rst:1101 +#: ../../library/doctest.rst:1105 msgid "" "The global ``__file__`` is added to the globals provided to doctests loaded " "from a text file using :func:`DocFileSuite`." msgstr "" -#: ../../library/doctest.rst:1107 +#: ../../library/doctest.rst:1111 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1109 +#: ../../library/doctest.rst:1113 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, " -"then the synthesized unit test fails, and a :exc:`failureException` " -"exception is raised showing the name of the file containing the test and a " -"(sometimes approximate) line number. If all the examples in a docstring are " -"skipped, then the synthesized unit test is also marked as skipped." +"framework and runs each doctest in the module. Each docstring is run as a " +"separate unit test. If any of the doctests fail, then the synthesized unit " +"test fails, and a :exc:`unittest.TestCase.failureException` exception is " +"raised showing the name of the file containing the test and a (sometimes " +"approximate) line number. If all the examples in a docstring are skipped, " +"then the" msgstr "" -#: ../../library/doctest.rst:1116 +#: ../../library/doctest.rst:1121 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:1124 +#: ../../library/doctest.rst:1125 +msgid "" +"Optional argument *globs* is a dictionary containing the initial global " +"variables for the tests. A new copy of this dictionary is created for each " +"test. By default, *globs* is the module's :attr:`~module.__dict__`." +msgstr "" + +#: ../../library/doctest.rst:1129 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:1127 +#: ../../library/doctest.rst:1132 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:1130 +#: ../../library/doctest.rst:1135 msgid "" "Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as " -"for function :func:`DocFileSuite` above." +"for function :func:`DocFileSuite` above, but they are called for each " +"docstring." msgstr "" -#: ../../library/doctest.rst:1133 +#: ../../library/doctest.rst:1138 msgid "This function uses the same search technique as :func:`testmod`." msgstr "" -#: ../../library/doctest.rst:1135 +#: ../../library/doctest.rst:1140 msgid "" ":func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if " "*module* contains no docstrings instead of raising :exc:`ValueError`." msgstr "" -#: ../../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 " -"showing the name of the file containing the test and a (sometimes " -"approximate) line number." -msgstr "" - -#: ../../library/doctest.rst:1145 +#: ../../library/doctest.rst:1144 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1731,67 +1733,67 @@ msgid "" "questions about the exact details of :mod:`unittest` integration." msgstr "" -#: ../../library/doctest.rst:1151 +#: ../../library/doctest.rst:1150 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:1155 +#: ../../library/doctest.rst:1154 msgid "" "So both ways of creating a :class:`unittest.TestSuite` run instances of :" "class:`!DocTestCase`. This is important for a subtle reason: when you run :" -"mod:`doctest` functions yourself, you can control the :mod:`doctest` options " -"in use directly, by passing option flags to :mod:`doctest` functions. " -"However, if you're writing a :mod:`unittest` framework, :mod:`unittest` " -"ultimately controls when and how tests get run. The framework author " -"typically wants to control :mod:`doctest` reporting options (perhaps, e.g., " -"specified by command line options), but there's no way to pass options " -"through :mod:`unittest` to :mod:`doctest` test runners." +"mod:`doctest` functions yourself, you can control the :mod:`!doctest` " +"options in use directly, by passing option flags to :mod:`!doctest` " +"functions. However, if you're writing a :mod:`unittest` framework, :mod:`!" +"unittest` ultimately controls when and how tests get run. The framework " +"author typically wants to control :mod:`!doctest` reporting options " +"(perhaps, e.g., specified by command line options), but there's no way to " +"pass options through :mod:`!unittest` to :mod:`!doctest` test runners." msgstr "" -#: ../../library/doctest.rst:1165 +#: ../../library/doctest.rst:1164 msgid "" -"For this reason, :mod:`doctest` also supports a notion of :mod:`doctest` " +"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:1171 +#: ../../library/doctest.rst:1170 msgid "Set the :mod:`doctest` reporting flags to use." msgstr "" -#: ../../library/doctest.rst:1173 +#: ../../library/doctest.rst:1172 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:1176 +#: ../../library/doctest.rst:1175 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" "DocTestCase` looks at the option flags specified for the test case when the :" "class:`!DocTestCase` instance was constructed. If no reporting flags were " -"specified (which is the typical and expected case), :mod:`!doctest`'s :mod:" -"`unittest` reporting flags are :ref:`bitwise ORed ` into the option " +"specified (which is the typical and expected case), :mod:`!doctest`'s :mod:`!" +"unittest` reporting flags are :ref:`bitwise ORed ` into the option " "flags, and the option flags so augmented are passed to the :class:" "`DocTestRunner` instance created to run the doctest. If any reporting flags " "were specified when the :class:`!DocTestCase` instance was constructed, :mod:" -"`!doctest`'s :mod:`unittest` reporting flags are ignored." +"`!doctest`'s :mod:`!unittest` reporting flags are ignored." msgstr "" -#: ../../library/doctest.rst:1187 +#: ../../library/doctest.rst:1186 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:1194 +#: ../../library/doctest.rst:1193 msgid "Advanced API" msgstr "" -#: ../../library/doctest.rst:1196 +#: ../../library/doctest.rst:1195 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 " @@ -1799,62 +1801,62 @@ msgid "" "doctest's capabilities, then you should use the advanced API." msgstr "" -#: ../../library/doctest.rst:1201 +#: ../../library/doctest.rst:1200 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:1204 +#: ../../library/doctest.rst:1203 msgid "" ":class:`Example`: A single Python :term:`statement`, paired with its " "expected output." msgstr "" -#: ../../library/doctest.rst:1207 +#: ../../library/doctest.rst:1206 msgid "" ":class:`DocTest`: A collection of :class:`Example`\\ s, typically extracted " "from a single docstring or text file." msgstr "" -#: ../../library/doctest.rst:1210 +#: ../../library/doctest.rst:1209 msgid "" "Additional processing classes are defined to find, parse, and run, and check " "doctest examples:" msgstr "" -#: ../../library/doctest.rst:1213 +#: ../../library/doctest.rst:1212 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:1217 +#: ../../library/doctest.rst:1216 msgid "" ":class:`DocTestParser`: Creates a :class:`DocTest` object from a string " "(such as an object's docstring)." msgstr "" -#: ../../library/doctest.rst:1220 +#: ../../library/doctest.rst:1219 msgid "" ":class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and " "uses an :class:`OutputChecker` to verify their output." msgstr "" -#: ../../library/doctest.rst:1223 +#: ../../library/doctest.rst:1222 msgid "" ":class:`OutputChecker`: Compares the actual output from a doctest example " "with the expected output, and decides whether they match." msgstr "" -#: ../../library/doctest.rst:1226 +#: ../../library/doctest.rst:1225 msgid "" "The relationships among these processing classes are summarized in the " "following diagram::" msgstr "" -#: ../../library/doctest.rst:1229 +#: ../../library/doctest.rst:1228 msgid "" " list of:\n" "+------+ +---------+\n" @@ -1874,30 +1876,30 @@ msgstr "" " DocTestParser | Example | OutputChecker\n" " +---------+" -#: ../../library/doctest.rst:1242 +#: ../../library/doctest.rst:1241 msgid "DocTest Objects" msgstr "DocTest 物件" -#: ../../library/doctest.rst:1247 +#: ../../library/doctest.rst:1246 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:1251 +#: ../../library/doctest.rst:1250 msgid "" ":class:`DocTest` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1257 +#: ../../library/doctest.rst:1256 msgid "" "A list of :class:`Example` objects encoding the individual interactive " "Python examples that should be run by this test." msgstr "" -#: ../../library/doctest.rst:1263 +#: ../../library/doctest.rst:1262 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 " @@ -1905,57 +1907,57 @@ msgid "" "`globs` after the test is run." msgstr "" -#: ../../library/doctest.rst:1271 +#: ../../library/doctest.rst:1270 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:1277 +#: ../../library/doctest.rst:1276 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 " +"``None`` if the filename is unknown, or if the :class:`!DocTest` was not " "extracted from a file." msgstr "" -#: ../../library/doctest.rst:1284 +#: ../../library/doctest.rst:1283 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:1291 +#: ../../library/doctest.rst:1290 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:1298 +#: ../../library/doctest.rst:1297 msgid "Example Objects" msgstr "Example 物件" -#: ../../library/doctest.rst:1303 +#: ../../library/doctest.rst:1302 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:1308 +#: ../../library/doctest.rst:1307 msgid "" ":class:`Example` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1314 +#: ../../library/doctest.rst:1313 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:1321 +#: ../../library/doctest.rst:1320 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 " @@ -1963,7 +1965,7 @@ msgid "" "The constructor adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1329 +#: ../../library/doctest.rst:1328 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 " @@ -1972,20 +1974,20 @@ msgid "" "unless it's ``None``. The constructor adds a newline if needed." msgstr "" -#: ../../library/doctest.rst:1338 +#: ../../library/doctest.rst:1337 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:1345 +#: ../../library/doctest.rst:1344 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:1351 +#: ../../library/doctest.rst:1350 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 " @@ -1994,11 +1996,11 @@ msgid "" "default, no options are set." msgstr "" -#: ../../library/doctest.rst:1361 +#: ../../library/doctest.rst:1360 msgid "DocTestFinder objects" msgstr "DocTestFinder 物件" -#: ../../library/doctest.rst:1366 +#: ../../library/doctest.rst:1365 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 " @@ -2006,48 +2008,48 @@ msgid "" "classes, functions, methods, staticmethods, classmethods, and properties." msgstr "" -#: ../../library/doctest.rst:1371 +#: ../../library/doctest.rst:1370 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:1374 +#: ../../library/doctest.rst:1373 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:1377 +#: ../../library/doctest.rst:1376 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:1380 +#: ../../library/doctest.rst:1379 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:1384 +#: ../../library/doctest.rst:1383 msgid ":class:`DocTestFinder` defines the following method:" msgstr "" -#: ../../library/doctest.rst:1389 +#: ../../library/doctest.rst:1388 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:1392 +#: ../../library/doctest.rst:1391 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:1396 +#: ../../library/doctest.rst:1395 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 " @@ -2055,26 +2057,26 @@ msgid "" "module is used:" msgstr "" -#: ../../library/doctest.rst:1400 +#: ../../library/doctest.rst:1399 msgid "As a default namespace, if *globs* is not specified." msgstr "" -#: ../../library/doctest.rst:1402 +#: ../../library/doctest.rst:1401 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:1406 +#: ../../library/doctest.rst:1405 msgid "To find the name of the file containing the object." msgstr "" -#: ../../library/doctest.rst:1408 +#: ../../library/doctest.rst:1407 msgid "To help find the line number of the object within its file." msgstr "" -#: ../../library/doctest.rst:1410 +#: ../../library/doctest.rst:1409 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 " @@ -2083,44 +2085,44 @@ msgid "" "contained objects will (recursively) be searched for doctests." msgstr "" -#: ../../library/doctest.rst:1416 +#: ../../library/doctest.rst:1415 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " -"shallow copy of the globals dictionary is created for each :class:`DocTest`. " -"If *globs* is not specified, then it defaults to the module's *__dict__*, if " -"specified, or ``{}`` otherwise. If *extraglobs* is not specified, then it " -"defaults to ``{}``." +"shallow copy of the globals dictionary is created for each :class:`!" +"DocTest`. If *globs* is not specified, then it defaults to the module's :" +"attr:`~module.__dict__`, if specified, or ``{}`` otherwise. If *extraglobs* " +"is not specified, then it defaults to ``{}``." msgstr "" -#: ../../library/doctest.rst:1427 +#: ../../library/doctest.rst:1426 msgid "DocTestParser objects" msgstr "DocTestParser 物件" -#: ../../library/doctest.rst:1432 +#: ../../library/doctest.rst:1431 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:1436 +#: ../../library/doctest.rst:1435 msgid ":class:`DocTestParser` defines the following methods:" msgstr "" -#: ../../library/doctest.rst:1441 +#: ../../library/doctest.rst:1440 msgid "" "Extract all doctest examples from the given string, and collect them into a :" "class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1444 +#: ../../library/doctest.rst:1443 msgid "" "*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" -"`DocTest` object. See the documentation for :class:`DocTest` for more " +"`!DocTest` object. See the documentation for :class:`DocTest` for more " "information." msgstr "" -#: ../../library/doctest.rst:1451 +#: ../../library/doctest.rst:1450 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 " @@ -2128,51 +2130,51 @@ msgid "" "error messages." msgstr "" -#: ../../library/doctest.rst:1458 +#: ../../library/doctest.rst:1457 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 " -"the :class:`Example`\\ s are 0-based. The optional argument *name* is a " +"the :class:`!Example`\\ s are 0-based. The optional argument *name* is a " "name identifying this string, and is only used for error messages." msgstr "" -#: ../../library/doctest.rst:1465 +#: ../../library/doctest.rst:1464 msgid "TestResults objects" msgstr "TestResults 物件" -#: ../../library/doctest.rst:1472 +#: ../../library/doctest.rst:1471 msgid "Number of failed tests." msgstr "" -#: ../../library/doctest.rst:1476 +#: ../../library/doctest.rst:1475 msgid "Number of attempted tests." msgstr "" -#: ../../library/doctest.rst:1480 +#: ../../library/doctest.rst:1479 msgid "Number of skipped tests." msgstr "" -#: ../../library/doctest.rst:1488 +#: ../../library/doctest.rst:1487 msgid "DocTestRunner objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1493 +#: ../../library/doctest.rst:1492 msgid "" "A processing class used to execute and verify the interactive examples in a :" "class:`DocTest`." msgstr "" -#: ../../library/doctest.rst:1496 +#: ../../library/doctest.rst:1495 msgid "" "The comparison between expected outputs and actual outputs is done by an :" "class:`OutputChecker`. This comparison may be customized with a number of " "option flags; see section :ref:`doctest-options` for more information. If " "the option flags are insufficient, then the comparison may also be " -"customized by passing a subclass of :class:`OutputChecker` to the " +"customized by passing a subclass of :class:`!OutputChecker` to the " "constructor." msgstr "" -#: ../../library/doctest.rst:1502 +#: ../../library/doctest.rst:1501 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 " @@ -2183,14 +2185,14 @@ msgid "" "`report_unexpected_exception`, and :meth:`report_failure`." msgstr "" -#: ../../library/doctest.rst:1510 +#: ../../library/doctest.rst:1509 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:1514 +#: ../../library/doctest.rst:1513 msgid "" "The optional keyword argument *verbose* controls the :class:" "`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " @@ -2199,14 +2201,14 @@ msgid "" "verbose output is used iff the command-line switch ``-v`` is used." msgstr "" -#: ../../library/doctest.rst:1520 +#: ../../library/doctest.rst:1519 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:1524 +#: ../../library/doctest.rst:1523 msgid "" "The test runner accumulates statistics. The aggregated number of attempted, " "failed and skipped examples is also available via the :attr:`tries`, :attr:" @@ -2214,53 +2216,53 @@ msgid "" "`summarize` methods return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1529 +#: ../../library/doctest.rst:1528 msgid ":class:`DocTestRunner` defines the following methods:" msgstr "" -#: ../../library/doctest.rst:1534 +#: ../../library/doctest.rst:1533 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:1538 +#: ../../library/doctest.rst:1537 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:" +"containing *example*. *out* is the output function that was passed to :meth:" "`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1545 +#: ../../library/doctest.rst:1544 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:1549 ../../library/doctest.rst:1560 +#: ../../library/doctest.rst:1548 ../../library/doctest.rst:1559 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:1556 +#: ../../library/doctest.rst:1555 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:1567 +#: ../../library/doctest.rst:1566 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:1571 +#: ../../library/doctest.rst:1570 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " "containing information about the unexpected exception (as returned by :func:" @@ -2268,14 +2270,14 @@ msgid "" "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1579 +#: ../../library/doctest.rst:1578 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:1583 +#: ../../library/doctest.rst:1582 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, " @@ -2283,54 +2285,54 @@ msgid "" "after the test completes, then use *clear_globs=False*." msgstr "" -#: ../../library/doctest.rst:1588 +#: ../../library/doctest.rst:1587 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:1592 +#: ../../library/doctest.rst:1591 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:1599 +#: ../../library/doctest.rst:1598 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:1602 +#: ../../library/doctest.rst:1601 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:1606 +#: ../../library/doctest.rst:1605 msgid ":class:`DocTestParser` has the following attributes:" msgstr ":class:`DocTestParser` 有以下屬性:" -#: ../../library/doctest.rst:1610 +#: ../../library/doctest.rst:1609 msgid "Number of attempted examples." msgstr "" -#: ../../library/doctest.rst:1614 +#: ../../library/doctest.rst:1613 msgid "Number of failed examples." msgstr "" -#: ../../library/doctest.rst:1618 +#: ../../library/doctest.rst:1617 msgid "Number of skipped examples." msgstr "" -#: ../../library/doctest.rst:1626 +#: ../../library/doctest.rst:1625 msgid "OutputChecker objects" msgstr "OutputChecker 物件" -#: ../../library/doctest.rst:1631 +#: ../../library/doctest.rst:1630 msgid "" "A class used to check the whether the actual output from a doctest example " "matches the expected output. :class:`OutputChecker` defines two methods: :" @@ -2339,11 +2341,11 @@ msgid "" "string describing the differences between two outputs." msgstr "" -#: ../../library/doctest.rst:1638 +#: ../../library/doctest.rst:1637 msgid ":class:`OutputChecker` defines the following methods:" msgstr "" -#: ../../library/doctest.rst:1642 +#: ../../library/doctest.rst:1641 msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " @@ -2352,28 +2354,28 @@ msgid "" "`doctest-options` for more information about option flags." msgstr "" -#: ../../library/doctest.rst:1651 +#: ../../library/doctest.rst:1650 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:1659 +#: ../../library/doctest.rst:1658 msgid "Debugging" msgstr "" -#: ../../library/doctest.rst:1661 +#: ../../library/doctest.rst:1660 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "" -#: ../../library/doctest.rst:1663 +#: ../../library/doctest.rst:1662 msgid "" "Several functions convert doctests to executable Python programs, which can " "be run under the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1666 +#: ../../library/doctest.rst:1665 msgid "" "The :class:`DebugRunner` class is a subclass of :class:`DocTestRunner` that " "raises an exception for the first failing example, containing information " @@ -2381,13 +2383,13 @@ msgid "" "debugging on the example." msgstr "" -#: ../../library/doctest.rst:1671 +#: ../../library/doctest.rst:1670 msgid "" "The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" "meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" -#: ../../library/doctest.rst:1674 +#: ../../library/doctest.rst:1673 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 " @@ -2395,7 +2397,7 @@ msgid "" "`a.py` contains just this module docstring::" msgstr "" -#: ../../library/doctest.rst:1679 +#: ../../library/doctest.rst:1678 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2417,11 +2419,11 @@ msgstr "" "9\n" "\"\"\"" -#: ../../library/doctest.rst:1689 +#: ../../library/doctest.rst:1688 msgid "Then an interactive Python session may look like this::" msgstr "" -#: ../../library/doctest.rst:1691 +#: ../../library/doctest.rst:1690 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2483,17 +2485,17 @@ msgstr "" "(0, 3)\n" ">>>" -#: ../../library/doctest.rst:1722 +#: ../../library/doctest.rst:1721 msgid "" "Functions that convert doctests to Python code, and possibly run the " "synthesized code under the debugger:" msgstr "" -#: ../../library/doctest.rst:1728 +#: ../../library/doctest.rst:1727 msgid "Convert text with examples to a script." msgstr "" -#: ../../library/doctest.rst:1730 +#: ../../library/doctest.rst:1729 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 " @@ -2501,7 +2503,7 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" -#: ../../library/doctest.rst:1735 +#: ../../library/doctest.rst:1734 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2514,11 +2516,11 @@ msgid "" "\"\"\"))" msgstr "" -#: ../../library/doctest.rst:1745 +#: ../../library/doctest.rst:1744 msgid "displays::" msgstr "" -#: ../../library/doctest.rst:1747 +#: ../../library/doctest.rst:1746 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2529,18 +2531,18 @@ msgid "" "## 3" msgstr "" -#: ../../library/doctest.rst:1755 +#: ../../library/doctest.rst:1754 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:1762 +#: ../../library/doctest.rst:1761 msgid "Convert the doctest for an object to a script." msgstr "" -#: ../../library/doctest.rst:1764 +#: ../../library/doctest.rst:1763 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 " @@ -2550,7 +2552,7 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" -#: ../../library/doctest.rst:1771 +#: ../../library/doctest.rst:1770 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" @@ -2558,17 +2560,17 @@ msgstr "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1774 +#: ../../library/doctest.rst:1773 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:1780 +#: ../../library/doctest.rst:1779 msgid "Debug the doctests for an object." msgstr "" -#: ../../library/doctest.rst:1782 +#: ../../library/doctest.rst:1781 msgid "" "The *module* and *name* arguments are the same as for function :func:" "`testsource` above. The synthesized Python script for the named object's " @@ -2576,13 +2578,13 @@ msgid "" "the control of the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1787 +#: ../../library/doctest.rst:1786 msgid "" "A shallow copy of ``module.__dict__`` is used for both local and global " "execution context." msgstr "" -#: ../../library/doctest.rst:1790 +#: ../../library/doctest.rst:1789 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 " @@ -2594,30 +2596,30 @@ msgid "" "to :func:`pdb.run`." msgstr "" -#: ../../library/doctest.rst:1801 +#: ../../library/doctest.rst:1800 msgid "Debug the doctests in a string." msgstr "" -#: ../../library/doctest.rst:1803 +#: ../../library/doctest.rst:1802 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:1806 +#: ../../library/doctest.rst:1805 msgid "" "Optional argument *pm* has the same meaning as in function :func:`debug` " "above." msgstr "" -#: ../../library/doctest.rst:1808 +#: ../../library/doctest.rst:1807 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:1813 +#: ../../library/doctest.rst:1812 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 " @@ -2625,7 +2627,7 @@ msgid "" "(which is a doctest!) for more details:" msgstr "" -#: ../../library/doctest.rst:1821 +#: ../../library/doctest.rst:1820 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " "failure is encountered. If an unexpected exception occurs, an :exc:" @@ -2635,89 +2637,89 @@ msgid "" "the actual output." msgstr "" -#: ../../library/doctest.rst:1828 +#: ../../library/doctest.rst:1827 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:1831 +#: ../../library/doctest.rst:1830 msgid "" "There are two exceptions that may be raised by :class:`DebugRunner` " "instances:" msgstr "" -#: ../../library/doctest.rst:1836 +#: ../../library/doctest.rst:1835 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:1840 +#: ../../library/doctest.rst:1839 msgid ":exc:`DocTestFailure` defines the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1845 ../../library/doctest.rst:1869 +#: ../../library/doctest.rst:1844 ../../library/doctest.rst:1868 msgid "The :class:`DocTest` object that was being run when the example failed." msgstr "" -#: ../../library/doctest.rst:1850 ../../library/doctest.rst:1874 +#: ../../library/doctest.rst:1849 ../../library/doctest.rst:1873 msgid "The :class:`Example` that failed." msgstr "" -#: ../../library/doctest.rst:1855 +#: ../../library/doctest.rst:1854 msgid "The example's actual output." msgstr "" -#: ../../library/doctest.rst:1860 +#: ../../library/doctest.rst:1859 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:1864 +#: ../../library/doctest.rst:1863 msgid ":exc:`UnexpectedException` defines the following attributes:" msgstr "" -#: ../../library/doctest.rst:1879 +#: ../../library/doctest.rst:1878 msgid "" "A tuple containing information about the unexpected exception, as returned " "by :func:`sys.exc_info`." msgstr "" -#: ../../library/doctest.rst:1886 +#: ../../library/doctest.rst:1885 msgid "Soapbox" msgstr "" -#: ../../library/doctest.rst:1888 +#: ../../library/doctest.rst:1887 msgid "" "As mentioned in the introduction, :mod:`doctest` has grown to have three " "primary uses:" msgstr "" -#: ../../library/doctest.rst:1891 +#: ../../library/doctest.rst:1890 msgid "Checking examples in docstrings." msgstr "" -#: ../../library/doctest.rst:1893 +#: ../../library/doctest.rst:1892 msgid "Regression testing." msgstr "" -#: ../../library/doctest.rst:1895 +#: ../../library/doctest.rst:1894 msgid "Executable documentation / literate testing." msgstr "" -#: ../../library/doctest.rst:1897 +#: ../../library/doctest.rst:1896 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:1901 +#: ../../library/doctest.rst:1900 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. " @@ -2729,7 +2731,7 @@ msgid "" "\"harmless\" change." msgstr "" -#: ../../library/doctest.rst:1909 +#: ../../library/doctest.rst:1908 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 " @@ -2750,13 +2752,13 @@ msgid "" "different results, blurring the distinction between testing and explaining." msgstr "" -#: ../../library/doctest.rst:1927 +#: ../../library/doctest.rst:1926 msgid "" "Regression testing is best confined to dedicated objects or files. There " "are several options for organizing tests:" msgstr "" -#: ../../library/doctest.rst:1930 +#: ../../library/doctest.rst:1929 msgid "" "Write text files containing test cases as interactive examples, and test the " "files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, " @@ -2764,7 +2766,7 @@ msgid "" "doctest." msgstr "" -#: ../../library/doctest.rst:1935 +#: ../../library/doctest.rst:1934 msgid "" "Define functions named ``_regrtest_topic`` that consist of single " "docstrings, containing test cases for the named topics. These functions can " @@ -2772,13 +2774,13 @@ msgid "" "test file." msgstr "" -#: ../../library/doctest.rst:1939 +#: ../../library/doctest.rst:1938 msgid "" -"Define a ``__test__`` dictionary mapping from regression test topics to " -"docstrings containing test cases." +"Define a :attr:`~module.__test__` dictionary mapping from regression test " +"topics to docstrings containing test cases." msgstr "" -#: ../../library/doctest.rst:1942 +#: ../../library/doctest.rst:1941 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-" @@ -2786,7 +2788,7 @@ msgid "" "example of such a test runner::" msgstr "" -#: ../../library/doctest.rst:1947 +#: ../../library/doctest.rst:1946 msgid "" "if __name__ == '__main__':\n" " import doctest\n" @@ -2818,54 +2820,54 @@ msgstr "" " fail, total = doctest.testmod(optionflags=flags)\n" " print(f\"{fail} failures out of {total} tests\")" -#: ../../library/doctest.rst:1964 +#: ../../library/doctest.rst:1963 msgid "Footnotes" msgstr "註腳" -#: ../../library/doctest.rst:1965 +#: ../../library/doctest.rst:1964 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:369 +#: ../../library/doctest.rst:372 msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:369 +#: ../../library/doctest.rst:372 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/doctest.rst:369 ../../library/doctest.rst:604 +#: ../../library/doctest.rst:372 ../../library/doctest.rst:607 msgid "..." msgstr "..." -#: ../../library/doctest.rst:535 +#: ../../library/doctest.rst:538 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/doctest.rst:535 +#: ../../library/doctest.rst:538 msgid "marker" msgstr "marker(標記)" -#: ../../library/doctest.rst:584 +#: ../../library/doctest.rst:587 msgid "" msgstr "" -#: ../../library/doctest.rst:604 ../../library/doctest.rst:729 +#: ../../library/doctest.rst:607 ../../library/doctest.rst:732 msgid "in doctests" msgstr "於 doctests 中" -#: ../../library/doctest.rst:729 +#: ../../library/doctest.rst:732 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/doctest.rst:729 +#: ../../library/doctest.rst:732 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/doctest.rst:729 +#: ../../library/doctest.rst:732 msgid "- (minus)" msgstr "- (減號)" diff --git a/library/email.header.po b/library/email.header.po index ab91339aba..2492b8b82e 100644 --- a/library/email.header.po +++ b/library/email.header.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-06-27 07:36+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-" @@ -273,43 +273,77 @@ msgid "" msgstr "" #: ../../library/email.header.rst:181 +msgid "For historical reasons, this function may return either:" +msgstr "" + +#: ../../library/email.header.rst:183 +msgid "" +"A list of pairs containing each of the decoded parts of the header, " +"``(decoded_bytes, charset)``, where *decoded_bytes* is always an instance " +"of :class:`bytes`, and *charset* is either:" +msgstr "" + +#: ../../library/email.header.rst:187 +msgid "A lower case string containing the name of the character set specified." +msgstr "" + +#: ../../library/email.header.rst:189 +msgid "``None`` for non-encoded parts of the header." +msgstr "" + +#: ../../library/email.header.rst:191 +msgid "" +"A list of length 1 containing a pair ``(string, None)``, where *string* is " +"always an instance of :class:`str`." +msgstr "" + +#: ../../library/email.header.rst:194 msgid "" -"This function returns a list of ``(decoded_string, charset)`` pairs " -"containing each of the decoded parts of the header. *charset* is ``None`` " -"for non-encoded parts of the header, otherwise a lower case string " -"containing the name of the character set specified in the encoded string." +"An :exc:`email.errors.HeaderParseError` may be raised when certain decoding " +"errors occur (e.g. a base64 decoding exception)." msgstr "" -#: ../../library/email.header.rst:186 -msgid "Here's an example::" -msgstr "以下是個範例: ::" +#: ../../library/email.header.rst:197 +msgid "Here are examples:" +msgstr "以下為範例: ::" -#: ../../library/email.header.rst:188 +#: ../../library/email.header.rst:209 msgid "" -">>> from email.header import decode_header\n" -">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" -"[(b'p\\xf6stal', 'iso-8859-1')]" +"This function exists for backwards compatibility only. For new code, we " +"recommend using :class:`email.headerregistry.HeaderRegistry`." msgstr "" -">>> from email.header import decode_header\n" -">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" -"[(b'p\\xf6stal', 'iso-8859-1')]" -#: ../../library/email.header.rst:195 +#: ../../library/email.header.rst:215 msgid "" "Create a :class:`Header` instance from a sequence of pairs as returned by :" "func:`decode_header`." msgstr "" -#: ../../library/email.header.rst:198 +#: ../../library/email.header.rst:218 msgid "" ":func:`decode_header` takes a header value string and returns a sequence of " "pairs of the format ``(decoded_string, charset)`` where *charset* is the " "name of the character set." msgstr "" -#: ../../library/email.header.rst:202 +#: ../../library/email.header.rst:222 msgid "" "This function takes one of those sequence of pairs and returns a :class:" "`Header` instance. Optional *maxlinelen*, *header_name*, and " "*continuation_ws* are as in the :class:`Header` constructor." msgstr "" + +#: ../../library/email.header.rst:228 +msgid "" +"This function exists for backwards compatibility only, and is not " +"recommended for use in new code." +msgstr "" + +#~ msgid "" +#~ ">>> from email.header import decode_header\n" +#~ ">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" +#~ "[(b'p\\xf6stal', 'iso-8859-1')]" +#~ msgstr "" +#~ ">>> from email.header import decode_header\n" +#~ ">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" +#~ "[(b'p\\xf6stal', 'iso-8859-1')]" diff --git a/library/exceptions.po b/library/exceptions.po index e862cec0b2..484c10cf19 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-04 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2024-12-20 16:57+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,13 +24,12 @@ msgstr "內建的例外" #: ../../library/exceptions.rst:10 msgid "" -"In Python, all exceptions must be instances of a class that derives " -"from :class:`BaseException`. In a :keyword:`try` statement with " -"an :keyword:`except` clause that mentions a particular class, that clause " -"also handles any exception classes derived from that class (but not " -"exception classes from which *it* is derived). Two exception classes that " -"are not related via subclassing are never equivalent, even if they have the " -"same name." +"In Python, all exceptions must be instances of a class that derives from :" +"class:`BaseException`. In a :keyword:`try` statement with an :keyword:" +"`except` clause that mentions a particular class, that clause also handles " +"any exception classes derived from that class (but not exception classes " +"from which *it* is derived). Two exception classes that are not related via " +"subclassing are never equivalent, even if they have the same name." msgstr "" "在 Python 中,所有例外必須是從 :class:`BaseException` 衍生的類別的實例。在陳" "述式 :keyword:`try` 搭配 :keyword:`except` 子句裡提到一個特定的類別時,那個子" @@ -67,10 +66,10 @@ msgstr "" #: ../../library/exceptions.rst:31 msgid "" "The built-in exception classes can be subclassed to define new exceptions; " -"programmers are encouraged to derive new exceptions from " -"the :exc:`Exception` class or one of its subclasses, and not " -"from :exc:`BaseException`. More information on defining exceptions is " -"available in the Python Tutorial under :ref:`tut-userexceptions`." +"programmers are encouraged to derive new exceptions from the :exc:" +"`Exception` class or one of its subclasses, and not from :exc:" +"`BaseException`. More information on defining exceptions is available in " +"the Python Tutorial under :ref:`tut-userexceptions`." msgstr "" "可以從內建的例外類別定義新的例外子類別;程式設計師被鼓勵從 :exc:`Exception` " "類別或其子類別衍生新的例外,而不是從 :exc:`BaseException` 來衍生。更多關於定" @@ -90,13 +89,13 @@ msgstr "三個例外物件上的屬性提供關於引發此例外的情境的資 msgid "" "When raising a new exception while another exception is already being " "handled, the new exception's :attr:`!__context__` attribute is automatically " -"set to the handled exception. An exception may be handled when " -"an :keyword:`except` or :keyword:`finally` clause, or a :keyword:`with` " -"statement, is used." +"set to the handled exception. An exception may be handled when an :keyword:" +"`except` or :keyword:`finally` clause, or a :keyword:`with` statement, is " +"used." msgstr "" "當引發一個新的例外而同時有另一個例外已經正在被處理時,這個新例外的 :attr:`!" -"__context__` 屬性會自動被設成那個已處理的例外。當使用 :keyword:`except` " -"或 :keyword:`finally` 子句或 :keyword:`with` 陳述式的時候例外會被處理。" +"__context__` 屬性會自動被設成那個已處理的例外。當使用 :keyword:`except` 或 :" +"keyword:`finally` 子句或 :keyword:`with` 陳述式的時候例外會被處理。" #: ../../library/exceptions.rst:59 msgid "" @@ -122,11 +121,11 @@ msgid "" "introspection when debugging." msgstr "" "在 :keyword:`from` 後面的運算式必須是一個例外或 ``None``。它將會被設定" -"成所引發例外的 :attr:`!__cause__`。設定 :attr:`!__cause__` 也隱含地設" -"定 :attr:`!__suppress_context__` 屬性為 ``True``,因此使用 ``raise new_exc " -"from None`` 實際上會以新的例外取代舊的例外以利於顯示(例如轉" -"換 :exc:`KeyError` 為 :exc:`AttributeError`),同時保持舊的例外可以透" -"過 :attr:`!__context__` 取得以方便 debug 的時候檢查。" +"成所引發例外的 :attr:`!__cause__`。設定 :attr:`!__cause__` 也隱含地設定 :" +"attr:`!__suppress_context__` 屬性為 ``True``,因此使用 ``raise new_exc from " +"None`` 實際上會以新的例外取代舊的例外以利於顯示(例如轉換 :exc:`KeyError` " +"為 :exc:`AttributeError`),同時保持舊的例外可以透過 :attr:`!__context__` 取" +"得以方便 debug 的時候檢查。" #: ../../library/exceptions.rst:74 msgid "" @@ -168,18 +167,17 @@ msgstr "" #: ../../library/exceptions.rst:95 msgid "" -"Most built-in exceptions are implemented in C for efficiency, " -"see: :source:`Objects/exceptions.c`. Some have custom memory layouts which " -"makes it impossible to create a subclass that inherits from multiple " -"exception types. The memory layout of a type is an implementation detail and " -"might change between Python versions, leading to new conflicts in the " -"future. Therefore, it's recommended to avoid subclassing multiple exception " -"types altogether." +"Most built-in exceptions are implemented in C for efficiency, see: :source:" +"`Objects/exceptions.c`. Some have custom memory layouts which makes it " +"impossible to create a subclass that inherits from multiple exception types. " +"The memory layout of a type is an implementation detail and might change " +"between Python versions, leading to new conflicts in the future. Therefore, " +"it's recommended to avoid subclassing multiple exception types altogether." msgstr "" -"為了效率,大部分的內建例外使用 C 來實作,參考 :source:`Objects/" -"exceptions.c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外型" -"別的子類別。型別的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成" -"未來新的衝突。因此,總之建議避免繼承多種例外型別。" +"為了效率,大部分的內建例外使用 C 來實作,參考 :source:`Objects/exceptions." +"c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外型別的子類" +"別。型別的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成未來新的" +"衝突。因此,總之建議避免繼承多種例外型別。" #: ../../library/exceptions.rst:105 msgid "Base classes" @@ -194,14 +192,14 @@ msgstr "以下的例外大部分被用在當作其他例外的基底類別。" #: ../../library/exceptions.rst:111 msgid "" "The base class for all built-in exceptions. It is not meant to be directly " -"inherited by user-defined classes (for that, use :exc:`Exception`). " -"If :func:`str` is called on an instance of this class, the representation of " -"the argument(s) to the instance are returned, or the empty string when there " +"inherited by user-defined classes (for that, use :exc:`Exception`). If :" +"func:`str` is called on an instance of this class, the representation of the " +"argument(s) to the instance are returned, or the empty string when there " "were no arguments." msgstr "" -"所有內建例外的基底類別。這不是為了讓使用者定義的類別直接繼承(可以使" -"用 :exc:`Exception`)。如果在這個類別的實例上呼叫 :func:`str`,會回傳實例的引" -"數的表示,或者沒有引數的時候會回傳空字串。" +"所有內建例外的基底類別。這不是為了讓使用者定義的類別直接繼承(可以使用 :exc:" +"`Exception`)。如果在這個類別的實例上呼叫 :func:`str`,會回傳實例的引數的表" +"示,或者沒有引數的時候會回傳空字串。" #: ../../library/exceptions.rst:119 msgid "" @@ -264,9 +262,8 @@ msgstr "" #: ../../library/exceptions.rst:157 msgid "" -"A list of the notes of this exception, which were added " -"with :meth:`add_note`. This attribute is created when :meth:`add_note` is " -"called." +"A list of the notes of this exception, which were added with :meth:" +"`add_note`. This attribute is created when :meth:`add_note` is called." msgstr "" "該例外的備註串列,使用 :meth:`add_note` 來新增。此屬性在 :meth:`add_note` 被" "呼叫的時候建立。" @@ -282,12 +279,11 @@ msgstr "" #: ../../library/exceptions.rst:171 msgid "" "The base class for those built-in exceptions that are raised for various " -"arithmetic " -"errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:`FloatingPointError`." +"arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:" +"`FloatingPointError`." msgstr "" -"各種運算錯誤所引發的那些內建例" -"外::exc:`OverflowError`、:exc:`ZeroDivisionError`、:exc:`FloatingPointError` " -"的基底類別。" +"各種運算錯誤所引發的那些內建例外::exc:`OverflowError`、:exc:" +"`ZeroDivisionError`、:exc:`FloatingPointError` 的基底類別。" #: ../../library/exceptions.rst:178 msgid "" @@ -303,9 +299,8 @@ msgid "" "on a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. " "This can be raised directly by :func:`codecs.lookup`." msgstr "" -"當使用在對映或序列上的鍵或索引是無效的時候所引發的例" -"外::exc:`IndexError`、:exc:`KeyError` 的基底類別。這可以" -"被 :func:`codecs.lookup` 直接引發。" +"當使用在對映或序列上的鍵或索引是無效的時候所引發的例外::exc:`IndexError`、:" +"exc:`KeyError` 的基底類別。這可以被 :func:`codecs.lookup` 直接引發。" #: ../../library/exceptions.rst:190 msgid "Concrete exceptions" @@ -346,9 +341,8 @@ msgstr "新增 :attr:`name` 與 :attr:`obj` 屬性。" #: ../../library/exceptions.rst:217 msgid "" "Raised when the :func:`input` function hits an end-of-file condition (EOF) " -"without reading any data. (N.B.: the :meth:`io.IOBase.read` " -"and :meth:`io.IOBase.readline` methods return an empty string when they hit " -"EOF.)" +"without reading any data. (N.B.: the :meth:`io.IOBase.read` and :meth:`io." +"IOBase.readline` methods return an empty string when they hit EOF.)" msgstr "" "當 :func:`input` 函式在沒有讀到任何資料而到達檔案結尾 (end-of-file, EOF) 條件" "的時候被引發。(注意::meth:`io.IOBase.read` 和 :meth:`io.IOBase.readline` 方" @@ -360,15 +354,14 @@ msgstr "目前沒有被使用。" #: ../../library/exceptions.rst:229 msgid "" -"Raised when a :term:`generator` or :term:`coroutine` is closed; " -"see :meth:`generator.close` and :meth:`coroutine.close`. It directly " -"inherits from :exc:`BaseException` instead of :exc:`Exception` since it is " -"technically not an error." +"Raised when a :term:`generator` or :term:`coroutine` is closed; see :meth:" +"`generator.close` and :meth:`coroutine.close`. It directly inherits from :" +"exc:`BaseException` instead of :exc:`Exception` since it is technically not " +"an error." msgstr "" -"當 :term:`generator` 或 :term:`coroutine` 被關閉的時候被引發;參" -"考 :meth:`generator.close` 和 :meth:`coroutine.close`。此例外直接繼承" -"自 :exc:`BaseException` 而不是 :exc:`Exception`,因為技術上來說這不是一個錯" -"誤。" +"當 :term:`generator` 或 :term:`coroutine` 被關閉的時候被引發;參考 :meth:" +"`generator.close` 和 :meth:`coroutine.close`。此例外直接繼承自 :exc:" +"`BaseException` 而不是 :exc:`Exception`,因為技術上來說這不是一個錯誤。" #: ../../library/exceptions.rst:237 msgid "" @@ -400,8 +393,8 @@ msgstr "新增 :attr:`name` 與 :attr:`path` 屬性。" #: ../../library/exceptions.rst:257 msgid "" "A subclass of :exc:`ImportError` which is raised by :keyword:`import` when a " -"module could not be located. It is also raised when ``None`` is found " -"in :data:`sys.modules`." +"module could not be located. It is also raised when ``None`` is found in :" +"data:`sys.modules`." msgstr "" ":exc:`ImportError` 的子類別,當模組不能被定位的時候會被 :keyword:`import` 所" "引發。當在 :data:`sys.modules` 裡找到 ``None`` 時也會被引發。" @@ -423,16 +416,16 @@ msgstr "當對映(字典)的鍵無法在已存在的鍵的集合中被找到 #: ../../library/exceptions.rst:282 msgid "" -"Raised when the user hits the interrupt key (normally :kbd:`Control-C` " -"or :kbd:`Delete`). During execution, a check for interrupts is made " -"regularly. The exception inherits from :exc:`BaseException` so as to not be " +"Raised when the user hits the interrupt key (normally :kbd:`Control-C` or :" +"kbd:`Delete`). During execution, a check for interrupts is made regularly. " +"The exception inherits from :exc:`BaseException` so as to not be " "accidentally caught by code that catches :exc:`Exception` and thus prevent " "the interpreter from exiting." msgstr "" -"當使用者輸入中斷鍵 (interrupt key)(一般來說是 :kbd:`Control-C` " -"或 :kbd:`Delete`)時會被引發。在執行過程中,會定期檢查是否產生中斷。此例外繼" -"承自 :exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕" -"捉,而因此讓直譯器無法結束。" +"當使用者輸入中斷鍵 (interrupt key)(一般來說是 :kbd:`Control-C` 或 :kbd:" +"`Delete`)時會被引發。在執行過程中,會定期檢查是否產生中斷。此例外繼承自 :" +"exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕捉,而因" +"此讓直譯器無法結束。" #: ../../library/exceptions.rst:290 msgid "" @@ -443,20 +436,19 @@ msgid "" "avoid raising it entirely. (See :ref:`handlers-and-exceptions`.)" msgstr "" "捕捉 :exc:`KeyboardInterrupt` 需要特殊的考量。因為它可以在無法預期的時間點被" -"引發,可能在某些情況下讓正在跑的程式處在一個不一致的狀態。一般來說最好" -"讓 :exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參" -"考 :ref:`handlers-and-exceptions`。)" +"引發,可能在某些情況下讓正在跑的程式處在一個不一致的狀態。一般來說最好讓 :" +"exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參考 :ref:" +"`handlers-and-exceptions`。)" #: ../../library/exceptions.rst:300 msgid "" "Raised when an operation runs out of memory but the situation may still be " "rescued (by deleting some objects). The associated value is a string " "indicating what kind of (internal) operation ran out of memory. Note that " -"because of the underlying memory management architecture " -"(C's :c:func:`malloc` function), the interpreter may not always be able to " -"completely recover from this situation; it nevertheless raises an exception " -"so that a stack traceback can be printed, in case a run-away program was the " -"cause." +"because of the underlying memory management architecture (C's :c:func:" +"`malloc` function), the interpreter may not always be able to completely " +"recover from this situation; it nevertheless raises an exception so that a " +"stack traceback can be printed, in case a run-away program was the cause." msgstr "" "當一個操作用光了記憶體但情況還可能被修復 (rescued)(透過刪除一些物件)的時候" "被引發。關聯值是一個字串,表示什麼類型的(內部)操作用光了記憶體。需注意的是" @@ -509,9 +501,8 @@ msgstr "" #: ../../library/exceptions.rst:338 msgid "" ":exc:`!NotImplementedError` and :data:`!NotImplemented` are not " -"interchangeable. This exception should only be used as described above; " -"see :data:`NotImplemented` for details on correct usage of the built-in " -"constant." +"interchangeable. This exception should only be used as described above; see :" +"data:`NotImplemented` for details on correct usage of the built-in constant." msgstr "" ":exc:`!NotImplementedError` 和 :data:`!NotImplemented` 並不是可互換的。這個例" "外只能用在上面描述的情況;參考 :data:`NotImplemented` 裡關於內建常數正確使用" @@ -520,8 +511,8 @@ msgstr "" #: ../../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 失敗會引" "發此例外(而非不合法的引數或其他次要的錯誤)。" @@ -530,22 +521,21 @@ msgstr "" msgid "" "The second form of the constructor sets the corresponding attributes, " "described below. The attributes default to :const:`None` if not specified. " -"For backwards compatibility, if three arguments are passed, " -"the :attr:`~BaseException.args` attribute contains only a 2-tuple of the " -"first two constructor arguments." +"For backwards compatibility, if three arguments are passed, the :attr:" +"`~BaseException.args` attribute contains only a 2-tuple of the first two " +"constructor arguments." msgstr "" -"建構函式的第二種形式會設定以下描述的相對應屬性。如果沒有給定則屬性預設" -"為 :const:`None`。為了向後相容,如果傳入三個引" -"數,:attr:`~BaseException.args` 屬性只會是包含建構函式前兩個引數的雙元素元" -"組。" +"建構函式的第二種形式會設定以下描述的相對應屬性。如果沒有給定則屬性預設為 :" +"const:`None`。為了向後相容,如果傳入三個引數,:attr:`~BaseException.args` 屬" +"性只會是包含建構函式前兩個引數的雙元素元組。" #: ../../library/exceptions.rst:359 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " -"final :attr:`.errno` value. This behaviour only occurs when " -"constructing :exc:`OSError` directly or via an alias, and is not inherited " -"when subclassing." +"final :attr:`.errno` value. This behaviour only occurs when constructing :" +"exc:`OSError` directly or via an alias, and is not inherited when " +"subclassing." msgstr "" "如同下面的\\ `作業系統例外 `_\\ 所描述,實際上建構函式通常回" "傳 :exc:`OSError` 的子類別。會依據最後 :attr:`.errno` 的值決定特定子類別。這" @@ -558,19 +548,19 @@ msgstr "從 C 變數 :c:data:`errno` 而來的數值錯誤代碼。" #: ../../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 native error code." +"Under Windows, this gives you the native Windows error code. The :attr:`." +"errno` attribute is then an approximate translation, in POSIX terms, of that " +"native error code." msgstr "" "在 Windows 下,這會提供你原生的 Windows 錯誤代碼。而 :attr:`.errno` 屬性是一" "個該原生錯誤代碼對於 POSIX 來說的近似翻譯。" #: ../../library/exceptions.rst: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 *errno* argument is ignored. On other platforms, the *winerror* " -"argument is ignored, and the :attr:`winerror` attribute does not exist." +"Under Windows, if the *winerror* constructor argument is an integer, the :" +"attr:`.errno` attribute is determined from the Windows error code, and the " +"*errno* argument is ignored. On other platforms, the *winerror* argument is " +"ignored, and the :attr:`winerror` attribute does not exist." msgstr "" "在 Windows 下,如果建構函式引數 *winerror* 是整數,則 :attr:`.errno` 屬性會根" "據該 Windows 錯誤代碼來決定,且 *errno* 引數會被忽略。在其他平台上," @@ -579,40 +569,40 @@ msgstr "" #: ../../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:`FormatMessage` under Windows." +"formatted by the C functions :c:func:`perror` under POSIX, and :c:func:" +"`FormatMessage` under Windows." msgstr "" "作業系統提供的對應錯誤訊息。在 POSIX 下會使用 C 函式 :c:func:`perror` 做格式" "化,而在 Windows 下會使用 :c:func:`FormatMessage`。" #: ../../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. For functions that involve two file system paths (such " -"as :func:`os.rename`), :attr:`filename2` corresponds to the second file name " -"passed to the function." +"For exceptions that involve a file system path (such as :func:`open` or :" +"func:`os.unlink`), :attr:`filename` is the file name passed to the function. " +"For functions that involve two file system paths (such as :func:`os." +"rename`), :attr:`filename2` corresponds to the second file name passed to " +"the function." msgstr "" -"對於包含檔案系統路徑的例外(像是 :func:`open` " -"或 :func:`os.unlink`),:attr:`filename` 是傳入函式的檔案名稱。對於包含兩個檔" -"案系統路徑的函式(像是 :func:`os.rename`),:attr:`filename2` 對應到傳入函式" -"的第二個檔案名稱。" +"對於包含檔案系統路徑的例外(像是 :func:`open` 或 :func:`os.unlink`),:attr:" +"`filename` 是傳入函式的檔案名稱。對於包含兩個檔案系統路徑的函式(像是 :func:" +"`os.rename`),:attr:`filename2` 對應到傳入函式的第二個檔案名稱。" #: ../../library/exceptions.rst:398 msgid "" -":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket.error`, :exc:`select.error` " -"and :exc:`mmap.error` have been merged into :exc:`OSError`, and the " -"constructor may return a subclass." +":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket." +"error`, :exc:`select.error` and :exc:`mmap.error` have been merged into :exc:" +"`OSError`, and the constructor may return a subclass." msgstr "" -":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket.error`、:exc:`select.error` " -"及 :exc:`mmap.error` 已合併進 :exc:`OSError`,而建構函式可能會回傳子類別。" +":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket." +"error`、:exc:`select.error` 及 :exc:`mmap.error` 已合併進 :exc:`OSError`,而" +"建構函式可能會回傳子類別。" #: ../../library/exceptions.rst: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:`filesystem encoding and error handler`. Also, the *filename2* " -"constructor argument and attribute was added." +"function, instead of the name encoded to or decoded from the :term:" +"`filesystem encoding and error handler`. Also, the *filename2* constructor " +"argument and attribute was added." msgstr "" ":attr:`filename` 屬性現在是傳入函式的原始檔名,而不是從\\ :term:`檔案系統編碼" "和錯誤處理函式 `\\ 編碼或解碼過的名" @@ -621,11 +611,11 @@ msgstr "" #: ../../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:`MemoryError` than give up). However, for historical reasons, " -"OverflowError is sometimes raised for integers that are outside a required " -"range. Because of the lack of standardization of floating-point exception " -"handling in C, most floating-point operations are not checked." +"represented. This cannot occur for integers (which would rather raise :exc:" +"`MemoryError` than give up). However, for historical reasons, OverflowError " +"is sometimes raised for integers that are outside a required range. " +"Because of the lack of standardization of floating-point exception handling " +"in C, most floating-point operations are not checked." msgstr "" "當運算操作的結果太大而無法表示的時候會引發此例外。這不會發生在整數上(會改成" "引發 :exc:`MemoryError` 而不是放棄)。然而,因為一些歷史因素,OverflowError " @@ -638,14 +628,14 @@ msgid "" "operation is blocked during interpreter shutdown also known as :term:`Python " "finalization `." msgstr "" -"此例外衍生自 :exc:`RuntimeError`。當一個操作在直譯器關閉(也稱" -"作 :term:`Python 最終化 (Python finalization) `)期間" -"被阻塞會引發此例外。" +"此例外衍生自 :exc:`RuntimeError`。當一個操作在直譯器關閉(也稱作 :term:" +"`Python 最終化 (Python finalization) `)期間被阻塞會引" +"發此例外。" #: ../../library/exceptions.rst:427 msgid "" -"Examples of operations which can be blocked with " -"a :exc:`PythonFinalizationError` during the Python finalization:" +"Examples of operations which can be blocked with a :exc:" +"`PythonFinalizationError` during the Python finalization:" msgstr "" "在 Python 最終化期間,能夠以 :exc:`PythonFinalizationError` 被阻塞的操作範" "例:" @@ -669,17 +659,17 @@ msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" #: ../../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.getrecursionlimit`) is exceeded." +"interpreter detects that the maximum recursion depth (see :func:`sys." +"getrecursionlimit`) is exceeded." msgstr "" -"此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參" -"考 :func:`sys.getrecursionlimit`)時會引發此例外。" +"此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參考 :" +"func:`sys.getrecursionlimit`)時會引發此例外。" #: ../../library/exceptions.rst: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 after it has been garbage collected. For more information on weak " +"This exception is raised when a weak reference proxy, created by the :func:" +"`weakref.proxy` function, is used to access an attribute of the referent " +"after it has been garbage collected. For more information on weak " "references, see the :mod:`weakref` module." msgstr "" "當一個被 :func:`weakref.proxy` 函式建立的弱參照代理 (weak reference proxy) 被" @@ -697,9 +687,9 @@ msgstr "" #: ../../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 produced by the iterator." +"Raised by built-in function :func:`next` and an :term:`iterator`\\'s :meth:" +"`~iterator.__next__` method to signal that there are no further items " +"produced by the iterator." msgstr "" "會被內建函式 :func:`next` 及 :term:`iterator` 的 :meth:`~iterator.__next__` " "方法引發,用來表示疊代器沒有更多項目可以產生。" @@ -707,22 +697,21 @@ msgstr "" #: ../../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:`None`." +"as an argument when constructing the exception, and defaults to :const:" +"`None`." msgstr "" -"此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設" -"為 :const:`None`。" +"此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設為 :" +"const:`None`。" #: ../../library/exceptions.rst: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 is used as the :attr:`value` parameter to the constructor of the " -"exception." +"When a :term:`generator` or :term:`coroutine` function returns, a new :exc:" +"`StopIteration` instance is raised, and the value returned by the function " +"is used as the :attr:`value` parameter to the constructor of the exception." msgstr "" -"當 :term:`generator` 或 :term:`coroutine` 函式回傳時,新" -"的 :exc:`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構" -"函式的 :attr:`value` 參數。" +"當 :term:`generator` 或 :term:`coroutine` 函式回傳時,新的 :exc:" +"`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構函式的 :" +"attr:`value` 參數。" #: ../../library/exceptions.rst:481 msgid "" @@ -730,8 +719,8 @@ msgid "" "is converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration` " "as the new exception's cause)." msgstr "" -"如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換" -"成 :exc:`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" +"如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換成 :exc:" +"`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" #: ../../library/exceptions.rst:485 msgid "" @@ -765,10 +754,10 @@ msgstr "" #: ../../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:`compile`, :func:`exec`, or :func:`eval`, or when reading " -"the initial script or standard input (also interactively)." +"Raised when the parser encounters a syntax error. This may occur in an :" +"keyword:`import` statement, in a call to the built-in functions :func:" +"`compile`, :func:`exec`, or :func:`eval`, or when reading the initial script " +"or standard input (also interactively)." msgstr "" "當剖析器遇到語法錯誤時會引發此例外。這可能發生在 :keyword:`import` 陳述式、在" "呼叫內建函式 :func:`compile`、:func:`exec` 或 :func:`eval` 的時候,或者在讀取" @@ -848,21 +837,21 @@ msgid "" "Raised when indentation contains an inconsistent use of tabs and spaces. " "This is a subclass of :exc:`IndentationError`." msgstr "" -"當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這" -"是 :exc:`IndentationError` 的子類別。" +"當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這是 :exc:" +"`IndentationError` 的子類別。" #: ../../library/exceptions.rst:565 msgid "" "Raised when the interpreter finds an internal error, but the situation does " "not look so serious to cause it to abandon all hope. The associated value is " -"a string indicating what went wrong (in low-level terms). " -"In :term:`CPython`, this could be raised by incorrectly using Python's C " -"API, such as returning a ``NULL`` value without an exception set." +"a string indicating what went wrong (in low-level terms). In :term:" +"`CPython`, this could be raised by incorrectly using Python's C API, such as " +"returning a ``NULL`` value without an exception set." msgstr "" "當直譯器找到一個內部錯誤,但該情況看起來沒有嚴重到要讓它放棄所有的希望時會引" -"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。" -"在 :term:`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 " -"``NULL`` 值而沒有設定例外。" +"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。在 :term:" +"`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 ``NULL`` " +"值而沒有設定例外。" #: ../../library/exceptions.rst:571 msgid "" @@ -886,17 +875,17 @@ msgid "" "accidentally caught by code that catches :exc:`Exception`. This allows the " "exception to properly propagate up and cause the interpreter to exit. When " "it is not handled, the Python interpreter exits; no stack traceback is " -"printed. The constructor accepts the same optional argument passed " -"to :func:`sys.exit`. If the value is an integer, it specifies the system " -"exit status (passed to C's :c:func:`exit` function); if it is ``None``, the " -"exit status is zero; if it has another type (such as a string), the object's " -"value is printed and the exit status is one." -msgstr "" -"此例外會被 :func:`sys.exit` 函式引發。它繼承自 :exc:`BaseException` 而不" -"是 :exc:`Exception` 因此不會被捕捉 :exc:`Exception` 的程式意外地捕捉。這允許" -"例外可以正確地向上傳遞並導致直譯器結束。當它未被處理時,Python 直譯器會結束;" -"不會印出堆疊回溯。建構函式接受跟傳入 :func:`sys.exit` 一樣的可選引數。如果該" -"值是整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`exit` 函式 );如果它是 " +"printed. The constructor accepts the same optional argument passed to :func:" +"`sys.exit`. If the value is an integer, it specifies the system exit status " +"(passed to C's :c:func:`exit` function); if it is ``None``, the exit status " +"is zero; if it has another type (such as a string), the object's value is " +"printed and the exit status is one." +msgstr "" +"此例外會被 :func:`sys.exit` 函式引發。它繼承自 :exc:`BaseException` 而不是 :" +"exc:`Exception` 因此不會被捕捉 :exc:`Exception` 的程式意外地捕捉。這允許例外" +"可以正確地向上傳遞並導致直譯器結束。當它未被處理時,Python 直譯器會結束;不會" +"印出堆疊回溯。建構函式接受跟傳入 :func:`sys.exit` 一樣的可選引數。如果該值是" +"整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`exit` 函式 );如果它是 " "``None``,結束狀態會是 0;如果它是其他型別(例如字串),則物件的值會被印出而" "結束狀態是 1。" @@ -911,8 +900,8 @@ msgid "" msgstr "" "對 :func:`sys.exit` 的呼叫會轉譯成例外讓負責清理的處理函式(:keyword:`try` 陳" "述式的 :keyword:`finally` 子句)可以被執行,且讓除錯器可以在不冒著失去控制的" -"風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫" -"完 :func:`os.fork` 之後 )可以使用 :func:`os._exit` 函式。" +"風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫完 :func:`os." +"fork` 之後 )可以使用 :func:`os._exit` 函式。" #: ../../library/exceptions.rst:602 msgid "" @@ -942,10 +931,10 @@ msgstr "" #: ../../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 arguments with the wrong value (e.g. a number outside expected " -"boundaries) should result in a :exc:`ValueError`." +"Passing arguments of the wrong type (e.g. passing a :class:`list` when an :" +"class:`int` is expected) should result in a :exc:`TypeError`, but passing " +"arguments with the wrong value (e.g. a number outside expected boundaries) " +"should result in a :exc:`ValueError`." msgstr "" "傳入錯誤型別的引數(例如當預期傳入 :class:`int` 卻傳入 :class:`list`)應該要" "導致 :exc:`TypeError`,但傳入帶有錯誤值的引數(例如超出預期範圍的數值)應該要" @@ -954,8 +943,8 @@ msgstr "" #: ../../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:`NameError`." +"but no value has been bound to that variable. This is a subclass of :exc:" +"`NameError`." msgstr "" "當在函式或方法裡引用某個區域變數,但該變數尚未被繫結到任何值的時候會引發此例" "外。這是 :exc:`NameError` 的子類別。" @@ -974,8 +963,8 @@ msgid "" "error. For example, ``err.object[err.start:err.end]`` gives the particular " "invalid input that the codec failed on." msgstr "" -":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 " -"``err.object[err.start:err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" +":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 ``err.object[err.start:" +"err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" #: ../../library/exceptions.rst:639 msgid "The name of the encoding that raised the error." @@ -1044,8 +1033,8 @@ msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." msgstr "" -"以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們" -"是 :exc:`OSError` 的別名。" +"以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們是 :exc:" +"`OSError` 的別名。" #: ../../library/exceptions.rst:699 msgid "Only available on Windows." @@ -1064,13 +1053,13 @@ msgstr "以下的例外是 :exc:`OSError` 的子類別,它們根據系統錯 #: ../../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.EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` " -"and :py:const:`~errno.EINPROGRESS`." +"blocking operation. Corresponds to :c:data:`errno` :py:const:`~errno." +"EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` and :py:" +"const:`~errno.EINPROGRESS`." msgstr "" "當設置為非阻塞操作的物件(例如 socket)上的操作將要阻塞時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:py:const:`~errno.EWOULDBLOCK` " -"及 :py:const:`~errno.EINPROGRESS`。" +"到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:" +"py:const:`~errno.EWOULDBLOCK` 及 :py:const:`~errno.EINPROGRESS`。" #: ../../library/exceptions.rst:715 msgid "" @@ -1090,11 +1079,11 @@ msgstr "" #: ../../library/exceptions.rst:726 msgid "" -"Raised when an operation on a child process failed. Corresponds " -"to :c:data:`errno` :py:const:`~errno.ECHILD`." +"Raised when an operation on a child process failed. Corresponds to :c:data:" +"`errno` :py:const:`~errno.ECHILD`." msgstr "" -"當子行程上的操作失敗時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.ECHILD`。" +"當子行程上的操作失敗時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." +"ECHILD`。" #: ../../library/exceptions.rst:731 msgid "A base class for connection-related issues." @@ -1102,30 +1091,28 @@ msgstr "連線相關問題的基礎類別。" #: ../../library/exceptions.rst:733 msgid "" -"Subclasses " -"are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:`ConnectionRefusedError` " -"and :exc:`ConnectionResetError`." +"Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" +"`ConnectionRefusedError` and :exc:`ConnectionResetError`." msgstr "" -"子類別" -"有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:`ConnectionRefusedError` " -"及 :exc:`ConnectionResetError`。" +"子類別有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:" +"`ConnectionRefusedError` 及 :exc:`ConnectionResetError`。" #: ../../library/exceptions.rst: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 " -"has been shutdown for writing. Corresponds " -"to :c:data:`errno` :py:const:`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." +"has been shutdown for writing. Corresponds to :c:data:`errno` :py:const:" +"`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." msgstr "" ":exc:`ConnectionError` 的子類別,當嘗試寫入管道 (pipe) 同時另一端已經被關閉時" -"會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應" -"到 :c:data:`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" +"會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應到 :c:data:" +"`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" #: ../../library/exceptions.rst: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.ECONNABORTED`." +"aborted by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." +"ECONNABORTED`." msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點 (peer) 中斷時會引" "發此例外。對應到 :c:data:`errno` :py:const:`~errno.ECONNABORTED`。" @@ -1133,8 +1120,8 @@ msgstr "" #: ../../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.ECONNREFUSED`." +"refused by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." +"ECONNREFUSED`." msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點拒絕時會引發此例" "外。對應到 :c:data:`errno` :py:const:`~errno.ECONNREFUSED`。" @@ -1152,24 +1139,24 @@ msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." msgstr "" -"當嘗試建立已存在的檔案或目錄時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.EEXIST`。" +"當嘗試建立已存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.EEXIST`。" #: ../../library/exceptions.rst:768 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." msgstr "" -"當請求不存在的檔案或目錄時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.ENOENT`。" +"當請求不存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.ENOENT`。" #: ../../library/exceptions.rst:773 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." msgstr "" -"當系統呼叫被傳入的信號中斷時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.EINTR`。" +"當系統呼叫被傳入的信號中斷時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.EINTR`。" #: ../../library/exceptions.rst:776 msgid "" @@ -1177,24 +1164,24 @@ msgid "" "except if the signal handler raises an exception (see :pep:`475` for the " "rationale), instead of raising :exc:`InterruptedError`." msgstr "" -"現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引" -"發 :exc:`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" +"現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引發 :exc:" +"`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" #: ../../library/exceptions.rst: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`." msgstr "" -"當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.EISDIR`。" +"當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應到 :c:" +"data:`errno` :py:const:`~errno.EISDIR`。" #: ../../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 " "be raised if an operation attempts to open or traverse a non-directory file " -"as if it were a directory. Corresponds " -"to :c:data:`errno` :py:const:`~errno.ENOTDIR`." +"as if it were a directory. Corresponds to :c:data:`errno` :py:const:`~errno." +"ENOTDIR`." msgstr "" "當在某個不是目錄的東西上請求目錄操作(例如 :func:`os.listdir`)時會引發此例" "外。在大多數的 POSIX 平台上,如果嘗試操作開啟或遍歷一個當作目錄的非目錄檔案也" @@ -1203,36 +1190,36 @@ msgstr "" #: ../../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:`~errno.EACCES`, :py:const:`~errno.EPERM`, " -"and :py:const:`~errno.ENOTCAPABLE`." +"for example filesystem permissions. Corresponds to :c:data:`errno` :py:const:" +"`~errno.EACCES`, :py:const:`~errno.EPERM`, and :py:const:`~errno." +"ENOTCAPABLE`." msgstr "" "當嘗試執行一個沒有合乎存取權限的操作時會引發此例外 — 例如檔案系統權限。對應" -"到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` " -"及 :py:const:`~errno.ENOTCAPABLE`。" +"到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` 及 :" +"py:const:`~errno.ENOTCAPABLE`。" #: ../../library/exceptions.rst:802 msgid "" -"WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped " -"to :exc:`PermissionError`." +"WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to :exc:" +"`PermissionError`." msgstr "" "WASI 的 :py:const:`~errno.ENOTCAPABLE` 現在對應到 :exc:`PermissionError`。" #: ../../library/exceptions.rst:808 msgid "" -"Raised when a given process doesn't exist. Corresponds " -"to :c:data:`errno` :py:const:`~errno.ESRCH`." +"Raised when a given process doesn't exist. Corresponds to :c:data:`errno` :" +"py:const:`~errno.ESRCH`." msgstr "" -"當給定的行程不存在時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.ESRCH`。" +"當給定的行程不存在時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." +"ESRCH`。" #: ../../library/exceptions.rst:813 msgid "" -"Raised when a system function timed out at the system level. Corresponds " -"to :c:data:`errno` :py:const:`~errno.ETIMEDOUT`." +"Raised when a system function timed out at the system level. Corresponds to :" +"c:data:`errno` :py:const:`~errno.ETIMEDOUT`." msgstr "" -"當系統函式在系統層級超時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.ETIMEDOUT`。" +"當系統函式在系統層級超時會引發此例外。對應到 :c:data:`errno` :py:const:" +"`~errno.ETIMEDOUT`。" #: ../../library/exceptions.rst:816 msgid "All the above :exc:`OSError` subclasses were added." @@ -1248,8 +1235,8 @@ msgstr "警告" #: ../../library/exceptions.rst:830 msgid "" -"The following exceptions are used as warning categories; see " -"the :ref:`warning-categories` documentation for more details." +"The following exceptions are used as warning categories; see the :ref:" +"`warning-categories` documentation for more details." msgstr "" "以下的例外是當作警告的種類使用;更多細節參考 :ref:`warning-categories` 文件。" @@ -1269,12 +1256,12 @@ msgstr "關於已棄用功能的警告的基礎類別,且當那些警告是針 #: ../../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 warning." +"Ignored by the default warning filters, except in the ``__main__`` module (:" +"pep:`565`). Enabling the :ref:`Python Development Mode ` shows this " +"warning." msgstr "" -"會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟" -"用 :ref:`Python 開發模式 `\\ 會顯示此警告。" +"會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟用 :ref:" +"`Python 開發模式 `\\ 會顯示此警告。" #: ../../library/exceptions.rst:852 ../../library/exceptions.rst:868 msgid "The deprecation policy is described in :pep:`387`." @@ -1366,31 +1353,29 @@ msgid "" "Both of these exception types wrap the exceptions in the sequence ``excs``. " "The ``msg`` parameter must be a string. The difference between the two " "classes is that :exc:`BaseExceptionGroup` extends :exc:`BaseException` and " -"it can wrap any exception, while :exc:`ExceptionGroup` " -"extends :exc:`Exception` and it can only wrap subclasses " -"of :exc:`Exception`. This design is so that ``except Exception`` catches " -"an :exc:`ExceptionGroup` but not :exc:`BaseExceptionGroup`." +"it can wrap any exception, while :exc:`ExceptionGroup` extends :exc:" +"`Exception` and it can only wrap subclasses of :exc:`Exception`. This design " +"is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" +"exc:`BaseExceptionGroup`." msgstr "" "這兩個例外型別都將例外包裝在序列 ``excs`` 中。``msg`` 參數必須是字串。這兩個" "類別的差異是 :exc:`BaseExceptionGroup` 擴充了 :exc:`BaseException` 且可以包裝" -"任何例外,而 :exc:`ExceptionGroup` 擴充了 :exc:`Exception` 且只能包" -"裝 :exc:`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕" -"捉 :exc:`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" +"任何例外,而 :exc:`ExceptionGroup` 擴充了 :exc:`Exception` 且只能包裝 :exc:" +"`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕捉 :exc:" +"`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" #: ../../library/exceptions.rst:946 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " -"rather than a :exc:`BaseExceptionGroup` if all contained exceptions " -"are :exc:`Exception` instances, so it can be used to make the selection " -"automatic. The :exc:`ExceptionGroup` constructor, on the other hand, raises " -"a :exc:`TypeError` if any contained exception is not an :exc:`Exception` " -"subclass." +"rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" +"`Exception` instances, so it can be used to make the selection automatic. " +"The :exc:`ExceptionGroup` constructor, on the other hand, raises a :exc:" +"`TypeError` if any contained exception is not an :exc:`Exception` subclass." msgstr "" "如果所有包含的例外都是 :exc:`Exception` 實例,:exc:`BaseExceptionGroup` 建構" "函式會回傳 :exc:`ExceptionGroup` 而不是 :exc:`BaseExceptionGroup`,因此可以被" -"使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不" -"是 :exc:`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引" -"發 :exc:`TypeError`。" +"使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不是 :exc:" +"`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引發 :exc:`TypeError`。" #: ../../library/exceptions.rst:955 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." @@ -1426,15 +1411,15 @@ msgstr "" #: ../../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.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " -"and :attr:`~BaseException.__notes__` fields. Empty nested groups are omitted " -"from the result." +"as are the values of its :attr:`message`, :attr:`~BaseException." +"__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." +"__context__` and :attr:`~BaseException.__notes__` fields. Empty nested " +"groups are omitted from the result." msgstr "" -"現有例外的巢狀結構會保留在結果裡," -"其 :attr:`message`、:attr:`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException.__context__` " -"及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組會從結果裡排" -"除。" +"現有例外的巢狀結構會保留在結果裡,其 :attr:`message`、:attr:`~BaseException." +"__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException." +"__context__` 及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組" +"會從結果裡排除。" #: ../../library/exceptions.rst:980 msgid "" @@ -1472,21 +1457,21 @@ msgid "" "instances of the subclass rather than :exc:`ExceptionGroup`." msgstr "" "此方法被 :meth:`subgroup` 及 :meth:`split` 使用,被用來在各種情境下拆分例外群" -"組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不" -"是 :exc:`ExceptionGroup` 的實例。" +"組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不是 :" +"exc:`ExceptionGroup` 的實例。" #: ../../library/exceptions.rst:1004 msgid "" -":meth:`subgroup` and :meth:`split` copy " -"the :attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " -"and :attr:`~BaseException.__notes__` fields from the original exception " -"group to the one returned by :meth:`derive`, so these fields do not need to " -"be updated by :meth:`derive`." +":meth:`subgroup` and :meth:`split` copy the :attr:`~BaseException." +"__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." +"__context__` and :attr:`~BaseException.__notes__` fields from the original " +"exception group to the one returned by :meth:`derive`, so these fields do " +"not need to be updated by :meth:`derive`." msgstr "" -":meth:`subgroup` 及 :meth:`split` 會從原始的例外群組複" -"製 :attr:`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException.__context__` " -"和 :attr:`~BaseException.__notes__` 欄位到 :meth:`derive` 所回傳的例外群組" -"上,因此這些欄位不需要被 :meth:`derive` 更新。" +":meth:`subgroup` 及 :meth:`split` 會從原始的例外群組複製 :attr:" +"`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:" +"`~BaseException.__context__` 和 :attr:`~BaseException.__notes__` 欄位到 :" +"meth:`derive` 所回傳的例外群組上,因此這些欄位不需要被 :meth:`derive` 更新。" #: ../../library/exceptions.rst:1011 msgid "" @@ -1547,7 +1532,7 @@ msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " "rather than :meth:`~object.__init__`. For example, the following defines an " -"exception group subclass which accepts an exit_code and and constructs the " +"exception group subclass which accepts an exit_code and constructs the " "group's message from it. ::" msgstr "" "需注意 :exc:`BaseExceptionGroup` 定義了 :meth:`~object.__new__`,因此需要不同" @@ -1577,8 +1562,8 @@ msgstr "" #: ../../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:`Exception`." +"is also a subclass of :exc:`Exception` can only wrap instances of :exc:" +"`Exception`." msgstr "" "像 :exc:`ExceptionGroup` 一樣,任何 :exc:`BaseExceptionGroup` 的子類別且也" "是 :exc:`Exception` 的子類別只能包裝 :exc:`Exception` 的實例。" diff --git a/library/functions.po b/library/functions.po index 9493604248..fb90fa4b56 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -460,9 +460,9 @@ msgid "" "iterator. If *default* is given, it is returned if the iterator is " "exhausted, otherwise :exc:`StopAsyncIteration` is raised." msgstr "" -"呼叫 *async_iterator* 的 :meth:`~object.__anext__` 方法,回" -"傳 :term:`awaitable`。等待返回疊代器的下一個值。如果指定 *default*,當疊代器" -"結束時會返回該值,否則會引發 :exc:`StopAsyncIteration` 。" +"呼叫 *async_iterator* 的 :meth:`~object.__anext__` 方法,回傳 :term:" +"`awaitable`。等待返回疊代器的下一個值。如果指定 *default*,當疊代器結束時會返" +"回該值,否則會引發 :exc:`StopAsyncIteration` 。" #: ../../library/functions.rst:104 msgid "" @@ -489,9 +489,9 @@ msgstr "" #: ../../library/functions.rst:116 msgid "" "As :func:`repr`, return a string containing a printable representation of an " -"object, but escape the non-ASCII characters in the string returned " -"by :func:`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates " -"a string similar to that returned by :func:`repr` in Python 2." +"object, but escape the non-ASCII characters in the string returned by :func:" +"`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a string " +"similar to that returned by :func:`repr` in Python 2." msgstr "" "就像函式 :func:`repr`,回傳一個表示物件的字串,但是 :func:`repr` 回傳的字串中" "非 ASCII 編碼的字元會被跳脫 (escape),像是 ``\\x``、``\\u`` 和 ``\\U``。這個" @@ -505,8 +505,8 @@ msgid "" "integer. Some examples:" msgstr "" "將一個整數轉變為一個前綴為 \"0b\" 的二進位制字串。結果是一個有效的 Python 運" -"算式。如果 *x* 不是 Python 的 :class:`int` 物件,那它需要定" -"義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" +"算式。如果 *x* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:`~object." +"__index__` method 回傳一個整數。舉例來說:" #: ../../library/functions.rst:134 msgid "" @@ -524,9 +524,9 @@ msgid "" "Return a Boolean value, i.e. one of ``True`` or ``False``. The argument is " "converted using the standard :ref:`truth testing procedure `. If the " "argument is false or omitted, this returns ``False``; otherwise, it returns " -"``True``. The :class:`bool` class is a subclass of :class:`int` " -"(see :ref:`typesnumeric`). It cannot be subclassed further. Its only " -"instances are ``False`` and ``True`` (see :ref:`typebool`)." +"``True``. The :class:`bool` class is a subclass of :class:`int` (see :ref:" +"`typesnumeric`). It cannot be subclassed further. Its only instances are " +"``False`` and ``True`` (see :ref:`typebool`)." msgstr "" "回傳一個布林值,即 ``True`` 或者 ``False``。引數會使用標準的\\ :ref:`真值測試" "程序 `\\ 來轉換。如果引數為假或者被省略,則回傳 ``False``;其他情況回" @@ -551,18 +551,18 @@ msgid "" "not accessible, this function will raise :exc:`RuntimeError`." msgstr "" "這個函式將呼叫 :func:`sys.breakpointhook` 函式,並將 ``args`` 和 ``kws`` 傳遞" -"給它。這將有效地讓你在特定的呼叫點進入除錯器。預設情況下," -"``sys.breakpointhook()`` 呼叫 :func:`pdb.set_trace` 不須帶任何引數。這樣的設" -"計是為了方便使用者,讓他們不需要額外地導入 :mod:`pdb` 模組或輸入太多程式就可" -"以進入除錯器。然而,可以將 :func:`sys.breakpointhook` 設置為其他函式,並" -"且 :func:`breakpoint` 將自動呼叫該函式,讓你進入所選擇的除錯器。如果無法存" -"取 :func:`sys.breakpointhook` 這個函式,則此函式將引發 :exc:`RuntimeError`。" +"給它。這將有效地讓你在特定的呼叫點進入除錯器。預設情況下,``sys." +"breakpointhook()`` 呼叫 :func:`pdb.set_trace` 不須帶任何引數。這樣的設計是為" +"了方便使用者,讓他們不需要額外地導入 :mod:`pdb` 模組或輸入太多程式就可以進入" +"除錯器。然而,可以將 :func:`sys.breakpointhook` 設置為其他函式,並且 :func:" +"`breakpoint` 將自動呼叫該函式,讓你進入所選擇的除錯器。如果無法存取 :func:" +"`sys.breakpointhook` 這個函式,則此函式將引發 :exc:`RuntimeError`。" #: ../../library/functions.rst:173 msgid "" -"By default, the behavior of :func:`breakpoint` can be changed with " -"the :envvar:`PYTHONBREAKPOINT` environment variable. " -"See :func:`sys.breakpointhook` for usage details." +"By default, the behavior of :func:`breakpoint` can be changed with the :" +"envvar:`PYTHONBREAKPOINT` environment variable. See :func:`sys." +"breakpointhook` for usage details." msgstr "" "預設情況下,:func:`breakpoint` 的行為可以透過 :envvar:`PYTHONBREAKPOINT` 環境" "變數來更改。有關使用詳情,請參考 :func:`sys.breakpointhook`。" @@ -589,9 +589,9 @@ msgid "" "as most methods that the :class:`bytes` type has, see :ref:`bytes-methods`." msgstr "" "回傳一個新的 bytes 陣列。:class:`bytearray` class 是一個可變的整數序列,包含" -"範圍為 0 <= x < 256 的整數。它有可變序列大部分常見的 method(如" -"在 :ref:`typesseq-mutable` 中所述),同時也有 :class:`bytes` 型別大部分的 " -"method,參見 :ref:`bytes-methods`。" +"範圍為 0 <= x < 256 的整數。它有可變序列大部分常見的 method(如在 :ref:" +"`typesseq-mutable` 中所述),同時也有 :class:`bytes` 型別大部分的 method,參" +"見 :ref:`bytes-methods`。" #: ../../library/functions.rst:195 msgid "" @@ -644,8 +644,8 @@ msgstr "可參考 :ref:`binaryseq` 和 :ref:`typebytearray`。" #: ../../library/functions.rst:222 msgid "" "Return a new \"bytes\" object which is an immutable sequence of integers in " -"the range ``0 <= x < 256``. :class:`bytes` is an immutable version " -"of :class:`bytearray` -- it has the same non-mutating methods and the same " +"the range ``0 <= x < 256``. :class:`bytes` is an immutable version of :" +"class:`bytearray` -- it has the same non-mutating methods and the same " "indexing and slicing behavior." msgstr "" "回傳一個新的 \"bytes\" 物件,會是一個元素是範圍為 ``0 <= x < 256`` 整數的不可" @@ -667,12 +667,11 @@ msgstr "可參考 :ref:`binaryseq`、:ref:`typebytes` 和 :ref:`bytes-methods` #: ../../library/functions.rst:236 msgid "" -"Return :const:`True` if the *object* argument appears " -"callable, :const:`False` if not. If this returns ``True``, it is still " -"possible that a call fails, but if it is ``False``, calling *object* will " -"never succeed. Note that classes are callable (calling a class returns a new " -"instance); instances are callable if their class has " -"a :meth:`~object.__call__` method." +"Return :const:`True` if the *object* argument appears callable, :const:" +"`False` if not. If this returns ``True``, it is still possible that a call " +"fails, but if it is ``False``, calling *object* will never succeed. Note " +"that classes are callable (calling a class returns a new instance); " +"instances are callable if their class has a :meth:`~object.__call__` method." msgstr "" "如果引數 *object* 是可呼叫的,回傳 :const:`True`,否則回傳 :const:`False`。如" "果回傳 ``True``,呼叫仍可能會失敗;但如果回傳 ``False``,則呼叫 *object* 肯定" @@ -727,8 +726,8 @@ msgstr "" #: ../../library/functions.rst:269 msgid "" -"The ``@classmethod`` form is a function :term:`decorator` -- " -"see :ref:`function` for details." +"The ``@classmethod`` form is a function :term:`decorator` -- see :ref:" +"`function` for details." msgstr "" "``@classmethod`` 語法是一個函式 :term:`decorator` — 參見 :ref:`function` 中關" "於函式定義的詳細介紹。" @@ -756,30 +755,31 @@ msgstr "" #: ../../library/functions.rst:281 msgid "" -"Class methods can now wrap other :term:`descriptors ` such " -"as :func:`property`." +"Class methods can now wrap other :term:`descriptors ` such as :" +"func:`property`." msgstr "" -"Class methods 現在可以包裝其他\\ :term:`描述器 `,例" -"如 :func:`property`" +"Class methods 現在可以包裝其他\\ :term:`描述器 `,例如 :func:" +"`property`" #: ../../library/functions.rst:285 msgid "" -"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." +"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 屬性" -"(:attr:`~function.__module__`、:attr:`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function.__doc__` " -"和 :attr:`~function.__annotations__`),並擁有一個新的 ``__wrapped__`` 屬性。" +"Class method 現在繼承了 method 屬性(:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " +"``__wrapped__`` 屬性。" #: ../../library/functions.rst:292 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." msgstr "" -"Class methods 不能再包裝其他的\\ :term:`描述器 `,例" -"如 :func:`property`。" +"Class methods 不能再包裝其他的\\ :term:`描述器 `,例如 :func:" +"`property`。" #: ../../library/functions.rst:299 msgid "" @@ -788,9 +788,9 @@ msgid "" "string, a byte string, or an AST object. Refer to the :mod:`ast` module " "documentation for information on how to work with AST objects." msgstr "" -"將 *source* 編譯成程式碼或 AST 物件。程式碼物件可以被 :func:`exec` " -"或 :func:`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。" -"參見 :mod:`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" +"將 *source* 編譯成程式碼或 AST 物件。程式碼物件可以被 :func:`exec` 或 :func:" +"`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。參見 :mod:" +"`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" #: ../../library/functions.rst:304 msgid "" @@ -816,16 +816,16 @@ msgstr "" #: ../../library/functions.rst:314 msgid "" -"The optional arguments *flags* and *dont_inherit* control " -"which :ref:`compiler options ` should be activated and " -"which :ref:`future features ` should be allowed. If neither is " -"present (or both are zero) the code is compiled with the same flags that " -"affect the code that is calling :func:`compile`. If the *flags* argument is " -"given and *dont_inherit* is not (or is zero) then the compiler options and " -"the future statements specified by the *flags* argument are used in addition " -"to those that would be used anyway. If *dont_inherit* is a non-zero integer " -"then the *flags* argument is it -- the flags (future features and compiler " -"options) in the surrounding code are ignored." +"The optional arguments *flags* and *dont_inherit* control which :ref:" +"`compiler options ` should be activated and which :ref:" +"`future features ` should be allowed. If neither is present (or both " +"are zero) the code is compiled with the same flags that affect the code that " +"is calling :func:`compile`. If the *flags* argument is given and " +"*dont_inherit* is not (or is zero) then the compiler options and the future " +"statements specified by the *flags* argument are used in addition to those " +"that would be used anyway. If *dont_inherit* is a non-zero integer then the " +"*flags* argument is it -- the flags (future features and compiler options) " +"in the surrounding code are ignored." msgstr "" "可選引數 *flags* 和 *dont_inherit* 控制啟用哪個\\ :ref:`編譯器選項 `\\ 以及允許哪個\\ :ref:`未來功能 `。如果兩者都不存在" @@ -838,18 +838,16 @@ msgstr "" msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " -"specify a given future feature can be found as " -"the :attr:`~__future__._Feature.compiler_flag` attribute on " -"the :class:`~__future__._Feature` instance in the :mod:`__future__` " -"module. :ref:`Compiler flags ` can be found " -"in :mod:`ast` module, with ``PyCF_`` prefix." +"specify a given future feature can be found as the :attr:`~__future__." +"_Feature.compiler_flag` attribute on the :class:`~__future__._Feature` " +"instance in the :mod:`__future__` module. :ref:`Compiler flags ` can be found in :mod:`ast` module, with ``PyCF_`` prefix." msgstr "" "編譯器選項和 future 陳述式使用 bits 來表示,可以一起被位元操作 OR 來表示複數" -"個選項。需要被具體定義特徵的位元域可以透過 :mod:`__future__` module " -"中 :class:`~__future__._Feature` 實例中" -"的 :attr:`~__future__._Feature.compiler_flag` 屬性來獲得。:ref:`編譯器旗標 " -"`\\ 可以在 :mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名" -"稱。" +"個選項。需要被具體定義特徵的位元域可以透過 :mod:`__future__` module 中 :" +"class:`~__future__._Feature` 實例中的 :attr:`~__future__._Feature." +"compiler_flag` 屬性來獲得。:ref:`編譯器旗標 `\\ 可以在 :" +"mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名稱。" #: ../../library/functions.rst:333 msgid "" @@ -859,8 +857,8 @@ msgid "" "optimization; ``__debug__`` is true), ``1`` (asserts are removed, " "``__debug__`` is false) or ``2`` (docstrings are removed too)." msgstr "" -"引數 *optimize* 用來指定編譯器的最佳化級別;預設值 ``-1`` 選擇與直譯器" -"的 :option:`-O` 選項相同的最佳化級別。其他級別為 ``0``\\ (沒有最佳化;\\ " +"引數 *optimize* 用來指定編譯器的最佳化級別;預設值 ``-1`` 選擇與直譯器的 :" +"option:`-O` 選項相同的最佳化級別。其他級別為 ``0``\\ (沒有最佳化;\\ " "``__debug__`` 為真值)、``1``\\ (assert 被刪除,``__debug__`` 為假值)或 " "``2``\\ (說明字串 (docstring) 也被刪除)。" @@ -874,8 +872,8 @@ msgstr "" #: ../../library/functions.rst:342 msgid "" -"If you want to parse Python code into its AST representation, " -"see :func:`ast.parse`." +"If you want to parse Python code into its AST representation, see :func:`ast." +"parse`." msgstr "如果你想解析 Python 程式碼為 AST 運算式,請參閱 :func:`ast.parse`。" #: ../../library/functions.rst:345 ../../library/functions.rst:347 @@ -891,8 +889,8 @@ msgstr "" 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 " -"to facilitate detection of incomplete and complete statements in " -"the :mod:`code` module." +"to facilitate detection of incomplete and complete statements in the :mod:" +"`code` module." msgstr "" "在 ``'single'`` 或 ``'eval'`` 模式編譯多行程式碼時,輸入必須以至少一個換行符" "結尾。這使 :mod:`code` module 更容易檢測陳述式的完整性。" @@ -985,23 +983,23 @@ msgid "" "and ``')'``, which are ignored. The string must not contain whitespace " "between ``'+'``, ``'-'``, the ``'j'`` or ``'J'`` suffix, and the decimal " "number. For example, ``complex('1+2j')`` is fine, but ``complex('1 + 2j')`` " -"raises :exc:`ValueError`. More precisely, the input must conform to " -"the :token:`~float:complexvalue` production rule in the following grammar, " -"after parentheses and leading and trailing whitespace characters are removed:" +"raises :exc:`ValueError`. More precisely, the input must conform to the :" +"token:`~float:complexvalue` production rule in the following grammar, after " +"parentheses and leading and trailing whitespace characters are removed:" msgstr "" #: ../../library/functions.rst:424 msgid "" "If the argument is a number, the constructor serves as a numeric conversion " "like :class:`int` and :class:`float`. For a general Python object ``x``, " -"``complex(x)`` delegates to ``x.__complex__()``. " -"If :meth:`~object.__complex__` is not defined then it falls back " -"to :meth:`~object.__float__`. If :meth:`!__float__` is not defined then it " -"falls back to :meth:`~object.__index__`." +"``complex(x)`` delegates to ``x.__complex__()``. If :meth:`~object." +"__complex__` is not defined then it falls back to :meth:`~object.__float__`. " +"If :meth:`!__float__` is not defined then it falls back to :meth:`~object." +"__index__`." msgstr "" "如果引數是一個數字,則建構函式會像 :class:`int` 和 :class:`float` 一樣進行數" -"值轉換。對於一個普通的 Python 物件 ``x``,``complex(x)`` 會委派給 " -"``x.__complex__()``。如果 :meth:`~object.__complex__` 未定義,則會回退 (fall " +"值轉換。對於一個普通的 Python 物件 ``x``,``complex(x)`` 會委派給 ``x." +"__complex__()``。如果 :meth:`~object.__complex__` 未定義,則會回退 (fall " "back) 到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未定義,則會再回" "退到 :meth:`~object.__index__`。" @@ -1031,8 +1029,8 @@ msgstr "可以使用底線將程式碼文字中的數字進行分組。" #: ../../library/functions.rst:450 msgid "" -"Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` " -"and :meth:`~object.__float__` are not defined." +"Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" +"meth:`~object.__float__` are not defined." msgstr "" "如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" "退到 :meth:`~object.__index__`。" @@ -1060,8 +1058,8 @@ msgstr "" #: ../../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." +"For other containers see the built-in :class:`list`, :class:`set`, and :" +"class:`tuple` classes, as well as the :mod:`collections` module." msgstr "" "其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " "class,以及 :mod:`collections` module。" @@ -1079,9 +1077,9 @@ msgstr "" 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 " -"implement a custom :func:`~object.__getattr__` " -"or :func:`~object.__getattribute__` function to customize the " -"way :func:`dir` reports their attributes." +"implement a custom :func:`~object.__getattr__` or :func:`~object." +"__getattribute__` function to customize the way :func:`dir` reports their " +"attributes." msgstr "" "如果物件有一個名為 :meth:`~object.__dir__` 的 method,那麼該 method 將被呼" "叫,並且必須回傳一個屬性列表。這允許實現自定義 :func:`~object.__getattr__` " @@ -1093,12 +1091,12 @@ 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__` " "attribute, if defined, and from its type object. The resulting list is not " -"necessarily complete and may be inaccurate when the object has a " -"custom :func:`~object.__getattr__`." +"necessarily complete and may be inaccurate when the object has a custom :" +"func:`~object.__getattr__`." msgstr "" -"如果物件不提供 :meth:`~object.__dir__`,這個函式會嘗試從物件已定義" -"的 :attr:`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的," -"如果物件有自定義 :func:`~object.__getattr__`,那結果可能不準確。" +"如果物件不提供 :meth:`~object.__dir__`,這個函式會嘗試從物件已定義的 :attr:" +"`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的,如果物件有" +"自定義 :func:`~object.__getattr__`,那結果可能不準確。" #: ../../library/functions.rst:496 msgid "" @@ -1155,30 +1153,30 @@ msgid "" "consisting of their quotient and remainder when using integer division. " "With mixed operand types, the rules for binary arithmetic operators apply. " "For integers, the result is the same as ``(a // b, a % b)``. For floating-" -"point numbers the result is ``(q, a % b)``, where *q* is usually " -"``math.floor(a / b)`` but may be 1 less than that. In any case ``q * b + a " -"% b`` is very close to *a*, if ``a % b`` is non-zero it has the same sign as " -"*b*, and ``0 <= abs(a % b) < abs(b)``." +"point numbers the result is ``(q, a % b)``, where *q* is usually ``math." +"floor(a / b)`` but may be 1 less than that. In any case ``q * b + a % b`` " +"is very close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, " +"and ``0 <= abs(a % b) < abs(b)``." msgstr "" "它將兩個(非複數)數字作為引數,並在執行整數除法時回傳一對商和餘數。對於混合" "運算元型別,適用二進位算術運算子的規則。對於整數,運算結果和 ``(a // b, a % " -"b)`` 一致。對於浮點數,運算結果是 ``(q, a % b)``,*q* 通常是 " -"``math.floor(a / b)`` 但可能會比 1 小。在任何情況下,``q * b + a % b`` 和 " -"*a* 基本相等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % " -"b) < abs(b)``。" +"b)`` 一致。對於浮點數,運算結果是 ``(q, a % b)``,*q* 通常是 ``math." +"floor(a / b)`` 但可能會比 1 小。在任何情況下,``q * b + a % b`` 和 *a* 基本相" +"等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % b) < " +"abs(b)``。" #: ../../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:`~iterator.__next__` method of the iterator returned " -"by :func:`enumerate` returns a tuple containing a count (from *start* which " -"defaults to 0) and the values obtained from iterating over *iterable*." +"Return an enumerate object. *iterable* must be a sequence, an :term:" +"`iterator`, or some other object which supports iteration. The :meth:" +"`~iterator.__next__` method of the iterator returned by :func:`enumerate` " +"returns a tuple containing a count (from *start* which defaults to 0) and " +"the values obtained from iterating over *iterable*." msgstr "" "回傳一個列舉 (enumerate) 物件。*iterable* 必須是一個序列、:term:`iterator` 或" -"其他支援疊代的物件。:func:`enumerate` 回傳之 iterator " -"的 :meth:`~iterator.__next__` method 回傳一個 tuple(元組),裡面包含一個計數" -"值(從 *start* 開始,預設為 0)和透過疊代 *iterable* 獲得的值。" +"其他支援疊代的物件。:func:`enumerate` 回傳之 iterator 的 :meth:`~iterator." +"__next__` method 回傳一個 tuple(元組),裡面包含一個計數值(從 *start* 開" +"始,預設為 0)和透過疊代 *iterable* 獲得的值。" #: ../../library/functions.rst:564 msgid "Equivalent to::" @@ -1245,14 +1243,14 @@ msgid "" "reference to the dictionary of the built-in module :mod:`builtins` is " "inserted under that key before *expression* is parsed. That way you can " "control what builtins are available to the executed code by inserting your " -"own ``__builtins__`` dictionary into *globals* before passing it " -"to :func:`eval`. If the *locals* mapping is omitted it defaults to the " -"*globals* dictionary. If both mappings are omitted, the expression is " -"executed with the *globals* and *locals* in the environment " -"where :func:`eval` is called. Note, *eval()* will only have access to " -"the :term:`nested scopes ` (non-locals) in the enclosing " -"environment if they are already referenced in the scope that is " -"calling :func:`eval` (e.g. via a :keyword:`nonlocal` statement)." +"own ``__builtins__`` dictionary into *globals* before passing it to :func:" +"`eval`. If the *locals* mapping is omitted it defaults to the *globals* " +"dictionary. If both mappings are omitted, the expression is executed with " +"the *globals* and *locals* in the environment where :func:`eval` is called. " +"Note, *eval()* will only have access to the :term:`nested scopes ` (non-locals) in the enclosing environment if they are already " +"referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:" +"`nonlocal` statement)." msgstr "" "*expression* 引數會被視為一條 Python 運算式(技術上而言,是條件列表)來剖析及" "求值,而 *globals* 和 *locals* 對映分別用作全域和區域命名空間。如果 " @@ -1260,11 +1258,11 @@ msgstr "" "析之前,將為該鍵插入對內建 :mod:`builtins` module dictionary 的引用。這麼一" "來,在將 ``__builtins__`` dictionary 傳入 :func:`eval` 之前,你可以透過將它插" "入 *globals* 來控制你需要哪些內建函式來執行程式碼。如果 *locals* 對映被省略," -"那它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以" -"在 :func:`eval` 被呼叫的環境中的 *globals* 和 *locals* 執行運算式。請注意," -"*eval()* 在封閉 (enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透" -"過 :keyword:`nonlocal` 陳述式)。" +"那它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以在 :func:" +"`eval` 被呼叫的環境中的 *globals* 和 *locals* 執行運算式。請注意,*eval()* 在" +"封閉 (enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-" +"locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過 :keyword:" +"`nonlocal` 陳述式)。" #: ../../library/functions.rst:612 msgid "Example:" @@ -1289,8 +1287,8 @@ msgid "" "pass around for use by :func:`eval` or :func:`exec`." msgstr "" "提示::func:`exec` 函式支援動態執行陳述式。:func:`globals` 和 :func:`locals` " -"函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞" -"給 :func:`eval` 或 :func:`exec` 可能會方便許多。" +"函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" +"`eval` 或 :func:`exec` 可能會方便許多。" #: ../../library/functions.rst:628 msgid "" @@ -1332,18 +1330,18 @@ msgid "" "as a suite of Python statements which is then executed (unless a syntax " "error occurs). [#]_ If it is a code object, it is simply executed. In all " "cases, the code that's executed is expected to be valid as file input (see " -"the section :ref:`file-input` in the Reference Manual). Be aware that " -"the :keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements " -"may not be used outside of function definitions even within the context of " -"code passed to the :func:`exec` function. The return value is ``None``." +"the section :ref:`file-input` in the Reference Manual). Be aware that the :" +"keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements may " +"not be used outside of function definitions even within the context of code " +"passed to the :func:`exec` function. The return value is ``None``." msgstr "" "這個函式支援動態執行 Python 程式碼。*source* 必須是字串或者程式碼物件。如果是" "字串,那麼該字串將被剖析為一系列 Python 陳述式並執行(除非發生語法錯誤)。" "[#]_ 如果是程式碼物件,它將被直接執行。無論哪種情況,被執行的程式碼都需要和檔" "案輸入一樣是有效的(可參閱語言參考手冊中關於\\ :ref:`file-input`\\ 的章節)。" -"請注意,即使在傳遞給 :func:`exec` 函式的程式碼的上下文" -"中,:keyword:`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在" -"函式之外使用。該函式回傳值是 ``None``。" +"請注意,即使在傳遞給 :func:`exec` 函式的程式碼的上下文中,:keyword:" +"`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在函式之外使" +"用。該函式回傳值是 ``None``。" #: ../../library/functions.rst:668 msgid "" @@ -1373,9 +1371,9 @@ msgstr "" #: ../../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:`builtins` is inserted under that key. That way you can control " -"what builtins are available to the executed code by inserting your own " +"``__builtins__``, a reference to the dictionary of the built-in module :mod:" +"`builtins` is inserted under that key. That way you can control what " +"builtins are available to the executed code by inserting your own " "``__builtins__`` dictionary into *globals* before passing it to :func:`exec`." msgstr "" "如果 *globals* dictionary 不包含 ``__builtins__`` 鍵值,則將為該鍵插入對內" @@ -1410,9 +1408,9 @@ msgid "" "Pass an explicit *locals* dictionary if you need to see effects of the code " "on *locals* after function :func:`exec` returns." msgstr "" -"預設情況下,*locals* 的行為如下面 :func:`locals` 函式描述的一樣。如果你想" -"在 :func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 " -"*locals* dictionary 。" +"預設情況下,*locals* 的行為如下面 :func:`locals` 函式描述的一樣。如果你想在 :" +"func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 *locals* " +"dictionary 。" #: ../../library/functions.rst:713 msgid "Added the *closure* parameter." @@ -1512,9 +1510,9 @@ msgstr "" #: ../../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 back to :meth:`~object.__index__`." +"For a general Python object ``x``, ``float(x)`` delegates to ``x." +"__float__()``. If :meth:`~object.__float__` is not defined then it falls " +"back to :meth:`~object.__index__`." msgstr "" "對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" "定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" @@ -1542,8 +1540,8 @@ msgid "" "is used by most built-in types: :ref:`formatspec`." msgstr "" "將 *value* 轉換為 *format_spec* 控制的 \"格式化\" 表示。*format_spec* 的解釋" -"取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語" -"法::ref:`formatspec`。" +"取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語法::ref:" +"`formatspec`。" #: ../../library/functions.rst:825 msgid "" @@ -1555,12 +1553,12 @@ msgstr "" #: ../../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 searching for the value's :meth:`~object.__format__` method. " -"A :exc:`TypeError` exception is raised if the method search " -"reaches :mod:`object` and the *format_spec* is non-empty, or if either the " -"*format_spec* or the return value are not strings." +"A call to ``format(value, format_spec)`` is translated to ``type(value)." +"__format__(value, format_spec)`` which bypasses the instance dictionary when " +"searching for the value's :meth:`~object.__format__` method. A :exc:" +"`TypeError` exception is raised if the method search reaches :mod:`object` " +"and the *format_spec* is non-empty, or if either the *format_spec* or the " +"return value are not strings." msgstr "" "呼叫 ``format(value, format_spec)`` 會轉換成 ``type(value).__format__(value, " "format_spec)``,當搜尋 value 的 :meth:`~object.__format__` method 時,會忽略" @@ -1572,24 +1570,23 @@ msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." msgstr "" -"當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引" -"發 :exc:`TypeError`。" +"當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引發 :" +"exc:`TypeError`。" #: ../../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 :ref:`types-set` for documentation about this class." +"*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" +"ref:`types-set` for documentation about this class." msgstr "" "回傳一個新的 :class:`frozenset` 物件,它包含選擇性引數 *iterable* 中的元素。" -"``frozenset`` 是一個內建的 class。有關此 class 的文件,請參" -"閱 :class:`frozenset` 和 :ref:`types-set`。" +"``frozenset`` 是一個內建的 class。有關此 class 的文件,請參閱 :class:" +"`frozenset` 和 :ref:`types-set`。" #: ../../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." +"For other containers see the built-in :class:`set`, :class:`list`, :class:" +"`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." msgstr "" "請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " "class,以及 :mod:`collections` module 來了解其它的容器。" @@ -1605,16 +1602,16 @@ msgid "" msgstr "" "回傳 *object* 之具名屬性的值。*name* 必須是字串。如果該字串是物件屬性之一的名" "稱,則回傳該屬性的值。例如,``getattr(x, 'foobar')`` 等同於 ``x.foobar``。如" -"果指定的屬性不存在,且提供了 *default* 值,則回傳其值,否則引" -"發 :exc:`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請" -"見 :func:`setattr`)。" +"果指定的屬性不存在,且提供了 *default* 值,則回傳其值,否則引發 :exc:" +"`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請見 :func:" +"`setattr`)。" #: ../../library/functions.rst:865 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 retrieve it " -"with :func:`getattr`." +"with two leading underscores) name in order to retrieve it with :func:" +"`getattr`." msgstr "" "由於\\ :ref:`私有名稱改編 (private name mangling) ` 是" "發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" @@ -1653,9 +1650,8 @@ msgstr "" #: ../../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." +"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." msgstr "" "請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" "運行機器的位元長度來截斷回傳值。" @@ -1701,12 +1697,12 @@ msgstr "" #: ../../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 :meth:`~object.__index__` method that returns an integer. Some examples:" +"\"0x\". If *x* is not a Python :class:`int` object, it has to define an :" +"meth:`~object.__index__` method that returns an integer. Some examples:" msgstr "" -"將整數轉換為以 \"0x\" 為前綴的小寫十六進位制字串。如果 *x* 不是 " -"Python :class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並" -"且回傳一個整數。舉例來說:" +"將整數轉換為以 \"0x\" 為前綴的小寫十六進位制字串。如果 *x* 不是 Python :" +"class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並且回傳一" +"個整數。舉例來說:" #: ../../library/functions.rst:932 msgid "" @@ -1725,8 +1721,8 @@ msgstr "另請參閱 :func:`int` 將十六進位制字串轉換為以 16 為基 #: ../../library/functions.rst:949 msgid "" -"To obtain a hexadecimal string representation for a float, use " -"the :meth:`float.hex` method." +"To obtain a hexadecimal string representation for a float, use the :meth:" +"`float.hex` method." msgstr "" "如果要取得浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" @@ -1834,11 +1830,11 @@ msgstr "" #: ../../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 ``x.__index__()``. If the argument " -"defines :meth:`~object.__trunc__`, it returns ``x.__trunc__()``. For " -"floating-point numbers, this truncates towards zero." +"If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x." +"__int__()``. If the argument defines :meth:`~object.__index__`, it returns " +"``x.__index__()``. If the argument defines :meth:`~object.__trunc__`, it " +"returns ``x.__trunc__()``. For floating-point numbers, this truncates " +"towards zero." msgstr "" "如果引數定義了 :meth:`~object.__int__`,則 ``int(x)`` 回傳 ``x.__int__()``。" "如果引數定義了 :meth:`~object.__index__` 則回傳 ``x.__index__()``。如果引數定" @@ -1853,10 +1849,10 @@ msgid "" "``-`` (with no space in between), have leading zeros, be surrounded by " "whitespace, and have single underscores interspersed between digits." msgstr "" -"如果引數不是數字或如果有給定 *base*,則它必須是個字串、:class:`bytes` " -"或 :class:`bytearray` 實例,表示基數 (radix) *base* 中的整數。可選地,字串之" -"前可以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、" -"或在數字間有單一底線。" +"如果引數不是數字或如果有給定 *base*,則它必須是個字串、:class:`bytes` 或 :" +"class:`bytearray` 實例,表示基數 (radix) *base* 中的整數。可選地,字串之前可" +"以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、或在" +"數字間有單一底線。" #: ../../library/functions.rst:1027 msgid "" @@ -1886,15 +1882,15 @@ msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" #: ../../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 " +"If *base* is not an instance of :class:`int` and the *base* object has a :" +"meth:`base.__index__ ` method, that method is called to " "obtain an integer for the base. Previous versions used :meth:`base.__int__ " "` instead of :meth:`base.__index__ `." msgstr "" "如果 *base* 不是 :class:`int` 的實例,但 *base* 物件有 :meth:`base.__index__ " "` method,則會呼叫該 method 來取得此進位制所需的整數。以前" -"的版本使用 :meth:`base.__int__ ` 而不" -"是 :meth:`base.__index__ `。" +"的版本使用 :meth:`base.__int__ ` 而不是 :meth:`base." +"__index__ `。" #: ../../library/functions.rst:1050 msgid "The first parameter is now positional-only." @@ -1916,14 +1912,14 @@ 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 " "limit is exceeded while converting a string to an :class:`int` or when " -"converting an :class:`int` into a string would exceed the limit. See " -"the :ref:`integer string conversion length limitation ` " +"converting an :class:`int` into a string would exceed the limit. See the :" +"ref:`integer string conversion length limitation ` " "documentation." msgstr "" ":class:`int` 的字串輸入和字串表示法可以被限制,以避免阻斷服務攻擊 (denial of " -"service attack)。在字串 *x* 轉換為 :class:`int` 時已超出限制,或是" -"在 :class:`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱" -"\\ :ref:`整數字串轉換的長度限制 `\\ 說明文件。" +"service attack)。在字串 *x* 轉換為 :class:`int` 時已超出限制,或是在 :class:" +"`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱\\ :ref:`整" +"數字串轉換的長度限制 `\\ 說明文件。" #: ../../library/functions.rst:1069 msgid "" @@ -1933,18 +1929,18 @@ msgid "" "the function always returns ``False``. If *classinfo* is a tuple of type " "objects (or recursively, other such tuples) or a :ref:`types-union` of " "multiple types, return ``True`` if *object* is an instance of any of the " -"types. If *classinfo* is not a type or tuple of types and such tuples, " -"a :exc:`TypeError` exception is raised. :exc:`TypeError` may not be raised " -"for an invalid type if an earlier check succeeds." -msgstr "" -"如果 *object* 引數是 *classinfo* 引數的實例,或者是(直接、間接" -"或 :term:`virtual `)subclass 的實例,則回傳 ``True``。" -"如果 *object* 不是給定型別的物件,函式始終回傳 ``False``。如果 *classinfo* 是" -"包含物件型別的 tuple(或多個遞迴 tuple)或一個包含多種型別的 :ref:`types-" -"union`,若 *object* 是其中的任何一個物件的實例則回傳 ``True``。如果 " -"*classinfo* 既不是型別,也不是型別 tuple 或型別的遞迴 tuple,那麼會引" -"發 :exc:`TypeError` 異常。若是先前檢查已經成功,:exc:`TypeError` 可能不會再因" -"為不合格的型別而被引發。" +"types. If *classinfo* is not a type or tuple of types and such tuples, a :" +"exc:`TypeError` exception is raised. :exc:`TypeError` may not be raised for " +"an invalid type if an earlier check succeeds." +msgstr "" +"如果 *object* 引數是 *classinfo* 引數的實例,或者是(直接、間接或 :term:" +"`virtual `)subclass 的實例,則回傳 ``True``。如果 " +"*object* 不是給定型別的物件,函式始終回傳 ``False``。如果 *classinfo* 是包含" +"物件型別的 tuple(或多個遞迴 tuple)或一個包含多種型別的 :ref:`types-union`," +"若 *object* 是其中的任何一個物件的實例則回傳 ``True``。如果 *classinfo* 既不" +"是型別,也不是型別 tuple 或型別的遞迴 tuple,那麼會引發 :exc:`TypeError` 異" +"常。若是先前檢查已經成功,:exc:`TypeError` 可能不會再因為不合格的型別而被引" +"發。" #: ../../library/functions.rst:1080 ../../library/functions.rst:1094 msgid "*classinfo* can be a :ref:`types-union`." @@ -1952,27 +1948,27 @@ msgstr "*classinfo* 可以是一個 :ref:`types-union`。" #: ../../library/functions.rst:1086 msgid "" -"Return ``True`` if *class* is a subclass (direct, indirect, " -"or :term:`virtual `) of *classinfo*. A class is " -"considered a subclass of itself. *classinfo* may be a tuple of class objects " -"(or recursively, other such tuples) or a :ref:`types-union`, in which case " +"Return ``True`` if *class* is a subclass (direct, indirect, or :term:" +"`virtual `) of *classinfo*. A class is considered a " +"subclass of itself. *classinfo* may be a tuple of class objects (or " +"recursively, other such tuples) or a :ref:`types-union`, in which case " "return ``True`` if *class* is a subclass of any entry in *classinfo*. In " "any other case, a :exc:`TypeError` exception is raised." msgstr "" "如果 *class* 是 *classinfo* 的 subclass(直接、間接或 :term:`virtual " "`),則回傳 ``True``。*classinfo* 可以是 class 物件的 " "tuple(或遞迴地其他類似 tuple)或是一個 :ref:`types-union`,此時若 *class* " -"是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引" -"發 :exc:`TypeError`。" +"是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引發 :" +"exc:`TypeError`。" #: ../../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 " -"second argument, *object* must be a collection object which supports " -"the :term:`iterable` protocol (the :meth:`~object.__iter__` method), or it " -"must support the sequence protocol (the :meth:`~object.__getitem__` method " -"with integer arguments starting at ``0``). If it does not support either of " +"second argument, *object* must be a collection object which supports the :" +"term:`iterable` protocol (the :meth:`~object.__iter__` method), or it must " +"support the sequence protocol (the :meth:`~object.__getitem__` method with " +"integer arguments starting at ``0``). If it does not support either of " "those protocols, :exc:`TypeError` is raised. If the second argument, " "*sentinel*, is given, then *object* must be a callable object. The iterator " "created in this case will call *object* with no arguments for each call to " @@ -1981,13 +1977,13 @@ msgid "" "returned." msgstr "" "回傳一個 :term:`iterator` 物件。根據是否存在第二個引數,第一個引數的意義是非" -"常不同的。如果沒有第二個引數,*object* 必須是支援 :term:`iterable` 協定" -"(有 :meth:`~object.__iter__` method)的集合物件,或必須支援序列協定" -"(有 :meth:`~object.__getitem__` 方法,且數字引數從 ``0`` 開始)。如果它不支" -"援這些協定,會引發 :exc:`TypeError`。如果有第二個引數 *sentinel*,那麼 " -"*object* 必須是可呼叫的物件,這種情況下生成的 iterator,每次疊代呼" -"叫 :meth:`~iterator.__next__` 時會不帶引數地呼叫 *object*;如果回傳的結果是 " -"*sentinel* 則引發 :exc:`StopIteration`,否則回傳呼叫結果。" +"常不同的。如果沒有第二個引數,*object* 必須是支援 :term:`iterable` 協定(有 :" +"meth:`~object.__iter__` method)的集合物件,或必須支援序列協定(有 :meth:" +"`~object.__getitem__` 方法,且數字引數從 ``0`` 開始)。如果它不支援這些協定," +"會引發 :exc:`TypeError`。如果有第二個引數 *sentinel*,那麼 *object* 必須是可" +"呼叫的物件,這種情況下生成的 iterator,每次疊代呼叫 :meth:`~iterator." +"__next__` 時會不帶引數地呼叫 *object*;如果回傳的結果是 *sentinel* 則引發 :" +"exc:`StopIteration`,否則回傳呼叫結果。" #: ../../library/functions.rst:1115 msgid "See also :ref:`typeiter`." @@ -2025,8 +2021,8 @@ msgstr "" #: ../../library/functions.rst:1135 msgid "" -"``len`` raises :exc:`OverflowError` on lengths larger " -"than :data:`sys.maxsize`, such as :class:`range(2 ** 100) `." +"``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." +"maxsize`, such as :class:`range(2 ** 100) `." msgstr "" "如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," "則 ``len`` 會引發 :exc:`OverflowError`。" @@ -2049,8 +2045,8 @@ msgstr "" #: ../../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`." +"single namespace, this function returns the same namespace as :func:" +"`globals`." msgstr "" #: ../../library/functions.rst:1158 @@ -2111,10 +2107,10 @@ msgstr "" #: ../../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:`optimized scopes ` is now as described above. " -"Aside from being defined, the behaviour in other scopes remains unchanged " -"from previous versions." +"returned from this function are now defined. The behavior in :term:" +"`optimized scopes ` is now as described above. Aside from " +"being defined, the behaviour in other scopes remains unchanged from previous " +"versions." msgstr "" #: ../../library/functions.rst:1203 @@ -2152,20 +2148,20 @@ 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 " "*default* argument specifies an object to return if the provided iterable is " -"empty. If the iterable is empty and *default* is not provided, " -"a :exc:`ValueError` is raised." +"empty. If the iterable is empty and *default* is not provided, a :exc:" +"`ValueError` is raised." msgstr "" "這個函式有兩個選擇性的僅限關鍵字引數。*key* 引數能指定單一引數所使用的排序函" "式,如同 :meth:`list.sort` 的使用方式。*default* 引數是當 iterable 為空時回傳" -"的物件。如果 iterable 為空,並且沒有提供 *default*,則會引" -"發 :exc:`ValueError`。" +"的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" +"`ValueError`。" #: ../../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 " -"such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and " -"``heapq.nlargest(1, iterable, key=keyfunc)``." +"such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and ``heapq." +"nlargest(1, iterable, key=keyfunc)``." msgstr "" "如果有多個最大元素,則此函式將回傳第一個找到的。這和其他穩定排序工具如 " "``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " @@ -2181,8 +2177,8 @@ msgstr "*key* 可以為 ``None``。" #: ../../library/functions.rst:1245 msgid "" -"Return a \"memory view\" object created from the given argument. " -"See :ref:`typememoryview` for more information." +"Return a \"memory view\" object created from the given argument. See :ref:" +"`typememoryview` for more information." msgstr "" "回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" "閱\\ :ref:`typememoryview`。" @@ -2215,14 +2211,13 @@ msgstr "" #: ../../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 iterator is exhausted, otherwise :exc:`StopIteration` is " -"raised." +"Retrieve the next item from the :term:`iterator` by calling its :meth:" +"`~iterator.__next__` method. If *default* is given, it is returned if the " +"iterator is exhausted, otherwise :exc:`StopIteration` is raised." msgstr "" "透過呼叫 :term:`iterator` 的 :meth:`~iterator.__next__` method 取得下一個元" -"素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引" -"發 :exc:`StopIteration`。" +"素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" +"exc:`StopIteration`。" #: ../../library/functions.rst:1289 msgid "" @@ -2251,8 +2246,8 @@ msgid "" "integer. For example:" msgstr "" "將一個整數轉變為一個前綴為 \"0o\" 的八進位制字串。回傳結果是一個有效的 " -"Python 運算式。如果 *x* 不是 Python 的 :class:`int` 物件,那它需要定" -"義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" +"Python 運算式。如果 *x* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:" +"`~object.__index__` method 回傳一個整數。舉例來說:" #: ../../library/functions.rst:1313 msgid "" @@ -2293,18 +2288,18 @@ msgid "" "already exists), ``'x'`` for exclusive creation, and ``'a'`` for appending " "(which on *some* Unix systems, means that *all* writes append to the end of " "the file regardless of the current seek position). In text mode, if " -"*encoding* is not specified the encoding used is platform-" -"dependent: :func:`locale.getencoding` is called to get the current locale " -"encoding. (For reading and writing raw bytes use binary mode and leave " -"*encoding* unspecified.) The available modes are:" +"*encoding* is not specified the encoding used is platform-dependent: :func:" +"`locale.getencoding` is called to get the current locale encoding. (For " +"reading and writing raw bytes use binary mode and leave *encoding* " +"unspecified.) The available modes are:" msgstr "" "*mode* 是一個選擇性字串,用於指定開啟檔案的模式。預設值是 ``'r'``,這意味著它" "以文字模式開啟並讀取。其他常見模式有:寫入 ``'w'``\\ (會捨去已經存在的檔" "案)、唯一性建立 ``'x'``、追加寫入 ``'a'``\\ (在\\ *一些* Unix 系統上,無論" "目前的檔案指標在什麼位置,*所有* 寫入都會追加到檔案末尾)。在文字模式,如果沒" -"有指定 *encoding*,則根據電腦平臺來決定使用的編碼:呼" -"叫 :func:`locale.getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 " -"bytes,請使用二進位制模式且不要指定 *encoding*。)可用的模式有:" +"有指定 *encoding*,則根據電腦平臺來決定使用的編碼:呼叫 :func:`locale." +"getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" +"式且不要指定 *encoding*。)可用的模式有:" #: ../../library/functions.rst:1357 msgid "Character" @@ -2434,9 +2429,9 @@ msgid "" "systems, the buffer will typically be 4096 or 8192 bytes long." msgstr "" "二進制檔案會以固定大小的區塊進行緩衝;緩衝區的大小是使用啟發式嘗試 " -"(heuristic trying) 來決定底層設備的「區塊大小」,並會回退" -"到 :attr:`io.DEFAULT_BUFFER_SIZE`。在許多系統上,緩衝區的長度通常為 4096 或 " -"8192 個位元組。" +"(heuristic trying) 來決定底層設備的「區塊大小」,並會回退到 :attr:`io." +"DEFAULT_BUFFER_SIZE`。在許多系統上,緩衝區的長度通常為 4096 或 8192 個位元" +"組。" #: ../../library/functions.rst:1401 msgid "" @@ -2465,9 +2460,8 @@ msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " "standard error handlers are available (listed under :ref:`error-handlers`), " -"though any error handling name that has been registered " -"with :func:`codecs.register_error` is also valid. The standard names " -"include:" +"though any error handling name that has been registered with :func:`codecs." +"register_error` is also valid. The standard names include:" msgstr "" "*errors* 是一個選擇性的字串,用於指定要如何處理編碼和解碼的錯誤——它不能在二進" "制模式下使用。有許多不同的標準錯誤處理程式(error handler,在\\ :ref:`error-" @@ -2561,10 +2555,10 @@ msgstr "" #: ../../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, :data:`os.linesep`. If *newline* is ``''`` or ``'\\n'``, no " -"translation takes place. If *newline* is any of the other legal values, any " -"``'\\n'`` characters written are translated to the given string." +"characters written are translated to the system default line separator, :" +"data:`os.linesep`. If *newline* is ``''`` or ``'\\n'``, no translation " +"takes place. If *newline* is any of the other legal values, any ``'\\n'`` " +"characters written are translated to the given string." msgstr "" "將輸出寫入資料串流時,如果 *newline* 是 ``None``,則被寫入的任何 ``'\\n'`` 字" "元都會轉換為系統預設的行分隔符號 :data:`os.linesep`。如果 *newline* 是 " @@ -2601,8 +2595,8 @@ msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" #: ../../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::" +"The following example uses the :ref:`dir_fd ` parameter of the :func:" +"`os.open` function to open a file relative to a given directory::" msgstr "" "下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," "從給定的目錄中用相對路徑開啟檔案: ::" @@ -2624,35 +2618,35 @@ msgstr "" 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 " -"mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass " -"of :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When " -"used to open a file in a binary mode with buffering, the returned class is a " +"mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of :" +"class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used " +"to open a file in a binary mode with buffering, the returned class is a " "subclass of :class:`io.BufferedIOBase`. The exact class varies: in read " "binary mode, it returns an :class:`io.BufferedReader`; in write binary and " "append binary modes, it returns an :class:`io.BufferedWriter`, and in read/" "write mode, it returns an :class:`io.BufferedRandom`. When buffering is " -"disabled, the raw stream, a subclass " -"of :class:`io.RawIOBase`, :class:`io.FileIO`, is returned." +"disabled, the raw stream, a subclass of :class:`io.RawIOBase`, :class:`io." +"FileIO`, is returned." msgstr "" ":func:`open` 函式回傳的 :term:`file object` 型別取決於模式。當 :func:`open` " "是在文字模式中開啟檔案時(``'w'``、``'r'``、``'wt'``、``'rt'`` 等),它會回" -"傳 :class:`io.TextIOBase` 的一個 subclass(具體來說,就" -"是 :class:`io.TextIOWrapper`)。使用有緩衝的二進制模式開啟檔案時,回傳的 " -"class 則會是 :class:`io.BufferedIOBase` 的 subclass。確切的 class 各不相同:" -"在讀取的二進制模式,它會回傳 :class:`io.BufferedReader`;在寫入和附加的二進制" -"模式,它會回傳 :class:`io.BufferedWriter`,而在讀/寫模式,它會回" -"傳 :class:`io.BufferedRandom`。當緩衝被停用時,會回傳原始資料串" -"流 :class:`io.FileIO`,它是 :class:`io.RawIOBase` 的一個 subclass。" +"傳 :class:`io.TextIOBase` 的一個 subclass(具體來說,就是 :class:`io." +"TextIOWrapper`)。使用有緩衝的二進制模式開啟檔案時,回傳的 class 則會是 :" +"class:`io.BufferedIOBase` 的 subclass。確切的 class 各不相同:在讀取的二進制" +"模式,它會回傳 :class:`io.BufferedReader`;在寫入和附加的二進制模式,它會回" +"傳 :class:`io.BufferedWriter`,而在讀/寫模式,它會回傳 :class:`io." +"BufferedRandom`。當緩衝被停用時,會回傳原始資料串流 :class:`io.FileIO`,它" +"是 :class:`io.RawIOBase` 的一個 subclass。" #: ../../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:`tempfile`, and :mod:`shutil`." +"(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" +"`tempfile`, and :mod:`shutil`." msgstr "" -"另請參閱檔案操作模組,例如 :mod:`fileinput`、:mod:`io`\\ (定義" -"了 :func:`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以" -"及 :mod:`shutil`。" +"另請參閱檔案操作模組,例如 :mod:`fileinput`、:mod:`io`\\ (定義了 :func:" +"`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以及 :mod:" +"`shutil`。" #: ../../library/functions.rst:1520 msgid "" @@ -2685,8 +2679,8 @@ msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." msgstr "" -"如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引" -"發 :exc:`FileExistsError`。" +"如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引發 :exc:" +"`FileExistsError`。" #: ../../library/functions.rst:1535 msgid "The file is now non-inheritable." @@ -2695,8 +2689,8 @@ msgstr "檔案在此版本開始是不可繼承的。" #: ../../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 :exc:`InterruptedError` exception (see :pep:`475` for the rationale)." +"exception, the function now retries the system call instead of raising an :" +"exc:`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" "如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" "不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" @@ -2711,8 +2705,8 @@ msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" #: ../../library/functions.rst:1547 msgid "" -"On Windows, opening a console buffer may return a subclass " -"of :class:`io.RawIOBase` other than :class:`io.FileIO`." +"On Windows, opening a console buffer may return a subclass of :class:`io." +"RawIOBase` other than :class:`io.FileIO`." msgstr "" "在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " "subclass,而不是 :class:`io.FileIO`。" @@ -2753,9 +2747,9 @@ msgid "" "2)`` returns ``100``, but ``pow(10, -2)`` returns ``0.01``. For a negative " "base of type :class:`int` or :class:`float` and a non-integral exponent, a " "complex result is delivered. For example, ``pow(-9, 0.5)`` returns a value " -"close to ``3j``. Whereas, for a negative base of type :class:`int` " -"or :class:`float` with an integral exponent, a float result is delivered. " -"For example, ``pow(-9, 2.0)`` returns ``81.0``." +"close to ``3j``. Whereas, for a negative base of type :class:`int` or :class:" +"`float` with an integral exponent, a float result is delivered. For example, " +"``pow(-9, 2.0)`` returns ``81.0``." msgstr "" "引數必須是數值型別。對於混合型別的運算元,會套用二元算術運算子的強制轉型 " "(coercion) 規則。對於 :class:`int` 運算元,運算結果會(在強制轉型後)與運算元" @@ -2763,9 +2757,9 @@ msgstr "" "並得到浮點數的結果。例如,``pow(10, 2)`` 會回傳 ``100``,但 ``pow(10, -2)`` " "會回傳 ``0.01``。如果底數 (base) 是型別為 :class:`int` 或 :class:`float` 的負" "數且指數 (exponent) 不是整數,則會得到一個複數的結果,例如 ``pow(-9, 0.5)`` " -"會回傳一個接近 ``3j`` 的值。如果底數 (base) 是型別為 :class:`int` " -"或 :class:`float` 的負數且指數為整數,則會得到一個浮點數的結果,例如 " -"``pow(-9, 2.0)`` 會回傳 ``81.0``。" +"會回傳一個接近 ``3j`` 的值。如果底數 (base) 是型別為 :class:`int` 或 :class:" +"`float` 的負數且指數為整數,則會得到一個浮點數的結果,例如 ``pow(-9, 2.0)`` " +"會回傳 ``81.0``。" #: ../../library/functions.rst:1580 msgid "" @@ -2916,12 +2910,12 @@ msgstr "" 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 " -"possible to create read-only properties easily using :func:`property` as " -"a :term:`decorator`::" +"possible to create read-only properties easily using :func:`property` as a :" +"term:`decorator`::" msgstr "" "如果有給定 *doc*,它將會是 property 屬性的說明字串。否則,property 會複製 " -"*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使" -"用 :func:`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" +"*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" +"`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" #: ../../library/functions.rst:1660 msgid "" @@ -3052,10 +3046,10 @@ msgstr "" #: ../../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 :meth:`~object.__len__` method and the :meth:`~object.__getitem__` " -"method with integer arguments starting at ``0``)." +"Return a reverse :term:`iterator`. *seq* must be an object which has a :" +"meth:`~object.__reversed__` method or supports the sequence protocol (the :" +"meth:`~object.__len__` method and the :meth:`~object.__getitem__` method " +"with integer arguments starting at ``0``)." msgstr "" #: ../../library/functions.rst:1762 @@ -3078,8 +3072,8 @@ msgstr "" #: ../../library/functions.rst:1775 msgid "" -"For a general Python object ``number``, ``round`` delegates to " -"``number.__round__``." +"For a general Python object ``number``, ``round`` delegates to ``number." +"__round__``." msgstr "" #: ../../library/functions.rst:1780 @@ -3100,9 +3094,9 @@ msgstr "" #: ../../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." +"For other containers see the built-in :class:`frozenset`, :class:`list`, :" +"class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " +"module." msgstr "" #: ../../library/functions.rst:1803 @@ -3117,10 +3111,10 @@ msgstr "" #: ../../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:`~object.__getattribute__` or via :attr:`~object.__slots__`. An " -"attribute whose name is not an identifier will not be accessible using the " -"dot notation, but is accessible through :func:`getattr` etc.." +"unless the object chooses to enforce that, for example in a custom :meth:" +"`~object.__getattribute__` or via :attr:`~object.__slots__`. An attribute " +"whose name is not an identifier will not be accessible using the dot " +"notation, but is accessible through :func:`getattr` etc.." msgstr "" #: ../../library/functions.rst:1817 @@ -3137,7 +3131,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/functions.rst:1834 +#: ../../library/functions.rst:1830 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3148,16 +3142,14 @@ msgstr "" #: ../../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`." +"example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" +"`itertools.islice` for an alternate version that returns an :term:`iterator`." msgstr "" #: ../../library/functions.rst:1844 msgid "" -"Slice objects are now :term:`hashable` " -"(provided :attr:`~slice.start`, :attr:`~slice.stop`, and :attr:`~slice.step` " -"are hashable)." +"Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" +"`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" #: ../../library/functions.rst:1850 @@ -3172,9 +3164,8 @@ msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" #: ../../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)." +"comparison key from each element in *iterable* (for example, ``key=str." +"lower``). The default value is ``None`` (compare the elements directly)." msgstr "" #: ../../library/functions.rst:1858 @@ -3236,8 +3227,8 @@ msgstr "" #: ../../library/functions.rst:1891 msgid "" -"The ``@staticmethod`` form is a function :term:`decorator` -- " -"see :ref:`function` for details." +"The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" +"`function` for details." msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" @@ -3245,9 +3236,9 @@ msgstr "" #: ../../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:`descriptor` is also callable, so it can be used in the class " -"definition (such as ``f()``)." +"an instance (such as ``C().f()``). Moreover, the static method :term:" +"`descriptor` is also callable, so it can be used in the class definition " +"(such as ``f()``)." msgstr "" #: ../../library/functions.rst:1899 @@ -3286,15 +3277,15 @@ msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" #: ../../library/functions.rst:1917 msgid "" -"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." +"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 "" -"Static method 現在繼承了 method 屬性" -"(:attr:`~function.__module__`、:attr:`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function.__doc__` " -"和 :attr:`~function.__annotations__`),並擁有一個新的 ``__wrapped__`` 屬性," -"且為如一般函式的可呼叫物件。" +"Static method 現在繼承了 method 屬性(:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " +"``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" #: ../../library/functions.rst:1933 msgid "" @@ -3317,10 +3308,10 @@ msgstr "" #: ../../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 " -"``''.join(sequence)``. To add floating-point values with extended " -"precision, see :func:`math.fsum`\\. To concatenate a series of iterables, " -"consider using :func:`itertools.chain`." +"preferred, fast way to concatenate a sequence of strings is by calling ``''." +"join(sequence)``. To add floating-point values with extended precision, " +"see :func:`math.fsum`\\. To concatenate a series of iterables, consider " +"using :func:`itertools.chain`." msgstr "" #: ../../library/functions.rst:1951 @@ -3348,17 +3339,17 @@ msgstr "" #: ../../library/functions.rst:1969 msgid "" -"For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C " -"-> A -> object`` and the value of *type* is ``B``, then :func:`super` " +"For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" +"> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" #: ../../library/functions.rst:1973 msgid "" "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." +"*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:1978 @@ -3441,9 +3432,9 @@ msgstr "" #: ../../library/functions.rst:2031 msgid "" -"For practical suggestions on how to design cooperative classes " -"using :func:`super`, see `guide to using super() `_." +"For practical suggestions on how to design cooperative classes using :func:" +"`super`, see `guide to using super() `_." msgstr "" #: ../../library/functions.rst:2041 @@ -3455,8 +3446,8 @@ msgstr "" #: ../../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__`." +"type object and generally the same object as returned by :attr:`object." +"__class__`." msgstr "" #: ../../library/functions.rst:2054 @@ -3473,9 +3464,9 @@ msgid "" "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:" +"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:2072 @@ -3518,11 +3509,10 @@ msgstr "" #: ../../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:`!__dict__` attributes (for example, " -"classes use a :class:`types.MappingProxyType` to prevent direct dictionary " -"updates)." +"Objects such as modules and instances have an updateable :attr:`~object." +"__dict__` attribute; however, other objects may have write restrictions on " +"their :attr:`!__dict__` attributes (for example, classes use a :class:`types." +"MappingProxyType` to prevent direct dictionary updates)." msgstr "" #: ../../library/functions.rst:2099 @@ -3577,15 +3567,15 @@ msgstr "" #: ../../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 `_." +"columns into rows. This is similar to `transposing a matrix `_." msgstr "" #: ../../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`." +"iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" +"`list`." msgstr "" #: ../../library/functions.rst:2136 @@ -3642,8 +3632,8 @@ msgstr "" #: ../../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`." +"iterables have the same length. This is done by :func:`itertools." +"zip_longest`." msgstr "" #: ../../library/functions.rst:2181 diff --git a/library/http.server.po b/library/http.server.po index 73e6238b9b..eee3322781 100644 --- a/library/http.server.po +++ b/library/http.server.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-16 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -31,8 +31,8 @@ msgstr "此模組定義了用於實作 HTTP 伺服器的類別。" #: ../../library/http.server.rst:22 msgid "" -":mod:`http.server` is not recommended for production. It only " -"implements :ref:`basic security checks `." +":mod:`http.server` is not recommended for production. It only implements :" +"ref:`basic security checks `." msgstr "" #: ../../includes/wasm-notavail.rst:3 @@ -69,9 +69,9 @@ msgstr "" #: ../../library/http.server.rst:39 msgid "" "This class builds on the :class:`~socketserver.TCPServer` class by storing " -"the server address as instance variables named :attr:`server_name` " -"and :attr:`server_port`. The server is accessible by the handler, typically " -"through the handler's :attr:`server` instance variable." +"the server address as instance variables named :attr:`server_name` and :attr:" +"`server_port`. The server is accessible by the handler, typically through " +"the handler's :attr:`server` instance variable." msgstr "" #: ../../library/http.server.rst:46 @@ -93,9 +93,9 @@ msgstr "" msgid "" "This class is used to handle the HTTP requests that arrive at the server. " "By itself, it cannot respond to any actual HTTP requests; it must be " -"subclassed to handle each request method (e.g. GET or " -"POST). :class:`BaseHTTPRequestHandler` provides a number of class and " -"instance variables, and methods for use by subclasses." +"subclassed to handle each request method (e.g. GET or POST). :class:" +"`BaseHTTPRequestHandler` provides a number of class and instance variables, " +"and methods for use by subclasses." msgstr "" #: ../../library/http.server.rst:66 @@ -132,9 +132,9 @@ msgstr "" #: ../../library/http.server.rst:92 msgid "" "Contains the string representation of the HTTP request line. The terminating " -"CRLF is stripped. This attribute should be set " -"by :meth:`handle_one_request`. If no valid request line was processed, it " -"should be set to the empty string." +"CRLF is stripped. This attribute should be set by :meth:" +"`handle_one_request`. If no valid request line was processed, it should be " +"set to the empty string." msgstr "" #: ../../library/http.server.rst:99 @@ -192,9 +192,9 @@ msgstr "" #: ../../library/http.server.rst:144 msgid "" -"Contains the Python system version, in a form usable by " -"the :attr:`version_string` method and the :attr:`server_version` class " -"variable. For example, ``'Python/1.4'``." +"Contains the Python system version, in a form usable by the :attr:" +"`version_string` method and the :attr:`server_version` class variable. For " +"example, ``'Python/1.4'``." msgstr "" #: ../../library/http.server.rst:150 @@ -225,8 +225,8 @@ msgstr "" #: ../../library/http.server.rst:172 msgid "" "Specifies an :class:`email.message.Message`\\ -like class to parse HTTP " -"headers. Typically, this is not overridden, and it defaults " -"to :class:`http.client.HTTPMessage`." +"headers. Typically, this is not overridden, and it defaults to :class:`http." +"client.HTTPMessage`." msgstr "" #: ../../library/http.server.rst:178 @@ -307,8 +307,8 @@ msgid "" "Adds the HTTP header to an internal buffer which will be written to the " "output stream when either :meth:`end_headers` or :meth:`flush_headers` is " "invoked. *keyword* should specify the header keyword, with *value* " -"specifying its value. Note that, after the send_header calls are " -"done, :meth:`end_headers` MUST BE called in order to complete the operation." +"specifying its value. Note that, after the send_header calls are done, :meth:" +"`end_headers` MUST BE called in order to complete the operation." msgstr "" #: ../../library/http.server.rst:250 @@ -357,15 +357,15 @@ msgstr "" msgid "" "Logs an arbitrary message to ``sys.stderr``. This is typically overridden to " "create custom error logging mechanisms. The *format* argument is a standard " -"printf-style format string, where the additional arguments " -"to :meth:`log_message` are applied as inputs to the formatting. The client " -"ip address and current date and time are prefixed to every message logged." +"printf-style format string, where the additional arguments to :meth:" +"`log_message` are applied as inputs to the formatting. The client ip address " +"and current date and time are prefixed to every message logged." msgstr "" #: ../../library/http.server.rst:301 msgid "" -"Returns the server software's version string. This is a combination of " -"the :attr:`server_version` and :attr:`sys_version` attributes." +"Returns the server software's version string. This is a combination of the :" +"attr:`server_version` and :attr:`sys_version` attributes." msgstr "" #: ../../library/http.server.rst:306 @@ -410,15 +410,15 @@ msgstr "" #: ../../library/http.server.rst:337 msgid "" -"A lot of the work, such as parsing the request, is done by the base " -"class :class:`BaseHTTPRequestHandler`. This class implements " -"the :func:`do_GET` and :func:`do_HEAD` functions." +"A lot of the work, such as parsing the request, is done by the base class :" +"class:`BaseHTTPRequestHandler`. This class implements the :func:`do_GET` " +"and :func:`do_HEAD` functions." msgstr "" #: ../../library/http.server.rst:341 msgid "" -"The following are defined as class-level attributes " -"of :class:`SimpleHTTPRequestHandler`:" +"The following are defined as class-level attributes of :class:" +"`SimpleHTTPRequestHandler`:" msgstr "" #: ../../library/http.server.rst:346 @@ -463,9 +463,9 @@ msgid "" "If the request was mapped to a directory, the directory is checked for a " "file named ``index.html`` or ``index.htm`` (in that order). If found, the " "file's contents are returned; otherwise a directory listing is generated by " -"calling the :meth:`list_directory` method. This method " -"uses :func:`os.listdir` to scan the directory, and returns a ``404`` error " -"response if the :func:`~os.listdir` fails." +"calling the :meth:`list_directory` method. This method uses :func:`os." +"listdir` to scan the directory, and returns a ``404`` error response if the :" +"func:`~os.listdir` fails." msgstr "" #: ../../library/http.server.rst:379 @@ -489,28 +489,27 @@ msgstr "" #: ../../library/http.server.rst:391 msgid "" "Then follows a blank line signifying the end of the headers, and then the " -"contents of the file are output. If the file's MIME type starts with ``text/" -"`` the file is opened in text mode; otherwise binary mode is used." +"contents of the file are output." msgstr "" -#: ../../library/http.server.rst:395 +#: ../../library/http.server.rst:394 msgid "" -"For example usage, see the implementation of the ``test`` function " -"in :source:`Lib/http/server.py`." +"For example usage, see the implementation of the ``test`` function in :" +"source:`Lib/http/server.py`." msgstr "" -#: ../../library/http.server.rst:398 +#: ../../library/http.server.rst:397 msgid "Support of the ``'If-Modified-Since'`` header." msgstr "" -#: ../../library/http.server.rst:401 +#: ../../library/http.server.rst:400 msgid "" "The :class:`SimpleHTTPRequestHandler` class can be used in the following " "manner in order to create a very basic webserver serving files relative to " "the current directory::" msgstr "" -#: ../../library/http.server.rst:405 +#: ../../library/http.server.rst:404 msgid "" "import http.server\n" "import socketserver\n" @@ -534,28 +533,28 @@ msgstr "" " print(\"serving at port\", PORT)\n" " httpd.serve_forever()" -#: ../../library/http.server.rst:417 +#: ../../library/http.server.rst:416 msgid "" ":class:`SimpleHTTPRequestHandler` can also be subclassed to enhance " "behavior, such as using different index file names by overriding the class " "attribute :attr:`index_pages`." msgstr "" -#: ../../library/http.server.rst:424 +#: ../../library/http.server.rst:423 msgid "" "This class is used to serve either files or output of CGI scripts from the " "current directory and below. Note that mapping HTTP hierarchic structure to " "local directory structure is exactly as in :class:`SimpleHTTPRequestHandler`." msgstr "" -#: ../../library/http.server.rst:430 +#: ../../library/http.server.rst:429 msgid "" "CGI scripts run by the :class:`CGIHTTPRequestHandler` class cannot execute " "redirects (HTTP code 302), because code 200 (script output follows) is sent " "prior to execution of the CGI script. This pre-empts the status code." msgstr "" -#: ../../library/http.server.rst:435 +#: ../../library/http.server.rst:434 msgid "" "The class will however, run the CGI script, instead of serving it as a file, " "if it guesses it to be a CGI script. Only directory-based CGI are used --- " @@ -563,79 +562,79 @@ msgid "" "denoting CGI scripts." msgstr "" -#: ../../library/http.server.rst:440 +#: ../../library/http.server.rst:439 msgid "" "The :func:`do_GET` and :func:`do_HEAD` functions are modified to run CGI " "scripts and serve the output, instead of serving files, if the request leads " "to somewhere below the ``cgi_directories`` path." msgstr "" -#: ../../library/http.server.rst:444 +#: ../../library/http.server.rst:443 msgid "The :class:`CGIHTTPRequestHandler` defines the following data member:" msgstr "" -#: ../../library/http.server.rst:448 +#: ../../library/http.server.rst:447 msgid "" "This defaults to ``['/cgi-bin', '/htbin']`` and describes directories to " "treat as containing CGI scripts." msgstr "" -#: ../../library/http.server.rst:451 +#: ../../library/http.server.rst:450 msgid "The :class:`CGIHTTPRequestHandler` defines the following method:" msgstr "" -#: ../../library/http.server.rst:455 +#: ../../library/http.server.rst:454 msgid "" "This method serves the ``'POST'`` request type, only allowed for CGI " "scripts. Error 501, \"Can only POST to CGI scripts\", is output when trying " "to POST to a non-CGI url." msgstr "" -#: ../../library/http.server.rst:459 +#: ../../library/http.server.rst:458 msgid "" "Note that CGI scripts will be run with UID of user nobody, for security " "reasons. Problems with the CGI script will be translated to error 403." msgstr "" -#: ../../library/http.server.rst:464 +#: ../../library/http.server.rst:463 msgid "" ":class:`CGIHTTPRequestHandler` is being removed in 3.15. CGI has not been " "considered a good way to do things for well over a decade. This code has " "been unmaintained for a while now and sees very little practical use. " -"Retaining it could lead to further :ref:`security considerations " -"`." +"Retaining it could lead to further :ref:`security considerations `." msgstr "" -#: ../../library/http.server.rst:474 +#: ../../library/http.server.rst:473 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/http.server.rst:476 +#: ../../library/http.server.rst:475 msgid "" ":mod:`http.server` can also be invoked directly using the :option:`-m` " "switch of the interpreter. The following example illustrates how to serve " "files relative to the current directory::" msgstr "" -#: ../../library/http.server.rst:480 +#: ../../library/http.server.rst:479 msgid "python -m http.server [OPTIONS] [port]" msgstr "python -m http.server [OPTIONS] [port]" -#: ../../library/http.server.rst:482 +#: ../../library/http.server.rst:481 msgid "The following options are accepted:" msgstr "可接受以下選項:" -#: ../../library/http.server.rst:488 +#: ../../library/http.server.rst:487 msgid "" "The server listens to port 8000 by default. The default can be overridden by " "passing the desired port number as an argument::" msgstr "" -#: ../../library/http.server.rst:491 +#: ../../library/http.server.rst:490 msgid "python -m http.server 9000" msgstr "python -m http.server 9000" -#: ../../library/http.server.rst:495 +#: ../../library/http.server.rst:494 msgid "" "Specifies a specific address to which it should bind. Both IPv4 and IPv6 " "addresses are supported. By default, the server binds itself to all " @@ -643,80 +642,80 @@ msgid "" "localhost only::" msgstr "" -#: ../../library/http.server.rst:500 +#: ../../library/http.server.rst:499 msgid "python -m http.server --bind 127.0.0.1" msgstr "python -m http.server --bind 127.0.0.1" -#: ../../library/http.server.rst:504 +#: ../../library/http.server.rst:503 msgid "Support IPv6 in the ``--bind`` option." msgstr "於 ``--bind`` 選項中支援 IPv6。" -#: ../../library/http.server.rst:509 +#: ../../library/http.server.rst:508 msgid "" "Specifies a directory to which it should serve the files. By default, the " "server uses the current directory. For example, the following command uses a " "specific directory::" msgstr "" -#: ../../library/http.server.rst:513 +#: ../../library/http.server.rst:512 msgid "python -m http.server --directory /tmp/" msgstr "python -m http.server --directory /tmp/" -#: ../../library/http.server.rst:519 +#: ../../library/http.server.rst:518 msgid "" "Specifies the HTTP version to which the server is conformant. By default, " "the server is conformant to HTTP/1.0. For example, the following command " "runs an HTTP/1.1 conformant server::" msgstr "" -#: ../../library/http.server.rst:523 +#: ../../library/http.server.rst:522 msgid "python -m http.server --protocol HTTP/1.1" msgstr "python -m http.server --protocol HTTP/1.1" -#: ../../library/http.server.rst:529 +#: ../../library/http.server.rst:528 msgid "" ":class:`CGIHTTPRequestHandler` can be enabled in the command line by passing " "the ``--cgi`` option::" msgstr "" -#: ../../library/http.server.rst:532 +#: ../../library/http.server.rst:531 msgid "python -m http.server --cgi" msgstr "python -m http.server --cgi" -#: ../../library/http.server.rst:536 +#: ../../library/http.server.rst:535 msgid "" -":mod:`http.server` command line ``--cgi`` support is being removed " -"because :class:`CGIHTTPRequestHandler` is being removed." +":mod:`http.server` command line ``--cgi`` support is being removed because :" +"class:`CGIHTTPRequestHandler` is being removed." msgstr "" -#: ../../library/http.server.rst:541 +#: ../../library/http.server.rst:540 msgid "" ":class:`CGIHTTPRequestHandler` and the ``--cgi`` command-line option are not " "intended for use by untrusted clients and may be vulnerable to exploitation. " "Always use within a secure environment." msgstr "" -#: ../../library/http.server.rst:549 +#: ../../library/http.server.rst:548 msgid "Security considerations" msgstr "安全性注意事項" -#: ../../library/http.server.rst:553 +#: ../../library/http.server.rst:552 msgid "" ":class:`SimpleHTTPRequestHandler` will follow symbolic links when handling " "requests, this makes it possible for files outside of the specified " "directory to be served." msgstr "" -#: ../../library/http.server.rst:557 +#: ../../library/http.server.rst:556 msgid "" "Earlier versions of Python did not scrub control characters from the log " -"messages emitted to stderr from ``python -m http.server`` or the " -"default :class:`BaseHTTPRequestHandler` ``.log_message`` implementation. " -"This could allow remote clients connecting to your server to send nefarious " -"control codes to your terminal." +"messages emitted to stderr from ``python -m http.server`` or the default :" +"class:`BaseHTTPRequestHandler` ``.log_message`` implementation. This could " +"allow remote clients connecting to your server to send nefarious control " +"codes to your terminal." msgstr "" -#: ../../library/http.server.rst:563 +#: ../../library/http.server.rst:562 msgid "Control characters are scrubbed in stderr logs." msgstr "" @@ -744,11 +743,11 @@ msgstr "URL(統一資源定位器)" msgid "httpd" msgstr "httpd" -#: ../../library/http.server.rst:551 +#: ../../library/http.server.rst:550 msgid "http.server" msgstr "http.server" -#: ../../library/http.server.rst:551 +#: ../../library/http.server.rst:550 msgid "security" msgstr "security(安全)" diff --git a/library/io.po b/library/io.po index d248520927..bbe8863356 100644 --- a/library/io.po +++ b/library/io.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-04 00:16+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-12-08 00:08+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -77,7 +77,7 @@ msgstr "" "原本會引發 :exc:`IOError` 的操作,現在將改成引發 :exc:`OSError`。因為 :exc:" "`IOError` 現在是 :exc:`OSError` 的別名。" -#: ../../library/io.rst:51 ../../library/io.rst:855 ../../library/io.rst:1150 +#: ../../library/io.rst:51 ../../library/io.rst:862 ../../library/io.rst:1158 msgid "Text I/O" msgstr "文字 I/O" @@ -118,7 +118,7 @@ msgid "" "`TextIOBase`." msgstr "文字資料串流 API 的詳細說明在 :class:`TextIOBase` 文件當中。" -#: ../../library/io.rst:72 ../../library/io.rst:1138 +#: ../../library/io.rst:72 ../../library/io.rst:1146 msgid "Binary I/O" msgstr "二進位 (Binary) I/O" @@ -778,7 +778,7 @@ msgid "" "negative" msgstr ":data:`os.SEEK_END` 或 ``2`` -- 串流的結尾;*offset* 通常是負數" -#: ../../library/io.rst:420 ../../library/io.rst:930 +#: ../../library/io.rst:420 ../../library/io.rst:938 msgid "The :data:`!SEEK_*` constants." msgstr ":data:`!SEEK_*` 常數。" @@ -934,31 +934,26 @@ msgstr "支援某種緩衝的二進位串流的基底類別。它繼承自 :clas msgid "" "The main difference with :class:`RawIOBase` is that methods :meth:`read`, :" "meth:`readinto` and :meth:`write` will try (respectively) to read as much " -"input as requested or to consume all given output, at the expense of making " -"perhaps more than one system call." +"input as requested or to emit all provided data." msgstr "" "與 :class:`RawIOBase` 的主要差異在於,:meth:`read`、:meth:`readinto` 及 :" -"meth:`write` 方法將分別嘗試讀取所請求的盡可能多的輸入,或消耗所有給定的輸出," -"即使可能需要進行多於一次的系統呼叫。" +"meth:`write` 方法將分別嘗試讀取所請求的盡可能多的輸入,或發出所有提供的資料。" -#: ../../library/io.rst:529 +#: ../../library/io.rst:528 msgid "" -"In addition, those methods can raise :exc:`BlockingIOError` if the " -"underlying raw stream is in non-blocking mode and cannot take or give enough " -"data; unlike their :class:`RawIOBase` counterparts, they will never return " -"``None``." +"In addition, if the underlying raw stream is in non-blocking mode, when the " +"system returns would block :meth:`write` will raise :exc:`BlockingIOError` " +"with :attr:`BlockingIOError.characters_written` and :meth:`read` will return " +"data read so far or ``None`` if no data is available." msgstr "" -"此外,如果底層的原始串流處於非阻塞模式且無法提供或接收足夠的資料,這些方法可" -"能會引發 :exc:`BlockingIOError` 例外;與 :class:`RawIOBase` 不同之處在於,它" -"們永遠不會回傳 ``None``。" -#: ../../library/io.rst:534 +#: ../../library/io.rst:533 msgid "" "Besides, the :meth:`read` method does not have a default implementation that " "defers to :meth:`readinto`." msgstr "此外,:meth:`read` 方法不存在一個遵從 :meth:`readinto` 的預設實作。" -#: ../../library/io.rst:537 +#: ../../library/io.rst:536 msgid "" "A typical :class:`BufferedIOBase` implementation should not inherit from a :" "class:`RawIOBase` implementation, but wrap one, like :class:`BufferedWriter` " @@ -968,7 +963,7 @@ msgstr "" "實作,而是應該改用包裝的方式,像 :class:`BufferedWriter` 和 :class:" "`BufferedReader` 那樣的作法。" -#: ../../library/io.rst:541 +#: ../../library/io.rst:540 msgid "" ":class:`BufferedIOBase` provides or overrides these data attributes and " "methods in addition to those from :class:`IOBase`:" @@ -976,7 +971,7 @@ msgstr "" ":class:`BufferedIOBase` 除了提供或覆寫來自 :class:`IOBase` 的資料屬性和方法以" "外,還包含了這些:" -#: ../../library/io.rst:546 +#: ../../library/io.rst:545 msgid "" "The underlying raw stream (a :class:`RawIOBase` instance) that :class:" "`BufferedIOBase` deals with. This is not part of the :class:" @@ -985,16 +980,16 @@ msgstr "" "底層的原始串流(一個 :class:`RawIOBase` 實例),:class:`BufferedIOBase` 處理" "的對象。這不是 :class:`BufferedIOBase` API 的一部分,且在某些實作可能不存在。" -#: ../../library/io.rst:552 +#: ../../library/io.rst:551 msgid "Separate the underlying raw stream from the buffer and return it." msgstr "將底層的原始串流從緩衝區中分離出來,並回傳它。" -#: ../../library/io.rst:554 +#: ../../library/io.rst:553 msgid "" "After the raw stream has been detached, the buffer is in an unusable state." msgstr "在原始串流被分離後,緩衝區處於一個不可用的狀態。" -#: ../../library/io.rst:557 +#: ../../library/io.rst:556 msgid "" "Some buffers, like :class:`BytesIO`, do not have the concept of a single raw " "stream to return from this method. They raise :exc:`UnsupportedOperation`." @@ -1002,56 +997,48 @@ msgstr "" "某些緩衝區,如 :class:`BytesIO`,沒有單一原始串流的概念可從此方法回傳。它們會" "引發 :exc:`UnsupportedOperation`。" -#: ../../library/io.rst:565 +#: ../../library/io.rst:564 msgid "" -"Read and return up to *size* bytes. If the argument is omitted, ``None``, " -"or negative, data is read and returned until EOF is reached. An empty :" -"class:`bytes` object is returned if the stream is already at EOF." +"Read and return up to *size* bytes. If the argument is omitted, ``None``, or " +"negative read as much as possible." msgstr "" "讀取並回傳最多 *size* 個位元組。如果引數被省略、為 ``None`` 或為負值,將讀取" -"並回傳資料直到達到 EOF 為止。如果串流已經處於 EOF,則回傳一個空的 :class:" -"`bytes` 物件。" +"盡可能最多的位元組。" -#: ../../library/io.rst:569 +#: ../../library/io.rst:567 msgid "" -"If the argument is positive, and the underlying raw stream is not " -"interactive, multiple raw reads may be issued to satisfy the byte count " -"(unless EOF is reached first). But for interactive raw streams, at most one " -"raw read will be issued, and a short result does not imply that EOF is " -"imminent." +"Fewer bytes may be returned than requested. An empty :class:`bytes` object " +"is returned if the stream is already at EOF. More than one read may be made " +"and calls may be retried if specific errors are encountered, see :meth:`os." +"read` and :pep:`475` for more details. Less than size bytes being returned " +"does not imply that EOF is imminent." msgstr "" -"如果引數為正數,且底層原始串流不是互動式的,可能會發出多次原始讀取來滿足位元" -"組數量(除非首先達到 EOF)。但對於互動式原始串流,最多只會發出一次原始讀取," -"且短少的資料不表示 EOF 即將到來。" -#: ../../library/io.rst:575 ../../library/io.rst:598 ../../library/io.rst:608 +#: ../../library/io.rst:573 msgid "" -"A :exc:`BlockingIOError` is raised if the underlying raw stream is in non " -"blocking-mode, and has no data available at the moment." +"When reading as much as possible the default implementation will use ``raw." +"readall`` if available (which should implement :meth:`RawIOBase.readall`), " +"otherwise will read in a loop until read returns ``None``, an empty :class:" +"`bytes`, or a non-retryable error. For most streams this is to EOF, but for " +"non-blocking streams more data may become available." msgstr "" -"如果底層原始串流處於非阻塞模式,且目前沒有可用資料,則會引發 :exc:" -"`BlockingIOError`。" -#: ../../library/io.rst:580 +#: ../../library/io.rst:582 ../../library/io.rst:595 msgid "" -"Read and return up to *size* bytes, with at most one call to the underlying " -"raw stream's :meth:`~RawIOBase.read` (or :meth:`~RawIOBase.readinto`) " -"method. This can be useful if you are implementing your own buffering on " -"top of a :class:`BufferedIOBase` object." +"When the underlying raw stream is non-blocking, implementations may either " +"raise :exc:`BlockingIOError` or return ``None`` if no data is available. :" +"mod:`io` implementations return ``None``." msgstr "" -"讀取並回傳最多 *size* 個位元組,最多呼叫一次底層原始串流的 :meth:`~RawIOBase." -"read` (或 :meth:`~RawIOBase.readinto`) 方法。如果你正在 :class:" -"`BufferedIOBase` 物件之上實作自己的緩衝區,這可能會很有用。" -#: ../../library/io.rst:586 +#: ../../library/io.rst:588 msgid "" -"If *size* is ``-1`` (the default), an arbitrary number of bytes are returned " -"(more than zero unless EOF is reached)." +"Read and return up to *size* bytes, calling :meth:`~RawIOBase.readinto` " +"which may retry if :py:const:`~errno.EINTR` is encountered per :pep:`475`. " +"If *size* is ``-1`` or not provided, the implementation will choose an " +"arbitrary value for *size*." msgstr "" -"如果 *size* 為 ``-1`` (預設值),則會回傳任意數量的位元組(除非達到 EOF,否" -"則會超過零)。" -#: ../../library/io.rst:591 +#: ../../library/io.rst:601 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b* and " "return the number of bytes read. For example, *b* might be a :class:" @@ -1060,7 +1047,7 @@ msgstr "" "讀取位元組到一個預先分配的、可寫的 :term:`bytes-like object` *b* 當中,並回傳" "讀取的位元組數量。例如,*b* 可能是一個 :class:`bytearray`。" -#: ../../library/io.rst:595 +#: ../../library/io.rst:605 msgid "" "Like :meth:`read`, multiple reads may be issued to the underlying raw " "stream, unless the latter is interactive." @@ -1068,7 +1055,15 @@ msgstr "" "類似於 :meth:`read`,除非後者是互動式的,否則可能會對底層原始串流發出多次讀" "取。" -#: ../../library/io.rst:603 +#: ../../library/io.rst:608 ../../library/io.rst:618 +msgid "" +"A :exc:`BlockingIOError` is raised if the underlying raw stream is in non " +"blocking-mode, and has no data available at the moment." +msgstr "" +"如果底層原始串流處於非阻塞模式,且目前沒有可用資料,則會引發 :exc:" +"`BlockingIOError`。" + +#: ../../library/io.rst:613 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b*, " "using at most one call to the underlying raw stream's :meth:`~RawIOBase." @@ -1079,7 +1074,7 @@ msgstr "" "一次底層原始串流的 :meth:`~RawIOBase.read` (或 :meth:`~RawIOBase.readinto`)" "方法。此方法回傳讀取的位元組數量。" -#: ../../library/io.rst:615 +#: ../../library/io.rst:625 msgid "" "Write the given :term:`bytes-like object`, *b*, and return the number of " "bytes written (always equal to the length of *b* in bytes, since if the " @@ -1092,7 +1087,7 @@ msgstr "" "實作,這些位元組可能會立即寫入底層串流,或出於性能和延遲的緣故而被留在緩衝區" "當中。" -#: ../../library/io.rst:622 +#: ../../library/io.rst:632 msgid "" "When in non-blocking mode, a :exc:`BlockingIOError` is raised if the data " "needed to be written to the raw stream but it couldn't accept all the data " @@ -1101,7 +1096,7 @@ msgstr "" "當處於非阻塞模式時,如果需要將資料寫入原始串流,但它無法接受所有資料而不阻" "塞,則會引發 :exc:`BlockingIOError`。" -#: ../../library/io.rst:626 +#: ../../library/io.rst:636 msgid "" "The caller may release or mutate *b* after this method returns, so the " "implementation should only access *b* during the method call." @@ -1109,11 +1104,11 @@ msgstr "" "呼叫者可以在此方法回傳後釋放或變更 *b*,因此實作應該僅在方法呼叫期間存取 " "*b*。" -#: ../../library/io.rst:631 +#: ../../library/io.rst:641 msgid "Raw File I/O" msgstr "原始檔案 I/O" -#: ../../library/io.rst:635 +#: ../../library/io.rst:645 msgid "" "A raw binary stream representing an OS-level file containing bytes data. It " "inherits from :class:`RawIOBase`." @@ -1121,11 +1116,11 @@ msgstr "" "一個代表包含位元組資料的 OS 層級檔案的原始二進制串流。它繼承自 :class:" "`RawIOBase`。" -#: ../../library/io.rst:638 +#: ../../library/io.rst:648 msgid "The *name* can be one of two things:" msgstr "*name* 可以是兩種事物之一:" -#: ../../library/io.rst:640 +#: ../../library/io.rst:650 msgid "" "a character string or :class:`bytes` object representing the path to the " "file which will be opened. In this case closefd must be ``True`` (the " @@ -1134,7 +1129,7 @@ msgstr "" "代表將要打開的檔案路徑的一個字元串或 :class:`bytes` 物件。在這種情況下," "closefd 必須是 ``True`` (預設值),否則將引發錯誤。" -#: ../../library/io.rst:643 +#: ../../library/io.rst:653 msgid "" "an integer representing the number of an existing OS-level file descriptor " "to which the resulting :class:`FileIO` object will give access. When the " @@ -1142,7 +1137,7 @@ msgid "" "set to ``False``." msgstr "" -#: ../../library/io.rst:648 +#: ../../library/io.rst:658 msgid "" "The *mode* can be ``'r'``, ``'w'``, ``'x'`` or ``'a'`` for reading " "(default), writing, exclusive creation or appending. The file will be " @@ -1153,14 +1148,14 @@ msgid "" "``'+'`` to the mode to allow simultaneous reading and writing." msgstr "" -#: ../../library/io.rst:656 +#: ../../library/io.rst:666 msgid "" "The :meth:`~RawIOBase.read` (when called with a positive argument), :meth:" "`~RawIOBase.readinto` and :meth:`~RawIOBase.write` methods on this class " "will only make one system call." msgstr "" -#: ../../library/io.rst:660 +#: ../../library/io.rst:670 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 " @@ -1169,77 +1164,77 @@ msgid "" "similar to passing ``None``)." msgstr "" -#: ../../library/io.rst:666 +#: ../../library/io.rst:676 msgid "The newly created file is :ref:`non-inheritable `." msgstr "" -#: ../../library/io.rst:668 +#: ../../library/io.rst:678 msgid "" "See the :func:`open` built-in function for examples on using the *opener* " "parameter." msgstr "" -#: ../../library/io.rst:671 +#: ../../library/io.rst:681 msgid "The *opener* parameter was added. The ``'x'`` mode was added." msgstr "" -#: ../../library/io.rst:675 +#: ../../library/io.rst:685 msgid "The file is now non-inheritable." msgstr "" -#: ../../library/io.rst:678 +#: ../../library/io.rst:688 msgid "" ":class:`FileIO` provides these data attributes in addition to those from :" "class:`RawIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:683 +#: ../../library/io.rst:693 msgid "The mode as given in the constructor." msgstr "" -#: ../../library/io.rst:687 +#: ../../library/io.rst:697 msgid "" "The file name. This is the file descriptor of the file when no name is " "given in the constructor." msgstr "" -#: ../../library/io.rst:692 +#: ../../library/io.rst:702 msgid "Buffered Streams" msgstr "" -#: ../../library/io.rst:694 +#: ../../library/io.rst:704 msgid "" "Buffered I/O streams provide a higher-level interface to an I/O device than " "raw I/O does." msgstr "" -#: ../../library/io.rst:699 +#: ../../library/io.rst:709 msgid "" "A binary stream using an in-memory bytes buffer. It inherits from :class:" "`BufferedIOBase`. The buffer is discarded when the :meth:`~IOBase.close` " "method is called." msgstr "" -#: ../../library/io.rst:703 +#: ../../library/io.rst:713 msgid "" "The optional argument *initial_bytes* is a :term:`bytes-like object` that " "contains initial data." msgstr "" -#: ../../library/io.rst:706 +#: ../../library/io.rst:716 msgid "" ":class:`BytesIO` provides or overrides these methods in addition to those " "from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:711 +#: ../../library/io.rst:721 msgid "" "Return a readable and writable view over the contents of the buffer without " "copying them. Also, mutating the view will transparently update the " "contents of the buffer::" msgstr "" -#: ../../library/io.rst:715 +#: ../../library/io.rst:725 msgid "" ">>> b = io.BytesIO(b\"abcdef\")\n" ">>> view = b.getbuffer()\n" @@ -1253,303 +1248,305 @@ msgstr "" ">>> b.getvalue()\n" "b'ab56ef'" -#: ../../library/io.rst:722 +#: ../../library/io.rst:732 msgid "" "As long as the view exists, the :class:`BytesIO` object cannot be resized or " "closed." msgstr "" -#: ../../library/io.rst:729 +#: ../../library/io.rst:739 msgid "Return :class:`bytes` containing the entire contents of the buffer." msgstr "" -#: ../../library/io.rst:734 +#: ../../library/io.rst:744 msgid "In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.read`." msgstr "" -#: ../../library/io.rst:736 ../../library/io.rst:779 +#: ../../library/io.rst:746 ../../library/io.rst:786 msgid "The *size* argument is now optional." msgstr "" -#: ../../library/io.rst:741 +#: ../../library/io.rst:751 msgid "" "In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.readinto`." msgstr "" -#: ../../library/io.rst:747 +#: ../../library/io.rst:757 msgid "" "A buffered binary stream providing higher-level access to a readable, non " "seekable :class:`RawIOBase` raw binary stream. It inherits from :class:" "`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:751 +#: ../../library/io.rst:761 msgid "" "When reading data from this object, a larger amount of data may be requested " "from the underlying raw stream, and kept in an internal buffer. The buffered " "data can then be returned directly on subsequent reads." msgstr "" -#: ../../library/io.rst:755 +#: ../../library/io.rst:765 msgid "" "The constructor creates a :class:`BufferedReader` for the given readable " "*raw* stream and *buffer_size*. If *buffer_size* is omitted, :data:" "`DEFAULT_BUFFER_SIZE` is used." msgstr "" -#: ../../library/io.rst:759 +#: ../../library/io.rst:769 msgid "" ":class:`BufferedReader` provides or overrides these methods in addition to " "those from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:764 +#: ../../library/io.rst:774 msgid "" -"Return bytes from the stream without advancing the position. At most one " -"single read on the raw stream is done to satisfy the call. The number of " -"bytes returned may be less or more than requested." +"Return bytes from the stream without advancing the position. The number of " +"bytes returned may be less or more than requested. If the underlying raw " +"stream is non-blocking and the operation would block, returns empty bytes." msgstr "" -#: ../../library/io.rst:770 +#: ../../library/io.rst:780 msgid "" -"Read and return *size* bytes, or if *size* is not given or negative, until " -"EOF or if the read call would block in non-blocking mode." +"In :class:`BufferedReader` this is the same as :meth:`io.BufferedIOBase.read`" msgstr "" -#: ../../library/io.rst:775 +#: ../../library/io.rst:784 msgid "" -"Read and return up to *size* bytes with only one call on the raw stream. If " -"at least one byte is buffered, only buffered bytes are returned. Otherwise, " -"one raw stream read call is made." +"In :class:`BufferedReader` this is the same as :meth:`io.BufferedIOBase." +"read1`" msgstr "" -#: ../../library/io.rst:785 +#: ../../library/io.rst:792 msgid "" "A buffered binary stream providing higher-level access to a writeable, non " "seekable :class:`RawIOBase` raw binary stream. It inherits from :class:" "`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:789 +#: ../../library/io.rst:796 msgid "" "When writing to this object, data is normally placed into an internal " "buffer. The buffer will be written out to the underlying :class:`RawIOBase` " "object under various conditions, including:" msgstr "" -#: ../../library/io.rst:793 +#: ../../library/io.rst:800 msgid "when the buffer gets too small for all pending data;" msgstr "" -#: ../../library/io.rst:794 +#: ../../library/io.rst:801 msgid "when :meth:`flush` is called;" msgstr "" -#: ../../library/io.rst:795 +#: ../../library/io.rst:802 msgid "" "when a :meth:`~IOBase.seek` is requested (for :class:`BufferedRandom` " "objects);" msgstr "" -#: ../../library/io.rst:796 +#: ../../library/io.rst:803 msgid "when the :class:`BufferedWriter` object is closed or destroyed." msgstr "" -#: ../../library/io.rst:798 +#: ../../library/io.rst:805 msgid "" "The constructor creates a :class:`BufferedWriter` for the given writeable " "*raw* stream. If the *buffer_size* is not given, it defaults to :data:" "`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:802 +#: ../../library/io.rst:809 msgid "" ":class:`BufferedWriter` provides or overrides these methods in addition to " "those from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:807 +#: ../../library/io.rst:814 msgid "" "Force bytes held in the buffer into the raw stream. A :exc:" "`BlockingIOError` should be raised if the raw stream blocks." msgstr "" -#: ../../library/io.rst:812 +#: ../../library/io.rst:819 msgid "" "Write the :term:`bytes-like object`, *b*, and return the number of bytes " -"written. When in non-blocking mode, a :exc:`BlockingIOError` is raised if " -"the buffer needs to be written out but the raw stream blocks." +"written. When in non-blocking mode, a :exc:`BlockingIOError` with :attr:" +"`BlockingIOError.characters_written` set is raised if the buffer needs to be " +"written out but the raw stream blocks." msgstr "" -#: ../../library/io.rst:820 +#: ../../library/io.rst:827 msgid "" "A buffered binary stream providing higher-level access to a seekable :class:" "`RawIOBase` raw binary stream. It inherits from :class:`BufferedReader` " "and :class:`BufferedWriter`." msgstr "" -#: ../../library/io.rst:824 +#: ../../library/io.rst:831 msgid "" "The constructor creates a reader and writer for a seekable raw stream, given " "in the first argument. If the *buffer_size* is omitted it defaults to :data:" "`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:828 +#: ../../library/io.rst:835 msgid "" ":class:`BufferedRandom` is capable of anything :class:`BufferedReader` or :" "class:`BufferedWriter` can do. In addition, :meth:`~IOBase.seek` and :meth:" "`~IOBase.tell` are guaranteed to be implemented." msgstr "" -#: ../../library/io.rst:835 +#: ../../library/io.rst:842 msgid "" "A buffered binary stream providing higher-level access to two non seekable :" "class:`RawIOBase` raw binary streams---one readable, the other writeable. It " "inherits from :class:`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:839 +#: ../../library/io.rst:846 msgid "" "*reader* and *writer* are :class:`RawIOBase` objects that are readable and " "writeable respectively. If the *buffer_size* is omitted it defaults to :" "data:`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:843 +#: ../../library/io.rst:850 msgid "" ":class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\\'s " "methods except for :meth:`~BufferedIOBase.detach`, which raises :exc:" "`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:849 +#: ../../library/io.rst:856 msgid "" ":class:`BufferedRWPair` does not attempt to synchronize accesses to its " "underlying raw streams. You should not pass it the same object as reader " "and writer; use :class:`BufferedRandom` instead." msgstr "" -#: ../../library/io.rst:859 +#: ../../library/io.rst:866 msgid "" "Base class for text streams. This class provides a character and line based " "interface to stream I/O. It inherits from :class:`IOBase`." msgstr "" -#: ../../library/io.rst:862 +#: ../../library/io.rst:869 msgid "" ":class:`TextIOBase` provides or overrides these data attributes and methods " "in addition to those from :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:867 +#: ../../library/io.rst:874 msgid "" "The name of the encoding used to decode the stream's bytes into strings, and " "to encode strings into bytes." msgstr "" -#: ../../library/io.rst:872 +#: ../../library/io.rst:879 msgid "The error setting of the decoder or encoder." msgstr "" -#: ../../library/io.rst:876 +#: ../../library/io.rst:883 msgid "" "A string, a tuple of strings, or ``None``, indicating the newlines " "translated so far. Depending on the implementation and the initial " "constructor flags, this may not be available." msgstr "" -#: ../../library/io.rst:882 +#: ../../library/io.rst:889 msgid "" -"The underlying binary buffer (a :class:`BufferedIOBase` instance) that :" -"class:`TextIOBase` deals with. This is not part of the :class:`TextIOBase` " -"API and may not exist in some implementations." +"The underlying binary buffer (a :class:`BufferedIOBase` or :class:" +"`RawIOBase` instance) that :class:`TextIOBase` deals with. This is not part " +"of the :class:`TextIOBase` API and may not exist in some implementations." msgstr "" +"底層的二進位緩衝(一個 :class:`BufferedIOBase` 或 :class:" +"`RawIOBase` 實例),為 :class:`TextIOBase` 處理的對象。" +"這不是 :class:`TextIOBase` API 的一部分,且在某些實作可能不存在。" -#: ../../library/io.rst:888 +#: ../../library/io.rst:896 msgid "" "Separate the underlying binary buffer from the :class:`TextIOBase` and " "return it." msgstr "" -#: ../../library/io.rst:891 +#: ../../library/io.rst:899 msgid "" "After the underlying buffer has been detached, the :class:`TextIOBase` is in " "an unusable state." msgstr "" -#: ../../library/io.rst:894 +#: ../../library/io.rst:902 msgid "" "Some :class:`TextIOBase` implementations, like :class:`StringIO`, may not " "have the concept of an underlying buffer and calling this method will raise :" "exc:`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:902 +#: ../../library/io.rst:910 msgid "" "Read and return at most *size* characters from the stream as a single :class:" "`str`. If *size* is negative or ``None``, reads until EOF." msgstr "" -#: ../../library/io.rst:907 +#: ../../library/io.rst:915 msgid "" "Read until newline or EOF and return a single :class:`str`. If the stream " "is already at EOF, an empty string is returned." msgstr "" -#: ../../library/io.rst:910 +#: ../../library/io.rst:918 msgid "If *size* is specified, at most *size* characters will be read." msgstr "" -#: ../../library/io.rst:914 +#: ../../library/io.rst:922 msgid "" "Change the stream position to the given *offset*. Behaviour depends on the " "*whence* parameter. The default value for *whence* is :data:`!SEEK_SET`." msgstr "" -#: ../../library/io.rst:918 +#: ../../library/io.rst:926 msgid "" ":data:`!SEEK_SET` or ``0``: seek from the start of the stream (the default); " "*offset* must either be a number returned by :meth:`TextIOBase.tell`, or " "zero. Any other *offset* value produces undefined behaviour." msgstr "" -#: ../../library/io.rst:922 +#: ../../library/io.rst:930 msgid "" ":data:`!SEEK_CUR` or ``1``: \"seek\" to the current position; *offset* must " "be zero, which is a no-operation (all other values are unsupported)." msgstr "" -#: ../../library/io.rst:925 +#: ../../library/io.rst:933 msgid "" ":data:`!SEEK_END` or ``2``: seek to the end of the stream; *offset* must be " "zero (all other values are unsupported)." msgstr "" -#: ../../library/io.rst:928 +#: ../../library/io.rst:936 msgid "Return the new absolute position as an opaque number." msgstr "" -#: ../../library/io.rst:935 +#: ../../library/io.rst:943 msgid "" "Return the current stream position as an opaque number. The number does not " "usually represent a number of bytes in the underlying binary storage." msgstr "" -#: ../../library/io.rst:941 +#: ../../library/io.rst:949 msgid "" "Write the string *s* to the stream and return the number of characters " "written." msgstr "" -#: ../../library/io.rst:948 +#: ../../library/io.rst:956 msgid "" "A buffered text stream providing higher-level access to a :class:" "`BufferedIOBase` buffered binary stream. It inherits from :class:" "`TextIOBase`." msgstr "" -#: ../../library/io.rst:952 +#: ../../library/io.rst:960 msgid "" "*encoding* gives the name of the encoding that the stream will be decoded or " "encoded with. In :ref:`UTF-8 Mode `, this defaults to UTF-8. " @@ -1558,7 +1555,7 @@ msgid "" "explicitly. See :ref:`io-text-encoding` for more information." msgstr "" -#: ../../library/io.rst:958 +#: ../../library/io.rst:966 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError` " @@ -1573,13 +1570,13 @@ msgid "" "that has been registered with :func:`codecs.register_error` is also valid." msgstr "" -#: ../../library/io.rst:974 +#: ../../library/io.rst:982 msgid "" "*newline* controls how line endings are handled. It can be ``None``, " "``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as follows:" msgstr "" -#: ../../library/io.rst:977 +#: ../../library/io.rst:985 msgid "" "When reading input from the stream, if *newline* is ``None``, :term:" "`universal newlines` mode is enabled. Lines in the input can end in " @@ -1591,7 +1588,7 @@ msgid "" "returned to the caller untranslated." msgstr "" -#: ../../library/io.rst:986 +#: ../../library/io.rst:994 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -1600,13 +1597,13 @@ msgid "" "characters written are translated to the given string." msgstr "" -#: ../../library/io.rst:992 +#: ../../library/io.rst:1000 msgid "" "If *line_buffering* is ``True``, :meth:`~IOBase.flush` is implied when a " "call to write contains a newline character or a carriage return." msgstr "" -#: ../../library/io.rst:995 +#: ../../library/io.rst:1003 msgid "" "If *write_through* is ``True``, calls to :meth:`~BufferedIOBase.write` are " "guaranteed not to be buffered: any data written on the :class:" @@ -1614,11 +1611,11 @@ msgid "" "*buffer*." msgstr "" -#: ../../library/io.rst:999 +#: ../../library/io.rst:1007 msgid "The *write_through* argument has been added." msgstr "" -#: ../../library/io.rst:1002 +#: ../../library/io.rst:1010 msgid "" "The default *encoding* is now ``locale.getpreferredencoding(False)`` instead " "of ``locale.getpreferredencoding()``. Don't change temporary the locale " @@ -1626,108 +1623,108 @@ msgid "" "instead of the user preferred encoding." msgstr "" -#: ../../library/io.rst:1008 +#: ../../library/io.rst:1016 msgid "" "The *encoding* argument now supports the ``\"locale\"`` dummy encoding name." msgstr "" -#: ../../library/io.rst:1011 +#: ../../library/io.rst:1019 msgid "" ":class:`TextIOWrapper` provides these data attributes and methods in " "addition to those from :class:`TextIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:1016 +#: ../../library/io.rst:1024 msgid "Whether line buffering is enabled." msgstr "" -#: ../../library/io.rst:1020 +#: ../../library/io.rst:1028 msgid "Whether writes are passed immediately to the underlying binary buffer." msgstr "" -#: ../../library/io.rst:1028 +#: ../../library/io.rst:1036 msgid "" "Reconfigure this text stream using new settings for *encoding*, *errors*, " "*newline*, *line_buffering* and *write_through*." msgstr "" -#: ../../library/io.rst:1031 +#: ../../library/io.rst:1039 msgid "" "Parameters not specified keep current settings, except ``errors='strict'`` " "is used when *encoding* is specified but *errors* is not specified." msgstr "" -#: ../../library/io.rst:1035 +#: ../../library/io.rst:1043 msgid "" "It is not possible to change the encoding or newline if some data has " "already been read from the stream. On the other hand, changing encoding " "after write is possible." msgstr "" -#: ../../library/io.rst:1039 +#: ../../library/io.rst:1047 msgid "" "This method does an implicit stream flush before setting the new parameters." msgstr "" -#: ../../library/io.rst:1044 +#: ../../library/io.rst:1052 msgid "The method supports ``encoding=\"locale\"`` option." msgstr "" -#: ../../library/io.rst:1049 +#: ../../library/io.rst:1057 msgid "" "Set the stream position. Return the new stream position as an :class:`int`." msgstr "" -#: ../../library/io.rst:1052 +#: ../../library/io.rst:1060 msgid "" "Four operations are supported, given by the following argument combinations:" msgstr "" -#: ../../library/io.rst:1055 +#: ../../library/io.rst:1063 msgid "``seek(0, SEEK_SET)``: Rewind to the start of the stream." msgstr "" -#: ../../library/io.rst:1056 +#: ../../library/io.rst:1064 msgid "" "``seek(cookie, SEEK_SET)``: Restore a previous position; *cookie* **must " "be** a number returned by :meth:`tell`." msgstr "" -#: ../../library/io.rst:1058 +#: ../../library/io.rst:1066 msgid "``seek(0, SEEK_END)``: Fast-forward to the end of the stream." msgstr "" -#: ../../library/io.rst:1059 +#: ../../library/io.rst:1067 msgid "``seek(0, SEEK_CUR)``: Leave the current stream position unchanged." msgstr "" -#: ../../library/io.rst:1061 +#: ../../library/io.rst:1069 msgid "Any other argument combinations are invalid, and may raise exceptions." msgstr "" -#: ../../library/io.rst:1066 +#: ../../library/io.rst:1074 msgid ":data:`os.SEEK_SET`, :data:`os.SEEK_CUR`, and :data:`os.SEEK_END`." msgstr "" -#: ../../library/io.rst:1070 +#: ../../library/io.rst:1078 msgid "" "Return the stream position as an opaque number. The return value of :meth:`!" "tell` can be given as input to :meth:`seek`, to restore a previous stream " "position." msgstr "" -#: ../../library/io.rst:1077 +#: ../../library/io.rst:1085 msgid "" "A text stream using an in-memory text buffer. It inherits from :class:" "`TextIOBase`." msgstr "" -#: ../../library/io.rst:1080 +#: ../../library/io.rst:1088 msgid "" "The text buffer is discarded when the :meth:`~IOBase.close` method is called." msgstr "" -#: ../../library/io.rst:1083 +#: ../../library/io.rst:1091 msgid "" "The initial value of the buffer can be set by providing *initial_value*. If " "newline translation is enabled, newlines will be encoded as if by :meth:" @@ -1739,31 +1736,31 @@ msgid "" "at the end of the buffer." msgstr "" -#: ../../library/io.rst:1092 +#: ../../library/io.rst:1100 msgid "" "The *newline* argument works like that of :class:`TextIOWrapper`, except " "that when writing output to the stream, if *newline* is ``None``, newlines " "are written as ``\\n`` on all platforms." msgstr "" -#: ../../library/io.rst:1096 +#: ../../library/io.rst:1104 msgid "" ":class:`StringIO` provides this method in addition to those from :class:" "`TextIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:1101 +#: ../../library/io.rst:1109 msgid "" "Return a :class:`str` containing the entire contents of the buffer. Newlines " "are decoded as if by :meth:`~TextIOBase.read`, although the stream position " "is not changed." msgstr "" -#: ../../library/io.rst:1105 +#: ../../library/io.rst:1113 msgid "Example usage::" msgstr "使用範例: ::" -#: ../../library/io.rst:1107 +#: ../../library/io.rst:1115 msgid "" "import io\n" "\n" @@ -1780,23 +1777,23 @@ msgid "" "output.close()" msgstr "" -#: ../../library/io.rst:1127 +#: ../../library/io.rst:1135 msgid "" "A helper codec that decodes newlines for :term:`universal newlines` mode. It " "inherits from :class:`codecs.IncrementalDecoder`." msgstr "" -#: ../../library/io.rst:1132 +#: ../../library/io.rst:1140 msgid "Performance" msgstr "" -#: ../../library/io.rst:1134 +#: ../../library/io.rst:1142 msgid "" "This section discusses the performance of the provided concrete I/O " "implementations." msgstr "" -#: ../../library/io.rst:1140 +#: ../../library/io.rst:1148 msgid "" "By reading and writing only large chunks of data even when the user asks for " "a single byte, buffered I/O hides any inefficiency in calling and executing " @@ -1809,7 +1806,7 @@ msgid "" "data." msgstr "" -#: ../../library/io.rst:1152 +#: ../../library/io.rst:1160 msgid "" "Text I/O over a binary storage (such as a file) is significantly slower than " "binary I/O over the same storage, because it requires conversions between " @@ -1819,24 +1816,24 @@ msgid "" "the reconstruction algorithm used." msgstr "" -#: ../../library/io.rst:1159 +#: ../../library/io.rst:1167 msgid "" ":class:`StringIO`, however, is a native in-memory unicode container and will " "exhibit similar speed to :class:`BytesIO`." msgstr "" -#: ../../library/io.rst:1163 +#: ../../library/io.rst:1171 msgid "Multi-threading" msgstr "" -#: ../../library/io.rst:1165 +#: ../../library/io.rst:1173 msgid "" ":class:`FileIO` objects are thread-safe to the extent that the operating " "system calls (such as :manpage:`read(2)` under Unix) they wrap are thread-" "safe too." msgstr "" -#: ../../library/io.rst:1168 +#: ../../library/io.rst:1176 msgid "" "Binary buffered objects (instances of :class:`BufferedReader`, :class:" "`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`) " @@ -1844,15 +1841,15 @@ msgid "" "them from multiple threads at once." msgstr "" -#: ../../library/io.rst:1173 +#: ../../library/io.rst:1181 msgid ":class:`TextIOWrapper` objects are not thread-safe." msgstr "" -#: ../../library/io.rst:1176 +#: ../../library/io.rst:1184 msgid "Reentrancy" msgstr "" -#: ../../library/io.rst:1178 +#: ../../library/io.rst:1186 msgid "" "Binary buffered objects (instances of :class:`BufferedReader`, :class:" "`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`) are " @@ -1863,7 +1860,7 @@ msgid "" "from entering the buffered object." msgstr "" -#: ../../library/io.rst:1186 +#: ../../library/io.rst:1194 msgid "" "The above implicitly extends to text files, since the :func:`open` function " "will wrap a buffered object inside a :class:`TextIOWrapper`. This includes " @@ -1879,14 +1876,52 @@ msgstr "file object(檔案物件)" msgid "io module" msgstr "io 模組" -#: ../../library/io.rst:971 ../../library/io.rst:1122 +#: ../../library/io.rst:979 ../../library/io.rst:1130 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/io.rst:971 +#: ../../library/io.rst:979 msgid "io.TextIOWrapper class" msgstr "io.TextIOWrapper 類別" -#: ../../library/io.rst:1122 +#: ../../library/io.rst:1130 msgid "io.IncrementalNewlineDecoder class" msgstr "io.IncrementalNewlineDecoder 類別" + +#~ msgid "" +#~ "In addition, those methods can raise :exc:`BlockingIOError` if the " +#~ "underlying raw stream is in non-blocking mode and cannot take or give " +#~ "enough data; unlike their :class:`RawIOBase` counterparts, they will " +#~ "never return ``None``." +#~ msgstr "" +#~ "此外,如果底層的原始串流處於非阻塞模式且無法提供或接收足夠的資料,這些方法" +#~ "可能會引發 :exc:`BlockingIOError` 例外;與 :class:`RawIOBase` 不同之處在" +#~ "於,它們永遠不會回傳 ``None``。" + +#~ msgid "" +#~ "If the argument is positive, and the underlying raw stream is not " +#~ "interactive, multiple raw reads may be issued to satisfy the byte count " +#~ "(unless EOF is reached first). But for interactive raw streams, at most " +#~ "one raw read will be issued, and a short result does not imply that EOF " +#~ "is imminent." +#~ msgstr "" +#~ "如果引數為正數,且底層原始串流不是互動式的,可能會發出多次原始讀取來滿足位" +#~ "元組數量(除非首先達到 EOF)。但對於互動式原始串流,最多只會發出一次原始讀" +#~ "取,且短少的資料不表示 EOF 即將到來。" + +#~ msgid "" +#~ "Read and return up to *size* bytes, with at most one call to the " +#~ "underlying raw stream's :meth:`~RawIOBase.read` (or :meth:`~RawIOBase." +#~ "readinto`) method. This can be useful if you are implementing your own " +#~ "buffering on top of a :class:`BufferedIOBase` object." +#~ msgstr "" +#~ "讀取並回傳最多 *size* 個位元組,最多呼叫一次底層原始串流的 :meth:" +#~ "`~RawIOBase.read` (或 :meth:`~RawIOBase.readinto`) 方法。如果你正在 :" +#~ "class:`BufferedIOBase` 物件之上實作自己的緩衝區,這可能會很有用。" + +#~ msgid "" +#~ "If *size* is ``-1`` (the default), an arbitrary number of bytes are " +#~ "returned (more than zero unless EOF is reached)." +#~ msgstr "" +#~ "如果 *size* 為 ``-1`` (預設值),則會回傳任意數量的位元組(除非達到 EOF," +#~ "否則會超過零)。" diff --git a/library/json.po b/library/json.po index 485a9121cb..41e3135ab2 100644 --- a/library/json.po +++ b/library/json.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-09 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-08-05 15:25+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,12 +30,12 @@ msgstr "**原始碼:**\\ :source:`Lib/json/__init__.py`" #: ../../library/json.rst:14 msgid "" -"`JSON (JavaScript Object Notation) `_, specified " -"by :rfc:`7159` (which obsoletes :rfc:`4627`) and by `ECMA-404 `_, specified by :rfc:" +"`7159` (which obsoletes :rfc:`4627`) and by `ECMA-404 `_, is a " -"lightweight data interchange format inspired by `JavaScript `_ object literal syntax (although it is " -"not a strict subset of JavaScript [#rfc-errata]_ )." +"lightweight data interchange format inspired by `JavaScript `_ object literal syntax (although it is not a " +"strict subset of JavaScript [#rfc-errata]_ )." msgstr "" "`JSON (JavaScript Object Notation) `_ 是一個輕量化的資料交" "換格式,在 :rfc:`7159`\\ (其廢棄了 :rfc:`4627`\\ )及 `ECMA-404 >> import json\n" ">>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])\n" @@ -101,22 +108,22 @@ msgstr "" ">>> io.getvalue()\n" "'[\"streaming API\"]'" -#: ../../library/json.rst:48 +#: ../../library/json.rst:53 msgid "Compact encoding::" msgstr "改用緊湊型編碼方式: ::" -#: ../../library/json.rst:50 +#: ../../library/json.rst:55 msgid "" ">>> import json\n" ">>> json.dumps([1, 2, 3, {'4': 5, '6': 7}], separators=(',', ':'))\n" "'[1,2,3,{\"4\":5,\"6\":7}]'" msgstr "" -#: ../../library/json.rst:54 +#: ../../library/json.rst:59 msgid "Pretty printing::" msgstr "美化輸出: ::" -#: ../../library/json.rst:56 +#: ../../library/json.rst:61 msgid "" ">>> import json\n" ">>> print(json.dumps({'6': 7, '4': 5}, sort_keys=True, indent=4))\n" @@ -132,28 +139,37 @@ msgstr "" " \"6\": 7\n" "}" -#: ../../library/json.rst:63 -msgid "Specializing JSON object encoding::" -msgstr "特殊化 JSON 物件解碼方式: ::" +#: ../../library/json.rst:68 +msgid "Customizing JSON object encoding::" +msgstr "自訂 JSON 物件編碼方式: ::" -#: ../../library/json.rst:65 +#: ../../library/json.rst:70 msgid "" ">>> import json\n" ">>> def custom_json(obj):\n" "... if isinstance(obj, complex):\n" -"... return {'__complex__': True, 'real': obj.real, 'imag': " -"obj.imag}\n" +"... return {'__complex__': True, 'real': obj.real, 'imag': obj." +"imag}\n" "... raise TypeError(f'Cannot serialize object of {type(obj)}')\n" "...\n" ">>> json.dumps(1 + 2j, default=custom_json)\n" "'{\"__complex__\": true, \"real\": 1.0, \"imag\": 2.0}'" msgstr "" +">>> import json\n" +">>> def custom_json(obj):\n" +"... if isinstance(obj, complex):\n" +"... return {'__complex__': True, 'real': obj.real, 'imag': obj." +"imag}\n" +"... raise TypeError(f'Cannot serialize object of {type(obj)}')\n" +"...\n" +">>> json.dumps(1 + 2j, default=custom_json)\n" +"'{\"__complex__\": true, \"real\": 1.0, \"imag\": 2.0}'" -#: ../../library/json.rst:74 +#: ../../library/json.rst:79 msgid "Decoding JSON::" msgstr "JSON 解碼: ::" -#: ../../library/json.rst:76 +#: ../../library/json.rst:81 msgid "" ">>> import json\n" ">>> json.loads('[\"foo\", {\"bar\":[\"baz\", null, 1.0, 2]}]')\n" @@ -175,11 +191,11 @@ msgstr "" ">>> json.load(io)\n" "['streaming API']" -#: ../../library/json.rst:86 -msgid "Specializing JSON object decoding::" -msgstr "自訂特殊的 JSON 解碼方式: ::" +#: ../../library/json.rst:91 +msgid "Customizing JSON object decoding::" +msgstr "自訂 JSON 物件解碼方式: ::" -#: ../../library/json.rst:88 +#: ../../library/json.rst:93 msgid "" ">>> import json\n" ">>> def as_complex(dct):\n" @@ -207,11 +223,11 @@ msgstr "" ">>> json.loads('1.1', parse_float=decimal.Decimal)\n" "Decimal('1.1')" -#: ../../library/json.rst:101 +#: ../../library/json.rst:106 msgid "Extending :class:`JSONEncoder`::" msgstr "繼承 :class:`JSONEncoder` 類別並自行擴充額外的編碼方法: ::" -#: ../../library/json.rst:103 +#: ../../library/json.rst:108 msgid "" ">>> import json\n" ">>> class ComplexEncoder(json.JSONEncoder):\n" @@ -229,11 +245,11 @@ msgid "" "['[2.0', ', 1.0', ']']" msgstr "" -#: ../../library/json.rst:119 +#: ../../library/json.rst:124 msgid "Using :mod:`json.tool` from the shell to validate and pretty-print:" msgstr "在命令列介面裡使用 :mod:`json.tool` 來驗證 JSON 語法和美化呈現方式:" -#: ../../library/json.rst:121 +#: ../../library/json.rst:126 msgid "" "$ echo '{\"json\":\"obj\"}' | python -m json.tool\n" "{\n" @@ -249,11 +265,11 @@ msgstr "" "$ echo '{1.2:3.4}' | python -m json.tool\n" "Expecting property name enclosed in double quotes: line 1 column 2 (char 1)" -#: ../../library/json.rst:130 +#: ../../library/json.rst:135 msgid "See :ref:`json-commandline` for detailed documentation." msgstr "更詳盡的文件請見 :ref:`json-commandline`。" -#: ../../library/json.rst:134 +#: ../../library/json.rst:139 msgid "" "JSON is a subset of `YAML `_ 1.2. The JSON produced by " "this module's default settings (in particular, the default *separators* " @@ -265,7 +281,7 @@ msgstr "" "輸出也符合 YAML 1.0 和 1.1 的子集合規範。因此你也可以利用這個模組來當作 YAML " "的序列化工具(serializer)。" -#: ../../library/json.rst:141 +#: ../../library/json.rst:146 msgid "" "This module's encoders and decoders preserve input and output order by " "default. Order is only lost if the underlying containers are unordered." @@ -273,23 +289,23 @@ msgstr "" "這個模組的編、解碼器預設會保存輸入與輸出資料的順序關係,除非一開始的輸入本身" "就是無序的。" -#: ../../library/json.rst:146 +#: ../../library/json.rst:151 msgid "Basic Usage" msgstr "基本用法" -#: ../../library/json.rst:153 +#: ../../library/json.rst:158 msgid "" "Serialize *obj* as a JSON formatted stream to *fp* (a ``.write()``-" "supporting :term:`file-like object`) using this :ref:`Python-to-JSON " "conversion table `." msgstr "" "參考這個 :ref:`Python-to-JSON 轉換表 `\\ 將 *obj* 序列化為" -"符合 JSON 格式的串流,並寫入到 *fp* (一個支援 ``.write()`` 方法" -"的 :term:`file-like object`)" +"符合 JSON 格式的串流,並寫入到 *fp* (一個支援 ``.write()`` 方法的 :term:" +"`file-like object`)" # SkyLull: 我想這裡的 "framed protocol" 指的是 # https://peps.python.org/pep-3154/#framing -#: ../../library/json.rst:159 +#: ../../library/json.rst:164 msgid "" "Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol, so " "trying to serialize multiple objects with repeated calls to :func:`dump` " @@ -303,32 +319,32 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/json.rst:163 +#: ../../library/json.rst:168 msgid "The Python object to be serialized." msgstr "要被序列化的 Python 物件。" -#: ../../library/json.rst:166 +#: ../../library/json.rst:171 msgid "" "The file-like object *obj* will be serialized to. The :mod:`!json` module " "always produces :class:`str` objects, not :class:`bytes` objects, therefore " "``fp.write()`` must support :class:`str` input." msgstr "" -#: ../../library/json.rst:173 +#: ../../library/json.rst:178 msgid "" -"If ``True``, keys that are not of a basic type " -"(:class:`str`, :class:`int`, :class:`float`, :class:`bool`, ``None``) will " -"be skipped instead of raising a :exc:`TypeError`. Default ``False``." +"If ``True``, keys that are not of a basic type (:class:`str`, :class:`int`, :" +"class:`float`, :class:`bool`, ``None``) will be skipped instead of raising " +"a :exc:`TypeError`. Default ``False``." msgstr "" -#: ../../library/json.rst:179 +#: ../../library/json.rst:184 msgid "" "If ``True`` (the default), the output is guaranteed to have all incoming non-" "ASCII characters escaped. If ``False``, these characters will be outputted " "as-is." msgstr "" -#: ../../library/json.rst:184 +#: ../../library/json.rst:189 msgid "" "If ``False``, the circular reference check for container types is skipped " "and a circular reference will result in a :exc:`RecursionError` (or worse). " @@ -338,7 +354,7 @@ msgstr "" "跳過,若有循環參照則最後將引發 :exc:`RecursionError`\\ (或其他更糟的錯誤)。" "預設為 ``True``。" -#: ../../library/json.rst:189 +#: ../../library/json.rst:194 msgid "" "If ``False``, serialization of out-of-range :class:`float` values (``nan``, " "``inf``, ``-inf``) will result in a :exc:`ValueError`, in strict compliance " @@ -350,14 +366,14 @@ msgstr "" "值),則將使用它們的 JavaScript 等效表示 (``NaN``, ``Infinity``, ``-" "Infinity``)。" -#: ../../library/json.rst:196 +#: ../../library/json.rst:201 msgid "" "If set, a custom JSON encoder with the :meth:`~JSONEncoder.default` method " "overridden, for serializing into custom datatypes. If ``None`` (the " "default), :class:`!JSONEncoder` is used." msgstr "" -#: ../../library/json.rst:203 +#: ../../library/json.rst:208 msgid "" "If a positive integer or string, JSON array elements and object members will " "be pretty-printed with that indent level. A positive integer indents that " @@ -366,7 +382,7 @@ msgid "" "inserted. If ``None`` (the default), the most compact representation is used." msgstr "" -#: ../../library/json.rst:213 +#: ../../library/json.rst:218 msgid "" "A two-tuple: ``(item_separator, key_separator)``. If ``None`` (the default), " "*separators* defaults to ``(', ', ': ')`` if *indent* is ``None``, and " @@ -377,42 +393,42 @@ msgstr "" "則 *separators* 被預設為 ``(', ', ': ')``,否則預設為 ``(',', ': ')``。想要獲" "得最緊湊的 JSON 表示形式,你可以指定 ``(',', ':')`` 來消除空格。" -#: ../../library/json.rst:222 +#: ../../library/json.rst:227 msgid "" "A function that is called for objects that can't otherwise be serialized. It " -"should return a JSON encodable version of the object or raise " -"a :exc:`TypeError`. If ``None`` (the default), :exc:`!TypeError` is raised." +"should return a JSON encodable version of the object or raise a :exc:" +"`TypeError`. If ``None`` (the default), :exc:`!TypeError` is raised." msgstr "" -#: ../../library/json.rst:229 +#: ../../library/json.rst:234 msgid "" "If ``True``, dictionaries will be outputted sorted by key. Default ``False``." msgstr "" -#: ../../library/json.rst:233 ../../library/json.rst:518 +#: ../../library/json.rst:238 ../../library/json.rst:523 msgid "Allow strings for *indent* in addition to integers." msgstr "除了整數之外,*indent* 還允許使用字串作為輸入。" -#: ../../library/json.rst:236 ../../library/json.rst:526 +#: ../../library/json.rst:241 ../../library/json.rst:531 msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``." msgstr "如果 *indent* 不是 ``None``,則使用 ``(',', ': ')`` 作為預設值" -#: ../../library/json.rst:239 ../../library/json.rst:338 +#: ../../library/json.rst:244 ../../library/json.rst:343 msgid "" "All optional parameters are now :ref:`keyword-only `." msgstr "" "所有可選參數現在都是\\ :ref:`僅限關鍵字 `\\ 參數了。" -#: ../../library/json.rst:248 +#: ../../library/json.rst:253 msgid "" "Serialize *obj* to a JSON formatted :class:`str` using this :ref:`conversion " -"table `. The arguments have the same meaning as " -"in :func:`dump`." +"table `. The arguments have the same meaning as in :func:" +"`dump`." msgstr "" -"使用此\\ :ref:`轉換表 `\\ 來將 *obj* 序列化為 JSON 格" -"式 :class:`str`。這個引數的作用與 :func:`dump` 中的同名引數意義相同。" +"使用此\\ :ref:`轉換表 `\\ 來將 *obj* 序列化為 JSON 格式 :" +"class:`str`。這個引數的作用與 :func:`dump` 中的同名引數意義相同。" -#: ../../library/json.rst:254 +#: ../../library/json.rst:259 msgid "" "Keys in key/value pairs of JSON are always of the type :class:`str`. When a " "dictionary is converted into JSON, all the keys of the dictionary are " @@ -425,7 +441,7 @@ msgstr "" "轉換回字典,則該字典可能不等於原始字典。也就是說,如果字典 x 含有非字串鍵值," "則 ``loads(dumps(x)) != x``。" -#: ../../library/json.rst:265 +#: ../../library/json.rst:270 msgid "" "Deserialize *fp* to a Python object using the :ref:`JSON-to-Python " "conversion table `." @@ -433,23 +449,23 @@ msgstr "" "使用此 :ref:`JSON-to-Python 轉換表 `\\ 將 *fp* 解碼為 " "Python 物件。" -#: ../../library/json.rst:268 +#: ../../library/json.rst:273 msgid "" "A ``.read()``-supporting :term:`text file` or :term:`binary file` containing " "the JSON document to be deserialized." msgstr "" -#: ../../library/json.rst:273 +#: ../../library/json.rst:278 msgid "" "If set, a custom JSON decoder. Additional keyword arguments to :func:`!load` " -"will be passed to the constructor of *cls*. If ``None`` (the " -"default), :class:`!JSONDecoder` is used." +"will be passed to the constructor of *cls*. If ``None`` (the default), :" +"class:`!JSONDecoder` is used." msgstr "" -#: ../../library/json.rst:280 +#: ../../library/json.rst:285 #, fuzzy msgid "" -"If set, a function that is called with the result of any object literal " +"If set, a function that is called with the result of any JSON object literal " "decoded (a :class:`dict`). The return value of this function will be used " "instead of the :class:`dict`. This feature can be used to implement custom " "decoders, for example `JSON-RPC `_ class hinting. " @@ -460,10 +476,10 @@ msgstr "" "先的 :class:`dict` 輸出。此功能可用於實作自訂解碼器(例如 `JSON-RPC `_ 類別提示)。" -#: ../../library/json.rst:290 +#: ../../library/json.rst:295 #, fuzzy msgid "" -"If set, a function that is called with the result of any object literal " +"If set, a function that is called with the result of any JSON object literal " "decoded with an ordered list of pairs. The return value of this function " "will be used instead of the :class:`dict`. This feature can be used to " "implement custom decoders. If *object_hook* is also set, *object_pairs_hook* " @@ -474,31 +490,31 @@ msgstr "" "*object_pairs_hook* 的回傳值來取代原先的 :class:`dict` 輸出。此功能可用於實作" "自訂解碼器。如果也同時給定了 *object_hook*,則 *object_pairs_hook* 優先。" -#: ../../library/json.rst:300 +#: ../../library/json.rst:305 #, fuzzy msgid "" "If set, a function that is called with the string of every JSON float to be " "decoded. If ``None`` (the default), it is equivalent to ``float(num_str)``. " -"This can be used to parse JSON floats into custom datatypes, for " -"example :class:`decimal.Decimal`." +"This can be used to parse JSON floats into custom datatypes, for example :" +"class:`decimal.Decimal`." msgstr "" "*parse_float* 為可選函式,每個要被解碼的 JSON 浮點數字串都會改用這個參數給定" "的函式來進行解碼。預設情況這等效於 ``float(num_str)``。這個參數可用於將 JSON " "中的浮點數解碼或剖析為另一種資料型別(例如 :class:`decimal.Decimal`\\ )。" -#: ../../library/json.rst:308 +#: ../../library/json.rst:313 #, fuzzy msgid "" "If set, a function that is called with the string of every JSON int to be " "decoded. If ``None`` (the default), it is equivalent to ``int(num_str)``. " -"This can be used to parse JSON integers into custom datatypes, for " -"example :class:`float`." +"This can be used to parse JSON integers into custom datatypes, for example :" +"class:`float`." msgstr "" "*parse_int* 為可選函式,當解碼 JSON 整數字串時會被呼叫。預設情況等效於 " "``int(num_str)``。這個參數可用於將 JSON 中的整數解碼或剖析為另一種資料型別" "(例如 :class:`float`)。" -#: ../../library/json.rst:316 +#: ../../library/json.rst:321 #, fuzzy msgid "" "If set, a function that is called with one of the following strings: ``'-" @@ -513,32 +529,32 @@ msgstr "" msgid "Raises" msgstr "" -#: ../../library/json.rst:324 +#: ../../library/json.rst:329 #, fuzzy msgid "When the data being deserialized is not a valid JSON document." msgstr "" -"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引" -"發 :exc:`JSONDecodeError` 例外。" +"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引發 :exc:" +"`JSONDecodeError` 例外。" -#: ../../library/json.rst:327 +#: ../../library/json.rst:332 #, fuzzy msgid "" "When the data being deserialized does not contain UTF-8, UTF-16 or UTF-32 " "encoded data." msgstr "" -"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引" -"發 :exc:`JSONDecodeError` 例外。" +"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引發 :exc:" +"`JSONDecodeError` 例外。" -#: ../../library/json.rst:333 +#: ../../library/json.rst:338 msgid "Added the optional *object_pairs_hook* parameter." msgstr "新增可選的 *object_pairs_hook* 參數。" -#: ../../library/json.rst:334 +#: ../../library/json.rst:339 msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore." msgstr "" "遭遇 'null'、'true' 或 'false' 時不再以 *parse_constant* 給定的函式來處理了。" -#: ../../library/json.rst:339 +#: ../../library/json.rst:344 msgid "" "*fp* can now be a :term:`binary file`. The input encoding should be UTF-8, " "UTF-16 or UTF-32." @@ -546,7 +562,7 @@ msgstr "" "現在,*fp* 可以是一個\\ :term:`二進位檔案 `,前提是其編碼格式為 " "UTF-8、UTF-16 或 UTF-32。" -#: ../../library/json.rst:342 +#: ../../library/json.rst:347 msgid "" "The default *parse_int* of :func:`int` now limits the maximum length of the " "integer string via the interpreter's :ref:`integer string conversion length " @@ -556,7 +572,7 @@ msgstr "" "由直譯器的\\ :ref:`整數字串轉換長度限制 `\\ 機制來達成," "這能防止阻斷服務攻擊 (Denial of Service attacks)。" -#: ../../library/json.rst:350 +#: ../../library/json.rst:355 #, fuzzy msgid "" "Identical to :func:`load`, but instead of a file-like object, deserialize " @@ -564,11 +580,11 @@ msgid "" "containing a JSON document) to a Python object using this :ref:`conversion " "table `." msgstr "" -"使用\\ :ref:`轉換表 `\\ 將 *s* (一個含有 JSON 文件" -"的 :class:`str`、:class:`bytes` 或 :class:`bytearray` 的實例(instance))去" -"序列化(deserialize)為一個 Python 物件" +"使用\\ :ref:`轉換表 `\\ 將 *s* (一個含有 JSON 文件的 :" +"class:`str`、:class:`bytes` 或 :class:`bytearray` 的實例(instance))去序列" +"化(deserialize)為一個 Python 物件" -#: ../../library/json.rst:355 +#: ../../library/json.rst:360 msgid "" "*s* can now be of type :class:`bytes` or :class:`bytearray`. The input " "encoding should be UTF-8, UTF-16 or UTF-32." @@ -576,95 +592,95 @@ msgstr "" "現在,*s* 可以是一個二進位檔案如 :class:`bytes` 或 :class:`bytearray`,前提是" "其編碼格式為 UTF-8、UTF-16 或 UTF-32。" -#: ../../library/json.rst:359 +#: ../../library/json.rst:364 msgid "The keyword argument *encoding* has been removed." msgstr "刪除關鍵字引數 *encoding*。" -#: ../../library/json.rst:364 +#: ../../library/json.rst:369 msgid "Encoders and Decoders" msgstr "編碼器與解碼器" -#: ../../library/json.rst:368 +#: ../../library/json.rst:373 msgid "Simple JSON decoder." msgstr "簡易 JSON 解碼器" -#: ../../library/json.rst:370 +#: ../../library/json.rst:375 msgid "Performs the following translations in decoding by default:" msgstr "預設將執行下列資料型別轉換:" -#: ../../library/json.rst:375 ../../library/json.rst:463 +#: ../../library/json.rst:380 ../../library/json.rst:468 msgid "JSON" msgstr "JSON" -#: ../../library/json.rst:375 ../../library/json.rst:463 +#: ../../library/json.rst:380 ../../library/json.rst:468 msgid "Python" msgstr "Python" -#: ../../library/json.rst:377 ../../library/json.rst:465 +#: ../../library/json.rst:382 ../../library/json.rst:470 msgid "object" msgstr "object" -#: ../../library/json.rst:377 ../../library/json.rst:465 +#: ../../library/json.rst:382 ../../library/json.rst:470 msgid "dict" msgstr "dict" -#: ../../library/json.rst:379 ../../library/json.rst:467 +#: ../../library/json.rst:384 ../../library/json.rst:472 msgid "array" msgstr "array" -#: ../../library/json.rst:379 +#: ../../library/json.rst:384 msgid "list" msgstr "list" -#: ../../library/json.rst:381 ../../library/json.rst:469 +#: ../../library/json.rst:386 ../../library/json.rst:474 msgid "string" msgstr "string" -#: ../../library/json.rst:381 ../../library/json.rst:469 +#: ../../library/json.rst:386 ../../library/json.rst:474 msgid "str" msgstr "str" -#: ../../library/json.rst:383 +#: ../../library/json.rst:388 msgid "number (int)" msgstr "number (整數)" -#: ../../library/json.rst:383 +#: ../../library/json.rst:388 msgid "int" msgstr "int" -#: ../../library/json.rst:385 +#: ../../library/json.rst:390 msgid "number (real)" msgstr "number (實數)" -#: ../../library/json.rst:385 +#: ../../library/json.rst:390 msgid "float" msgstr "float" -#: ../../library/json.rst:387 ../../library/json.rst:473 +#: ../../library/json.rst:392 ../../library/json.rst:478 msgid "true" msgstr "true" -#: ../../library/json.rst:387 ../../library/json.rst:473 +#: ../../library/json.rst:392 ../../library/json.rst:478 msgid "True" msgstr "True" -#: ../../library/json.rst:389 ../../library/json.rst:475 +#: ../../library/json.rst:394 ../../library/json.rst:480 msgid "false" msgstr "false" -#: ../../library/json.rst:389 ../../library/json.rst:475 +#: ../../library/json.rst:394 ../../library/json.rst:480 msgid "False" msgstr "False" -#: ../../library/json.rst:391 ../../library/json.rst:477 +#: ../../library/json.rst:396 ../../library/json.rst:482 msgid "null" msgstr "null" -#: ../../library/json.rst:391 ../../library/json.rst:477 +#: ../../library/json.rst:396 ../../library/json.rst:482 msgid "None" msgstr "None" -#: ../../library/json.rst:394 +#: ../../library/json.rst:399 msgid "" "It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their " "corresponding ``float`` values, which is outside the JSON spec." @@ -672,31 +688,31 @@ msgstr "" "雖然 ``NaN``、``Infinity`` 和 ``-Infinity`` 並不符合 JSON 規範,但解碼器依然" "能正確地將其轉換到相應的 Python ``float`` 值。" -#: ../../library/json.rst:397 +#: ../../library/json.rst:402 msgid "" "*object_hook* is an optional function that will be called with the result of " "every JSON object decoded and its return value will be used in place of the " -"given :class:`dict`. This can be used to provide custom deserializations " -"(e.g. to support `JSON-RPC `_ class hinting)." +"given :class:`dict`. This can be used to provide custom deserializations (e." +"g. to support `JSON-RPC `_ class hinting)." msgstr "" "*object_hook* 是一個可選函式,其接受一個解碼後的 JSON 物件作為輸入,並使用其" "回傳值來取代原先的 :class:`dict`。這個功能可用於提供自訂的去序列化(例如支援 " "`JSON-RPC `_ 類別提示)。" -#: ../../library/json.rst:402 +#: ../../library/json.rst:407 msgid "" "*object_pairs_hook* is an optional function that will be called with the " "result of every JSON object decoded with an ordered list of pairs. The " -"return value of *object_pairs_hook* will be used instead of " -"the :class:`dict`. This feature can be used to implement custom decoders. " -"If *object_hook* is also defined, the *object_pairs_hook* takes priority." +"return value of *object_pairs_hook* will be used instead of the :class:" +"`dict`. This feature can be used to implement custom decoders. If " +"*object_hook* is also defined, the *object_pairs_hook* takes priority." msgstr "" -#: ../../library/json.rst:408 +#: ../../library/json.rst:413 msgid "Added support for *object_pairs_hook*." msgstr "新增對於 *object_pairs_hook* 的支援。" -#: ../../library/json.rst:411 +#: ../../library/json.rst:416 msgid "" "*parse_float* is an optional function that will be called with the string of " "every JSON float to be decoded. By default, this is equivalent to " @@ -707,7 +723,7 @@ msgstr "" "的函式來進行解碼。預設情況這等效於 ``float(num_str)``。這個參數可用於將 JSON " "中的浮點數解碼或剖析為另一種資料型別(例如 :class:`decimal.Decimal`\\ )。" -#: ../../library/json.rst:416 +#: ../../library/json.rst:421 msgid "" "*parse_int* is an optional function that will be called with the string of " "every JSON int to be decoded. By default, this is equivalent to " @@ -718,7 +734,7 @@ msgstr "" "``int(num_str)``。這個參數可用於將 JSON 中的整數解碼或剖析為另一種資料型別" "(例如 :class:`float`)。" -#: ../../library/json.rst:421 +#: ../../library/json.rst:426 msgid "" "*parse_constant* is an optional function that will be called with one of the " "following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be " @@ -728,7 +744,7 @@ msgstr "" "``'Infinity'`` 或 ``'NaN'`` 其中之一則會改用這個參數給定的函式來進行解碼。這" "也可用於使解碼過程中遇到無效的 JSON 數字時引發一個例外。" -#: ../../library/json.rst:425 +#: ../../library/json.rst:430 msgid "" "If *strict* is false (``True`` is the default), then control characters will " "be allowed inside strings. Control characters in this context are those " @@ -739,33 +755,33 @@ msgstr "" "語境中的控制字元指的是 ASCII 字元編碼在 0~31 範圍內的字元,包括 ``'\\t'``" "(tab)、``'\\n'``、``'\\r'`` 和 ``'\\0'``。" -#: ../../library/json.rst:430 +#: ../../library/json.rst:435 msgid "" -"If the data being deserialized is not a valid JSON document, " -"a :exc:`JSONDecodeError` will be raised." +"If the data being deserialized is not a valid JSON document, a :exc:" +"`JSONDecodeError` will be raised." msgstr "" -"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引" -"發 :exc:`JSONDecodeError` 例外。" +"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引發 :exc:" +"`JSONDecodeError` 例外。" -#: ../../library/json.rst:433 ../../library/json.rst:534 +#: ../../library/json.rst:438 ../../library/json.rst:539 msgid "All parameters are now :ref:`keyword-only `." msgstr "" "所有參數現在都是\\ :ref:`僅限關鍵字參數 `\\ 了。" -#: ../../library/json.rst:438 +#: ../../library/json.rst:443 msgid "" "Return the Python representation of *s* (a :class:`str` instance containing " "a JSON document)." msgstr "" "回傳用 Python 型式表達的 *s* (一個含有 JSON 文件的 :class:`str` 實例)。" -#: ../../library/json.rst:441 +#: ../../library/json.rst:446 msgid "" ":exc:`JSONDecodeError` will be raised if the given JSON document is not " "valid." msgstr "若給定的輸入不符合 JSON 格式會引發 :exc:`JSONDecodeError` 例外。" -#: ../../library/json.rst:446 +#: ../../library/json.rst:451 msgid "" "Decode a JSON document from *s* (a :class:`str` beginning with a JSON " "document) and return a 2-tuple of the Python representation and the index in " @@ -774,43 +790,43 @@ msgstr "" "將 *s* (一個開頭部分含有合格 JSON 文件的 :class:`str`) 解碼,並將 JSON 文件" "結束點的索引值(index)和解碼結果合併為一個二元組(2-tuple)後回傳。" -#: ../../library/json.rst:450 +#: ../../library/json.rst:455 msgid "" "This can be used to decode a JSON document from a string that may have " "extraneous data at the end." msgstr "這個方法可以用來解碼尾段可能帶有 JSON 以外資料的文字。" -#: ../../library/json.rst:456 +#: ../../library/json.rst:461 msgid "Extensible JSON encoder for Python data structures." msgstr "可擴充的 Python 資料結構 JSON 編碼器。" -#: ../../library/json.rst:458 +#: ../../library/json.rst:463 msgid "Supports the following objects and types by default:" msgstr "預設可支援下列物件及型別:" -#: ../../library/json.rst:467 +#: ../../library/json.rst:472 msgid "list, tuple" msgstr "list, tuple" -#: ../../library/json.rst:471 +#: ../../library/json.rst:476 msgid "int, float, int- & float-derived Enums" msgstr "" "int、float 或可作為整數或浮點數運算的衍生列舉(int- or float-derived Enums)" -#: ../../library/json.rst:471 +#: ../../library/json.rst:476 msgid "number" msgstr "number" -#: ../../library/json.rst:480 +#: ../../library/json.rst:485 msgid "Added support for int- and float-derived Enum classes." msgstr "" "增加對整數(int)、浮點數(float)或可作為整數或浮點數運算的衍生列舉(int- " "or float-derived Enums)類別的支援性。" -#: ../../library/json.rst:483 +#: ../../library/json.rst:488 msgid "" -"To extend this to recognize other objects, subclass and implement " -"a :meth:`~JSONEncoder.default` method with another method that returns a " +"To extend this to recognize other objects, subclass and implement a :meth:" +"`~JSONEncoder.default` method with another method that returns a " "serializable object for ``o`` if possible, otherwise it should call the " "superclass implementation (to raise :exc:`TypeError`)." msgstr "" @@ -818,19 +834,18 @@ msgstr "" "方法。此方法應回傳一個可序列化的 ``o`` 物件,否則此方法應呼叫父類別的 " "JSONEncoder.default 方法(以引發 :exc:`TypeError` 例外)。" -#: ../../library/json.rst:488 +#: ../../library/json.rst:493 msgid "" "If *skipkeys* is false (the default), a :exc:`TypeError` will be raised when " -"trying to encode keys that are " -"not :class:`str`, :class:`int`, :class:`float`, :class:`bool` or ``None``. " -"If *skipkeys* is true, such items are simply skipped." +"trying to encode keys that are not :class:`str`, :class:`int`, :class:" +"`float`, :class:`bool` or ``None``. If *skipkeys* is true, such items are " +"simply skipped." msgstr "" -"若 *skipkeys* 為 false(預設值),則當在編碼不" -"是 :class:`str`、:class:`int`、:class:`float`、:class:`bool` 或 ``None`` 的鍵" -"值時,將引發 :exc:`TypeError`。如果 *skipkeys* 為 true,這些項目將直接被跳" -"過。" +"若 *skipkeys* 為 false(預設值),則當在編碼不是 :class:`str`、:class:" +"`int`、:class:`float`、:class:`bool` 或 ``None`` 的鍵值時,將引發 :exc:" +"`TypeError`。如果 *skipkeys* 為 true,這些項目將直接被跳過。" -#: ../../library/json.rst:492 +#: ../../library/json.rst:497 msgid "" "If *ensure_ascii* is true (the default), the output is guaranteed to have " "all incoming non-ASCII characters escaped. If *ensure_ascii* is false, " @@ -839,7 +854,7 @@ msgstr "" "如果 *ensure_ascii* 被設為 true(預設值),則輸出時將確保所有輸入的非 ASCII " "字元都會被轉義。若 *ensure_ascii* 為 false,則這些字元將照原樣輸出。" -#: ../../library/json.rst:496 +#: ../../library/json.rst:501 msgid "" "If *check_circular* is true (the default), then lists, dicts, and custom " "encoded objects will be checked for circular references during encoding to " @@ -847,10 +862,10 @@ msgid "" "Otherwise, no such check takes place." msgstr "" "如果 *check_circular* 為 true(預設值),則會在編碼期間檢查串列(list)、字典" -"(dict)和自訂編碼物件的循環參照,以防止無限遞迴(一個會導" -"致 :exc:`RecursionError` 例外的問題)。否則不會進行此類檢查。" +"(dict)和自訂編碼物件的循環參照,以防止無限遞迴(一個會導致 :exc:" +"`RecursionError` 例外的問題)。否則不會進行此類檢查。" -#: ../../library/json.rst:501 +#: ../../library/json.rst:506 msgid "" "If *allow_nan* is true (the default), then ``NaN``, ``Infinity``, and ``-" "Infinity`` will be encoded as such. This behavior is not JSON specification " @@ -862,7 +877,7 @@ msgstr "" "數基於 JavaScript 的編碼器和解碼器一致。否則若設為 false,嘗試對這些浮點數進" "行編碼將引發 :exc:`ValueError` 例外。" -#: ../../library/json.rst:507 +#: ../../library/json.rst:512 msgid "" "If *sort_keys* is true (default: ``False``), then the output of dictionaries " "will be sorted by key; this is useful for regression tests to ensure that " @@ -872,7 +887,7 @@ msgstr "" "按鍵值排序。這項功能可確保 JSON 序列化的結果能被互相比較,能讓日常的回歸測試" "檢查變得方便一些。" -#: ../../library/json.rst:511 +#: ../../library/json.rst:516 msgid "" "If *indent* is a non-negative integer or string, then JSON array elements " "and object members will be pretty-printed with that indent level. An indent " @@ -886,7 +901,7 @@ msgstr "" "值)等於是選擇最緊湊的表示法。使用正整數縮排可以在每層縮排數量相同的空格。如" "果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個層級。" -#: ../../library/json.rst:521 +#: ../../library/json.rst:526 msgid "" "If specified, *separators* should be an ``(item_separator, key_separator)`` " "tuple. The default is ``(', ', ': ')`` if *indent* is ``None`` and ``(',', " @@ -898,35 +913,35 @@ msgstr "" "')``,否則預設為 ``(',', ': ')``。想要獲得最緊湊的 JSON 表示形式,你可以改成" "指定 ``(',', ':')`` 來消除空格。" -#: ../../library/json.rst:529 +#: ../../library/json.rst:534 msgid "" "If specified, *default* should be a function that gets called for objects " "that can't otherwise be serialized. It should return a JSON encodable " -"version of the object or raise a :exc:`TypeError`. If not " -"specified, :exc:`TypeError` is raised." +"version of the object or raise a :exc:`TypeError`. If not specified, :exc:" +"`TypeError` is raised." msgstr "" "如果有指定本參數,*default* 會是一個遭遇無法序列化的物件時會被呼叫的函式。它" "應該回傳該物件的 JSON 可編碼版本或引發 :exc:`TypeError`。如果未指定,則會直接" "引發 :exc:`TypeError`。" -#: ../../library/json.rst:540 +#: ../../library/json.rst:545 msgid "" "Implement this method in a subclass such that it returns a serializable " -"object for *o*, or calls the base implementation (to raise " -"a :exc:`TypeError`)." +"object for *o*, or calls the base implementation (to raise a :exc:" +"`TypeError`)." msgstr "" "在任意一個子類別裡實作這個方法時須讓其回傳一個可序列化的物件 *o* ,或呼叫原始" "的實作以引發 :exc:`TypeError` 例外。" -#: ../../library/json.rst:544 +#: ../../library/json.rst:549 msgid "" -"For example, to support arbitrary iterators, you could " -"implement :meth:`~JSONEncoder.default` like this::" +"For example, to support arbitrary iterators, you could implement :meth:" +"`~JSONEncoder.default` like this::" msgstr "" -"舉例來說,想要讓編碼器支援任意疊代器(iterator),你可以實作這樣子" -"的 :meth:`~JSONEncoder.default`: ::" +"舉例來說,想要讓編碼器支援任意疊代器(iterator),你可以實作這樣子的 :meth:" +"`~JSONEncoder.default`: ::" -#: ../../library/json.rst:547 +#: ../../library/json.rst:552 msgid "" "def default(self, o):\n" " try:\n" @@ -939,13 +954,13 @@ msgid "" " return super().default(o)" msgstr "" -#: ../../library/json.rst:560 +#: ../../library/json.rst:565 msgid "" "Return a JSON string representation of a Python data structure, *o*. For " "example::" msgstr "回傳一個 Python 資料結構物件 *o* 的 JSON 的字串表示。例如: ::" -#: ../../library/json.rst:563 +#: ../../library/json.rst:568 msgid "" ">>> json.JSONEncoder().encode({\"foo\": [\"bar\", \"baz\"]})\n" "'{\"foo\": [\"bar\", \"baz\"]}'" @@ -953,7 +968,7 @@ msgstr "" ">>> json.JSONEncoder().encode({\"foo\": [\"bar\", \"baz\"]})\n" "'{\"foo\": [\"bar\", \"baz\"]}'" -#: ../../library/json.rst:569 +#: ../../library/json.rst:574 msgid "" "Encode the given object, *o*, and yield each string representation as " "available. For example::" @@ -961,7 +976,7 @@ msgstr "" "將物件 *o* 編碼,並將結果統整為一個能依序產生(yield)各結果字串的物件。如下" "例: ::" -#: ../../library/json.rst:572 +#: ../../library/json.rst:577 msgid "" "for chunk in json.JSONEncoder().iterencode(bigobject):\n" " mysocket.write(chunk)" @@ -969,39 +984,39 @@ msgstr "" "for chunk in json.JSONEncoder().iterencode(bigobject):\n" " mysocket.write(chunk)" -#: ../../library/json.rst:577 +#: ../../library/json.rst:582 msgid "Exceptions" msgstr "例外" -#: ../../library/json.rst:581 +#: ../../library/json.rst:586 msgid "Subclass of :exc:`ValueError` with the following additional attributes:" msgstr ":exc:`ValueError` 的子類別具有下列額外屬性:" -#: ../../library/json.rst:585 +#: ../../library/json.rst:590 msgid "The unformatted error message." msgstr "未受格式化的錯誤訊息。" -#: ../../library/json.rst:589 +#: ../../library/json.rst:594 msgid "The JSON document being parsed." msgstr "正在被剖析的 JSON 文件。" -#: ../../library/json.rst:593 +#: ../../library/json.rst:598 msgid "The start index of *doc* where parsing failed." msgstr "*doc* 剖析失敗處的起始點的索引值。" -#: ../../library/json.rst:597 +#: ../../library/json.rst:602 msgid "The line corresponding to *pos*." msgstr "*pos* 所在的列(line)數。" -#: ../../library/json.rst:601 +#: ../../library/json.rst:606 msgid "The column corresponding to *pos*." msgstr "*pos* 所在的行(column)數。" -#: ../../library/json.rst:607 +#: ../../library/json.rst:612 msgid "Standard Compliance and Interoperability" msgstr "合規性與互通性(Interoperability)" -#: ../../library/json.rst:609 +#: ../../library/json.rst:614 msgid "" "The JSON format is specified by :rfc:`7159` and by `ECMA-404 `_. This " @@ -1014,7 +1029,7 @@ msgstr "" "組對 RFC 的遵循程度。簡單起見,:class:`JSONEncoder` 和 :class:`JSONDecoder` " "子類別以及未明確提及的參數將不予討論。" -#: ../../library/json.rst:615 +#: ../../library/json.rst:620 msgid "" "This module does not comply with the RFC in a strict fashion, implementing " "some extensions that are valid JavaScript but not valid JSON. In particular:" @@ -1022,17 +1037,17 @@ msgstr "" "這個模組的部份實作並未非常嚴格地遵循 RFC 規範。準確來說,下列實際實作符合 " "JavaScript 語法格式,但並不符合 JSON 格式:" -#: ../../library/json.rst:618 +#: ../../library/json.rst:623 msgid "Infinite and NaN number values are accepted and output;" msgstr "無限(Infinite)和非數字(NaN)值會被接受。" -#: ../../library/json.rst:619 +#: ../../library/json.rst:624 msgid "" "Repeated names within an object are accepted, and only the value of the last " "name-value pair is used." msgstr "同一個物件內可以有重複的名稱,但只有最後一個同名物件是有效的。" -#: ../../library/json.rst:622 +#: ../../library/json.rst:627 msgid "" "Since the RFC permits RFC-compliant parsers to accept input texts that are " "not RFC-compliant, this module's deserializer is technically RFC-compliant " @@ -1041,11 +1056,11 @@ msgstr "" "不過 RFC 准許遵循 RFC 的剖析器接受不合規的文字輸入,所以技術上來說若以預設設" "定運作,本模組的去序列化器(deserializer)是符合 RFC 規範的。" -#: ../../library/json.rst:627 +#: ../../library/json.rst:632 msgid "Character Encodings" msgstr "字元編碼格式" -#: ../../library/json.rst:629 +#: ../../library/json.rst:634 msgid "" "The RFC requires that JSON be represented using either UTF-8, UTF-16, or " "UTF-32, with UTF-8 being the recommended default for maximum " @@ -1054,7 +1069,7 @@ msgstr "" "RFC 要求 JSON 必須以 UTF-8、UTF-16 或 UTF-32 格式編碼。並推薦以 UTF-8 編碼以" "達成最佳的互通性。" -#: ../../library/json.rst:632 +#: ../../library/json.rst:637 msgid "" "As permitted, though not required, by the RFC, this module's serializer sets " "*ensure_ascii=True* by default, thus escaping the output so that the " @@ -1063,18 +1078,17 @@ msgstr "" "RFC 准許但並不強制編碼器的 *ensure_ascii=True* 行為是預設值,但本模組依然實作" "了此一選項作為預設,因此本模組預設會轉義所有非 ASCII 字元。" -#: ../../library/json.rst:636 +#: ../../library/json.rst:641 msgid "" "Other than the *ensure_ascii* parameter, this module is defined strictly in " "terms of conversion between Python objects and :class:`Unicode strings " "`, and thus does not otherwise directly address the issue of character " "encodings." msgstr "" -"除了 *ensure_ascii* 選項參數之外,本模組嚴格遵循 Python 物件" -"與 :class:`Unicode strings ` 之間的轉換規範,因此並不另外處理字元編碼的" -"問題。" +"除了 *ensure_ascii* 選項參數之外,本模組嚴格遵循 Python 物件與 :class:" +"`Unicode strings ` 之間的轉換規範,因此並不另外處理字元編碼的問題。" -#: ../../library/json.rst:641 +#: ../../library/json.rst:646 msgid "" "The RFC prohibits adding a byte order mark (BOM) to the start of a JSON " "text, and this module's serializer does not add a BOM to its output. The RFC " @@ -1087,24 +1101,24 @@ msgstr "" "(deserializer)忽略文件初始的端序記號,因此本模組的去序列化器將在遭遇位於文" "件開頭的端序記號時引發 :exc:`ValueError` 例外。" -#: ../../library/json.rst:647 +#: ../../library/json.rst:652 msgid "" "The RFC does not explicitly forbid JSON strings which contain byte sequences " "that don't correspond to valid Unicode characters (e.g. unpaired UTF-16 " "surrogates), but it does note that they may cause interoperability problems. " -"By default, this module accepts and outputs (when present in the " -"original :class:`str`) code points for such sequences." +"By default, this module accepts and outputs (when present in the original :" +"class:`str`) code points for such sequences." msgstr "" "RFC 並未明確禁止 JSON 文件包含無法對應有效 Unicode 字元的位元組序列(例如未配" "對的 UTF-16 代理對(surrogate pairs)),但這個特性的確可能會引起相容性問題。" "預設情況下,當原始輸入的 :class:`str` 中存在此類序列時,該模組將接受並輸出這" "些序列的編碼位置(code points)。" -#: ../../library/json.rst:655 +#: ../../library/json.rst:660 msgid "Infinite and NaN Number Values" msgstr "正負無限與非數值" -#: ../../library/json.rst:657 +#: ../../library/json.rst:662 msgid "" "The RFC does not permit the representation of infinite or NaN number values. " "Despite that, by default, this module accepts and outputs ``Infinity``, ``-" @@ -1113,7 +1127,7 @@ msgstr "" "RFC 不允許表現無限大或非數值(NaN)。但預設情況下,這個模組仍接受並輸出 " "``Infinity``、``-Infinity`` 和 ``NaN``,如同它們是有效的 JSON 數值字面值: ::" -#: ../../library/json.rst:661 +#: ../../library/json.rst:666 msgid "" ">>> # Neither of these calls raises an exception, but the results are not " "valid JSON\n" @@ -1128,7 +1142,7 @@ msgid "" "nan" msgstr "" -#: ../../library/json.rst:672 +#: ../../library/json.rst:677 msgid "" "In the serializer, the *allow_nan* parameter can be used to alter this " "behavior. In the deserializer, the *parse_constant* parameter can be used " @@ -1137,11 +1151,11 @@ msgstr "" "在序列化器中,*allow_nan* 參數可以改變這個行為。在去序列化器中," "*parse_constant* 參數可以改變這個行為。" -#: ../../library/json.rst:678 +#: ../../library/json.rst:683 msgid "Repeated Names Within an Object" msgstr "物件內重複的名稱" -#: ../../library/json.rst:680 +#: ../../library/json.rst:685 msgid "" "The RFC specifies that the names within a JSON object should be unique, but " "does not mandate how repeated names in JSON objects should be handled. By " @@ -1152,22 +1166,22 @@ msgstr "" "字。預設情況下,本模組不會因此引發例外;相反的,它會忽略該名字的所有重複鍵值" "對,並只保留最後一個: ::" -#: ../../library/json.rst:685 +#: ../../library/json.rst:690 msgid "" ">>> weird_json = '{\"x\": 1, \"x\": 2, \"x\": 3}'\n" ">>> json.loads(weird_json)\n" "{'x': 3}" msgstr "" -#: ../../library/json.rst:689 +#: ../../library/json.rst:694 msgid "The *object_pairs_hook* parameter can be used to alter this behavior." msgstr "*object_parts_hook* 參數可以改變這個行為。" -#: ../../library/json.rst:693 +#: ../../library/json.rst:698 msgid "Top-level Non-Object, Non-Array Values" msgstr "位於頂層的非物件及非列表值" -#: ../../library/json.rst:695 +#: ../../library/json.rst:700 msgid "" "The old version of JSON specified by the obsolete :rfc:`4627` required that " "the top-level value of a JSON text must be either a JSON object or array " @@ -1181,37 +1195,37 @@ msgstr "" "boolean、數字或字串值。 :rfc:`7159` 移除了這個限制,而本模組的序列化器或去串" "列化器中未曾實施過該限制。" -#: ../../library/json.rst:702 +#: ../../library/json.rst:707 msgid "" "Regardless, for maximum interoperability, you may wish to voluntarily adhere " "to the restriction yourself." msgstr "如果想要最大限度地保留互通性,你可能還是會想要自行施加這個限制。" -#: ../../library/json.rst:707 +#: ../../library/json.rst:712 msgid "Implementation Limitations" msgstr "實作限制" -#: ../../library/json.rst:709 +#: ../../library/json.rst:714 msgid "Some JSON deserializer implementations may set limits on:" msgstr "某些 JSON 去序列化器的實作可能會造成下列限制:" -#: ../../library/json.rst:711 +#: ../../library/json.rst:716 msgid "the size of accepted JSON texts" msgstr "JSON 文件長度上限" -#: ../../library/json.rst:712 +#: ../../library/json.rst:717 msgid "the maximum level of nesting of JSON objects and arrays" msgstr "JSON 物件或陣列的最大巢狀層數(level of nesting)限制" -#: ../../library/json.rst:713 +#: ../../library/json.rst:718 msgid "the range and precision of JSON numbers" msgstr "數字的精準度或範圍" -#: ../../library/json.rst:714 +#: ../../library/json.rst:719 msgid "the content and maximum length of JSON strings" msgstr "JSON 字串長度上限" -#: ../../library/json.rst:716 +#: ../../library/json.rst:721 msgid "" "This module does not impose any such limits beyond those of the relevant " "Python datatypes themselves or the Python interpreter itself." @@ -1219,7 +1233,7 @@ msgstr "" "本模組除了 Python 資料型態本身或 Python 直譯器本身的限制以外,不會設定任何此" "類限制。" -#: ../../library/json.rst:719 +#: ../../library/json.rst:724 msgid "" "When serializing to JSON, beware any such limitations in applications that " "may consume your JSON. In particular, it is common for JSON numbers to be " @@ -1234,31 +1248,30 @@ msgstr "" "因而受到其表示範圍和精度限制的影響。這在序列化極大的 Python :class:`int` 數" "值、或是序列化特殊數字型別的實例時(例如 :class:`decimal.Decimal`)尤其重要。" -#: ../../library/json.rst:732 +#: ../../library/json.rst:737 msgid "Command Line Interface" msgstr "命令列介面" -#: ../../library/json.rst:737 +#: ../../library/json.rst:742 msgid "**Source code:** :source:`Lib/json/tool.py`" msgstr "**原始碼:**\\ :source:`Lib/json/tool.py`" -#: ../../library/json.rst:741 +#: ../../library/json.rst:746 msgid "" "The :mod:`json.tool` module provides a simple command line interface to " "validate and pretty-print JSON objects." msgstr "" ":mod:`json.tool` 模組提供了一個簡易的命令列介面以供校驗與美化呈現 JSON 物件。" -#: ../../library/json.rst:744 +#: ../../library/json.rst:749 msgid "" -"If the optional ``infile`` and ``outfile`` arguments are not " -"specified, :data:`sys.stdin` and :data:`sys.stdout` will be used " -"respectively:" +"If the optional ``infile`` and ``outfile`` arguments are not specified, :" +"data:`sys.stdin` and :data:`sys.stdout` will be used respectively:" msgstr "" -"如果沒有指定可選引數 ``infile`` 和 ``outfile`` ,則 :data:`sys.stdin` " -"和 :data:`sys.stdout` 將各自做為輸入和輸出的預設值。" +"如果沒有指定可選引數 ``infile`` 和 ``outfile`` ,則 :data:`sys.stdin` 和 :" +"data:`sys.stdout` 將各自做為輸入和輸出的預設值。" -#: ../../library/json.rst:747 +#: ../../library/json.rst:752 msgid "" "$ echo '{\"json\": \"obj\"}' | python -m json.tool\n" "{\n" @@ -1268,7 +1281,7 @@ msgid "" "Expecting property name enclosed in double quotes: line 1 column 2 (char 1)" msgstr "" -#: ../../library/json.rst:756 +#: ../../library/json.rst:761 msgid "" "The output is now in the same order as the input. Use the :option:`--sort-" "keys` option to sort the output of dictionaries alphabetically by key." @@ -1276,15 +1289,15 @@ msgstr "" "現在開始輸出和輸入的資料順序會是相同的。傳入 :option:`--sort-keys` 引數以按照" "鍵值的字母順序對輸出進行排序。" -#: ../../library/json.rst:763 +#: ../../library/json.rst:768 msgid "Command line options" msgstr "命令列選項" -#: ../../library/json.rst:767 +#: ../../library/json.rst:772 msgid "The JSON file to be validated or pretty-printed:" msgstr "將被用於校驗或美化呈現的 JSON 文件:" -#: ../../library/json.rst:769 +#: ../../library/json.rst:774 msgid "" "$ python -m json.tool mp_films.json\n" "[\n" @@ -1310,45 +1323,45 @@ msgstr "" " }\n" "]" -#: ../../library/json.rst:783 +#: ../../library/json.rst:788 msgid "If *infile* is not specified, read from :data:`sys.stdin`." msgstr "如果沒有指定 *infile* 則會從 :data:`sys.stdin` 讀取輸入。" -#: ../../library/json.rst:787 +#: ../../library/json.rst:792 msgid "" "Write the output of the *infile* to the given *outfile*. Otherwise, write it " "to :data:`sys.stdout`." msgstr "" -"將 *infile* 的結果寫入到給定的 *outfile*。若未提供則寫入" -"到 :data:`sys.stdout`。" +"將 *infile* 的結果寫入到給定的 *outfile*。若未提供則寫入到 :data:`sys." +"stdout`。" -#: ../../library/json.rst:792 +#: ../../library/json.rst:797 msgid "Sort the output of dictionaries alphabetically by key." msgstr "按照鍵值的字母順序對輸出字典進行排序。" -#: ../../library/json.rst:798 +#: ../../library/json.rst:803 msgid "" "Disable escaping of non-ascii characters, see :func:`json.dumps` for more " "information." msgstr "關閉非 ASCII 字元的自動轉義功能。詳情請參照 :func:`json.dumps`。" -#: ../../library/json.rst:804 +#: ../../library/json.rst:809 msgid "Parse every input line as separate JSON object." msgstr "將每一行輸入都單獨輸出為一個 JSON 物件。" -#: ../../library/json.rst:810 +#: ../../library/json.rst:815 msgid "Mutually exclusive options for whitespace control." msgstr "互斥的空白字元控制選項。" -#: ../../library/json.rst:816 +#: ../../library/json.rst:821 msgid "Show the help message." msgstr "顯示說明訊息。" -#: ../../library/json.rst:820 +#: ../../library/json.rst:825 msgid "Footnotes" msgstr "註解" -#: ../../library/json.rst:821 +#: ../../library/json.rst:826 msgid "" "As noted in `the errata for RFC 7159 `_, JSON permits literal U+2028 (LINE SEPARATOR) " diff --git a/library/logging.config.po b/library/logging.config.po index bac0b9d580..a3e26920da 100644 --- a/library/logging.config.po +++ b/library/logging.config.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-09 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:05+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -804,10 +804,10 @@ msgstr "" #: ../../library/logging.config.rst:551 msgid "" -"You can also specify a special key ``'.'`` whose value is a dictionary is a " -"mapping of attribute names to values. If found, the specified attributes " -"will be set on the user-defined object before it is returned. Thus, with the " -"following configuration::" +"You can also specify a special key ``'.'`` whose value is a mapping of " +"attribute names to values. If found, the specified attributes will be set on " +"the user-defined object before it is returned. Thus, with the following " +"configuration::" msgstr "" #: ../../library/logging.config.rst:556 @@ -862,7 +862,7 @@ msgid "" "handler has been configured) it points to the configured handler instance. " "Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a " "handler instance. In general, it is wise to name handlers in a way such that " -"dependent handlers are configured _after_ any handlers they depend on; that " +"dependent handlers are configured *after* any handlers they depend on; that " "allows something like ``cfg://handlers.foo`` to be used in configuring a " "handler that depends on handler ``foo``. If that dependent handler were " "named ``bar``, problems would result, because the configuration of ``bar`` " diff --git a/library/logging.handlers.po b/library/logging.handlers.po index e8b7682ec7..b8f0f87f91 100644 --- a/library/logging.handlers.po +++ b/library/logging.handlers.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-14 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:05+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -147,7 +147,7 @@ msgstr "" #: ../../library/logging.handlers.rst:105 #: ../../library/logging.handlers.rst:190 #: ../../library/logging.handlers.rst:338 -#: ../../library/logging.handlers.rst:444 +#: ../../library/logging.handlers.rst:448 msgid "" "As well as string values, :class:`~pathlib.Path` objects are also accepted " "for the *filename* argument." @@ -156,7 +156,7 @@ msgstr "" #: ../../library/logging.handlers.rst:109 #: ../../library/logging.handlers.rst:194 #: ../../library/logging.handlers.rst:342 -#: ../../library/logging.handlers.rst:448 +#: ../../library/logging.handlers.rst:452 msgid "The *errors* parameter was added." msgstr "新增 *errors* 參數。" @@ -419,7 +419,7 @@ msgid "" msgstr "" #: ../../library/logging.handlers.rst:347 -#: ../../library/logging.handlers.rst:453 +#: ../../library/logging.handlers.rst:457 msgid "Does a rollover, as described above." msgstr "" @@ -429,18 +429,24 @@ msgid "" "previously." msgstr "" -#: ../../library/logging.handlers.rst:358 +#: ../../library/logging.handlers.rst:357 +msgid "" +"See if the supplied record would cause the file to exceed the configured " +"size limit." +msgstr "" + +#: ../../library/logging.handlers.rst:362 msgid "TimedRotatingFileHandler" msgstr "TimedRotatingFileHandler" -#: ../../library/logging.handlers.rst:360 +#: ../../library/logging.handlers.rst:364 msgid "" "The :class:`TimedRotatingFileHandler` class, located in the :mod:`logging." "handlers` module, supports rotation of disk log files at certain timed " "intervals." msgstr "" -#: ../../library/logging.handlers.rst:367 +#: ../../library/logging.handlers.rst:371 msgid "" "Returns a new instance of the :class:`TimedRotatingFileHandler` class. The " "specified file is opened and used as the stream for logging. On rotating it " @@ -448,92 +454,92 @@ msgid "" "*when* and *interval*." msgstr "" -#: ../../library/logging.handlers.rst:372 +#: ../../library/logging.handlers.rst:376 msgid "" "You can use the *when* to specify the type of *interval*. The list of " "possible values is below. Note that they are not case sensitive." msgstr "" -#: ../../library/logging.handlers.rst:376 +#: ../../library/logging.handlers.rst:380 msgid "Value" msgstr "" -#: ../../library/logging.handlers.rst:376 +#: ../../library/logging.handlers.rst:380 msgid "Type of interval" msgstr "" -#: ../../library/logging.handlers.rst:376 +#: ../../library/logging.handlers.rst:380 msgid "If/how *atTime* is used" msgstr "" -#: ../../library/logging.handlers.rst:378 +#: ../../library/logging.handlers.rst:382 msgid "``'S'``" msgstr "``'S'``" -#: ../../library/logging.handlers.rst:378 +#: ../../library/logging.handlers.rst:382 msgid "Seconds" msgstr "" -#: ../../library/logging.handlers.rst:378 -#: ../../library/logging.handlers.rst:380 #: ../../library/logging.handlers.rst:382 #: ../../library/logging.handlers.rst:384 +#: ../../library/logging.handlers.rst:386 +#: ../../library/logging.handlers.rst:388 msgid "Ignored" msgstr "" -#: ../../library/logging.handlers.rst:380 +#: ../../library/logging.handlers.rst:384 msgid "``'M'``" msgstr "``'M'``" -#: ../../library/logging.handlers.rst:380 +#: ../../library/logging.handlers.rst:384 msgid "Minutes" msgstr "" -#: ../../library/logging.handlers.rst:382 +#: ../../library/logging.handlers.rst:386 msgid "``'H'``" msgstr "``'H'``" -#: ../../library/logging.handlers.rst:382 +#: ../../library/logging.handlers.rst:386 msgid "Hours" msgstr "" -#: ../../library/logging.handlers.rst:384 +#: ../../library/logging.handlers.rst:388 msgid "``'D'``" msgstr "``'D'``" -#: ../../library/logging.handlers.rst:384 +#: ../../library/logging.handlers.rst:388 msgid "Days" msgstr "" -#: ../../library/logging.handlers.rst:386 +#: ../../library/logging.handlers.rst:390 msgid "``'W0'-'W6'``" msgstr "``'W0'-'W6'``" -#: ../../library/logging.handlers.rst:386 +#: ../../library/logging.handlers.rst:390 msgid "Weekday (0=Monday)" msgstr "" -#: ../../library/logging.handlers.rst:386 -#: ../../library/logging.handlers.rst:389 +#: ../../library/logging.handlers.rst:390 +#: ../../library/logging.handlers.rst:393 msgid "Used to compute initial rollover time" msgstr "" -#: ../../library/logging.handlers.rst:389 +#: ../../library/logging.handlers.rst:393 msgid "``'midnight'``" msgstr "``'midnight'``" -#: ../../library/logging.handlers.rst:389 +#: ../../library/logging.handlers.rst:393 msgid "Roll over at midnight, if *atTime* not specified, else at time *atTime*" msgstr "" -#: ../../library/logging.handlers.rst:394 +#: ../../library/logging.handlers.rst:398 msgid "" "When using weekday-based rotation, specify 'W0' for Monday, 'W1' for " "Tuesday, and so on up to 'W6' for Sunday. In this case, the value passed for " "*interval* isn't used." msgstr "" -#: ../../library/logging.handlers.rst:398 +#: ../../library/logging.handlers.rst:402 msgid "" "The system will save old log files by appending extensions to the filename. " "The extensions are date-and-time based, using the strftime format ``%Y-%m-" @@ -541,20 +547,20 @@ msgid "" "interval." msgstr "" -#: ../../library/logging.handlers.rst:403 +#: ../../library/logging.handlers.rst:407 msgid "" "When computing the next rollover time for the first time (when the handler " "is created), the last modification time of an existing log file, or else the " "current time, is used to compute when the next rotation will occur." msgstr "" -#: ../../library/logging.handlers.rst:407 +#: ../../library/logging.handlers.rst:411 msgid "" "If the *utc* argument is true, times in UTC will be used; otherwise local " "time is used." msgstr "" -#: ../../library/logging.handlers.rst:410 +#: ../../library/logging.handlers.rst:414 msgid "" "If *backupCount* is nonzero, at most *backupCount* files will be kept, and " "if more would be created when rollover occurs, the oldest one is deleted. " @@ -562,13 +568,13 @@ msgid "" "changing the interval may leave old files lying around." msgstr "" -#: ../../library/logging.handlers.rst:415 +#: ../../library/logging.handlers.rst:419 msgid "" "If *delay* is true, then file opening is deferred until the first call to :" "meth:`emit`." msgstr "" -#: ../../library/logging.handlers.rst:418 +#: ../../library/logging.handlers.rst:422 msgid "" "If *atTime* is not ``None``, it must be a ``datetime.time`` instance which " "specifies the time of day when rollover occurs, for the cases where rollover " @@ -578,13 +584,13 @@ msgid "" "normal interval calculation." msgstr "" -#: ../../library/logging.handlers.rst:425 +#: ../../library/logging.handlers.rst:429 msgid "" "If *errors* is specified, it's used to determine how encoding errors are " "handled." msgstr "" -#: ../../library/logging.handlers.rst:428 +#: ../../library/logging.handlers.rst:432 msgid "" "Calculation of the initial rollover time is done when the handler is " "initialised. Calculation of subsequent rollover times is done only when " @@ -599,51 +605,56 @@ msgid "" "to the minutes where no output (and hence no rollover) occurred." msgstr "" -#: ../../library/logging.handlers.rst:441 +#: ../../library/logging.handlers.rst:445 msgid "*atTime* parameter was added." msgstr "新增 *atTime* 參數。" -#: ../../library/logging.handlers.rst:457 +#: ../../library/logging.handlers.rst:461 msgid "" "Outputs the record to the file, catering for rollover as described above." msgstr "" -#: ../../library/logging.handlers.rst:461 +#: ../../library/logging.handlers.rst:465 msgid "" "Returns a list of filenames which should be deleted as part of rollover. " -"These are the absolute paths of the oldest backup log files written by the " -"handler." +"These" msgstr "" -#: ../../library/logging.handlers.rst:467 +#: ../../library/logging.handlers.rst:469 +msgid "" +"See if enough time has passed for a rollover to occur and if it has, compute " +"the next rollover time." +msgstr "" + +#: ../../library/logging.handlers.rst:475 msgid "SocketHandler" msgstr "SocketHandler" -#: ../../library/logging.handlers.rst:469 +#: ../../library/logging.handlers.rst:477 msgid "" "The :class:`SocketHandler` class, located in the :mod:`logging.handlers` " "module, sends logging output to a network socket. The base class uses a TCP " "socket." msgstr "" -#: ../../library/logging.handlers.rst:475 +#: ../../library/logging.handlers.rst:483 msgid "" "Returns a new instance of the :class:`SocketHandler` class intended to " "communicate with a remote machine whose address is given by *host* and " "*port*." msgstr "" -#: ../../library/logging.handlers.rst:478 +#: ../../library/logging.handlers.rst:486 msgid "" "If ``port`` is specified as ``None``, a Unix domain socket is created using " "the value in ``host`` - otherwise, a TCP socket is created." msgstr "" -#: ../../library/logging.handlers.rst:484 +#: ../../library/logging.handlers.rst:492 msgid "Closes the socket." msgstr "" -#: ../../library/logging.handlers.rst:489 +#: ../../library/logging.handlers.rst:497 msgid "" "Pickles the record's attribute dictionary and writes it to the socket in " "binary format. If there is an error with the socket, silently drops the " @@ -652,28 +663,28 @@ msgid "" "`~logging.LogRecord`, use the :func:`~logging.makeLogRecord` function." msgstr "" -#: ../../library/logging.handlers.rst:499 +#: ../../library/logging.handlers.rst:507 msgid "" "Handles an error which has occurred during :meth:`emit`. The most likely " "cause is a lost connection. Closes the socket so that we can retry on the " "next event." msgstr "" -#: ../../library/logging.handlers.rst:506 +#: ../../library/logging.handlers.rst:514 msgid "" "This is a factory method which allows subclasses to define the precise type " "of socket they want. The default implementation creates a TCP socket (:const:" "`socket.SOCK_STREAM`)." msgstr "" -#: ../../library/logging.handlers.rst:513 +#: ../../library/logging.handlers.rst:521 msgid "" "Pickles the record's attribute dictionary in binary format with a length " "prefix, and returns it ready for transmission across the socket. The details " "of this operation are equivalent to::" msgstr "" -#: ../../library/logging.handlers.rst:517 +#: ../../library/logging.handlers.rst:525 msgid "" "data = pickle.dumps(record_attr_dict, 1)\n" "datalen = struct.pack('>L', len(data))\n" @@ -683,7 +694,7 @@ msgstr "" "datalen = struct.pack('>L', len(data))\n" "return datalen + data" -#: ../../library/logging.handlers.rst:521 +#: ../../library/logging.handlers.rst:529 msgid "" "Note that pickles aren't completely secure. If you are concerned about " "security, you may want to override this method to implement a more secure " @@ -692,20 +703,20 @@ msgid "" "objects on the receiving end." msgstr "" -#: ../../library/logging.handlers.rst:530 +#: ../../library/logging.handlers.rst:538 msgid "" "Send a pickled byte-string *packet* to the socket. The format of the sent " "byte-string is as described in the documentation for :meth:`~SocketHandler." "makePickle`." msgstr "" -#: ../../library/logging.handlers.rst:534 +#: ../../library/logging.handlers.rst:542 msgid "" "This function allows for partial sends, which can happen when the network is " "busy." msgstr "" -#: ../../library/logging.handlers.rst:540 +#: ../../library/logging.handlers.rst:548 msgid "" "Tries to create a socket; on failure, uses an exponential back-off " "algorithm. On initial failure, the handler will drop the message it was " @@ -716,23 +727,23 @@ msgid "" "each time up to a maximum of 30 seconds." msgstr "" -#: ../../library/logging.handlers.rst:548 +#: ../../library/logging.handlers.rst:556 msgid "This behaviour is controlled by the following handler attributes:" msgstr "" -#: ../../library/logging.handlers.rst:550 +#: ../../library/logging.handlers.rst:558 msgid "``retryStart`` (initial delay, defaulting to 1.0 seconds)." msgstr "" -#: ../../library/logging.handlers.rst:551 +#: ../../library/logging.handlers.rst:559 msgid "``retryFactor`` (multiplier, defaulting to 2.0)." msgstr "" -#: ../../library/logging.handlers.rst:552 +#: ../../library/logging.handlers.rst:560 msgid "``retryMax`` (maximum delay, defaulting to 30.0 seconds)." msgstr "" -#: ../../library/logging.handlers.rst:554 +#: ../../library/logging.handlers.rst:562 msgid "" "This means that if the remote listener starts up *after* the handler has " "been used, you could lose messages (since the handler won't even attempt a " @@ -740,25 +751,25 @@ msgid "" "during the delay period)." msgstr "" -#: ../../library/logging.handlers.rst:563 +#: ../../library/logging.handlers.rst:571 msgid "DatagramHandler" msgstr "DatagramHandler" -#: ../../library/logging.handlers.rst:565 +#: ../../library/logging.handlers.rst:573 msgid "" "The :class:`DatagramHandler` class, located in the :mod:`logging.handlers` " "module, inherits from :class:`SocketHandler` to support sending logging " "messages over UDP sockets." msgstr "" -#: ../../library/logging.handlers.rst:572 +#: ../../library/logging.handlers.rst:580 msgid "" "Returns a new instance of the :class:`DatagramHandler` class intended to " "communicate with a remote machine whose address is given by *host* and " "*port*." msgstr "" -#: ../../library/logging.handlers.rst:575 +#: ../../library/logging.handlers.rst:583 msgid "" "As UDP is not a streaming protocol, there is no persistent connection " "between an instance of this handler and *host*. For this reason, when using " @@ -768,13 +779,13 @@ msgid "" "looked-up IP address rather than the hostname." msgstr "" -#: ../../library/logging.handlers.rst:582 +#: ../../library/logging.handlers.rst:590 msgid "" "If ``port`` is specified as ``None``, a Unix domain socket is created using " "the value in ``host`` - otherwise, a UDP socket is created." msgstr "" -#: ../../library/logging.handlers.rst:588 +#: ../../library/logging.handlers.rst:596 msgid "" "Pickles the record's attribute dictionary and writes it to the socket in " "binary format. If there is an error with the socket, silently drops the " @@ -782,29 +793,29 @@ msgid "" "LogRecord`, use the :func:`~logging.makeLogRecord` function." msgstr "" -#: ../../library/logging.handlers.rst:597 +#: ../../library/logging.handlers.rst:605 msgid "" "The factory method of :class:`SocketHandler` is here overridden to create a " "UDP socket (:const:`socket.SOCK_DGRAM`)." msgstr "" -#: ../../library/logging.handlers.rst:603 +#: ../../library/logging.handlers.rst:611 msgid "" "Send a pickled byte-string to a socket. The format of the sent byte-string " "is as described in the documentation for :meth:`SocketHandler.makePickle`." msgstr "" -#: ../../library/logging.handlers.rst:610 +#: ../../library/logging.handlers.rst:618 msgid "SysLogHandler" msgstr "SysLogHandler" -#: ../../library/logging.handlers.rst:612 +#: ../../library/logging.handlers.rst:620 msgid "" "The :class:`SysLogHandler` class, located in the :mod:`logging.handlers` " "module, supports sending logging messages to a remote or local Unix syslog." msgstr "" -#: ../../library/logging.handlers.rst:618 +#: ../../library/logging.handlers.rst:626 msgid "" "Returns a new instance of the :class:`SysLogHandler` class intended to " "communicate with a remote Unix machine whose address is given by *address* " @@ -819,7 +830,7 @@ msgid "" "rsyslog), specify a value of :const:`socket.SOCK_STREAM`." msgstr "" -#: ../../library/logging.handlers.rst:630 +#: ../../library/logging.handlers.rst:638 msgid "" "Note that if your server is not listening on UDP port 514, :class:" "`SysLogHandler` may appear not to work. In that case, check what address you " @@ -830,26 +841,26 @@ msgid "" "platforms). On Windows, you pretty much have to use the UDP option." msgstr "" -#: ../../library/logging.handlers.rst:639 +#: ../../library/logging.handlers.rst:647 msgid "" "On macOS 12.x (Monterey), Apple has changed the behaviour of their syslog " "daemon - it no longer listens on a domain socket. Therefore, you cannot " "expect :class:`SysLogHandler` to work on this system." msgstr "" -#: ../../library/logging.handlers.rst:643 +#: ../../library/logging.handlers.rst:651 msgid "See :gh:`91070` for more information." msgstr "" -#: ../../library/logging.handlers.rst:645 +#: ../../library/logging.handlers.rst:653 msgid "*socktype* was added." msgstr "新增 *socktype*。" -#: ../../library/logging.handlers.rst:651 +#: ../../library/logging.handlers.rst:659 msgid "Closes the socket to the remote host." msgstr "" -#: ../../library/logging.handlers.rst:655 +#: ../../library/logging.handlers.rst:663 msgid "" "Tries to create a socket and, if it's not a datagram socket, connect it to " "the other end. This method is called during handler initialization, but it's " @@ -858,13 +869,13 @@ msgid "" "socket at that point." msgstr "" -#: ../../library/logging.handlers.rst:665 +#: ../../library/logging.handlers.rst:673 msgid "" "The record is formatted, and then sent to the syslog server. If exception " "information is present, it is *not* sent to the server." msgstr "" -#: ../../library/logging.handlers.rst:668 +#: ../../library/logging.handlers.rst:676 msgid "" "(See: :issue:`12168`.) In earlier versions, the message sent to the syslog " "daemons was always terminated with a NUL byte, because early versions of " @@ -875,7 +886,7 @@ msgid "" "byte on as part of the message." msgstr "" -#: ../../library/logging.handlers.rst:677 +#: ../../library/logging.handlers.rst:685 msgid "" "To enable easier handling of syslog messages in the face of all these " "differing daemon behaviours, the appending of the NUL byte has been made " @@ -885,7 +896,7 @@ msgid "" "*not* append the NUL terminator." msgstr "" -#: ../../library/logging.handlers.rst:684 +#: ../../library/logging.handlers.rst:692 msgid "" "(See: :issue:`12419`.) In earlier versions, there was no facility for an " "\"ident\" or \"tag\" prefix to identify the source of the message. This can " @@ -896,262 +907,262 @@ msgid "" "bytes, and is prepended to the message exactly as is." msgstr "" -#: ../../library/logging.handlers.rst:695 +#: ../../library/logging.handlers.rst:703 msgid "" "Encodes the facility and priority into an integer. You can pass in strings " "or integers - if strings are passed, internal mapping dictionaries are used " "to convert them to integers." msgstr "" -#: ../../library/logging.handlers.rst:699 +#: ../../library/logging.handlers.rst:707 msgid "" "The symbolic ``LOG_`` values are defined in :class:`SysLogHandler` and " "mirror the values defined in the ``sys/syslog.h`` header file." msgstr "" -#: ../../library/logging.handlers.rst:702 +#: ../../library/logging.handlers.rst:710 msgid "**Priorities**" msgstr "" -#: ../../library/logging.handlers.rst:705 -#: ../../library/logging.handlers.rst:727 +#: ../../library/logging.handlers.rst:713 +#: ../../library/logging.handlers.rst:735 msgid "Name (string)" msgstr "" -#: ../../library/logging.handlers.rst:705 -#: ../../library/logging.handlers.rst:727 +#: ../../library/logging.handlers.rst:713 +#: ../../library/logging.handlers.rst:735 msgid "Symbolic value" msgstr "" -#: ../../library/logging.handlers.rst:707 +#: ../../library/logging.handlers.rst:715 msgid "``alert``" msgstr "``alert``" -#: ../../library/logging.handlers.rst:707 +#: ../../library/logging.handlers.rst:715 msgid "LOG_ALERT" msgstr "LOG_ALERT" -#: ../../library/logging.handlers.rst:709 +#: ../../library/logging.handlers.rst:717 msgid "``crit`` or ``critical``" msgstr "``crit`` 或 ``critical``" -#: ../../library/logging.handlers.rst:709 +#: ../../library/logging.handlers.rst:717 msgid "LOG_CRIT" msgstr "LOG_CRIT" -#: ../../library/logging.handlers.rst:711 +#: ../../library/logging.handlers.rst:719 msgid "``debug``" msgstr "``debug``" -#: ../../library/logging.handlers.rst:711 +#: ../../library/logging.handlers.rst:719 msgid "LOG_DEBUG" msgstr "LOG_DEBUG" -#: ../../library/logging.handlers.rst:713 +#: ../../library/logging.handlers.rst:721 msgid "``emerg`` or ``panic``" msgstr "``emerg`` 或 ``panic``" -#: ../../library/logging.handlers.rst:713 +#: ../../library/logging.handlers.rst:721 msgid "LOG_EMERG" msgstr "LOG_EMERG" -#: ../../library/logging.handlers.rst:715 +#: ../../library/logging.handlers.rst:723 msgid "``err`` or ``error``" msgstr "``err`` 或 ``error``" -#: ../../library/logging.handlers.rst:715 +#: ../../library/logging.handlers.rst:723 msgid "LOG_ERR" msgstr "LOG_ERR" -#: ../../library/logging.handlers.rst:717 +#: ../../library/logging.handlers.rst:725 msgid "``info``" msgstr "``info``" -#: ../../library/logging.handlers.rst:717 +#: ../../library/logging.handlers.rst:725 msgid "LOG_INFO" msgstr "LOG_INFO" -#: ../../library/logging.handlers.rst:719 +#: ../../library/logging.handlers.rst:727 msgid "``notice``" msgstr "``notice``" -#: ../../library/logging.handlers.rst:719 +#: ../../library/logging.handlers.rst:727 msgid "LOG_NOTICE" msgstr "LOG_NOTICE" -#: ../../library/logging.handlers.rst:721 +#: ../../library/logging.handlers.rst:729 msgid "``warn`` or ``warning``" msgstr "``warn`` 或 ``warning``" -#: ../../library/logging.handlers.rst:721 +#: ../../library/logging.handlers.rst:729 msgid "LOG_WARNING" msgstr "LOG_WARNING" -#: ../../library/logging.handlers.rst:724 +#: ../../library/logging.handlers.rst:732 msgid "**Facilities**" msgstr "" -#: ../../library/logging.handlers.rst:729 +#: ../../library/logging.handlers.rst:737 msgid "``auth``" msgstr "``auth``" -#: ../../library/logging.handlers.rst:729 +#: ../../library/logging.handlers.rst:737 msgid "LOG_AUTH" msgstr "LOG_AUTH" -#: ../../library/logging.handlers.rst:731 +#: ../../library/logging.handlers.rst:739 msgid "``authpriv``" msgstr "``authpriv``" -#: ../../library/logging.handlers.rst:731 +#: ../../library/logging.handlers.rst:739 msgid "LOG_AUTHPRIV" msgstr "LOG_AUTHPRIV" -#: ../../library/logging.handlers.rst:733 +#: ../../library/logging.handlers.rst:741 msgid "``cron``" msgstr "``cron``" -#: ../../library/logging.handlers.rst:733 +#: ../../library/logging.handlers.rst:741 msgid "LOG_CRON" msgstr "LOG_CRON" -#: ../../library/logging.handlers.rst:735 +#: ../../library/logging.handlers.rst:743 msgid "``daemon``" msgstr "``daemon``" -#: ../../library/logging.handlers.rst:735 +#: ../../library/logging.handlers.rst:743 msgid "LOG_DAEMON" msgstr "LOG_DAEMON" -#: ../../library/logging.handlers.rst:737 +#: ../../library/logging.handlers.rst:745 msgid "``ftp``" msgstr "``ftp``" -#: ../../library/logging.handlers.rst:737 +#: ../../library/logging.handlers.rst:745 msgid "LOG_FTP" msgstr "LOG_FTP" -#: ../../library/logging.handlers.rst:739 +#: ../../library/logging.handlers.rst:747 msgid "``kern``" msgstr "``kern``" -#: ../../library/logging.handlers.rst:739 +#: ../../library/logging.handlers.rst:747 msgid "LOG_KERN" msgstr "LOG_KERN" -#: ../../library/logging.handlers.rst:741 +#: ../../library/logging.handlers.rst:749 msgid "``lpr``" msgstr "``lpr``" -#: ../../library/logging.handlers.rst:741 +#: ../../library/logging.handlers.rst:749 msgid "LOG_LPR" msgstr "LOG_LPR" -#: ../../library/logging.handlers.rst:743 +#: ../../library/logging.handlers.rst:751 msgid "``mail``" msgstr "``mail``" -#: ../../library/logging.handlers.rst:743 +#: ../../library/logging.handlers.rst:751 msgid "LOG_MAIL" msgstr "LOG_MAIL" -#: ../../library/logging.handlers.rst:745 +#: ../../library/logging.handlers.rst:753 msgid "``news``" msgstr "``news``" -#: ../../library/logging.handlers.rst:745 +#: ../../library/logging.handlers.rst:753 msgid "LOG_NEWS" msgstr "LOG_NEWS" -#: ../../library/logging.handlers.rst:747 +#: ../../library/logging.handlers.rst:755 msgid "``syslog``" msgstr "``syslog``" -#: ../../library/logging.handlers.rst:747 +#: ../../library/logging.handlers.rst:755 msgid "LOG_SYSLOG" msgstr "LOG_SYSLOG" -#: ../../library/logging.handlers.rst:749 +#: ../../library/logging.handlers.rst:757 msgid "``user``" msgstr "``user``" -#: ../../library/logging.handlers.rst:749 +#: ../../library/logging.handlers.rst:757 msgid "LOG_USER" msgstr "LOG_USER" -#: ../../library/logging.handlers.rst:751 +#: ../../library/logging.handlers.rst:759 msgid "``uucp``" msgstr "``uucp``" -#: ../../library/logging.handlers.rst:751 +#: ../../library/logging.handlers.rst:759 msgid "LOG_UUCP" msgstr "LOG_UUCP" -#: ../../library/logging.handlers.rst:753 +#: ../../library/logging.handlers.rst:761 msgid "``local0``" msgstr "``local0``" -#: ../../library/logging.handlers.rst:753 +#: ../../library/logging.handlers.rst:761 msgid "LOG_LOCAL0" msgstr "LOG_LOCAL0" -#: ../../library/logging.handlers.rst:755 +#: ../../library/logging.handlers.rst:763 msgid "``local1``" msgstr "``local1``" -#: ../../library/logging.handlers.rst:755 +#: ../../library/logging.handlers.rst:763 msgid "LOG_LOCAL1" msgstr "LOG_LOCAL1" -#: ../../library/logging.handlers.rst:757 +#: ../../library/logging.handlers.rst:765 msgid "``local2``" msgstr "``local2``" -#: ../../library/logging.handlers.rst:757 +#: ../../library/logging.handlers.rst:765 msgid "LOG_LOCAL2" msgstr "LOG_LOCAL2" -#: ../../library/logging.handlers.rst:759 +#: ../../library/logging.handlers.rst:767 msgid "``local3``" msgstr "``local3``" -#: ../../library/logging.handlers.rst:759 +#: ../../library/logging.handlers.rst:767 msgid "LOG_LOCAL3" msgstr "LOG_LOCAL3" -#: ../../library/logging.handlers.rst:761 +#: ../../library/logging.handlers.rst:769 msgid "``local4``" msgstr "``local4``" -#: ../../library/logging.handlers.rst:761 +#: ../../library/logging.handlers.rst:769 msgid "LOG_LOCAL4" msgstr "LOG_LOCAL4" -#: ../../library/logging.handlers.rst:763 +#: ../../library/logging.handlers.rst:771 msgid "``local5``" msgstr "``local5``" -#: ../../library/logging.handlers.rst:763 +#: ../../library/logging.handlers.rst:771 msgid "LOG_LOCAL5" msgstr "LOG_LOCAL5" -#: ../../library/logging.handlers.rst:765 +#: ../../library/logging.handlers.rst:773 msgid "``local6``" msgstr "``local6``" -#: ../../library/logging.handlers.rst:765 +#: ../../library/logging.handlers.rst:773 msgid "LOG_LOCAL6" msgstr "LOG_LOCAL6" -#: ../../library/logging.handlers.rst:767 +#: ../../library/logging.handlers.rst:775 msgid "``local7``" msgstr "``local7``" -#: ../../library/logging.handlers.rst:767 +#: ../../library/logging.handlers.rst:775 msgid "LOG_LOCAL7" msgstr "LOG_LOCAL7" -#: ../../library/logging.handlers.rst:772 +#: ../../library/logging.handlers.rst:780 msgid "" "Maps a logging level name to a syslog priority name. You may need to " "override this if you are using custom levels, or if the default algorithm is " @@ -1160,11 +1171,11 @@ msgid "" "all other level names to 'warning'." msgstr "" -#: ../../library/logging.handlers.rst:782 +#: ../../library/logging.handlers.rst:790 msgid "NTEventLogHandler" msgstr "NTEventLogHandler" -#: ../../library/logging.handlers.rst:784 +#: ../../library/logging.handlers.rst:792 msgid "" "The :class:`NTEventLogHandler` class, located in the :mod:`logging.handlers` " "module, supports sending logging messages to a local Windows NT, Windows " @@ -1172,7 +1183,7 @@ msgid "" "Win32 extensions for Python installed." msgstr "" -#: ../../library/logging.handlers.rst:792 +#: ../../library/logging.handlers.rst:800 msgid "" "Returns a new instance of the :class:`NTEventLogHandler` class. The " "*appname* is used to define the application name as it appears in the event " @@ -1188,7 +1199,7 @@ msgid "" "or ``'Security'``, and defaults to ``'Application'``." msgstr "" -#: ../../library/logging.handlers.rst:808 +#: ../../library/logging.handlers.rst:816 msgid "" "At this point, you can remove the application name from the registry as a " "source of event log entries. However, if you do this, you will not be able " @@ -1197,19 +1208,19 @@ msgid "" "not do this." msgstr "" -#: ../../library/logging.handlers.rst:817 +#: ../../library/logging.handlers.rst:825 msgid "" "Determines the message ID, event category and event type, and then logs the " "message in the NT event log." msgstr "" -#: ../../library/logging.handlers.rst:823 +#: ../../library/logging.handlers.rst:831 msgid "" "Returns the event category for the record. Override this if you want to " "specify your own categories. This version returns 0." msgstr "" -#: ../../library/logging.handlers.rst:829 +#: ../../library/logging.handlers.rst:837 msgid "" "Returns the event type for the record. Override this if you want to specify " "your own types. This version does a mapping using the handler's typemap " @@ -1220,7 +1231,7 @@ msgid "" "the handler's *typemap* attribute." msgstr "" -#: ../../library/logging.handlers.rst:840 +#: ../../library/logging.handlers.rst:848 msgid "" "Returns the message ID for the record. If you are using your own messages, " "you could do this by having the *msg* passed to the logger being an ID " @@ -1229,17 +1240,17 @@ msgid "" "message ID in :file:`win32service.pyd`." msgstr "" -#: ../../library/logging.handlers.rst:849 +#: ../../library/logging.handlers.rst:857 msgid "SMTPHandler" msgstr "SMTPHandler" -#: ../../library/logging.handlers.rst:851 +#: ../../library/logging.handlers.rst:859 msgid "" "The :class:`SMTPHandler` class, located in the :mod:`logging.handlers` " "module, supports sending logging messages to an email address via SMTP." msgstr "" -#: ../../library/logging.handlers.rst:857 +#: ../../library/logging.handlers.rst:865 msgid "" "Returns a new instance of the :class:`SMTPHandler` class. The instance is " "initialized with the from and to addresses and subject line of the email. " @@ -1250,7 +1261,7 @@ msgid "" "*credentials* argument." msgstr "" -#: ../../library/logging.handlers.rst:864 +#: ../../library/logging.handlers.rst:872 msgid "" "To specify the use of a secure protocol (TLS), pass in a tuple to the " "*secure* argument. This will only be used when authentication credentials " @@ -1260,31 +1271,31 @@ msgid "" "SMTP.starttls` method.)" msgstr "" -#: ../../library/logging.handlers.rst:871 +#: ../../library/logging.handlers.rst:879 msgid "" "A timeout can be specified for communication with the SMTP server using the " "*timeout* argument." msgstr "" -#: ../../library/logging.handlers.rst:874 +#: ../../library/logging.handlers.rst:882 msgid "Added the *timeout* parameter." msgstr "新增 *timeout* 參數。" -#: ../../library/logging.handlers.rst:879 +#: ../../library/logging.handlers.rst:887 msgid "Formats the record and sends it to the specified addressees." msgstr "" -#: ../../library/logging.handlers.rst:884 +#: ../../library/logging.handlers.rst:892 msgid "" "If you want to specify a subject line which is record-dependent, override " "this method." msgstr "" -#: ../../library/logging.handlers.rst:890 +#: ../../library/logging.handlers.rst:898 msgid "MemoryHandler" msgstr "MemoryHandler" -#: ../../library/logging.handlers.rst:892 +#: ../../library/logging.handlers.rst:900 msgid "" "The :class:`MemoryHandler` class, located in the :mod:`logging.handlers` " "module, supports buffering of logging records in memory, periodically " @@ -1292,7 +1303,7 @@ msgid "" "buffer is full, or when an event of a certain severity or greater is seen." msgstr "" -#: ../../library/logging.handlers.rst:897 +#: ../../library/logging.handlers.rst:905 msgid "" ":class:`MemoryHandler` is a subclass of the more general :class:" "`BufferingHandler`, which is an abstract class. This buffers logging records " @@ -1301,32 +1312,32 @@ msgid "" "should, then :meth:`flush` is expected to do the flushing." msgstr "" -#: ../../library/logging.handlers.rst:906 +#: ../../library/logging.handlers.rst:914 msgid "" "Initializes the handler with a buffer of the specified capacity. Here, " "*capacity* means the number of logging records buffered." msgstr "" -#: ../../library/logging.handlers.rst:912 +#: ../../library/logging.handlers.rst:920 msgid "" "Append the record to the buffer. If :meth:`shouldFlush` returns true, call :" "meth:`flush` to process the buffer." msgstr "" -#: ../../library/logging.handlers.rst:918 +#: ../../library/logging.handlers.rst:926 msgid "" "For a :class:`BufferingHandler` instance, flushing means that it sets the " "buffer to an empty list. This method can be overwritten to implement more " "useful flushing behavior." msgstr "" -#: ../../library/logging.handlers.rst:925 +#: ../../library/logging.handlers.rst:933 msgid "" "Return ``True`` if the buffer is up to capacity. This method can be " "overridden to implement custom flushing strategies." msgstr "" -#: ../../library/logging.handlers.rst:931 +#: ../../library/logging.handlers.rst:939 msgid "" "Returns a new instance of the :class:`MemoryHandler` class. The instance is " "initialized with a buffer size of *capacity* (number of records buffered). " @@ -1338,15 +1349,15 @@ msgid "" "the buffer will occur when the handler is closed." msgstr "" -#: ../../library/logging.handlers.rst:940 +#: ../../library/logging.handlers.rst:948 msgid "The *flushOnClose* parameter was added." msgstr "新增 *flushOnClose* 參數。" -#: ../../library/logging.handlers.rst:946 +#: ../../library/logging.handlers.rst:954 msgid "Calls :meth:`flush`, sets the target to ``None`` and clears the buffer." msgstr "" -#: ../../library/logging.handlers.rst:952 +#: ../../library/logging.handlers.rst:960 msgid "" "For a :class:`MemoryHandler` instance, flushing means just sending the " "buffered records to the target, if there is one. The buffer is also cleared " @@ -1354,26 +1365,26 @@ msgid "" "behavior." msgstr "" -#: ../../library/logging.handlers.rst:959 +#: ../../library/logging.handlers.rst:967 msgid "Sets the target handler for this handler." msgstr "" -#: ../../library/logging.handlers.rst:964 +#: ../../library/logging.handlers.rst:972 msgid "Checks for buffer full or a record at the *flushLevel* or higher." msgstr "" -#: ../../library/logging.handlers.rst:970 +#: ../../library/logging.handlers.rst:978 msgid "HTTPHandler" msgstr "HTTPHandler" -#: ../../library/logging.handlers.rst:972 +#: ../../library/logging.handlers.rst:980 msgid "" "The :class:`HTTPHandler` class, located in the :mod:`logging.handlers` " "module, supports sending logging messages to a web server, using either " "``GET`` or ``POST`` semantics." msgstr "" -#: ../../library/logging.handlers.rst:979 +#: ../../library/logging.handlers.rst:987 msgid "" "Returns a new instance of the :class:`HTTPHandler` class. The *host* can be " "of the form ``host:port``, should you need to use a specific port number. " @@ -1387,11 +1398,11 @@ msgid "" "cleartext across the wire." msgstr "" -#: ../../library/logging.handlers.rst:990 +#: ../../library/logging.handlers.rst:998 msgid "The *context* parameter was added." msgstr "新增 *context* 參數。" -#: ../../library/logging.handlers.rst:995 +#: ../../library/logging.handlers.rst:1003 msgid "" "Provides a dictionary, based on ``record``, which is to be URL-encoded and " "sent to the web server. The default implementation just returns ``record." @@ -1400,14 +1411,14 @@ msgid "" "customization of what's sent to the server is required." msgstr "" -#: ../../library/logging.handlers.rst:1003 +#: ../../library/logging.handlers.rst:1011 msgid "" "Sends the record to the web server as a URL-encoded dictionary. The :meth:" "`mapLogRecord` method is used to convert the record to the dictionary to be " "sent." msgstr "" -#: ../../library/logging.handlers.rst:1007 +#: ../../library/logging.handlers.rst:1015 msgid "" "Since preparing a record for sending it to a web server is not the same as a " "generic formatting operation, using :meth:`~logging.Handler.setFormatter` to " @@ -1417,18 +1428,18 @@ msgid "" "the dictionary in a form suitable for sending to a web server." msgstr "" -#: ../../library/logging.handlers.rst:1020 +#: ../../library/logging.handlers.rst:1028 msgid "QueueHandler" msgstr "QueueHandler" -#: ../../library/logging.handlers.rst:1024 +#: ../../library/logging.handlers.rst:1032 msgid "" "The :class:`QueueHandler` class, located in the :mod:`logging.handlers` " "module, supports sending logging messages to a queue, such as those " "implemented in the :mod:`queue` or :mod:`multiprocessing` modules." msgstr "" -#: ../../library/logging.handlers.rst:1028 +#: ../../library/logging.handlers.rst:1036 msgid "" "Along with the :class:`QueueListener` class, :class:`QueueHandler` can be " "used to let handlers do their work on a separate thread from the one which " @@ -1438,7 +1449,7 @@ msgid "" "an email via :class:`SMTPHandler`) are done on a separate thread." msgstr "" -#: ../../library/logging.handlers.rst:1037 +#: ../../library/logging.handlers.rst:1045 msgid "" "Returns a new instance of the :class:`QueueHandler` class. The instance is " "initialized with the queue to send messages to. The *queue* can be any queue-" @@ -1448,14 +1459,24 @@ msgid "" "instances for *queue*." msgstr "" -#: ../../library/logging.handlers.rst:1044 -#: ../../library/logging.handlers.rst:1133 +#: ../../library/logging.handlers.rst:1052 +#: ../../library/logging.handlers.rst:1150 msgid "" "If you are using :mod:`multiprocessing`, you should avoid using :class:" "`~queue.SimpleQueue` and instead use :class:`multiprocessing.Queue`." msgstr "" -#: ../../library/logging.handlers.rst:1049 +#: ../../library/logging.handlers.rst:1057 +msgid "" +"The :mod:`multiprocessing` module uses an internal logger created and " +"accessed via :meth:`~multiprocessing.get_logger`. :class:`multiprocessing." +"Queue` will log ``DEBUG`` level messages upon items being queued. If those " +"log messages are processed by a :class:`QueueHandler` using the same :class:" +"`multiprocessing.Queue` instance, it will cause a deadlock or infinite " +"recursion." +msgstr "" + +#: ../../library/logging.handlers.rst:1066 msgid "" "Enqueues the result of preparing the LogRecord. Should an exception occur (e." "g. because a bounded queue has filled up), the :meth:`~logging.Handler." @@ -1465,13 +1486,13 @@ msgid "" "raiseExceptions` is ``True``)." msgstr "" -#: ../../library/logging.handlers.rst:1058 +#: ../../library/logging.handlers.rst:1075 msgid "" "Prepares a record for queuing. The object returned by this method is " "enqueued." msgstr "" -#: ../../library/logging.handlers.rst:1061 +#: ../../library/logging.handlers.rst:1078 msgid "" "The base implementation formats the record to merge the message, arguments, " "exception and stack information, if present. It also removes unpickleable " @@ -1481,14 +1502,14 @@ msgid "" "attr:`exc_info` and :attr:`exc_text` attributes to ``None``." msgstr "" -#: ../../library/logging.handlers.rst:1069 +#: ../../library/logging.handlers.rst:1086 msgid "" "You might want to override this method if you want to convert the record to " "a dict or JSON string, or send a modified copy of the record while leaving " "the original intact." msgstr "" -#: ../../library/logging.handlers.rst:1073 +#: ../../library/logging.handlers.rst:1090 msgid "" "The base implementation formats the message with arguments, sets the " "``message`` and ``msg`` attributes to the formatted message and sets the " @@ -1504,25 +1525,25 @@ msgid "" "libraries that you use.)" msgstr "" -#: ../../library/logging.handlers.rst:1089 +#: ../../library/logging.handlers.rst:1106 msgid "" "Enqueues the record on the queue using ``put_nowait()``; you may want to " "override this if you want to use blocking behaviour, or a timeout, or a " "customized queue implementation." msgstr "" -#: ../../library/logging.handlers.rst:1095 +#: ../../library/logging.handlers.rst:1112 msgid "" "When created via configuration using :func:`~logging.config.dictConfig`, " "this attribute will contain a :class:`QueueListener` instance for use with " "this handler. Otherwise, it will be ``None``." msgstr "" -#: ../../library/logging.handlers.rst:1104 +#: ../../library/logging.handlers.rst:1121 msgid "QueueListener" msgstr "QueueListener" -#: ../../library/logging.handlers.rst:1108 +#: ../../library/logging.handlers.rst:1125 msgid "" "The :class:`QueueListener` class, located in the :mod:`logging.handlers` " "module, supports receiving logging messages from a queue, such as those " @@ -1533,7 +1554,7 @@ msgid "" "works hand-in-hand with :class:`QueueHandler`." msgstr "" -#: ../../library/logging.handlers.rst:1116 +#: ../../library/logging.handlers.rst:1133 msgid "" "Along with the :class:`QueueHandler` class, :class:`QueueListener` can be " "used to let handlers do their work on a separate thread from the one which " @@ -1543,7 +1564,7 @@ msgid "" "an email via :class:`SMTPHandler`) are done on a separate thread." msgstr "" -#: ../../library/logging.handlers.rst:1125 +#: ../../library/logging.handlers.rst:1142 msgid "" "Returns a new instance of the :class:`QueueListener` class. The instance is " "initialized with the queue to send messages to and a list of handlers which " @@ -1554,7 +1575,7 @@ msgid "" "class:`~queue.SimpleQueue` instances for *queue*." msgstr "" -#: ../../library/logging.handlers.rst:1136 +#: ../../library/logging.handlers.rst:1153 msgid "" "If ``respect_handler_level`` is ``True``, a handler's level is respected " "(compared with the level for the message) when deciding whether to pass " @@ -1562,87 +1583,87 @@ msgid "" "versions - to always pass each message to each handler." msgstr "" -#: ../../library/logging.handlers.rst:1141 +#: ../../library/logging.handlers.rst:1158 msgid "The ``respect_handler_level`` argument was added." msgstr "新增 ``respect_handler_level`` 引數。" -#: ../../library/logging.handlers.rst:1146 +#: ../../library/logging.handlers.rst:1163 msgid "Dequeues a record and return it, optionally blocking." msgstr "" -#: ../../library/logging.handlers.rst:1148 +#: ../../library/logging.handlers.rst:1165 msgid "" "The base implementation uses ``get()``. You may want to override this method " "if you want to use timeouts or work with custom queue implementations." msgstr "" -#: ../../library/logging.handlers.rst:1154 +#: ../../library/logging.handlers.rst:1171 msgid "Prepare a record for handling." msgstr "" -#: ../../library/logging.handlers.rst:1156 +#: ../../library/logging.handlers.rst:1173 msgid "" "This implementation just returns the passed-in record. You may want to " "override this method if you need to do any custom marshalling or " "manipulation of the record before passing it to the handlers." msgstr "" -#: ../../library/logging.handlers.rst:1162 +#: ../../library/logging.handlers.rst:1179 msgid "Handle a record." msgstr "" -#: ../../library/logging.handlers.rst:1164 +#: ../../library/logging.handlers.rst:1181 msgid "" "This just loops through the handlers offering them the record to handle. The " "actual object passed to the handlers is that which is returned from :meth:" "`prepare`." msgstr "" -#: ../../library/logging.handlers.rst:1170 +#: ../../library/logging.handlers.rst:1187 msgid "Starts the listener." msgstr "" -#: ../../library/logging.handlers.rst:1172 +#: ../../library/logging.handlers.rst:1189 msgid "" "This starts up a background thread to monitor the queue for LogRecords to " "process." msgstr "" -#: ../../library/logging.handlers.rst:1175 +#: ../../library/logging.handlers.rst:1192 msgid "" "Raises :exc:`RuntimeError` if called and the listener is already running." msgstr "" -#: ../../library/logging.handlers.rst:1181 +#: ../../library/logging.handlers.rst:1198 msgid "Stops the listener." msgstr "" -#: ../../library/logging.handlers.rst:1183 +#: ../../library/logging.handlers.rst:1200 msgid "" "This asks the thread to terminate, and then waits for it to do so. Note that " "if you don't call this before your application exits, there may be some " "records still left on the queue, which won't be processed." msgstr "" -#: ../../library/logging.handlers.rst:1189 +#: ../../library/logging.handlers.rst:1206 msgid "" "Writes a sentinel to the queue to tell the listener to quit. This " "implementation uses ``put_nowait()``. You may want to override this method " "if you want to use timeouts or work with custom queue implementations." msgstr "" -#: ../../library/logging.handlers.rst:1199 +#: ../../library/logging.handlers.rst:1216 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../library/logging.handlers.rst:1200 +#: ../../library/logging.handlers.rst:1217 msgid "API reference for the logging module." msgstr "" -#: ../../library/logging.handlers.rst:1202 +#: ../../library/logging.handlers.rst:1219 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../library/logging.handlers.rst:1203 +#: ../../library/logging.handlers.rst:1220 msgid "Configuration API for the logging module." msgstr "" diff --git a/library/math.po b/library/math.po index 1c6cb27a07..8eee7acf44 100644 --- a/library/math.po +++ b/library/math.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-19 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2024-04-26 15:15+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,9 +24,9 @@ msgstr ":mod:`!math` --- 數學函式" #: ../../library/math.rst:13 msgid "" -"This module provides access to the mathematical functions defined by the C " -"standard." -msgstr "此模組提供對 C 標準中定義的數學相關函式的存取。" +"This module provides access to common mathematical functions and constants, " +"including those defined by the C standard." +msgstr "此模組提供對常見數學函式與常數的存取,包括於 C 標準中定義的那些。" #: ../../library/math.rst:16 msgid "" @@ -620,7 +620,7 @@ msgstr "" "因為此值等同於 ``(1 + x)ⁿ`` 進行多項式展開後第 k 項的係數,所以又稱為二項式係" "數。" -#: ../../library/math.rst:139 ../../library/math.rst:205 +#: ../../library/math.rst:139 ../../library/math.rst:204 msgid "" "Raises :exc:`TypeError` if either of the arguments are not integers. Raises :" "exc:`ValueError` if either of the arguments are negative." @@ -629,17 +629,14 @@ msgstr "" "`ValueError`。" #: ../../library/math.rst:147 -msgid "" -"Return *n* factorial as an integer. Raises :exc:`ValueError` if *n* is not " -"integral or is negative." +msgid "Return factorial of the nonnegative integer *n*." msgstr "" -"以整數回傳 *n* 的階乘。若 *n* 非整數型別或其值為負會引發 :exc:`ValueError`。" -#: ../../library/math.rst:150 +#: ../../library/math.rst:149 msgid "Floats with integral values (like ``5.0``) are no longer accepted." msgstr "其值為整數的浮點數(如:``5.0``)已不再被接受。" -#: ../../library/math.rst:156 +#: ../../library/math.rst:155 msgid "" "Return the greatest common divisor of the specified integer arguments. If " "any of the arguments is nonzero, then the returned value is the largest " @@ -651,13 +648,13 @@ msgstr "" "最大的正整數。若所有引數皆為零,則回傳值為 ``0``。``gcd()`` 若未傳入任何引數" "也將回傳 ``0``。" -#: ../../library/math.rst:164 +#: ../../library/math.rst:163 msgid "" "Added support for an arbitrary number of arguments. Formerly, only two " "arguments were supported." msgstr "新增支援任意數量的引數。先前僅支援兩個引數。" -#: ../../library/math.rst:171 +#: ../../library/math.rst:170 msgid "" "Return the integer square root of the nonnegative integer *n*. This is the " "floor of the exact square root of *n*, or equivalently the greatest integer " @@ -666,7 +663,7 @@ msgstr "" "回傳非負整數 *n* 的整數平方根。此值為 *n* 精確平方根經下取整的值,亦等同於滿" "足 *a*\\ ² |nbsp| ≤ |nbsp| *n* 的最大整數值 *a*。" -#: ../../library/math.rst:175 +#: ../../library/math.rst:174 msgid "" "For some applications, it may be more convenient to have the least integer " "*a* such that *n* |nbsp| ≤ |nbsp| *a*\\ ², or in other words the ceiling of " @@ -677,7 +674,7 @@ msgstr "" "者說 *n* 精確平方根經上取整的值 ── 會更加方便。對正數 *n*,此值可使用 ``a = " "1 + isqrt(n - 1)`` 計算。" -#: ../../library/math.rst:185 +#: ../../library/math.rst:184 msgid "" "Return the least common multiple of the specified integer arguments. If all " "arguments are nonzero, then the returned value is the smallest positive " @@ -689,29 +686,29 @@ msgstr "" "最小的正整數。若存在任一引數值為零,則回傳值為 ``0``。``lcm()`` 若未傳入任何" "引數將回傳 ``1``。" -#: ../../library/math.rst:196 +#: ../../library/math.rst:195 msgid "" "Return the number of ways to choose *k* items from *n* items without " "repetition and with order." msgstr "" -#: ../../library/math.rst:199 +#: ../../library/math.rst:198 msgid "" "Evaluates to ``n! / (n - k)!`` when ``k <= n`` and evaluates to zero when " "``k > n``." msgstr "" -#: ../../library/math.rst:202 +#: ../../library/math.rst:201 msgid "" "If *k* is not specified or is ``None``, then *k* defaults to *n* and the " "function returns ``n!``." msgstr "" -#: ../../library/math.rst:212 +#: ../../library/math.rst:211 msgid "Floating point arithmetic" msgstr "" -#: ../../library/math.rst:216 +#: ../../library/math.rst:215 msgid "" "Return the ceiling of *x*, the smallest integer greater than or equal to " "*x*. If *x* is not a float, delegates to :meth:`x.__ceil__ `,並回傳 :class:`~numbers." "Integral` 型別的值。" -#: ../../library/math.rst:223 +#: ../../library/math.rst:222 msgid "Return the absolute value of *x*." msgstr "回傳 *x* 的絕對值。" -#: ../../library/math.rst:228 +#: ../../library/math.rst:227 msgid "" "Return the floor of *x*, the largest integer less than or equal to *x*. If " "*x* is not a float, delegates to :meth:`x.__floor__ `, " @@ -735,7 +732,7 @@ msgstr "" "將委派給 :meth:`x.__floor__ `,並回傳 :class:`~numbers." "Integral` 型別的值。" -#: ../../library/math.rst:235 +#: ../../library/math.rst:234 msgid "" "Fused multiply-add operation. Return ``(x * y) + z``, computed as though " "with infinite precision and range followed by a single round to the " @@ -743,7 +740,7 @@ msgid "" "direct expression ``(x * y) + z``." msgstr "" -#: ../../library/math.rst:240 +#: ../../library/math.rst:239 msgid "" "This function follows the specification of the fusedMultiplyAdd operation " "described in the IEEE 754 standard. The standard leaves one case " @@ -752,7 +749,7 @@ msgid "" "not raise any exception." msgstr "" -#: ../../library/math.rst:251 +#: ../../library/math.rst:250 msgid "" "Return the floating-point remainder of ``x / y``, as defined by the platform " "C library function ``fmod(x, y)``. Note that the Python expression ``x % y`` " @@ -777,13 +774,13 @@ msgstr "" "``1e100``。因此,處理浮點數時通常會選擇函式 :func:`fmod`,而處理整數時會選擇 " "Python 運算式 ``x % y``。" -#: ../../library/math.rst:267 +#: ../../library/math.rst:266 msgid "" "Return the fractional and integer parts of *x*. Both results carry the sign " "of *x* and are floats." msgstr "" -#: ../../library/math.rst:270 +#: ../../library/math.rst:269 msgid "" "Note that :func:`modf` has a different call/return pattern than its C " "equivalents: it takes a single argument and return a pair of values, rather " @@ -791,7 +788,7 @@ msgid "" "is no such thing in Python)." msgstr "" -#: ../../library/math.rst:278 +#: ../../library/math.rst:277 msgid "" "Return the IEEE 754-style remainder of *x* with respect to *y*. For finite " "*x* and finite nonzero *y*, this is the difference ``x - n*y``, where ``n`` " @@ -801,7 +798,7 @@ msgid "" "thus always satisfies ``abs(r) <= 0.5 * abs(y)``." msgstr "" -#: ../../library/math.rst:285 +#: ../../library/math.rst:284 msgid "" "Special cases follow IEEE 754: in particular, ``remainder(x, math.inf)`` is " "*x* for any finite *x*, and ``remainder(x, 0)`` and ``remainder(math.inf, " @@ -809,13 +806,13 @@ msgid "" "remainder operation is zero, that zero will have the same sign as *x*." msgstr "" -#: ../../library/math.rst:291 +#: ../../library/math.rst:290 msgid "" "On platforms using IEEE 754 binary floating point, the result of this " "operation is always exactly representable: no rounding error is introduced." msgstr "" -#: ../../library/math.rst:299 +#: ../../library/math.rst:298 msgid "" "Return *x* with the fractional part removed, leaving the integer part. This " "rounds toward 0: ``trunc()`` is equivalent to :func:`floor` for positive " @@ -824,7 +821,7 @@ msgid "" "class:`~numbers.Integral` value." msgstr "" -#: ../../library/math.rst:306 +#: ../../library/math.rst:305 msgid "" "For the :func:`ceil`, :func:`floor`, and :func:`modf` functions, note that " "*all* floating-point numbers of sufficiently large magnitude are exact " @@ -833,11 +830,11 @@ msgid "" "``abs(x) >= 2**52`` necessarily has no fractional bits." msgstr "" -#: ../../library/math.rst:314 +#: ../../library/math.rst:313 msgid "Floating point manipulation functions" msgstr "" -#: ../../library/math.rst:318 +#: ../../library/math.rst:317 msgid "" "Return a float with the magnitude (absolute value) of *x* but the sign of " "*y*. On platforms that support signed zeros, ``copysign(1.0, -0.0)`` " @@ -846,7 +843,7 @@ msgstr "" "回傳與 *x* 相同長度(絕對值)且與 *y* 同號的浮點數。在支援帶符號零的平臺上," "``copysign(1.0, -0.0)`` 回傳 *-1.0*。" -#: ../../library/math.rst:325 +#: ../../library/math.rst:324 msgid "" "Return the mantissa and exponent of *x* as the pair ``(m, e)``. *m* is a " "float and *e* is an integer such that ``x == m * 2**e`` exactly. If *x* is " @@ -857,7 +854,7 @@ msgstr "" "數,且兩者精確地使 ``x == m * 2**e``。若 *x* 為零,回傳 ``(0.0, 0)``,否則令 " "``0.5 <= abs(m) < 1``。此函式用於以可攜的方式「分割」浮點數內部表示法。" -#: ../../library/math.rst:330 +#: ../../library/math.rst:329 msgid "" "Note that :func:`frexp` has a different call/return pattern than its C " "equivalents: it takes a single argument and return a pair of values, rather " @@ -865,13 +862,13 @@ msgid "" "is no such thing in Python)." msgstr "" -#: ../../library/math.rst:337 +#: ../../library/math.rst:336 msgid "" "Return ``True`` if the values *a* and *b* are close to each other and " "``False`` otherwise." msgstr "若 *a* 及 *b* 兩值足夠接近便回傳 ``True``,否則回傳 ``False``。" -#: ../../library/math.rst:340 +#: ../../library/math.rst:339 msgid "" "Whether or not two values are considered close is determined according to " "given absolute and relative tolerances. If no errors occur, the result will " @@ -880,7 +877,7 @@ msgstr "" "兩數是否足夠接近取決於給定的絕對及相對容許偏差 (tolerance)。如果沒有錯誤發" "生,結果將為:``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``。" -#: ../../library/math.rst:344 +#: ../../library/math.rst:343 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*. " @@ -894,7 +891,7 @@ msgstr "" "設值為 ``1e-09``,該值可確保兩數於大約 9 個十進數位內相同。*rel_tol* 須不為負" "且小於 ``1.0``。" -#: ../../library/math.rst:351 +#: ../../library/math.rst:350 msgid "" "*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be " "nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed " @@ -903,7 +900,7 @@ msgid "" "argument to the call." msgstr "" -#: ../../library/math.rst:357 +#: ../../library/math.rst:356 msgid "" "The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be " "handled according to IEEE rules. Specifically, ``NaN`` is not considered " @@ -914,11 +911,11 @@ msgstr "" "處理。更明確地說,``NaN`` 不會與包含自身在內的任何數字足夠接近,而 ``inf`` " "及 ``-inf`` 皆只與自身接近。" -#: ../../library/math.rst:366 +#: ../../library/math.rst:365 msgid ":pep:`485` -- A function for testing approximate equality" msgstr ":pep:`485` ── 用於測試近似相等的函式" -#: ../../library/math.rst:371 +#: ../../library/math.rst:370 msgid "" "Return ``True`` if *x* is neither an infinity nor a NaN, and ``False`` " "otherwise. (Note that ``0.0`` *is* considered finite.)" @@ -926,128 +923,128 @@ msgstr "" "若 *x* 不是無限值或 ``NaN`` 便回傳 ``True``,否則回傳 ``False``。(注意 " "``0.0`` 被視為有限數。)" -#: ../../library/math.rst:379 +#: ../../library/math.rst:378 msgid "" "Return ``True`` if *x* is a positive or negative infinity, and ``False`` " "otherwise." msgstr "若 *x* 是正無限值或負無限值便回傳 ``True``,否則回傳 ``False``。" -#: ../../library/math.rst:385 +#: ../../library/math.rst:384 msgid "" "Return ``True`` if *x* is a NaN (not a number), and ``False`` otherwise." msgstr "" "若 *x* 是 ``NaN`` ── 即非數字(NaN, not a number)── 便回傳 ``True``,否則回" "傳 ``False``。" -#: ../../library/math.rst:390 +#: ../../library/math.rst:389 msgid "" "Return ``x * (2**i)``. This is essentially the inverse of function :func:" "`frexp`." msgstr "回傳 ``x * (2**i)``。此函式本質上為 :func:`frexp` 的反函式。" -#: ../../library/math.rst:396 +#: ../../library/math.rst:395 msgid "Return the floating-point value *steps* steps after *x* towards *y*." msgstr "" -#: ../../library/math.rst:398 +#: ../../library/math.rst:397 msgid "If *x* is equal to *y*, return *y*, unless *steps* is zero." msgstr "" -#: ../../library/math.rst:400 +#: ../../library/math.rst:399 msgid "Examples:" msgstr "範例:" -#: ../../library/math.rst:402 +#: ../../library/math.rst:401 msgid "``math.nextafter(x, math.inf)`` goes up: towards positive infinity." msgstr "" -#: ../../library/math.rst:403 +#: ../../library/math.rst:402 msgid "``math.nextafter(x, -math.inf)`` goes down: towards minus infinity." msgstr "" -#: ../../library/math.rst:404 +#: ../../library/math.rst:403 msgid "``math.nextafter(x, 0.0)`` goes towards zero." msgstr "" -#: ../../library/math.rst:405 +#: ../../library/math.rst:404 msgid "``math.nextafter(x, math.copysign(math.inf, x))`` goes away from zero." msgstr "" -#: ../../library/math.rst:407 +#: ../../library/math.rst:406 msgid "See also :func:`math.ulp`." msgstr "另請參閱 :func:`math.ulp`。" -#: ../../library/math.rst:411 +#: ../../library/math.rst:410 msgid "Added the *steps* argument." msgstr "新增 *steps* 引數。" -#: ../../library/math.rst:417 +#: ../../library/math.rst:416 msgid "Return the value of the least significant bit of the float *x*:" msgstr "" -#: ../../library/math.rst:419 +#: ../../library/math.rst:418 msgid "If *x* is a NaN (not a number), return *x*." msgstr "" -#: ../../library/math.rst:420 +#: ../../library/math.rst:419 msgid "If *x* is negative, return ``ulp(-x)``." msgstr "若 *x* 為負值,回傳 ``ulp(-x)``。" -#: ../../library/math.rst:421 +#: ../../library/math.rst:420 msgid "If *x* is a positive infinity, return *x*." msgstr "若 *x* 為正無限值,回傳 *x*。" -#: ../../library/math.rst:422 +#: ../../library/math.rst:421 msgid "" "If *x* is equal to zero, return the smallest positive *denormalized* " "representable float (smaller than the minimum positive *normalized* float, :" "data:`sys.float_info.min `)." msgstr "" -#: ../../library/math.rst:425 +#: ../../library/math.rst:424 msgid "" "If *x* is equal to the largest positive representable float, return the " "value of the least significant bit of *x*, such that the first float smaller " "than *x* is ``x - ulp(x)``." msgstr "" -#: ../../library/math.rst:428 +#: ../../library/math.rst:427 msgid "" "Otherwise (*x* is a positive finite number), return the value of the least " "significant bit of *x*, such that the first float bigger than *x* is ``x + " "ulp(x)``." msgstr "" -#: ../../library/math.rst:432 +#: ../../library/math.rst:431 msgid "ULP stands for \"Unit in the Last Place\"." msgstr "" -#: ../../library/math.rst:434 +#: ../../library/math.rst:433 msgid "" "See also :func:`math.nextafter` and :data:`sys.float_info.epsilon `." msgstr "" -#: ../../library/math.rst:441 +#: ../../library/math.rst:440 msgid "Power, exponential and logarithmic functions" msgstr "" -#: ../../library/math.rst:445 +#: ../../library/math.rst:444 msgid "Return the cube root of *x*." msgstr "" -#: ../../library/math.rst:452 +#: ../../library/math.rst:451 msgid "" "Return *e* raised to the power *x*, where *e* = 2.718281... is the base of " "natural logarithms. This is usually more accurate than ``math.e ** x`` or " "``pow(math.e, x)``." msgstr "" -#: ../../library/math.rst:459 +#: ../../library/math.rst:458 msgid "Return *2* raised to the power *x*." msgstr "" -#: ../../library/math.rst:466 +#: ../../library/math.rst:465 msgid "" "Return *e* raised to the power *x*, minus 1. Here *e* is the base of " "natural logarithms. For small floats *x*, the subtraction in ``exp(x) - 1`` " @@ -1056,41 +1053,41 @@ msgid "" "compute this quantity to full precision:" msgstr "" -#: ../../library/math.rst:483 +#: ../../library/math.rst:482 msgid "With one argument, return the natural logarithm of *x* (to base *e*)." msgstr "" -#: ../../library/math.rst:485 +#: ../../library/math.rst:484 msgid "" "With two arguments, return the logarithm of *x* to the given *base*, " "calculated as ``log(x)/log(base)``." msgstr "" -#: ../../library/math.rst:491 +#: ../../library/math.rst:490 msgid "" "Return the natural logarithm of *1+x* (base *e*). The result is calculated " "in a way which is accurate for *x* near zero." msgstr "" -#: ../../library/math.rst:497 +#: ../../library/math.rst:496 msgid "" "Return the base-2 logarithm of *x*. This is usually more accurate than " "``log(x, 2)``." msgstr "" -#: ../../library/math.rst:504 +#: ../../library/math.rst:503 msgid "" ":meth:`int.bit_length` returns the number of bits necessary to represent an " "integer in binary, excluding the sign and leading zeros." msgstr "" -#: ../../library/math.rst:510 +#: ../../library/math.rst:509 msgid "" "Return the base-10 logarithm of *x*. This is usually more accurate than " "``log(x, 10)``." msgstr "" -#: ../../library/math.rst:516 +#: ../../library/math.rst:515 msgid "" "Return *x* raised to the power *y*. Exceptional cases follow the IEEE 754 " "standard as far as possible. In particular, ``pow(1.0, x)`` and ``pow(x, " @@ -1099,44 +1096,44 @@ msgid "" "y)`` is undefined, and raises :exc:`ValueError`." msgstr "" -#: ../../library/math.rst:523 +#: ../../library/math.rst:522 msgid "" "Unlike the built-in ``**`` operator, :func:`math.pow` converts both its " "arguments to type :class:`float`. Use ``**`` or the built-in :func:`pow` " "function for computing exact integer powers." msgstr "" -#: ../../library/math.rst:527 +#: ../../library/math.rst:526 msgid "" "The special cases ``pow(0.0, -inf)`` and ``pow(-0.0, -inf)`` were changed to " "return ``inf`` instead of raising :exc:`ValueError`, for consistency with " "IEEE 754." msgstr "" -#: ../../library/math.rst:535 +#: ../../library/math.rst:534 msgid "Return the square root of *x*." msgstr "" -#: ../../library/math.rst:539 +#: ../../library/math.rst:538 msgid "Summation and product functions" msgstr "" -#: ../../library/math.rst:543 +#: ../../library/math.rst:542 msgid "" "Return the Euclidean distance between two points *p* and *q*, each given as " "a sequence (or iterable) of coordinates. The two points must have the same " "dimension." msgstr "" -#: ../../library/math.rst:547 ../../library/math.rst:608 +#: ../../library/math.rst:546 ../../library/math.rst:607 msgid "Roughly equivalent to::" msgstr "" -#: ../../library/math.rst:549 +#: ../../library/math.rst:548 msgid "sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))" msgstr "sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))" -#: ../../library/math.rst:556 +#: ../../library/math.rst:555 msgid "" "Return an accurate floating-point sum of values in the iterable. Avoids " "loss of precision by tracking multiple intermediate partial sums." @@ -1144,7 +1141,7 @@ msgstr "" "回傳可疊代物件(iterable)中所有值的精確浮點數和。透過追蹤過程中多個部分和" "(partial sum)以避免精確度損失。" -#: ../../library/math.rst:559 +#: ../../library/math.rst:558 msgid "" "The algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the " "typical case where the rounding mode is half-even. On some non-Windows " @@ -1156,7 +1153,7 @@ msgstr "" "有些非 Windows 平台建置時,底層 C 函式庫使用延伸精度加法運算,而可能導致對過" "程中同一部分和重複捨入,並使其最低有效位不如預期。" -#: ../../library/math.rst:565 +#: ../../library/math.rst:564 msgid "" "For further discussion and two alternative approaches, see the `ASPN " "cookbook recipes for accurate floating-point summation `_。" -#: ../../library/math.rst:572 +#: ../../library/math.rst:571 msgid "" "Return the Euclidean norm, ``sqrt(sum(x**2 for x in coordinates))``. This is " "the length of the vector from the origin to the point given by the " "coordinates." msgstr "" -#: ../../library/math.rst:576 +#: ../../library/math.rst:575 msgid "" "For a two dimensional point ``(x, y)``, this is equivalent to computing the " "hypotenuse of a right triangle using the Pythagorean theorem, ``sqrt(x*x + " "y*y)``." msgstr "" -#: ../../library/math.rst:580 +#: ../../library/math.rst:579 msgid "" "Added support for n-dimensional points. Formerly, only the two dimensional " "case was supported." msgstr "" -#: ../../library/math.rst:584 +#: ../../library/math.rst:583 msgid "" "Improved the algorithm's accuracy so that the maximum error is under 1 ulp " "(unit in the last place). More typically, the result is almost always " "correctly rounded to within 1/2 ulp." msgstr "" -#: ../../library/math.rst:592 +#: ../../library/math.rst:591 msgid "" "Calculate the product of all the elements in the input *iterable*. The " "default *start* value for the product is ``1``." msgstr "" -#: ../../library/math.rst:595 +#: ../../library/math.rst:594 msgid "" "When the iterable is empty, return the start value. This function is " "intended specifically for use with numeric values and may reject non-numeric " "types." msgstr "" -#: ../../library/math.rst:604 +#: ../../library/math.rst:603 msgid "Return the sum of products of values from two iterables *p* and *q*." msgstr "" -#: ../../library/math.rst:606 +#: ../../library/math.rst:605 msgid "Raises :exc:`ValueError` if the inputs do not have the same length." msgstr "" -#: ../../library/math.rst:610 +#: ../../library/math.rst:609 msgid "sum(itertools.starmap(operator.mul, zip(p, q, strict=True)))" msgstr "sum(itertools.starmap(operator.mul, zip(p, q, strict=True)))" -#: ../../library/math.rst:612 +#: ../../library/math.rst:611 msgid "" "For float and mixed int/float inputs, the intermediate products and sums are " "computed with extended precision." msgstr "" -#: ../../library/math.rst:619 +#: ../../library/math.rst:618 msgid "Angular conversion" msgstr "" -#: ../../library/math.rst:623 +#: ../../library/math.rst:622 msgid "Convert angle *x* from radians to degrees." msgstr "" -#: ../../library/math.rst:628 +#: ../../library/math.rst:627 msgid "Convert angle *x* from degrees to radians." msgstr "" -#: ../../library/math.rst:632 +#: ../../library/math.rst:631 msgid "Trigonometric functions" msgstr "" -#: ../../library/math.rst:636 +#: ../../library/math.rst:635 msgid "" "Return the arc cosine of *x*, in radians. The result is between ``0`` and " "``pi``." msgstr "" -#: ../../library/math.rst:642 +#: ../../library/math.rst:641 msgid "" "Return the arc sine of *x*, in radians. The result is between ``-pi/2`` and " "``pi/2``." msgstr "" -#: ../../library/math.rst:648 +#: ../../library/math.rst:647 msgid "" "Return the arc tangent of *x*, in radians. The result is between ``-pi/2`` " "and ``pi/2``." msgstr "" -#: ../../library/math.rst:654 +#: ../../library/math.rst:653 msgid "" "Return ``atan(y / x)``, in radians. The result is between ``-pi`` and " "``pi``. The vector in the plane from the origin to point ``(x, y)`` makes " @@ -1268,78 +1265,78 @@ msgid "" "``pi/4``, but ``atan2(-1, -1)`` is ``-3*pi/4``." msgstr "" -#: ../../library/math.rst:664 +#: ../../library/math.rst:663 msgid "Return the cosine of *x* radians." msgstr "" -#: ../../library/math.rst:669 +#: ../../library/math.rst:668 msgid "Return the sine of *x* radians." msgstr "" -#: ../../library/math.rst:674 +#: ../../library/math.rst:673 msgid "Return the tangent of *x* radians." msgstr "" -#: ../../library/math.rst:678 +#: ../../library/math.rst:677 msgid "Hyperbolic functions" msgstr "" -#: ../../library/math.rst:680 +#: ../../library/math.rst:679 msgid "" "`Hyperbolic functions `_ " "are analogs of trigonometric functions that are based on hyperbolas instead " "of circles." msgstr "" -#: ../../library/math.rst:686 +#: ../../library/math.rst:685 msgid "Return the inverse hyperbolic cosine of *x*." msgstr "" -#: ../../library/math.rst:691 +#: ../../library/math.rst:690 msgid "Return the inverse hyperbolic sine of *x*." msgstr "" -#: ../../library/math.rst:696 +#: ../../library/math.rst:695 msgid "Return the inverse hyperbolic tangent of *x*." msgstr "" -#: ../../library/math.rst:701 +#: ../../library/math.rst:700 msgid "Return the hyperbolic cosine of *x*." msgstr "" -#: ../../library/math.rst:706 +#: ../../library/math.rst:705 msgid "Return the hyperbolic sine of *x*." msgstr "" -#: ../../library/math.rst:711 +#: ../../library/math.rst:710 msgid "Return the hyperbolic tangent of *x*." msgstr "" -#: ../../library/math.rst:715 +#: ../../library/math.rst:714 msgid "Special functions" msgstr "特殊函式" -#: ../../library/math.rst:719 +#: ../../library/math.rst:718 msgid "" "Return the `error function `_ " "at *x*." msgstr "" -#: ../../library/math.rst:722 +#: ../../library/math.rst:721 msgid "" "The :func:`erf` function can be used to compute traditional statistical " "functions such as the `cumulative standard normal distribution `_::" msgstr "" -#: ../../library/math.rst:726 +#: ../../library/math.rst:725 msgid "" "def phi(x):\n" " 'Cumulative distribution function for the standard normal distribution'\n" " return (1.0 + erf(x / sqrt(2.0))) / 2.0" msgstr "" -#: ../../library/math.rst:735 +#: ../../library/math.rst:734 msgid "" "Return the complementary error function at *x*. The `complementary error " "function `_ is defined as " @@ -1348,31 +1345,31 @@ msgid "" "Loss_of_significance>`_\\." msgstr "" -#: ../../library/math.rst:746 +#: ../../library/math.rst:745 msgid "" "Return the `Gamma function `_ " "at *x*." msgstr "" -#: ../../library/math.rst:754 +#: ../../library/math.rst:753 msgid "" "Return the natural logarithm of the absolute value of the Gamma function at " "*x*." msgstr "" -#: ../../library/math.rst:761 +#: ../../library/math.rst:760 msgid "Constants" msgstr "常數" -#: ../../library/math.rst:765 +#: ../../library/math.rst:764 msgid "The mathematical constant *π* = 3.141592..., to available precision." msgstr "" -#: ../../library/math.rst:770 +#: ../../library/math.rst:769 msgid "The mathematical constant *e* = 2.718281..., to available precision." msgstr "" -#: ../../library/math.rst:775 +#: ../../library/math.rst:774 msgid "" "The mathematical constant *τ* = 6.283185..., to available precision. Tau is " "a circle constant equal to 2\\ *π*, the ratio of a circle's circumference to " @@ -1381,13 +1378,13 @@ msgid "" "celebrating `Tau day `_ by eating twice as much pie!" msgstr "" -#: ../../library/math.rst:786 +#: ../../library/math.rst:785 msgid "" "A floating-point positive infinity. (For negative infinity, use ``-math." "inf``.) Equivalent to the output of ``float('inf')``." msgstr "" -#: ../../library/math.rst:794 +#: ../../library/math.rst:793 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to the output of " "``float('nan')``. Due to the requirements of the `IEEE-754 standard \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -380,7 +380,7 @@ msgstr "" msgid "" "Resizing a map created with *access* of :const:`ACCESS_READ` or :const:" "`ACCESS_COPY`, will raise a :exc:`TypeError` exception. Resizing a map " -"created with with *trackfd* set to ``False``, will raise a :exc:`ValueError` " +"created with *trackfd* set to ``False``, will raise a :exc:`ValueError` " "exception." msgstr "" diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 810572ad3d..77bc4341ef 100644 --- a/library/multiprocessing.po +++ b/library/multiprocessing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-23 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1605,7 +1605,7 @@ msgstr "" #: ../../library/multiprocessing.rst:1044 msgid "" "Add support for when a program which uses :mod:`multiprocessing` has been " -"frozen to produce a Windows executable. (Has been tested with **py2exe**, " +"frozen to produce an executable. (Has been tested with **py2exe**, " "**PyInstaller** and **cx_Freeze**.)" msgstr "" @@ -1643,10 +1643,10 @@ msgstr "" #: ../../library/multiprocessing.rst:1063 msgid "" -"Calling ``freeze_support()`` has no effect when invoked on any operating " -"system other than Windows. In addition, if the module is being run normally " -"by the Python interpreter on Windows (the program has not been frozen), then " -"``freeze_support()`` has no effect." +"Calling ``freeze_support()`` has no effect when the start method is not " +"*spawn*. In addition, if the module is being run normally by the Python " +"interpreter (the program has not been frozen), then ``freeze_support()`` has " +"no effect." msgstr "" #: ../../library/multiprocessing.rst:1070 diff --git a/library/netrc.po b/library/netrc.po index 81fdb294b8..b19a56f6d2 100644 --- a/library/netrc.po +++ b/library/netrc.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-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:06+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,29 +42,35 @@ msgid "" "user's home directory -- as determined by :func:`os.path.expanduser` -- will " "be read. Otherwise, a :exc:`FileNotFoundError` exception will be raised. " "Parse errors will raise :exc:`NetrcParseError` with diagnostic information " -"including the file name, line number, and terminating token. If no argument " -"is specified on a POSIX system, the presence of passwords in the :file:`." -"netrc` file will raise a :exc:`NetrcParseError` if the file ownership or " -"permissions are insecure (owned by a user other than the user running the " -"process, or accessible for read or write by any other user). This implements " -"security behavior equivalent to that of ftp and other programs that use :" -"file:`.netrc`." +"including the file name, line number, and terminating token." msgstr "" ":class:`~netrc.netrc` 實例或其子類別實例能夠封裝來自 netrc 檔案的資料。可用初" "始化引數(如有給定)指定要剖析的檔案,如果未給定引數,則將讀取(由 :func:`os." "path.expanduser` 指定的)使用者主目錄中的 :file:`.netrc` 檔案,否則將引發 :" "exc:`FileNotFoundError` 例外。剖析錯誤會引發 :exc:`NetrcParseError`,其帶有包" -"括檔案名稱、列號和終止 token 的診斷資訊。如果在 POSIX 系統上未指定引數,且若" +"括檔案名稱、列號和終止 token 的診斷資訊。" + +#: ../../library/netrc.rst:28 +msgid "" +"If no argument is specified on a POSIX system, the presence of passwords in " +"the :file:`.netrc` file will raise a :exc:`NetrcParseError` if the file " +"ownership or permissions are insecure (owned by a user other than the user " +"running the process, or accessible for read or write by any other user). " +"This implements security behavior equivalent to that of ftp and other " +"programs that use :file:`.netrc`. Such security checks are not available on " +"platforms that do not support :func:`os.getuid`." +msgstr "" +"如果在 POSIX 系統上未指定引數,且若" "檔案所有權或權限不安全(擁有者與運行該行程的使用者不同,或者可供任何其他使用" "者讀取或寫入),存有密碼的 :file:`.netrc` 檔案將會引發 :exc:" "`NetrcParseError`。這實作了與 ftp 和其他使用 :file:`.netrc` 程式等效的安全行" -"為。" +"為。這種安全檢查在不支援 :func:`os.getuid` 的平台上不可用。" -#: ../../library/netrc.rst:34 +#: ../../library/netrc.rst:36 msgid "Added the POSIX permission check." msgstr "新增了 POSIX 權限檢查。" -#: ../../library/netrc.rst:36 +#: ../../library/netrc.rst:38 msgid "" ":func:`os.path.expanduser` is used to find the location of the :file:`." "netrc` file when *file* is not passed as argument." @@ -72,7 +78,7 @@ msgstr "" "當未傳遞 *file* 引數時,:func:`os.path.expanduser` 可用於查找 :file:`.netrc` " "檔案的位置。" -#: ../../library/netrc.rst:40 +#: ../../library/netrc.rst:42 msgid "" ":class:`netrc` try UTF-8 encoding before using locale specific encoding. The " "entry in the netrc file no longer needs to contain all tokens. The missing " @@ -86,7 +92,7 @@ msgstr "" "其值都可以包含任意字元,例如空格和非 ASCII 字元。如果登入名稱為匿名,就不會觸" "發安全檢查。" -#: ../../library/netrc.rst:51 +#: ../../library/netrc.rst:53 msgid "" "Exception raised by the :class:`~netrc.netrc` class when syntactical errors " "are encountered in source text. Instances of this exception provide three " @@ -95,27 +101,27 @@ msgstr "" "當原始文本中遇到語法錯誤時,:class:`~netrc.netrc` 類別會引發例外。此例外的實" "例提供了三個有趣的屬性:" -#: ../../library/netrc.rst:57 +#: ../../library/netrc.rst:59 msgid "Textual explanation of the error." msgstr "錯誤的文字解釋。" -#: ../../library/netrc.rst:61 +#: ../../library/netrc.rst:63 msgid "The name of the source file." msgstr "原始檔案的名稱。" -#: ../../library/netrc.rst:65 +#: ../../library/netrc.rst:67 msgid "The line number on which the error was found." msgstr "發現錯誤的列號。" -#: ../../library/netrc.rst:71 +#: ../../library/netrc.rst:73 msgid "netrc Objects" msgstr "netrc 物件" -#: ../../library/netrc.rst:73 +#: ../../library/netrc.rst:75 msgid "A :class:`~netrc.netrc` instance has the following methods:" msgstr ":class:`~netrc.netrc` 實例具有以下方法:" -#: ../../library/netrc.rst:78 +#: ../../library/netrc.rst:80 msgid "" "Return a 3-tuple ``(login, account, password)`` of authenticators for " "*host*. If the netrc file did not contain an entry for the given host, " @@ -126,7 +132,7 @@ msgstr "" "netrc 檔案不包含給定主機的條目,則回傳與 'default' 條目關聯的 tuple。如果並無" "匹配主機且預設條目也不可用則回傳 ``None``。" -#: ../../library/netrc.rst:86 +#: ../../library/netrc.rst:88 msgid "" "Dump the class data as a string in the format of a netrc file. (This " "discards comments and may reorder the entries.)" @@ -134,11 +140,11 @@ msgstr "" "將類別資料傾印 (dump) 為 netrc 檔案格式的字串。(這會將註解移除,並可能會對條" "目重新排序。)" -#: ../../library/netrc.rst:89 +#: ../../library/netrc.rst:91 msgid "Instances of :class:`~netrc.netrc` have public instance variables:" msgstr ":class:`~netrc.netrc` 的實例具有公開實例變數:" -#: ../../library/netrc.rst:94 +#: ../../library/netrc.rst:96 msgid "" "Dictionary mapping host names to ``(login, account, password)`` tuples. The " "'default' entry, if any, is represented as a pseudo-host by that name." @@ -146,6 +152,6 @@ msgstr "" "將主機名稱對映到 ``(login, account, password)`` tuple 的字典。'default' 條目" "(如存在)表示為該名稱對應到的偽主機 (pseudo-host)。" -#: ../../library/netrc.rst:100 +#: ../../library/netrc.rst:102 msgid "Dictionary mapping macro names to string lists." msgstr "巨集 (macro) 名稱與字串 list(串列)的對映字典。" diff --git a/library/os.path.po b/library/os.path.po index 0aa9f44b60..12a8476e27 100644 --- a/library/os.path.po +++ b/library/os.path.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-07-13 14:06+0800\n" "Last-Translator: Po-Chuan Chen \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,9 +37,9 @@ msgid "" "module. The path parameters can be passed as strings, or bytes, or any " "object implementing the :class:`os.PathLike` protocol." msgstr "" -"該模組實現了一些有用的路徑名操作函式。若要讀取或寫入檔案,請參" -"閱 :func:`open` 函式,要存取檔案系統,請參閱 :mod:`os` 模組。路徑參數可以以字" -"串、位元組或任何依照 :class:`os.PathLike` 協議實作的物件傳遞。" +"該模組實現了一些有用的路徑名操作函式。若要讀取或寫入檔案,請參閱 :func:" +"`open` 函式,要存取檔案系統,請參閱 :mod:`os` 模組。路徑參數可以以字串、位元" +"組或任何依照 :class:`os.PathLike` 協議實作的物件傳遞。" #: ../../library/os.path.rst:19 msgid "" @@ -68,12 +68,12 @@ msgstr "" #: ../../library/os.path.rst:37 msgid "" "Since different operating systems have different path name conventions, " -"there are several versions of this module in the standard library. " -"The :mod:`os.path` module is always the path module suitable for the " -"operating system Python is running on, and therefore usable for local " -"paths. However, you can also import and use the individual modules if you " -"want to manipulate a path that is *always* in one of the different formats. " -"They all have the same interface:" +"there are several versions of this module in the standard library. The :mod:" +"`os.path` module is always the path module suitable for the operating system " +"Python is running on, and therefore usable for local paths. However, you " +"can also import and use the individual modules if you want to manipulate a " +"path that is *always* in one of the different formats. They all have the " +"same interface:" msgstr "" "由於不同的作業系統具有不同的路徑命名慣例,在標準函式庫中的路徑模組有數個版本" "可供使用,而 :mod:`os.path` 模組都會是運行 Python 之作業系統所適用本地路徑。" @@ -90,13 +90,14 @@ msgstr ":mod:`ntpath` 用於 Windows 的路徑" #: ../../library/os.path.rst:51 msgid "" -":func:`exists`, :func:`lexists`, :func:`isdir`, :func:`isfile`, :func:`islink`, " -"and :func:`ismount` now return ``False`` instead of raising an exception for " -"paths that contain characters or bytes unrepresentable at the OS level." +":func:`exists`, :func:`lexists`, :func:`isdir`, :func:`isfile`, :func:" +"`islink`, and :func:`ismount` now return ``False`` instead of raising an " +"exception for paths that contain characters or bytes unrepresentable at the " +"OS level." msgstr "" -"對於包含有作業系統層級無法表示之字元或位元組的路" -"徑,:func:`exists`、:func:`lexists`、:func:`isdir`、:func:`isfile`、:func:`islink` " -"和 :func:`ismount` 函式現在會回傳 ``False``,而不是引發例外。" +"對於包含有作業系統層級無法表示之字元或位元組的路徑,:func:`exists`、:func:" +"`lexists`、:func:`isdir`、:func:`isfile`、:func:`islink` 和 :func:`ismount` " +"函式現在會回傳 ``False``,而不是引發例外。" #: ../../library/os.path.rst:59 msgid "" @@ -104,8 +105,8 @@ msgid "" "platforms, this is equivalent to calling the function :func:`normpath` as " "follows: ``normpath(join(os.getcwd(), path))``." msgstr "" -"回傳經正規化的絕對路徑名 *path* 。在大多數平台上,這等效於按照以下方式呼" -"叫 :func:`normpath` 函式:``normpath(join(os.getcwd(), path))``。" +"回傳經正規化的絕對路徑名 *path* 。在大多數平台上,這等效於按照以下方式呼叫 :" +"func:`normpath` 函式:``normpath(join(os.getcwd(), path))``。" #: ../../library/os.path.rst:63 ../../library/os.path.rst:76 #: ../../library/os.path.rst:117 ../../library/os.path.rst:126 @@ -116,10 +117,10 @@ msgstr "" #: ../../library/os.path.rst:260 ../../library/os.path.rst:270 #: ../../library/os.path.rst:289 ../../library/os.path.rst:308 #: ../../library/os.path.rst:380 ../../library/os.path.rst:400 -#: ../../library/os.path.rst:423 ../../library/os.path.rst:443 -#: ../../library/os.path.rst:459 ../../library/os.path.rst:470 -#: ../../library/os.path.rst:484 ../../library/os.path.rst:500 -#: ../../library/os.path.rst:525 ../../library/os.path.rst:589 +#: ../../library/os.path.rst:440 ../../library/os.path.rst:469 +#: ../../library/os.path.rst:485 ../../library/os.path.rst:496 +#: ../../library/os.path.rst:510 ../../library/os.path.rst:526 +#: ../../library/os.path.rst:551 ../../library/os.path.rst:615 msgid "Accepts a :term:`path-like object`." msgstr "接受一個 :term:`path-like object`。" @@ -133,20 +134,19 @@ msgid "" msgstr "" "回傳路徑名 *path* 的基底名稱。這是將 *path* 傳遞給函式 :func:`split` 後回傳結" "果中的第二個元素。請注意,此函式的結果與 Unix 的 :program:`basename` 程式不" -"同;對於 ``'/foo/bar/'``,:program:`basename` 回傳 ``'bar'``," -"而 :func:`basename` 函式回傳空字串(``''``)。" +"同;對於 ``'/foo/bar/'``,:program:`basename` 回傳 ``'bar'``,而 :func:" +"`basename` 函式回傳空字串(``''``)。" #: ../../library/os.path.rst:82 -#, fuzzy msgid "" "Return the longest common sub-path of each pathname in the iterable " "*paths*. Raise :exc:`ValueError` if *paths* contain both absolute and " "relative pathnames, if *paths* are on different drives, or if *paths* is " "empty. Unlike :func:`commonprefix`, this returns a valid path." msgstr "" -"回傳序列 *paths* 中每個路徑名的最長共同子路徑。如果 *paths* 同時包含絕對路徑" -"和相對路徑、*paths* 位於不同的驅動機或 *paths* 為空,則引" -"發 :exc:`ValueError`。與 :func:`commonprefix` 不同,此函式回傳的是有效路徑。" +"回傳可疊代物件 *paths* 中每個路徑名稱的最長共同子路徑。如果 *paths* 同時包含絕對路徑名稱" +"和相對路徑名稱、*paths* 位於不同的驅動機或 *paths* 為空,則引發 :exc:" +"`ValueError`。與 :func:`commonprefix` 不同,此函式回傳的是有效路徑。" #: ../../library/os.path.rst:90 msgid "Accepts a sequence of :term:`path-like objects `." @@ -218,11 +218,11 @@ msgstr "" #: ../../library/os.path.rst:148 msgid "" "Return ``True`` if *path* refers to an existing path, including broken " -"symbolic links. Equivalent to :func:`exists` on platforms " -"lacking :func:`os.lstat`." +"symbolic links. Equivalent to :func:`exists` on platforms lacking :func:" +"`os.lstat`." msgstr "" -"如果 *path* 是一個存在的路徑則回傳 ``True``,對已損壞的符號連結也是。在缺" -"乏 :func:`os.lstat` 的平台上,與 :func:`exists` 函式等效。" +"如果 *path* 是一個存在的路徑則回傳 ``True``,對已損壞的符號連結也是。在缺乏 :" +"func:`os.lstat` 的平台上,與 :func:`exists` 函式等效。" #: ../../library/os.path.rst:160 msgid "" @@ -234,11 +234,10 @@ msgstr "" #: ../../library/os.path.rst:165 msgid "" -"On Unix, an initial ``~`` is replaced by the environment " -"variable :envvar:`HOME` if it is set; otherwise the current user's home " -"directory is looked up in the password directory through the built-in " -"module :mod:`pwd`. An initial ``~user`` is looked up directly in the " -"password directory." +"On Unix, an initial ``~`` is replaced by the environment variable :envvar:" +"`HOME` if it is set; otherwise the current user's home directory is looked " +"up in the password directory through the built-in module :mod:`pwd`. An " +"initial ``~user`` is looked up directly in the password directory." msgstr "" "在 Unix 上,如果環境變數 :envvar:`HOME` 有被設置,則將初始的 ``~`` 替換為該變" "數的值;否則將使用內建模組 :mod:`pwd` 在密碼目錄中查找目前使用者的家目錄。對" @@ -289,9 +288,9 @@ msgstr "" #: ../../library/os.path.rst:204 msgid "" "Return the time of last access of *path*. The return value is a floating-" -"point number giving the number of seconds since the epoch (see " -"the :mod:`time` module). Raise :exc:`OSError` if the file does not exist " -"or is inaccessible." +"point number giving the number of seconds since the epoch (see the :mod:" +"`time` module). Raise :exc:`OSError` if the file does not exist or is " +"inaccessible." msgstr "" "回傳 *path* 的最後存取時間。回傳值是一個浮點數,表示自紀元(參見 :mod:`time` " "模組)以來的秒數。如果檔案不存在或無法存取,則引發 :exc:`OSError`。" @@ -324,8 +323,8 @@ msgid "" "Return the size, in bytes, of *path*. Raise :exc:`OSError` if the file does " "not exist or is inaccessible." msgstr "" -"回傳 *path* 的大小(以位元組為單位)。如果檔案不存在或無法存取,則引" -"發 :exc:`OSError`。" +"回傳 *path* 的大小(以位元組為單位)。如果檔案不存在或無法存取,則引發 :exc:" +"`OSError`。" #: ../../library/os.path.rst:242 msgid "" @@ -350,8 +349,8 @@ msgid "" "true for the same path." msgstr "" "如果 *path* 是一個\\ :func:`已存在的 `\\ 常規檔案,則回傳 ``True``。" -"這將跟隨符號連結,因此同一個路徑可以同時回傳 :func:`islink` " -"和 :func:`isfile` 的結果為真。" +"這將跟隨符號連結,因此同一個路徑可以同時回傳 :func:`islink` 和 :func:" +"`isfile` 的結果為真。" #: ../../library/os.path.rst:266 msgid "" @@ -394,12 +393,12 @@ msgid "" "called to see if it is different from the input path." msgstr "" "如果路徑名 *path* 是一個掛載點 (:dfn:`mount point`),則回傳 ``True``:即在檔" -"案系統中掛載了不同的檔案系統。在 POSIX 系統上,該函式檢查 *path* 的父目" -"錄 :file:`{path}/..` 是否位於不同的設備上,或者 :file:`{path}/..` 和 *path* " -"是否指向同一設備上的相同 i-node --- 這應該能夠檢測出所有 Unix 和 POSIX 變體的" -"掛載點。但無法可靠地檢測出相同檔案系統上的綁定掛載點 (bind mount)。在 " -"Windows 上,以驅動機字母開頭的根目錄和 UNC 共享路徑始終是掛載點,對於任何其他" -"路徑,會呼叫 ``GetVolumePathName`` 函式來檢查它是否與輸入路徑不同。" +"案系統中掛載了不同的檔案系統。在 POSIX 系統上,該函式檢查 *path* 的父目錄 :" +"file:`{path}/..` 是否位於不同的設備上,或者 :file:`{path}/..` 和 *path* 是否" +"指向同一設備上的相同 i-node --- 這應該能夠檢測出所有 Unix 和 POSIX 變體的掛載" +"點。但無法可靠地檢測出相同檔案系統上的綁定掛載點 (bind mount)。在 Windows " +"上,以驅動機字母開頭的根目錄和 UNC 共享路徑始終是掛載點,對於任何其他路徑,會" +"呼叫 ``GetVolumePathName`` 函式來檢查它是否與輸入路徑不同。" #: ../../library/os.path.rst:305 msgid "Added support for detecting non-root mount points on Windows." @@ -425,9 +424,8 @@ msgid "" "windows/dev-drive/>`_ for information on enabling and creating Dev Drives." msgstr "" "可能會對無效的路徑引發錯誤,例如,沒有可識別的驅動機的路徑,但在不支援 Dev 磁" -"碟機的平台上返回 ``False``。請參閱 `Windows 文件 `_\\ 以了解有關啟用和建立 Dev 驅動機的" -"資訊。" +"碟機的平台上返回 ``False``。請參閱 `Windows 文件 `_\\ 以了解有關啟用和建立 Dev 驅動機的資訊。" #: ../../library/os.path.rst:327 msgid "" @@ -480,9 +478,9 @@ msgid "" "On Windows, the drive is not reset when a rooted path segment (e.g., " "``r'\\foo'``) is encountered. If a segment is on a different drive or is an " "absolute path, all previous segments are ignored and the drive is reset. " -"Note that since there is a current directory for each drive, " -"``os.path.join(\"c:\", \"foo\")`` represents a path relative to the current " -"directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\\\foo`." +"Note that since there is a current directory for each drive, ``os.path." +"join(\"c:\", \"foo\")`` represents a path relative to the current directory " +"on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\\\foo`." msgstr "" "在 Windows 上,當遇到根路徑段(例如,``r'\\foo'``)時,驅動機不會被重置。如果" "一個段位於不同的驅動機上,或者是絕對路徑,則將忽略所有之前的段並重置驅動機。" @@ -526,13 +524,12 @@ msgid "" "leading characters shall be treated as a single character." msgstr "" "在 POSIX 系統中,根據 `IEEE Std 1003.1 2013 版; 4.13 Pathname Resolution " -"`_ 標準,如果一個路徑名恰好以兩個斜線開頭,則在前導" -"字元後的第一個部分可能會以由實作品自行定義的方式解釋,雖然多於兩個前導字元應" -"該被視為單個字元。" +"`_ 標準,如果一個路徑名恰好以兩個斜線開頭,則在前導字元後的第" +"一個部分可能會以由實作品自行定義的方式解釋,雖然多於兩個前導字元應該被視為單" +"個字元。" #: ../../library/os.path.rst:406 -#, fuzzy msgid "" "Return the canonical path of the specified filename, eliminating any " "symbolic links encountered in the path (if they are supported by the " @@ -540,21 +537,47 @@ msgid "" "called 8.3) style names such as ``C:\\\\PROGRA~1`` to ``C:\\\\Program " "Files``." msgstr "" -"回傳指定檔案名稱的規範路徑,消除路徑中遇到的所有符號連結(如果作業系統支" -"援)。" +"回傳指定檔案名稱的規範路徑,會消除路徑中遇到的所有符號連結(如果作業系統支" +"援)。在 Windows 上,此函式還會解析 MS-DOS(也稱為 8.3)" +"樣式的名稱,例如 ``C:\\\\PROGRA~1`` 會被解析為 " +"``C:\\\\Program Files``。" #: ../../library/os.path.rst:411 -#, fuzzy msgid "" -"If a path doesn't exist or a symlink loop is encountered, and *strict* is " -"``True``, :exc:`OSError` is raised. If *strict* is ``False`` these errors " -"are ignored, and so the result might be missing or otherwise inaccessible." +"By default, the path is evaluated up to the first component that does not " +"exist, is a symlink loop, or whose evaluation raises :exc:`OSError`. All " +"such components are appended unchanged to the existing part of the path." msgstr "" -"如果路徑不存在或遇到符號連結迴圈,且 *strict* 為 ``True``,則引" -"發 :exc:`OSError`。如果 *strict* 為 ``False``,則將路徑盡可能解析,並將任何剩" -"餘部分附加在後面,而不檢查其是否存在。" -#: ../../library/os.path.rst:416 +#: ../../library/os.path.rst:415 +msgid "" +"Some errors that are handled this way include \"access denied\", \"not a " +"directory\", or \"bad argument to internal function\". Thus, the resulting " +"path may be missing or inaccessible, may still contain links or loops, and " +"may traverse non-directories." +msgstr "" + +#: ../../library/os.path.rst:420 +msgid "This behavior can be modified by keyword arguments:" +msgstr "" + +#: ../../library/os.path.rst:422 +msgid "" +"If *strict* is ``True``, the first error encountered when evaluating the " +"path is re-raised. In particular, :exc:`FileNotFoundError` is raised if " +"*path* does not exist, or another :exc:`OSError` if it is otherwise " +"inaccessible." +msgstr "" + +#: ../../library/os.path.rst:427 +msgid "" +"If *strict* is :py:data:`os.path.ALLOW_MISSING`, errors other than :exc:" +"`FileNotFoundError` are re-raised (as with ``strict=True``). Thus, the " +"returned path will not contain any symbolic links, but the named file and " +"some of its parent directories may be missing." +msgstr "" + +#: ../../library/os.path.rst:433 msgid "" "This function emulates the operating system's procedure for making a path " "canonical, which differs slightly between Windows and UNIX with respect to " @@ -563,21 +586,31 @@ msgstr "" "此函式模擬作業系統使路徑成為規範的過程,Windows 和 UNIX 之間在鏈接和後續路徑" "部份交互方式方面略有不同。" -#: ../../library/os.path.rst:420 +#: ../../library/os.path.rst:437 msgid "" "Operating system APIs make paths canonical as needed, so it's not normally " "necessary to call this function." msgstr "作業系統的 API 會根據需要自動使路徑正則,因此通常不需要呼叫此函式。" -#: ../../library/os.path.rst:426 +#: ../../library/os.path.rst:443 msgid "Symbolic links and junctions are now resolved on Windows." msgstr "在 Windows 上,現在會解析符號連結和連接點。" -#: ../../library/os.path.rst:429 +#: ../../library/os.path.rst:446 msgid "The *strict* parameter was added." msgstr "新增 *strict* 參數。" -#: ../../library/os.path.rst:435 +#: ../../library/os.path.rst:449 +msgid "" +"The :py:data:`~os.path.ALLOW_MISSING` value for the *strict* parameter was " +"added." +msgstr "" + +#: ../../library/os.path.rst:455 +msgid "Special value used for the *strict* argument in :func:`realpath`." +msgstr "" + +#: ../../library/os.path.rst:461 msgid "" "Return a relative filepath to *path* either from the current directory or " "from an optional *start* directory. This is a path computation: the " @@ -589,11 +622,11 @@ msgstr "" "算:不會存取檔案系統來確認 *path* 或 *start* 的存在或屬性。在 Windows 上,當 " "*path* 和 *start* 在不同的驅動機上時,會引發 :exc:`ValueError`。" -#: ../../library/os.path.rst:441 +#: ../../library/os.path.rst:467 msgid "*start* defaults to :data:`os.curdir`." msgstr "*start* 的預設值為 :data:`os.curdir`。" -#: ../../library/os.path.rst:449 +#: ../../library/os.path.rst:475 msgid "" "Return ``True`` if both pathname arguments refer to the same file or " "directory. This is determined by the device number and i-node number and " @@ -603,34 +636,33 @@ msgstr "" "i-node 編號來確定的,如果對任一路徑名的 :func:`os.stat` 呼叫失敗,則會引發異" "常。" -#: ../../library/os.path.rst:453 ../../library/os.path.rst:467 -#: ../../library/os.path.rst:481 +#: ../../library/os.path.rst:479 ../../library/os.path.rst:493 +#: ../../library/os.path.rst:507 msgid "Added Windows support." msgstr "新增對 Windows 的支援。" -#: ../../library/os.path.rst:456 +#: ../../library/os.path.rst:482 msgid "Windows now uses the same implementation as all other platforms." msgstr "現在在 Windows 上使用與其他所有平台相同的實作方式。" -#: ../../library/os.path.rst:465 +#: ../../library/os.path.rst:491 msgid "" "Return ``True`` if the file descriptors *fp1* and *fp2* refer to the same " "file." msgstr "如果文件描述符 *fp1* 和 *fp2* 指向同一個檔案,則回傳 ``True``。" -#: ../../library/os.path.rst:476 +#: ../../library/os.path.rst:502 msgid "" "Return ``True`` if the stat tuples *stat1* and *stat2* refer to the same " -"file. These structures may have been returned " -"by :func:`os.fstat`, :func:`os.lstat`, or :func:`os.stat`. This function " -"implements the underlying comparison used by :func:`samefile` " -"and :func:`sameopenfile`." +"file. These structures may have been returned by :func:`os.fstat`, :func:`os." +"lstat`, or :func:`os.stat`. This function implements the underlying " +"comparison used by :func:`samefile` and :func:`sameopenfile`." msgstr "" "如果 stat 值組 *stat1* 和 *stat2* 指向同一個檔案,則回傳 ``True``。這些結構可" -"能由 :func:`os.fstat`、:func:`os.lstat` 或 :func:`os.stat` 回傳。此函式使" -"用 :func:`samefile` 和 :func:`sameopenfile` 實現了底層比較。" +"能由 :func:`os.fstat`、:func:`os.lstat` 或 :func:`os.stat` 回傳。此函式使用 :" +"func:`samefile` 和 :func:`sameopenfile` 實現了底層比較。" -#: ../../library/os.path.rst:490 +#: ../../library/os.path.rst:516 msgid "" "Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the " "last pathname component and *head* is everything leading up to that. The " @@ -647,10 +679,10 @@ msgstr "" "結尾,則 *tail* 將為空。如果 *path* 中沒有斜線,則 *head* 將為空。如果 " "*path* 為空,則 *head* 和 *tail* 都為空。除非 *head* 是根目錄(僅有一個或多個" "斜線),否則從 *head* 中刪除尾部的斜線。在所有情況下,``join(head, tail)`` 回" -"傳指向與 *path* 相同位置的路徑(但字串可能不同)。還可以參考函" -"式 :func:`dirname` 和 :func:`basename`。" +"傳指向與 *path* 相同位置的路徑(但字串可能不同)。還可以參考函式 :func:" +"`dirname` 和 :func:`basename`。" -#: ../../library/os.path.rst:506 +#: ../../library/os.path.rst:532 msgid "" "Split the pathname *path* into a pair ``(drive, tail)`` where *drive* is " "either a mount point or the empty string. On systems which do not use drive " @@ -661,12 +693,12 @@ msgstr "" "串。在不使用驅動機規範的系統上,*drive* 將始終為空字串。在所有情況下," "``drive + tail`` 將與 *path* 相同。" -#: ../../library/os.path.rst:511 +#: ../../library/os.path.rst:537 msgid "" "On Windows, splits a pathname into drive/UNC sharepoint and relative path." msgstr "在 Windows 上,將路徑名拆分為驅動機或 UNC 共享點以及相對路徑。" -#: ../../library/os.path.rst:513 +#: ../../library/os.path.rst:539 msgid "" "If the path contains a drive letter, drive will contain everything up to and " "including the colon::" @@ -674,7 +706,7 @@ msgstr "" "如果路徑包含驅動機字母,則 *drive* 將包含從頭到冒號(包括冒號)的所有內" "容: ::" -#: ../../library/os.path.rst:516 +#: ../../library/os.path.rst:542 msgid "" ">>> splitdrive(\"c:/dir\")\n" "(\"c:\", \"/dir\")" @@ -682,12 +714,12 @@ msgstr "" ">>> splitdrive(\"c:/dir\")\n" "(\"c:\", \"/dir\")" -#: ../../library/os.path.rst:519 +#: ../../library/os.path.rst:545 msgid "" "If the path contains a UNC path, drive will contain the host name and share::" msgstr "如果路徑包含 UNC 路徑,則驅動機將包含主機名和共享名: ::" -#: ../../library/os.path.rst:522 +#: ../../library/os.path.rst:548 msgid "" ">>> splitdrive(\"//host/computer/dir\")\n" "(\"//host/computer\", \"/dir\")" @@ -695,7 +727,7 @@ msgstr "" ">>> splitdrive(\"//host/computer/dir\")\n" "(\"//host/computer\", \"/dir\")" -#: ../../library/os.path.rst:531 +#: ../../library/os.path.rst:557 msgid "" "Split the pathname *path* into a 3-item tuple ``(drive, root, tail)`` where " "*drive* is a device name or mount point, *root* is a string of separators " @@ -708,7 +740,7 @@ msgstr "" "這些項目中的任何一個都可能是空字串。在所有情況下,``drive + root + tail`` 將" "與 *path* 相同。" -#: ../../library/os.path.rst:537 +#: ../../library/os.path.rst:563 msgid "" "On POSIX systems, *drive* is always empty. The *root* may be empty (if " "*path* is relative), a single forward slash (if *path* is absolute), or two " @@ -718,10 +750,11 @@ msgid "" msgstr "" "在 POSIX 系統上,*drive* 始終為空。*root* 可能為空(如果 *path* 是相對路" "徑),一個斜線(如果 *path* 是絕對路徑),或者兩個斜線(根據 `IEEE Std " -"1003.1-2017; 4.13 Pathname Resolution `_ 的實作定義)。例如: ::" +"1003.1-2017; 4.13 Pathname Resolution `_ 的實作定義)。例" +"如: ::" -#: ../../library/os.path.rst:543 +#: ../../library/os.path.rst:569 msgid "" ">>> splitroot('/home/sam')\n" "('', '/', 'home/sam')\n" @@ -737,7 +770,7 @@ msgstr "" ">>> splitroot('///home/sam')\n" "('', '/', '//home/sam')" -#: ../../library/os.path.rst:550 +#: ../../library/os.path.rst:576 msgid "" "On Windows, *drive* may be empty, a drive-letter name, a UNC share, or a " "device name. The *root* may be empty, a forward slash, or a backward slash. " @@ -746,7 +779,7 @@ msgstr "" "在 Windows 上,*drive* 可能為空、驅動機名稱、UNC 共享或設備名稱。*root* 可能" "為空,斜線或反斜線。例如: ::" -#: ../../library/os.path.rst:554 +#: ../../library/os.path.rst:580 msgid "" ">>> splitroot('C:/Users/Sam')\n" "('C:', '/', 'Users/Sam')\n" @@ -758,7 +791,7 @@ msgstr "" ">>> splitroot('//Server/Share/Users/Sam')\n" "('//Server/Share', '/', 'Users/Sam')" -#: ../../library/os.path.rst:564 +#: ../../library/os.path.rst:590 msgid "" "Split the pathname *path* into a pair ``(root, ext)`` such that ``root + " "ext == path``, and the extension, *ext*, is empty or begins with a period " @@ -767,11 +800,11 @@ msgstr "" "將路徑名 *path* 拆分為一對 ``(root, ext)``,使得 ``root + ext == path``,且副" "檔名 *ext* 為空或以點開頭且最多包含一個點 (period)。" -#: ../../library/os.path.rst:568 +#: ../../library/os.path.rst:594 msgid "If the path contains no extension, *ext* will be ``''``::" msgstr "如果路徑不包含副檔名,則 *ext* 將為 ``''``: ::" -#: ../../library/os.path.rst:570 +#: ../../library/os.path.rst:596 msgid "" ">>> splitext('bar')\n" "('bar', '')" @@ -779,7 +812,7 @@ msgstr "" ">>> splitext('bar')\n" "('bar', '')" -#: ../../library/os.path.rst:573 +#: ../../library/os.path.rst:599 msgid "" "If the path contains an extension, then *ext* will be set to this extension, " "including the leading period. Note that previous periods will be ignored::" @@ -787,7 +820,7 @@ msgstr "" "如果路徑包含副檔名,則 *ext* 將設置為該副檔名,包括前導的點。請注意,前面的點" "將被忽略: ::" -#: ../../library/os.path.rst:576 +#: ../../library/os.path.rst:602 msgid "" ">>> splitext('foo.bar.exe')\n" "('foo.bar', '.exe')\n" @@ -799,13 +832,13 @@ msgstr "" ">>> splitext('/foo/bar.exe')\n" "('/foo/bar', '.exe')" -#: ../../library/os.path.rst:581 +#: ../../library/os.path.rst:607 msgid "" "Leading periods of the last component of the path are considered to be part " "of the root::" msgstr "路徑的最後一個部份的前導點被認為是根的一部分: ::" -#: ../../library/os.path.rst:584 +#: ../../library/os.path.rst:610 msgid "" ">>> splitext('.cshrc')\n" "('.cshrc', '')\n" @@ -817,7 +850,7 @@ msgstr "" ">>> splitext('/foo/....jpg')\n" "('/foo/....jpg', '')" -#: ../../library/os.path.rst:595 +#: ../../library/os.path.rst:621 msgid "" "``True`` if arbitrary Unicode strings can be used as file names (within " "limitations imposed by the file system)." diff --git a/library/pathlib.po b/library/pathlib.po index 86e5df8c15..a9e1873341 100644 --- a/library/pathlib.po +++ b/library/pathlib.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-06-27 07:36+0000\n" "PO-Revision-Date: 2024-12-23 19:15+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -76,8 +76,8 @@ msgid "" "You cannot instantiate a :class:`WindowsPath` when running on Unix, but you " "can instantiate :class:`PureWindowsPath`." msgstr "" -"如果你想在 Unix 機器上處理 Windows 路徑(或反過來),你無法在 Unix 上實例" -"化 :class:`WindowsPath`,但你可以實例化 :class:`PureWindowsPath`。" +"如果你想在 Unix 機器上處理 Windows 路徑(或反過來),你無法在 Unix 上實例化 :" +"class:`WindowsPath`,但你可以實例化 :class:`PureWindowsPath`。" #: ../../library/pathlib.rst:40 msgid "" @@ -94,8 +94,8 @@ msgstr ":pep:`428`:pathlib 模組 -- 物件導向檔案系統路徑。" #: ../../library/pathlib.rst:48 msgid "" -"For low-level path manipulation on strings, you can also use " -"the :mod:`os.path` module." +"For low-level path manipulation on strings, you can also use the :mod:`os." +"path` module." msgstr "針對字串上的底層路徑操作,你也可以使用 :mod:`os.path` 模組。" #: ../../library/pathlib.rst:53 @@ -222,8 +222,8 @@ msgid "" "A generic class that represents the system's path flavour (instantiating it " "creates either a :class:`PurePosixPath` or a :class:`PureWindowsPath`)::" msgstr "" -"一個通用的類別,表示系統的路徑類型(實例化時會建立一" -"個 :class:`PurePosixPath` 或 :class:`PureWindowsPath`): ::" +"一個通用的類別,表示系統的路徑類型(實例化時會建立一個 :class:" +"`PurePosixPath` 或 :class:`PureWindowsPath`): ::" #: ../../library/pathlib.rst:121 msgid "" @@ -241,8 +241,8 @@ msgid "" "path object::" msgstr "" "*pathsegments* 中的每個元素可以是以下的其中一種:一個表示路徑片段的字串,或一" -"個物件,它實作了 :class:`os.PathLike` 介面且其中" -"的 :meth:`~os.PathLike.__fspath__` 方法會回傳字串,就像是另一個路徑物件: ::" +"個物件,它實作了 :class:`os.PathLike` 介面且其中的 :meth:`~os.PathLike." +"__fspath__` 方法會回傳字串,就像是另一個路徑物件: ::" #: ../../library/pathlib.rst:129 msgid "" @@ -270,11 +270,11 @@ msgstr "" #: ../../library/pathlib.rst:139 msgid "" -"If a segment is an absolute path, all previous segments are ignored " -"(like :func:`os.path.join`)::" +"If a segment is an absolute path, all previous segments are ignored (like :" +"func:`os.path.join`)::" msgstr "" -"如果一個片段是絕對路徑,則所有之前的片段會被忽略(類" -"似 :func:`os.path.join`): ::" +"如果一個片段是絕對路徑,則所有之前的片段會被忽略(類似 :func:`os.path." +"join`): ::" #: ../../library/pathlib.rst:142 msgid "" @@ -290,8 +290,8 @@ msgstr "" #: ../../library/pathlib.rst:147 msgid "" -"On Windows, the drive is not reset when a rooted relative path segment " -"(e.g., ``r'\\foo'``) is encountered::" +"On Windows, the drive is not reset when a rooted relative path segment (e." +"g., ``r'\\foo'``) is encountered::" msgstr "" "在 Windows 系統上,當遇到具有根目錄的相對路徑片段(例如 ``r'\\foo'``)時,磁" "碟機 (drive) 部分不會被重置: ::" @@ -504,8 +504,8 @@ msgstr "" #: ../../library/pathlib.rst:251 msgid "" -"A path object can be used anywhere an object " -"implementing :class:`os.PathLike` is accepted::" +"A path object can be used anywhere an object implementing :class:`os." +"PathLike` is accepted::" msgstr "" "路徑物件可以被用在任何可以接受實作 :class:`os.PathLike` 的物件的地方: ::" @@ -690,8 +690,8 @@ msgstr "" #: ../../library/pathlib.rst:350 msgid "" -"If the path starts with more than two successive " -"slashes, :class:`~pathlib.PurePosixPath` collapses them::" +"If the path starts with more than two successive slashes, :class:`~pathlib." +"PurePosixPath` collapses them::" msgstr "" "如果路徑以超過兩個連續的斜線開頭,:class:`~pathlib.PurePosixPath` 會合併它" "們: ::" @@ -715,12 +715,12 @@ msgstr "" #: ../../library/pathlib.rst:362 msgid "" "This behavior conforms to *The Open Group Base Specifications Issue 6*, " -"paragraph `4.11 Pathname Resolution `_:" +"paragraph `4.11 Pathname Resolution `_:" msgstr "" "此行為符合 *The Open Group Base Specifications Issue 6*,章節 `4.11 路徑名稱" -"解析 `_:" +"解析 `_:" #: ../../library/pathlib.rst:366 msgid "" @@ -1132,9 +1132,9 @@ msgid "" "\"``**``\" isn't supported (it acts like non-recursive \"``*``\"), and if a " "relative pattern is provided, then matching is done from the right::" msgstr "" -"此方法類似於 :meth:`~PurePath.full_match`,但不允許空白模式(會引" -"發 :exc:`ValueError`)、不支援遞迴萬用字元 \"``**``\"(它會像非遞迴的 " -"\"``*``\" 一樣),且如果提供相對模式,則會從右邊進行比對: ::" +"此方法類似於 :meth:`~PurePath.full_match`,但不允許空白模式(會引發 :exc:" +"`ValueError`)、不支援遞迴萬用字元 \"``**``\"(它會像非遞迴的 \"``*``\" 一" +"樣),且如果提供相對模式,則會從右邊進行比對: ::" #: ../../library/pathlib.rst:605 msgid "" @@ -1167,8 +1167,8 @@ msgid "" "Compute a version of this path relative to the path represented by *other*. " "If it's impossible, :exc:`ValueError` is raised::" msgstr "" -"計算這個路徑相對於 *other* 所表示路徑的版本。如果做不到會引" -"發 :exc:`ValueError`: ::" +"計算這個路徑相對於 *other* 所表示路徑的版本。如果做不到會引發 :exc:" +"`ValueError`: ::" #: ../../library/pathlib.rst:624 msgid "" @@ -1202,8 +1202,8 @@ msgstr "" msgid "" "When *walk_up* is false (the default), the path must start with *other*. " "When the argument is true, ``..`` entries may be added to form the relative " -"path. In all other cases, such as the paths referencing different " -"drives, :exc:`ValueError` is raised.::" +"path. In all other cases, such as the paths referencing different drives, :" +"exc:`ValueError` is raised.::" msgstr "" "當 *walk_up* 是 False(預設值),路徑必須以 *other* 為開始。當此引數是 True," "可能會加入 ``..`` 以組成相對路徑。在其他情況下,例如路徑參考到不同的磁碟機," @@ -1454,11 +1454,11 @@ msgstr "" #: ../../library/pathlib.rst:778 msgid "" -"Raises :exc:`UnsupportedOperation` on Windows. In previous " -"versions, :exc:`NotImplementedError` was raised instead." +"Raises :exc:`UnsupportedOperation` on Windows. In previous versions, :exc:" +"`NotImplementedError` was raised instead." msgstr "" -"在 Windows 上會引發 :exc:`UnsupportedOperation`。在先前版本中,則是引" -"發 :exc:`NotImplementedError`。" +"在 Windows 上會引發 :exc:`UnsupportedOperation`。在先前版本中,則是引發 :exc:" +"`NotImplementedError`。" #: ../../library/pathlib.rst:785 msgid "" @@ -1607,8 +1607,8 @@ msgid "" ":exc:`ValueError` is raised if the URI does not start with ``file:``, or the " "parsed path isn't absolute." msgstr "" -"如果 URI 不是 ``file:`` 開頭,或是剖析後的路徑不是絕對路徑,則會引" -"發 :exc:`ValueError`。" +"如果 URI 不是 ``file:`` 開頭,或是剖析後的路徑不是絕對路徑,則會引發 :exc:" +"`ValueError`。" #: ../../library/pathlib.rst:864 msgid "" @@ -1638,8 +1638,8 @@ msgid "" "For historical reasons, this method is also available from :class:`PurePath` " "objects. However, its use of :func:`os.fsencode` makes it strictly impure." msgstr "" -"因為歷史上的原因,此方法也可以從 :class:`PurePath` 物件上使用。然而,它使" -"用 :func:`os.fsencode` 而讓它完全不純粹。" +"因為歷史上的原因,此方法也可以從 :class:`PurePath` 物件上使用。然而,它使用 :" +"func:`os.fsencode` 而讓它完全不純粹。" #: ../../library/pathlib.rst:882 msgid "Expanding and resolving paths" @@ -1651,9 +1651,8 @@ msgid "" "by :func:`os.path.expanduser` with ``~`` construct). If the home directory " "can't be resolved, :exc:`RuntimeError` is raised." msgstr "" -"回傳一個代表使用者家目錄的新的路徑物件(像以 ``~`` 構成" -"的 :func:`os.path.expanduser` 的回傳一樣)。如果無法解析家目錄,會引" -"發 :exc:`RuntimeError`。" +"回傳一個代表使用者家目錄的新的路徑物件(像以 ``~`` 構成的 :func:`os.path." +"expanduser` 的回傳一樣)。如果無法解析家目錄,會引發 :exc:`RuntimeError`。" #: ../../library/pathlib.rst:892 msgid "" @@ -1666,8 +1665,8 @@ msgstr "" #: ../../library/pathlib.rst:900 msgid "" "Return a new path with expanded ``~`` and ``~user`` constructs, as returned " -"by :meth:`os.path.expanduser`. If a home directory can't be " -"resolved, :exc:`RuntimeError` is raised." +"by :meth:`os.path.expanduser`. If a home directory can't be resolved, :exc:" +"`RuntimeError` is raised." msgstr "" "回傳一個展開 ``~`` 和 ``~user`` 構成的新路徑,像 :meth:`os.path.expanduser` " "回傳的一樣。如果無法解析家目錄,會引發 :exc:`RuntimeError`。" @@ -1684,8 +1683,8 @@ msgstr "" #: ../../library/pathlib.rst:915 msgid "" -"Return a new path object representing the current directory (as returned " -"by :func:`os.getcwd`)::" +"Return a new path object representing the current directory (as returned by :" +"func:`os.getcwd`)::" msgstr "" "回傳一個代表目前目錄的新的路徑物件(像 :func:`os.getcwd` 回傳的一樣): ::" @@ -1761,9 +1760,9 @@ msgid "" "resolved as far as possible and any remainder is appended without checking " "whether it exists." msgstr "" -"如果路徑不存在或遇到符號連結迴圈,且 *strict* 為 ``True``,則引" -"發 :exc:`OSError`。如果 *strict* 為 ``False``,則將盡可能解析該路徑,並將任何" -"剩餘部分追加到路徑中,而不檢查其是否存在。" +"如果路徑不存在或遇到符號連結迴圈,且 *strict* 為 ``True``,則引發 :exc:" +"`OSError`。如果 *strict* 為 ``False``,則將盡可能解析該路徑,並將任何剩餘部分" +"追加到路徑中,而不檢查其是否存在。" #: ../../library/pathlib.rst:956 msgid "The *strict* parameter was added (pre-3.6 behavior is strict)." @@ -1781,8 +1780,8 @@ msgstr "" #: ../../library/pathlib.rst:967 msgid "" -"Return the path to which the symbolic link points (as returned " -"by :func:`os.readlink`)::" +"Return the path to which the symbolic link points (as returned by :func:`os." +"readlink`)::" msgstr "回傳符號連結指向的路徑(如 :func:`os.readlink` 的回傳值): ::" #: ../../library/pathlib.rst:970 @@ -1811,11 +1810,15 @@ msgstr "查詢檔案類型和狀態" #: ../../library/pathlib.rst:987 msgid "" -":meth:`~Path.exists`, :meth:`~Path.is_dir`, :meth:`~Path.is_file`, :meth:`~Path.is_mount`, :meth:`~Path.is_symlink`, :meth:`~Path.is_block_device`, :meth:`~Path.is_char_device`, :meth:`~Path.is_fifo`, :meth:`~Path.is_socket` " +":meth:`~Path.exists`, :meth:`~Path.is_dir`, :meth:`~Path.is_file`, :meth:" +"`~Path.is_mount`, :meth:`~Path.is_symlink`, :meth:`~Path.is_block_device`, :" +"meth:`~Path.is_char_device`, :meth:`~Path.is_fifo`, :meth:`~Path.is_socket` " "now return ``False`` instead of raising an exception for paths that contain " "characters unrepresentable at the OS level." msgstr "" -":meth:`~Path.exists`、:meth:`~Path.is_dir`、:meth:`~Path.is_file`、:meth:`~Path.is_mount`、:meth:`~Path.is_symlink`、:meth:`~Path.is_block_device`、:meth:`~Path.is_char_device`、:meth:`~Path.is_fifo`、:meth:`~Path.is_socket` " +":meth:`~Path.exists`、:meth:`~Path.is_dir`、:meth:`~Path.is_file`、:meth:" +"`~Path.is_mount`、:meth:`~Path.is_symlink`、:meth:`~Path.is_block_device`、:" +"meth:`~Path.is_char_device`、:meth:`~Path.is_fifo`、:meth:`~Path.is_socket` " "遇到路徑包含 OS 層無法表示的字元時現在會回傳 ``False`` 而不是引發例外。" #: ../../library/pathlib.rst:997 @@ -2016,12 +2019,12 @@ msgstr "" #: ../../library/pathlib.rst:1144 msgid "" "Return whether this path points to the same file as *other_path*, which can " -"be either a Path object, or a string. The semantics are similar " -"to :func:`os.path.samefile` and :func:`os.path.samestat`." +"be either a Path object, or a string. The semantics are similar to :func:" +"`os.path.samefile` and :func:`os.path.samestat`." msgstr "" "回傳此路徑是否指向與 *other_path* 相同的檔案,*other_path* 可以是路徑 (Path) " -"物件或字串。其語義類似於 :func:`os.path.samefile` " -"和 :func:`os.path.samestat`。" +"物件或字串。其語義類似於 :func:`os.path.samefile` 和 :func:`os.path." +"samestat`。" #: ../../library/pathlib.rst:1148 msgid "" @@ -2200,8 +2203,8 @@ msgstr "" #: ../../library/pathlib.rst:1279 msgid "" ">>> sorted(Path('.').glob('*.py'))\n" -"[PosixPath('pathlib.py'), PosixPath('setup.py'), " -"PosixPath('test_pathlib.py')]\n" +"[PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib." +"py')]\n" ">>> sorted(Path('.').glob('*/*.py'))\n" "[PosixPath('docs/conf.py')]\n" ">>> sorted(Path('.').glob('**/*.py'))\n" @@ -2212,8 +2215,8 @@ msgid "" " PosixPath('test_pathlib.py')]" msgstr "" ">>> sorted(Path('.').glob('*.py'))\n" -"[PosixPath('pathlib.py'), PosixPath('setup.py'), " -"PosixPath('test_pathlib.py')]\n" +"[PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib." +"py')]\n" ">>> sorted(Path('.').glob('*/*.py'))\n" "[PosixPath('docs/conf.py')]\n" ">>> sorted(Path('.').glob('**/*.py'))\n" @@ -2268,8 +2271,8 @@ msgstr "" #: ../../library/pathlib.rst:1321 msgid "" -"Glob the given relative *pattern* recursively. This is like " -"calling :func:`Path.glob` with \"``**/``\" added in front of the *pattern*." +"Glob the given relative *pattern* recursively. This is like calling :func:" +"`Path.glob` with \"``**/``\" added in front of the *pattern*." msgstr "" "遞迴地 glob 給定的相對 *pattern*。這相當於在給定的相對 *pattern* 前面加上 " "\"``**/``\" 並呼叫 :func:`Path.glob`。" @@ -2335,15 +2338,14 @@ msgstr "" #: ../../library/pathlib.rst:1364 msgid "" "When *top_down* is true, the caller can modify the *dirnames* list in-place " -"(for example, using :keyword:`del` or slice assignment), " -"and :meth:`Path.walk` will only recurse into the subdirectories whose names " -"remain in *dirnames*. This can be used to prune the search, or to impose a " -"specific order of visiting, or even to inform :meth:`Path.walk` about " -"directories the caller creates or renames before it " -"resumes :meth:`Path.walk` again. Modifying *dirnames* when *top_down* is " -"false has no effect on the behavior of :meth:`Path.walk` since the " -"directories in *dirnames* have already been generated by the time *dirnames* " -"is yielded to the caller." +"(for example, using :keyword:`del` or slice assignment), and :meth:`Path." +"walk` will only recurse into the subdirectories whose names remain in " +"*dirnames*. This can be used to prune the search, or to impose a specific " +"order of visiting, or even to inform :meth:`Path.walk` about directories the " +"caller creates or renames before it resumes :meth:`Path.walk` again. " +"Modifying *dirnames* when *top_down* is false has no effect on the behavior " +"of :meth:`Path.walk` since the directories in *dirnames* have already been " +"generated by the time *dirnames* is yielded to the caller." msgstr "" "當 *top_down* 是 true,呼叫者可以原地 (in-place) 修改 *dirnames* 串列(例如使" "用 :keyword:`del` 或切片賦值 (slice assignment)),且 :meth:`Path.walk` 只會" @@ -2382,9 +2384,8 @@ msgstr "" #: ../../library/pathlib.rst:1387 msgid "" "Be aware that setting *follow_symlinks* to true can lead to infinite " -"recursion if a link points to a parent directory of " -"itself. :meth:`Path.walk` does not keep track of the directories it has " -"already visited." +"recursion if a link points to a parent directory of itself. :meth:`Path." +"walk` does not keep track of the directories it has already visited." msgstr "" "需要注意的是如果符號連結指向一個其本身的父目錄,則將 *follow_symlinks* 設定" "為 true 會導致無窮的遞迴。:meth:`Path.walk` 不會紀錄其已經瀏覽過的目錄。" @@ -2398,17 +2399,17 @@ msgid "" "*dirnames* as appropriate." msgstr "" ":meth:`Path.walk` 假設其走訪的目錄在執行過程中不會被修改。舉例來說,如果在 " -"*dirnames* 裡的目錄已經被一個符號連結取代,且 *follow_symlinks* 是 " -"false,:meth:`Path.walk` 依然會試著往下進入它。為了防止這樣的行為,可以從 " -"*dirnames* 適當地移除目錄。" +"*dirnames* 裡的目錄已經被一個符號連結取代,且 *follow_symlinks* 是 false,:" +"meth:`Path.walk` 依然會試著往下進入它。為了防止這樣的行為,可以從 *dirnames* " +"適當地移除目錄。" #: ../../library/pathlib.rst:1400 msgid "" "Unlike :func:`os.walk`, :meth:`Path.walk` lists symlinks to directories in " "*filenames* if *follow_symlinks* is false." msgstr "" -"如果 *follow_symlinks* 是 false,和 :func:`os.walk` 行為不同的" -"是 :meth:`Path.walk` 會將指向目錄的符號連結放在 *filenames* 串列。" +"如果 *follow_symlinks* 是 false,和 :func:`os.walk` 行為不同的是 :meth:`Path." +"walk` 會將指向目錄的符號連結放在 *filenames* 串列。" #: ../../library/pathlib.rst:1403 msgid "" @@ -2421,8 +2422,8 @@ msgstr "" #: ../../library/pathlib.rst:1406 msgid "" "from pathlib import Path\n" -"for root, dirs, files in Path(\"cpython/Lib/" -"concurrent\").walk(on_error=print):\n" +"for root, dirs, files in Path(\"cpython/Lib/concurrent\")." +"walk(on_error=print):\n" " print(\n" " root,\n" " \"consumes\",\n" @@ -2435,8 +2436,8 @@ msgid "" " dirs.remove('__pycache__')" msgstr "" "from pathlib import Path\n" -"for root, dirs, files in Path(\"cpython/Lib/" -"concurrent\").walk(on_error=print):\n" +"for root, dirs, files in Path(\"cpython/Lib/concurrent\")." +"walk(on_error=print):\n" " print(\n" " root,\n" " \"consumes\",\n" @@ -2486,8 +2487,8 @@ msgid "" "Create a file at this given path. If *mode* is given, it is combined with " "the process's ``umask`` value to determine the file mode and access flags. " "If the file already exists, the function succeeds when *exist_ok* is true " -"(and its modification time is updated to the current time), " -"otherwise :exc:`FileExistsError` is raised." +"(and its modification time is updated to the current time), otherwise :exc:" +"`FileExistsError` is raised." msgstr "" "根據給定路徑來建立一個檔案。如果 *mode* 有給定,它會與行程的 ``umask`` 值結" "合,以確定檔案模式和存取旗標。當檔案已經存在時,若 *exist_ok* 為 true 則函式" @@ -2495,8 +2496,8 @@ msgstr "" #: ../../library/pathlib.rst:1447 msgid "" -"The :meth:`~Path.open`, :meth:`~Path.write_text` " -"and :meth:`~Path.write_bytes` methods are often used to create files." +"The :meth:`~Path.open`, :meth:`~Path.write_text` and :meth:`~Path." +"write_bytes` methods are often used to create files." msgstr "" ":meth:`~Path.open`、:meth:`~Path.write_text` 和 :meth:`~Path.write_bytes` 方" "法通常用於建立檔案。" @@ -2522,19 +2523,19 @@ msgstr "" #: ../../library/pathlib.rst:1462 msgid "" -"If *parents* is false (the default), a missing parent " -"raises :exc:`FileNotFoundError`." +"If *parents* is false (the default), a missing parent raises :exc:" +"`FileNotFoundError`." msgstr "" -"如果 *parents* 是 false(預設值),缺少的父路徑會引" -"發 :exc:`FileNotFoundError`。" +"如果 *parents* 是 false(預設值),缺少的父路徑會引發 :exc:" +"`FileNotFoundError`。" #: ../../library/pathlib.rst:1465 msgid "" "If *exist_ok* is false (the default), :exc:`FileExistsError` is raised if " "the target directory already exists." msgstr "" -"如果 *exist_ok* 是 false(預設值),則當目標目錄已經存在的話會引" -"發 :exc:`FileExistsError`。" +"如果 *exist_ok* 是 false(預設值),則當目標目錄已經存在的話會引發 :exc:" +"`FileExistsError`。" #: ../../library/pathlib.rst:1468 msgid "" @@ -2542,9 +2543,8 @@ msgid "" "given path already exists in the file system and is not a directory (same " "behavior as the POSIX ``mkdir -p`` command)." msgstr "" -"如果 *exist_ok* 是 true,只有當最後的路徑組成不是一個已存在的非目錄檔" -"案,:exc:`FileExistsError` 例外會被忽略(與 POSIX 的 ``mkdir -p`` 指令行為相" -"同)。" +"如果 *exist_ok* 是 true,只有當最後的路徑組成不是一個已存在的非目錄檔案,:" +"exc:`FileExistsError` 例外會被忽略(與 POSIX 的 ``mkdir -p`` 指令行為相同)。" #: ../../library/pathlib.rst:1472 msgid "The *exist_ok* parameter was added." @@ -2623,11 +2623,11 @@ msgstr "重新命名和刪除" #: ../../library/pathlib.rst:1526 msgid "" -"Rename this file or directory to the given *target*, and return a " -"new :class:`!Path` instance pointing to *target*. On Unix, if *target* " -"exists and is a file, it will be replaced silently if the user has " -"permission. On Windows, if *target* exists, :exc:`FileExistsError` will be " -"raised. *target* can be either a string or another path object::" +"Rename this file or directory to the given *target*, and return a new :class:" +"`!Path` instance pointing to *target*. On Unix, if *target* exists and is a " +"file, it will be replaced silently if the user has permission. On Windows, " +"if *target* exists, :exc:`FileExistsError` will be raised. *target* can be " +"either a string or another path object::" msgstr "" "將此檔案或目錄重新命名為給定的 *target* ,並回傳一個新的 :class:`!Path` 實例" "指向該 *target*。在 Unix 系統上,若 *target* 存在且為一個檔案,若使用者有權" @@ -2657,8 +2657,8 @@ msgstr "" #: ../../library/pathlib.rst:1541 ../../library/pathlib.rst:1557 msgid "" "The target path may be absolute or relative. Relative paths are interpreted " -"relative to the current working directory, *not* the directory of " -"the :class:`!Path` object." +"relative to the current working directory, *not* the directory of the :class:" +"`!Path` object." msgstr "" "目標路徑可以是絕對路徑或相對路徑。相對路徑會相對於目前的工作目錄進行解釋,*而" "不是*\\ 相對於 :class:`!Path` 物件所在的目錄。" @@ -2675,18 +2675,17 @@ msgstr "新增了回傳值,回傳新的 :class:`!Path` 實例。" #: ../../library/pathlib.rst:1553 msgid "" -"Rename this file or directory to the given *target*, and return a " -"new :class:`!Path` instance pointing to *target*. If *target* points to an " -"existing file or empty directory, it will be unconditionally replaced." +"Rename this file or directory to the given *target*, and return a new :class:" +"`!Path` instance pointing to *target*. If *target* points to an existing " +"file or empty directory, it will be unconditionally replaced." msgstr "" -"將此檔案或目錄重新命名為給定的 *target*,並回傳一個指向 *target* 的" -"新 :class:`!Path` 實例。如果 *target* 指向一個現有的檔案或空目錄,它將被無條" -"件地取代。" +"將此檔案或目錄重新命名為給定的 *target*,並回傳一個指向 *target* 的新 :class:" +"`!Path` 實例。如果 *target* 指向一個現有的檔案或空目錄,它將被無條件地取代。" #: ../../library/pathlib.rst:1567 msgid "" -"Remove this file or symbolic link. If the path points to a directory, " -"use :func:`Path.rmdir` instead." +"Remove this file or symbolic link. If the path points to a directory, use :" +"func:`Path.rmdir` instead." msgstr "移除這個檔案或符號連結。如果路徑指向目錄,請改用 :func:`Path.rmdir`。" #: ../../library/pathlib.rst:1570 @@ -2808,11 +2807,11 @@ msgstr "模式語言 (pattern language)" #: ../../library/pathlib.rst:1652 msgid "" -"The following wildcards are supported in patterns " -"for :meth:`~PurePath.full_match`, :meth:`~Path.glob` and :meth:`~Path.rglob`:" +"The following wildcards are supported in patterns for :meth:`~PurePath." +"full_match`, :meth:`~Path.glob` and :meth:`~Path.rglob`:" msgstr "" -"以下的萬用字元在 :meth:`~PurePath.full_match`、:meth:`~Path.glob` " -"和 :meth:`~Path.rglob` 的模式中被支援:" +"以下的萬用字元在 :meth:`~PurePath.full_match`、:meth:`~Path.glob` 和 :meth:" +"`~Path.rglob` 的模式中被支援:" #: ../../library/pathlib.rst:1655 msgid "``**`` (entire segment)" @@ -2851,18 +2850,24 @@ msgid "``[seq]``" msgstr "``[seq]``" #: ../../library/pathlib.rst:1664 -msgid "Matches one character in *seq*." -msgstr "匹配一個在 *seq* 中的字元。" +msgid "" +"Matches one character in *seq*, where *seq* is a sequence of characters. " +"Range expressions are supported; for example, ``[a-z]`` matches any " +"lowercase ASCII letter. Multiple ranges can be combined: ``[a-zA-Z0-9_]`` " +"matches any ASCII letter, digit, or underscore." +msgstr "" -#: ../../library/pathlib.rst:1665 +#: ../../library/pathlib.rst:1668 msgid "``[!seq]``" msgstr "``[!seq]``" -#: ../../library/pathlib.rst:1666 -msgid "Matches one character not in *seq*." -msgstr "匹配一個不在 *seq* 中的字元。" +#: ../../library/pathlib.rst:1669 +msgid "" +"Matches one character not in *seq*, where *seq* follows the same rules as " +"above." +msgstr "匹配一個不在 *seq* 中的字元,其中 *seq* 遵循上述相同的規則。" -#: ../../library/pathlib.rst:1668 +#: ../../library/pathlib.rst:1671 msgid "" "For a literal match, wrap the meta-characters in brackets. For example, " "``\"[?]\"`` matches the character ``\"?\"``." @@ -2870,52 +2875,52 @@ msgstr "" "對於文本 (literal) 匹配,可以用方括號包裝元字元 (meta-characters)。例如," "``\"[?]\"`` 會匹配字元 ``\"?\"``。" -#: ../../library/pathlib.rst:1671 +#: ../../library/pathlib.rst:1674 msgid "The \"``**``\" wildcard enables recursive globbing. A few examples:" msgstr "\"``**``\" 萬用字元讓它可以做遞迴 glob。例如:" -#: ../../library/pathlib.rst:1674 +#: ../../library/pathlib.rst:1677 msgid "Pattern" msgstr "模式" -#: ../../library/pathlib.rst:1674 +#: ../../library/pathlib.rst:1677 msgid "Meaning" msgstr "意涵" -#: ../../library/pathlib.rst:1676 +#: ../../library/pathlib.rst:1679 msgid "\"``**/*``\"" msgstr "\"``**/*``\"" -#: ../../library/pathlib.rst:1676 +#: ../../library/pathlib.rst:1679 msgid "Any path with at least one segment." msgstr "至少有一個片段的路徑。" -#: ../../library/pathlib.rst:1677 +#: ../../library/pathlib.rst:1680 msgid "\"``**/*.py``\"" msgstr "\"``**/*.py``\"" -#: ../../library/pathlib.rst:1677 +#: ../../library/pathlib.rst:1680 msgid "Any path with a final segment ending \"``.py``\"." msgstr "最後一個片段以 \"``.py``\" 結尾的任何路徑。" -#: ../../library/pathlib.rst:1678 +#: ../../library/pathlib.rst:1681 msgid "\"``assets/**``\"" msgstr "\"``assets/**``\"" -#: ../../library/pathlib.rst:1678 +#: ../../library/pathlib.rst:1681 msgid "Any path starting with \"``assets/``\"." msgstr "任何以 \"``assets/``\" 開頭的路徑。" -#: ../../library/pathlib.rst:1679 +#: ../../library/pathlib.rst:1682 msgid "\"``assets/**/*``\"" msgstr "\"``assets/**/*``\"" -#: ../../library/pathlib.rst:1679 +#: ../../library/pathlib.rst:1682 msgid "" "Any path starting with \"``assets/``\", excluding \"``assets/``\" itself." msgstr "任何以 \"``assets/``\" 開頭的路徑,不包括 \"``assets/``\" 本身。" -#: ../../library/pathlib.rst:1683 +#: ../../library/pathlib.rst:1686 msgid "" "Globbing with the \"``**``\" wildcard visits every directory in the tree. " "Large directory trees may take a long time to search." @@ -2923,7 +2928,7 @@ msgstr "" "Glob 使用 ``**`` 萬用字元會訪問目錄樹中的每個目錄。對於大型的目錄樹,搜尋可能" "需要花費很長的時間。" -#: ../../library/pathlib.rst:1686 +#: ../../library/pathlib.rst:1689 msgid "" "Globbing with a pattern that ends with \"``**``\" returns both files and " "directories. In previous versions, only directories were returned." @@ -2931,7 +2936,7 @@ msgstr "" "Glob 使用結尾為 ``**`` 的模式會同時回傳檔案和目錄。在先前版本中,只會回傳目" "錄。" -#: ../../library/pathlib.rst:1690 +#: ../../library/pathlib.rst:1693 msgid "" "In :meth:`Path.glob` and :meth:`~Path.rglob`, a trailing slash may be added " "to the pattern to match only directories." @@ -2939,43 +2944,43 @@ msgstr "" "在 :meth:`Path.glob` 和 :meth:`~Path.rglob` 中,可以在模式後面加上斜線以只匹" "配目錄。" -#: ../../library/pathlib.rst:1693 +#: ../../library/pathlib.rst:1696 msgid "" -"Globbing with a pattern that ends with a pathname components separator " -"(:data:`~os.sep` or :data:`~os.altsep`) returns only directories." +"Globbing with a pattern that ends with a pathname components separator (:" +"data:`~os.sep` or :data:`~os.altsep`) returns only directories." msgstr "" "Glob 使用以路徑名稱組成的分隔符號(:data:`~os.sep` 或 :data:`~os.altsep`)作" "結尾的模式則只會回傳目錄。" -#: ../../library/pathlib.rst:1699 +#: ../../library/pathlib.rst:1702 msgid "Comparison to the :mod:`glob` module" msgstr "與 :mod:`glob` 模組的比較" -#: ../../library/pathlib.rst:1701 +#: ../../library/pathlib.rst:1704 msgid "" -"The patterns accepted and results generated by :meth:`Path.glob` " -"and :meth:`Path.rglob` differ slightly from those by the :mod:`glob` module:" +"The patterns accepted and results generated by :meth:`Path.glob` and :meth:" +"`Path.rglob` differ slightly from those by the :mod:`glob` module:" msgstr "" ":meth:`Path.glob` 和 :meth:`Path.rglob` 接受的模式和產生的結果與 :mod:`glob` " "模組略有不同:" -#: ../../library/pathlib.rst:1704 +#: ../../library/pathlib.rst:1707 msgid "" "Files beginning with a dot are not special in pathlib. This is like passing " "``include_hidden=True`` to :func:`glob.glob`." msgstr "" -"pathlib 中以點開頭的檔案並不特別。這和將 ``include_hidden=True`` 傳遞" -"給 :func:`glob.glob` 相同。" +"pathlib 中以點開頭的檔案並不特別。這和將 ``include_hidden=True`` 傳遞給 :" +"func:`glob.glob` 相同。" -#: ../../library/pathlib.rst:1706 +#: ../../library/pathlib.rst:1709 msgid "" "\"``**``\" pattern components are always recursive in pathlib. This is like " "passing ``recursive=True`` to :func:`glob.glob`." msgstr "" -"``**`` 模式組成在 pathlib 中總是遞迴的。這與將 ``recursive=True`` 傳遞" -"給 :func:`glob.glob` 相同。" +"``**`` 模式組成在 pathlib 中總是遞迴的。這與將 ``recursive=True`` 傳遞給 :" +"func:`glob.glob` 相同。" -#: ../../library/pathlib.rst:1708 +#: ../../library/pathlib.rst:1711 msgid "" "\"``**``\" pattern components do not follow symlinks by default in pathlib. " "This behaviour has no equivalent in :func:`glob.glob`, but you can pass " @@ -2985,24 +2990,24 @@ msgstr "" "有等效的行為,但你可以將 ``recurse_symlinks=True`` 傳遞給 :meth:`Path.glob` " "以獲得相容的行為。" -#: ../../library/pathlib.rst:1711 +#: ../../library/pathlib.rst:1714 msgid "" "Like all :class:`PurePath` and :class:`Path` objects, the values returned " "from :meth:`Path.glob` and :meth:`Path.rglob` don't include trailing slashes." msgstr "" -"與所有 :class:`PurePath` 和 :class:`Path` 物件一樣,從 :meth:`Path.glob` " -"和 :meth:`Path.rglob` 回傳的值不包含結尾斜線。" +"與所有 :class:`PurePath` 和 :class:`Path` 物件一樣,從 :meth:`Path.glob` 和 :" +"meth:`Path.rglob` 回傳的值不包含結尾斜線。" -#: ../../library/pathlib.rst:1714 +#: ../../library/pathlib.rst:1717 msgid "" "The values returned from pathlib's ``path.glob()`` and ``path.rglob()`` " -"include the *path* as a prefix, unlike the results of " -"``glob.glob(root_dir=path)``." +"include the *path* as a prefix, unlike the results of ``glob." +"glob(root_dir=path)``." msgstr "" "pathlib 的 ``path.glob()`` 和 ``path.rglob()`` 回傳的值包含了 *path* 作為前" "綴,而 ``glob.glob(root_dir=path)`` 的結果則不會如此。" -#: ../../library/pathlib.rst:1717 +#: ../../library/pathlib.rst:1720 msgid "" "The values returned from pathlib's ``path.glob()`` and ``path.rglob()`` may " "include *path* itself, for example when globbing \"``**``\", whereas the " @@ -3013,15 +3018,15 @@ msgstr "" "例如當使用 \"``**``\" 做 glob 的時候,然而 ``glob.glob(root_dir=path)`` 的結" "果則永遠不會包含一個對應到 *path* 的空字串。" -#: ../../library/pathlib.rst:1724 +#: ../../library/pathlib.rst:1727 msgid "Comparison to the :mod:`os` and :mod:`os.path` modules" msgstr "與 :mod:`os` 和 :mod:`os.path` 模組的比較" -#: ../../library/pathlib.rst:1726 +#: ../../library/pathlib.rst:1729 msgid "" "pathlib implements path operations using :class:`PurePath` and :class:`Path` " -"objects, and so it's said to be *object-oriented*. On the other hand, " -"the :mod:`os` and :mod:`os.path` modules supply functions that work with low-" +"objects, and so it's said to be *object-oriented*. On the other hand, the :" +"mod:`os` and :mod:`os.path` modules supply functions that work with low-" "level ``str`` and ``bytes`` objects, which is a more *procedural* approach. " "Some users consider the object-oriented style to be more readable." msgstr "" @@ -3030,27 +3035,27 @@ msgstr "" "與底層 ``str`` 和 ``bytes`` 物件互動的函式,這是一種更\\ *程序式*\\ 的方法。" "有些使用者認為物件導向的風格更易讀。" -#: ../../library/pathlib.rst:1732 +#: ../../library/pathlib.rst:1735 msgid "" -"Many functions in :mod:`os` and :mod:`os.path` support ``bytes`` paths " -"and :ref:`paths relative to directory descriptors `. These features " +"Many functions in :mod:`os` and :mod:`os.path` support ``bytes`` paths and :" +"ref:`paths relative to directory descriptors `. These features " "aren't available in pathlib." msgstr "" ":mod:`os` 和 :mod:`os.path` 中的許多函式支援 ``bytes`` 路徑和\\ :ref:`相對路" "徑的目錄描述器 (paths relative to directory descriptors) `。這些功能" "在 pathlib 中不可用。" -#: ../../library/pathlib.rst:1736 +#: ../../library/pathlib.rst:1739 msgid "" -"Python's ``str`` and ``bytes`` types, and portions of the :mod:`os` " -"and :mod:`os.path` modules, are written in C and are very speedy. pathlib is " -"written in pure Python and is often slower, but rarely slow enough to matter." +"Python's ``str`` and ``bytes`` types, and portions of the :mod:`os` and :mod:" +"`os.path` modules, are written in C and are very speedy. pathlib is written " +"in pure Python and is often slower, but rarely slow enough to matter." msgstr "" "Python 的 ``str`` 和 ``bytes`` 型別,以及 :mod:`os` 和 :mod:`os.path` 模組的" "一些部分,是用 C 寫的且非常快速。pathlib 是用純 Python 寫的且通常比較慢,但很" "少會慢到足以產生影響。" -#: ../../library/pathlib.rst:1740 +#: ../../library/pathlib.rst:1743 msgid "" "pathlib's path normalization is slightly more opinionated and consistent " "than :mod:`os.path`. For example, whereas :func:`os.path.abspath` eliminates " @@ -3058,16 +3063,16 @@ msgid "" "are involved, :meth:`Path.absolute` preserves these segments for greater " "safety." msgstr "" -"pathlib 的路徑正規化略比 :mod:`os.path` 更武斷和一致。例如,儘" -"管 :func:`os.path.abspath` 會從路徑中移除 \"``..``\" 片段,如果包含符號連結的" -"話這可能會改變其意義,而 :meth:`Path.absolute` 則會保留這些片段以增加安全性。" +"pathlib 的路徑正規化略比 :mod:`os.path` 更武斷和一致。例如,儘管 :func:`os." +"path.abspath` 會從路徑中移除 \"``..``\" 片段,如果包含符號連結的話這可能會改" +"變其意義,而 :meth:`Path.absolute` 則會保留這些片段以增加安全性。" -#: ../../library/pathlib.rst:1745 +#: ../../library/pathlib.rst:1748 msgid "" "pathlib's path normalization may render it unsuitable for some applications:" msgstr "pathlib 的路徑正規化可能會使它不適合某些應用程式:" -#: ../../library/pathlib.rst:1747 +#: ../../library/pathlib.rst:1750 msgid "" "pathlib normalizes ``Path(\"my_folder/\")`` to ``Path(\"my_folder\")``, " "which changes a path's meaning when supplied to various operating system " @@ -3079,7 +3084,7 @@ msgstr "" "提供給各種操作系統 API 和命令列工具時改變路徑的意義。具體來說,缺少結尾分隔符" "號可能會允許該路徑被解析為檔案或目錄,而不只是目錄。" -#: ../../library/pathlib.rst:1752 +#: ../../library/pathlib.rst:1755 msgid "" "pathlib normalizes ``Path(\"./my_program\")`` to ``Path(\"my_program\")``, " "which changes a path's meaning when used as an executable search path, such " @@ -3092,285 +3097,285 @@ msgstr "" "程時。具體來說,在路徑中缺少分隔符號可能會使其強制在 :envvar:`PATH` 中尋找," "而不是目前目錄。" -#: ../../library/pathlib.rst:1758 +#: ../../library/pathlib.rst:1761 msgid "" "As a consequence of these differences, pathlib is not a drop-in replacement " "for :mod:`os.path`." msgstr "因為這些差異,pathlib 不是 :mod:`os.path` 的直接替代品。" -#: ../../library/pathlib.rst:1763 +#: ../../library/pathlib.rst:1766 msgid "Corresponding tools" msgstr "對應工具" -#: ../../library/pathlib.rst:1765 +#: ../../library/pathlib.rst:1768 msgid "" -"Below is a table mapping various :mod:`os` functions to their " -"corresponding :class:`PurePath`/:class:`Path` equivalent." +"Below is a table mapping various :mod:`os` functions to their corresponding :" +"class:`PurePath`/:class:`Path` equivalent." msgstr "" -"以下是一張表格,對應許多 :mod:`os` 函式及其相符" -"於 :class:`PurePath`/:class:`Path` 的項目。" +"以下是一張表格,對應許多 :mod:`os` 函式及其相符於 :class:`PurePath`/:class:" +"`Path` 的項目。" -#: ../../library/pathlib.rst:1769 +#: ../../library/pathlib.rst:1772 msgid ":mod:`os` and :mod:`os.path`" msgstr ":mod:`os` 和 :mod:`os.path`" -#: ../../library/pathlib.rst:1769 +#: ../../library/pathlib.rst:1772 msgid ":mod:`pathlib`" msgstr ":mod:`pathlib`" -#: ../../library/pathlib.rst:1771 +#: ../../library/pathlib.rst:1774 msgid ":func:`os.path.dirname`" msgstr ":func:`os.path.dirname`" -#: ../../library/pathlib.rst:1771 +#: ../../library/pathlib.rst:1774 msgid ":attr:`PurePath.parent`" msgstr ":attr:`PurePath.parent`" -#: ../../library/pathlib.rst:1772 +#: ../../library/pathlib.rst:1775 msgid ":func:`os.path.basename`" msgstr ":func:`os.path.basename`" -#: ../../library/pathlib.rst:1772 +#: ../../library/pathlib.rst:1775 msgid ":attr:`PurePath.name`" msgstr ":attr:`PurePath.name`" -#: ../../library/pathlib.rst:1773 +#: ../../library/pathlib.rst:1776 msgid ":func:`os.path.splitext`" msgstr ":func:`os.path.splitext`" -#: ../../library/pathlib.rst:1773 +#: ../../library/pathlib.rst:1776 msgid ":attr:`PurePath.stem`, :attr:`PurePath.suffix`" msgstr ":attr:`PurePath.stem` 和 :attr:`PurePath.suffix`" -#: ../../library/pathlib.rst:1774 +#: ../../library/pathlib.rst:1777 msgid ":func:`os.path.join`" msgstr ":func:`os.path.join`" -#: ../../library/pathlib.rst:1774 +#: ../../library/pathlib.rst:1777 msgid ":meth:`PurePath.joinpath`" msgstr ":meth:`PurePath.joinpath`" -#: ../../library/pathlib.rst:1775 +#: ../../library/pathlib.rst:1778 msgid ":func:`os.path.isabs`" msgstr ":func:`os.path.isabs`" -#: ../../library/pathlib.rst:1775 +#: ../../library/pathlib.rst:1778 msgid ":meth:`PurePath.is_absolute`" msgstr ":meth:`PurePath.is_absolute`" -#: ../../library/pathlib.rst:1776 +#: ../../library/pathlib.rst:1779 msgid ":func:`os.path.relpath`" msgstr ":func:`os.path.relpath`" -#: ../../library/pathlib.rst:1776 +#: ../../library/pathlib.rst:1779 msgid ":meth:`PurePath.relative_to` [1]_" msgstr ":meth:`PurePath.relative_to` [1]_" -#: ../../library/pathlib.rst:1777 +#: ../../library/pathlib.rst:1780 msgid ":func:`os.path.expanduser`" msgstr ":func:`os.path.expanduser`" -#: ../../library/pathlib.rst:1777 +#: ../../library/pathlib.rst:1780 msgid ":meth:`Path.expanduser` [2]_" msgstr ":meth:`Path.expanduser` [2]_" -#: ../../library/pathlib.rst:1778 +#: ../../library/pathlib.rst:1781 msgid ":func:`os.path.realpath`" msgstr ":func:`os.path.realpath`" -#: ../../library/pathlib.rst:1778 +#: ../../library/pathlib.rst:1781 msgid ":meth:`Path.resolve`" msgstr ":meth:`Path.resolve`" -#: ../../library/pathlib.rst:1779 +#: ../../library/pathlib.rst:1782 msgid ":func:`os.path.abspath`" msgstr ":func:`os.path.abspath`" -#: ../../library/pathlib.rst:1779 +#: ../../library/pathlib.rst:1782 msgid ":meth:`Path.absolute` [3]_" msgstr ":meth:`Path.absolute` [3]_" -#: ../../library/pathlib.rst:1780 +#: ../../library/pathlib.rst:1783 msgid ":func:`os.path.exists`" msgstr ":func:`os.path.exists`" -#: ../../library/pathlib.rst:1780 +#: ../../library/pathlib.rst:1783 msgid ":meth:`Path.exists`" msgstr ":meth:`Path.exists`" -#: ../../library/pathlib.rst:1781 +#: ../../library/pathlib.rst:1784 msgid ":func:`os.path.isfile`" msgstr ":func:`os.path.isfile`" -#: ../../library/pathlib.rst:1781 +#: ../../library/pathlib.rst:1784 msgid ":meth:`Path.is_file`" msgstr ":meth:`Path.is_file`" -#: ../../library/pathlib.rst:1782 +#: ../../library/pathlib.rst:1785 msgid ":func:`os.path.isdir`" msgstr ":func:`os.path.isdir`" -#: ../../library/pathlib.rst:1782 +#: ../../library/pathlib.rst:1785 msgid ":meth:`Path.is_dir`" msgstr ":meth:`Path.is_dir`" -#: ../../library/pathlib.rst:1783 +#: ../../library/pathlib.rst:1786 msgid ":func:`os.path.islink`" msgstr ":func:`os.path.islink`" -#: ../../library/pathlib.rst:1783 +#: ../../library/pathlib.rst:1786 msgid ":meth:`Path.is_symlink`" msgstr ":meth:`Path.is_symlink`" -#: ../../library/pathlib.rst:1784 +#: ../../library/pathlib.rst:1787 msgid ":func:`os.path.isjunction`" msgstr ":func:`os.path.isjunction`" -#: ../../library/pathlib.rst:1784 +#: ../../library/pathlib.rst:1787 msgid ":meth:`Path.is_junction`" msgstr ":meth:`Path.is_junction`" -#: ../../library/pathlib.rst:1785 +#: ../../library/pathlib.rst:1788 msgid ":func:`os.path.ismount`" msgstr ":func:`os.path.ismount`" -#: ../../library/pathlib.rst:1785 +#: ../../library/pathlib.rst:1788 msgid ":meth:`Path.is_mount`" msgstr ":meth:`Path.is_mount`" -#: ../../library/pathlib.rst:1786 +#: ../../library/pathlib.rst:1789 msgid ":func:`os.path.samefile`" msgstr ":func:`os.path.samefile`" -#: ../../library/pathlib.rst:1786 +#: ../../library/pathlib.rst:1789 msgid ":meth:`Path.samefile`" msgstr ":meth:`Path.samefile`" -#: ../../library/pathlib.rst:1787 +#: ../../library/pathlib.rst:1790 msgid ":func:`os.getcwd`" msgstr ":func:`os.getcwd`" -#: ../../library/pathlib.rst:1787 +#: ../../library/pathlib.rst:1790 msgid ":meth:`Path.cwd`" msgstr ":meth:`Path.cwd`" -#: ../../library/pathlib.rst:1788 +#: ../../library/pathlib.rst:1791 msgid ":func:`os.stat`" msgstr ":func:`os.stat`" -#: ../../library/pathlib.rst:1788 +#: ../../library/pathlib.rst:1791 msgid ":meth:`Path.stat`" msgstr ":meth:`Path.stat`" -#: ../../library/pathlib.rst:1789 +#: ../../library/pathlib.rst:1792 msgid ":func:`os.lstat`" msgstr ":func:`os.lstat`" -#: ../../library/pathlib.rst:1789 +#: ../../library/pathlib.rst:1792 msgid ":meth:`Path.lstat`" msgstr ":meth:`Path.lstat`" -#: ../../library/pathlib.rst:1790 +#: ../../library/pathlib.rst:1793 msgid ":func:`os.listdir`" msgstr ":func:`os.listdir`" -#: ../../library/pathlib.rst:1790 +#: ../../library/pathlib.rst:1793 msgid ":meth:`Path.iterdir`" msgstr ":meth:`Path.iterdir`" -#: ../../library/pathlib.rst:1791 +#: ../../library/pathlib.rst:1794 msgid ":func:`os.walk`" msgstr ":func:`os.walk`" -#: ../../library/pathlib.rst:1791 +#: ../../library/pathlib.rst:1794 msgid ":meth:`Path.walk` [4]_" msgstr ":meth:`Path.walk` [4]_" -#: ../../library/pathlib.rst:1792 +#: ../../library/pathlib.rst:1795 msgid ":func:`os.mkdir`, :func:`os.makedirs`" msgstr ":func:`os.mkdir`、:func:`os.makedirs`" -#: ../../library/pathlib.rst:1792 +#: ../../library/pathlib.rst:1795 msgid ":meth:`Path.mkdir`" msgstr ":meth:`Path.mkdir`" -#: ../../library/pathlib.rst:1793 +#: ../../library/pathlib.rst:1796 msgid ":func:`os.link`" msgstr ":func:`os.link`" -#: ../../library/pathlib.rst:1793 +#: ../../library/pathlib.rst:1796 msgid ":meth:`Path.hardlink_to`" msgstr ":meth:`Path.hardlink_to`" -#: ../../library/pathlib.rst:1794 +#: ../../library/pathlib.rst:1797 msgid ":func:`os.symlink`" msgstr ":func:`os.symlink`" -#: ../../library/pathlib.rst:1794 +#: ../../library/pathlib.rst:1797 msgid ":meth:`Path.symlink_to`" msgstr ":meth:`Path.symlink_to`" -#: ../../library/pathlib.rst:1795 +#: ../../library/pathlib.rst:1798 msgid ":func:`os.readlink`" msgstr ":func:`os.readlink`" -#: ../../library/pathlib.rst:1795 +#: ../../library/pathlib.rst:1798 msgid ":meth:`Path.readlink`" msgstr ":meth:`Path.readlink`" -#: ../../library/pathlib.rst:1796 +#: ../../library/pathlib.rst:1799 msgid ":func:`os.rename`" msgstr ":func:`os.rename`" -#: ../../library/pathlib.rst:1796 +#: ../../library/pathlib.rst:1799 msgid ":meth:`Path.rename`" msgstr ":meth:`Path.rename`" -#: ../../library/pathlib.rst:1797 +#: ../../library/pathlib.rst:1800 msgid ":func:`os.replace`" msgstr ":func:`os.replace`" -#: ../../library/pathlib.rst:1797 +#: ../../library/pathlib.rst:1800 msgid ":meth:`Path.replace`" msgstr ":meth:`Path.replace`" -#: ../../library/pathlib.rst:1798 +#: ../../library/pathlib.rst:1801 msgid ":func:`os.remove`, :func:`os.unlink`" msgstr ":func:`os.remove`、:func:`os.unlink`" -#: ../../library/pathlib.rst:1798 +#: ../../library/pathlib.rst:1801 msgid ":meth:`Path.unlink`" msgstr ":meth:`Path.unlink`" -#: ../../library/pathlib.rst:1799 +#: ../../library/pathlib.rst:1802 msgid ":func:`os.rmdir`" msgstr ":func:`os.rmdir`" -#: ../../library/pathlib.rst:1799 +#: ../../library/pathlib.rst:1802 msgid ":meth:`Path.rmdir`" msgstr ":meth:`Path.rmdir`" -#: ../../library/pathlib.rst:1800 +#: ../../library/pathlib.rst:1803 msgid ":func:`os.chmod`" msgstr ":func:`os.chmod`" -#: ../../library/pathlib.rst:1800 +#: ../../library/pathlib.rst:1803 msgid ":meth:`Path.chmod`" msgstr ":meth:`Path.chmod`" -#: ../../library/pathlib.rst:1801 +#: ../../library/pathlib.rst:1804 msgid ":func:`os.lchmod`" msgstr ":func:`os.lchmod`" -#: ../../library/pathlib.rst:1801 +#: ../../library/pathlib.rst:1804 msgid ":meth:`Path.lchmod`" msgstr ":meth:`Path.lchmod`" -#: ../../library/pathlib.rst:1805 +#: ../../library/pathlib.rst:1808 msgid "Footnotes" msgstr "註腳" -#: ../../library/pathlib.rst:1806 +#: ../../library/pathlib.rst:1809 msgid "" ":func:`os.path.relpath` calls :func:`~os.path.abspath` to make paths " "absolute and remove \"``..``\" parts, whereas :meth:`PurePath.relative_to` " @@ -3379,28 +3384,28 @@ msgid "" msgstr "" ":func:`os.path.relpath` 會呼叫 :func:`~os.path.abspath` 來將路徑變成絕對路徑" "並移除 \"``..``\" 部分,而 :meth:`PurePath.relative_to` 是一個文本上的操作," -"當它輸入的錨點不同時(例如一個是絕對路徑,另一個則是相對路徑)會引" -"發 :exc:`ValueError`。" +"當它輸入的錨點不同時(例如一個是絕對路徑,另一個則是相對路徑)會引發 :exc:" +"`ValueError`。" -#: ../../library/pathlib.rst:1810 +#: ../../library/pathlib.rst:1813 msgid "" ":func:`os.path.expanduser` returns the path unchanged if the home directory " -"can't be resolved, whereas :meth:`Path.expanduser` " -"raises :exc:`RuntimeError`." +"can't be resolved, whereas :meth:`Path.expanduser` raises :exc:" +"`RuntimeError`." msgstr "" -":func:`os.path.expanduser` 會在無法解析家目錄時回傳原始路徑," -"而 :meth:`Path.expanduser` 則會引發 :exc:`RuntimeError`。" +":func:`os.path.expanduser` 會在無法解析家目錄時回傳原始路徑,而 :meth:`Path." +"expanduser` 則會引發 :exc:`RuntimeError`。" -#: ../../library/pathlib.rst:1813 +#: ../../library/pathlib.rst:1816 msgid "" ":func:`os.path.abspath` removes \"``..``\" components without resolving " -"symlinks, which may change the meaning of the path, " -"whereas :meth:`Path.absolute` leaves any \"``..``\" components in the path." +"symlinks, which may change the meaning of the path, whereas :meth:`Path." +"absolute` leaves any \"``..``\" components in the path." msgstr "" ":func:`os.path.abspath` 將 \"``..``\" 組成移除而不解析符號連結,這可能會改變" "路徑的意義,而 :meth:`Path.absolute` 則會保留路徑中任何 \"``..``\" 組成。" -#: ../../library/pathlib.rst:1816 +#: ../../library/pathlib.rst:1819 msgid "" ":func:`os.walk` always follows symlinks when categorizing paths into " "*dirnames* and *filenames*, whereas :meth:`Path.walk` categorizes all " @@ -3417,3 +3422,6 @@ msgstr "path(路徑)" #: ../../library/pathlib.rst:11 msgid "operations" msgstr "operations(操作)" + +#~ msgid "Matches one character in *seq*." +#~ msgstr "匹配一個在 *seq* 中的字元。" diff --git a/library/pkgutil.po b/library/pkgutil.po index 3851b2c077..d1733250d3 100644 --- a/library/pkgutil.po +++ b/library/pkgutil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-10 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2024-03-08 16:07+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -41,8 +41,8 @@ msgid "" "Extend the search path for the modules which comprise a package. Intended " "use is to place the following code in a package's :file:`__init__.py`::" msgstr "" -"擴充組成一個套件之模組的搜尋路徑。預期用法是將以下程式碼放入套件" -"的 :file:`__init__.py`: ::" +"擴充組成一個套件之模組的搜尋路徑。預期用法是將以下程式碼放入套件的 :file:" +"`__init__.py`: ::" #: ../../library/pkgutil.rst:25 msgid "" @@ -55,10 +55,9 @@ msgstr "" #: ../../library/pkgutil.rst:28 msgid "" "For each directory on :data:`sys.path` that has a subdirectory that matches " -"the package name, add the subdirectory to the " -"package's :attr:`~module.__path__`. This is useful if one wants to " -"distribute different parts of a single logical package as multiple " -"directories." +"the package name, add the subdirectory to the package's :attr:`~module." +"__path__`. This is useful if one wants to distribute different parts of a " +"single logical package as multiple directories." msgstr "" "對於 :data:`sys.path` 上具有與套件名稱相符的子目錄的每個目錄,將該子目錄新增" "至套件的 :attr:`~module.__path__` 中。如果想要將單一邏輯套件的不同部分給分配" @@ -67,12 +66,12 @@ msgstr "" #: ../../library/pkgutil.rst:34 msgid "" "It also looks for :file:`\\*.pkg` files beginning where ``*`` matches the " -"*name* argument. This feature is similar to :file:`\\*.pth` files (see " -"the :mod:`site` module for more information), except that it doesn't special-" -"case lines starting with ``import``. A :file:`\\*.pkg` file is trusted at " -"face value: apart from skipping blank lines and ignoring comments, all " -"entries found in a :file:`\\*.pkg` file are added to the path, regardless of " -"whether they exist on the filesystem (this is a feature)." +"*name* argument. This feature is similar to :file:`\\*.pth` files (see the :" +"mod:`site` module for more information), except that it doesn't special-case " +"lines starting with ``import``. A :file:`\\*.pkg` file is trusted at face " +"value: apart from skipping blank lines and ignoring comments, all entries " +"found in a :file:`\\*.pkg` file are added to the path, regardless of whether " +"they exist on the filesystem (this is a feature)." msgstr "" "它還會尋找 :file:`\\*.pkg` 檔案,其中開頭的 ``*`` 與 *name* 引數相符。此功能" "類似於 :file:`\\*.pth` 檔案(更多資訊請參閱 :mod:`site` 模組),但他不特別處" @@ -91,11 +90,11 @@ msgstr "" #: ../../library/pkgutil.rst:46 msgid "" -"It is assumed that :data:`sys.path` is a sequence. Items " -"of :data:`sys.path` that are not strings referring to existing directories " -"are ignored. Unicode items on :data:`sys.path` that cause errors when used " -"as filenames may cause this function to raise an exception (in line " -"with :func:`os.path.isdir` behavior)." +"It is assumed that :data:`sys.path` is a sequence. Items of :data:`sys." +"path` that are not strings referring to existing directories are ignored. " +"Unicode items on :data:`sys.path` that cause errors when used as filenames " +"may cause this function to raise an exception (in line with :func:`os.path." +"isdir` behavior)." msgstr "" ":data:`sys.path` 被假設是一個序列,:data:`sys.path` 中的項目裡,若不是代表現" "存目錄的字串則將被忽略。:data:`sys.path` 上用作檔案名稱時導致錯誤的 Unicode " @@ -107,14 +106,14 @@ msgstr "取得給定之 *fullname* 的模組 :term:`loader`。" #: ../../library/pkgutil.rst:56 msgid "" -"This is a backwards compatibility wrapper " -"around :func:`importlib.util.find_spec` that converts most failures " -"to :exc:`ImportError` and only returns the loader rather than the " -"full :class:`importlib.machinery.ModuleSpec`." +"This is a backwards compatibility wrapper around :func:`importlib.util." +"find_spec` that converts most failures to :exc:`ImportError` and only " +"returns the loader rather than the full :class:`importlib.machinery." +"ModuleSpec`." msgstr "" "這是一個 :func:`importlib.util.find_spec` 的向後相容包裝器,它將大多數的失敗" -"轉換為 :exc:`ImportError` 並且僅回傳載入器而不是完整" -"的 :class:`importlib.machinery.ModuleSpec`。" +"轉換為 :exc:`ImportError` 並且僅回傳載入器而不是完整的 :class:`importlib." +"machinery.ModuleSpec`。" #: ../../library/pkgutil.rst:61 ../../library/pkgutil.rst:82 #: ../../library/pkgutil.rst:97 ../../library/pkgutil.rst:121 @@ -148,8 +147,8 @@ msgstr "" #: ../../library/pkgutil.rst:79 msgid "" -"The cache (or part of it) can be cleared manually if a rescan " -"of :data:`sys.path_hooks` is necessary." +"The cache (or part of it) can be cleared manually if a rescan of :data:`sys." +"path_hooks` is necessary." msgstr "" "如果需要重新掃描 :data:`sys.path_hooks`,可以手動清除快取(或部分快取)。" @@ -175,11 +174,12 @@ msgstr "yield 給定模組名稱的 :term:`finder` 物件。" #: ../../library/pkgutil.rst:112 msgid "" -"If fullname contains a ``'.'``, the finders will be for the package " -"containing fullname, otherwise they will be all registered top level finders " -"(i.e. those on both :data:`sys.meta_path` and :data:`sys.path_hooks`)." +"If *fullname* contains a ``'.'``, the finders will be for the package " +"containing *fullname*, otherwise they will be all registered top level " +"finders (i.e. those on both :data:`sys.meta_path` and :data:`sys." +"path_hooks`)." msgstr "" -"如果 fullname 包含 ``'.'``,則尋檢器將針對包含 fullname 的套件,否則它們全部" +"如果 *fullname* 包含 ``'.'``,則尋檢器將針對包含 *fullname* 的套件,否則它們全部" "會是在頂層被註冊的尋檢器(即 :data:`sys.meta_path` 和 :data:`sys.path_hooks` " "上的尋檢器)。" @@ -217,12 +217,12 @@ msgstr "*prefix* 是在輸出的每個模組名稱前面的輸出字串。" msgid "" "Only works for a :term:`finder` which defines an ``iter_modules()`` method. " "This interface is non-standard, so the module also provides implementations " -"for :class:`importlib.machinery.FileFinder` " -"and :class:`zipimport.zipimporter`." +"for :class:`importlib.machinery.FileFinder` and :class:`zipimport." +"zipimporter`." msgstr "" "僅適用於有定義 ``iter_modules()`` 方法的 :term:`finder`。此介面並非是標準的," -"因此該模組還提供了 :class:`importlib.machinery.FileFinder` " -"和 :class:`zipimport.zipimporter` 的實作。" +"因此該模組還提供了 :class:`importlib.machinery.FileFinder` 和 :class:" +"`zipimport.zipimporter` 的實作。" #: ../../library/pkgutil.rst:149 msgid "" @@ -245,13 +245,13 @@ msgstr "" msgid "" "*onerror* is a function which gets called with one argument (the name of the " "package which was being imported) if any exception occurs while trying to " -"import a package. If no *onerror* function is " -"supplied, :exc:`ImportError`\\s are caught and ignored, while all other " -"exceptions are propagated, terminating the search." +"import a package. If no *onerror* function is supplied, :exc:" +"`ImportError`\\s are caught and ignored, while all other exceptions are " +"propagated, terminating the search." msgstr "" "*onerror* 是一個函式,如果在嘗試引入套件時發生任何例外,則使用一個引數(正在" -"引入之套件的名稱)來呼叫函式。如果未提供 *onerror* 函式,則會捕獲並忽" -"略 :exc:`ImportError`,同時傳播所有其他例外並終止搜尋。" +"引入之套件的名稱)來呼叫函式。如果未提供 *onerror* 函式,則會捕獲並忽略 :exc:" +"`ImportError`,同時傳播所有其他例外並終止搜尋。" #: ../../library/pkgutil.rst:166 msgid "Examples::" @@ -277,12 +277,12 @@ msgstr "從套件中取得資源。" #: ../../library/pkgutil.rst:190 msgid "" -"This is a wrapper for the :term:`loader` :meth:`get_data " -"` API. The *package* argument should " -"be the name of a package, in standard module format (``foo.bar``). The " -"*resource* argument should be in the form of a relative filename, using ``/" -"`` as the path separator. The parent directory name ``..`` is not allowed, " -"and nor is a rooted name (starting with a ``/``)." +"This is a wrapper for the :term:`loader` :meth:`get_data ` API. The *package* argument should be the name of " +"a package, in standard module format (``foo.bar``). The *resource* argument " +"should be in the form of a relative filename, using ``/`` as the path " +"separator. The parent directory name ``..`` is not allowed, and nor is a " +"rooted name (starting with a ``/``)." msgstr "" "這是 :term:`loader` :meth:`get_data ` " "API 的包裝器。*package* 引數應該是採用標準模組格式 (``foo.bar``) 的套件名稱。" @@ -312,16 +312,15 @@ msgstr "" #: ../../library/pkgutil.rst:206 msgid "" "If the package cannot be located or loaded, or it uses a :term:`loader` " -"which does not support :meth:`get_data " -"`, then ``None`` is returned. In " -"particular, the :term:`loader` for :term:`namespace packages ` does not support :meth:`get_data " -"`." +"which does not support :meth:`get_data `, then ``None`` is returned. In particular, the :term:`loader` " +"for :term:`namespace packages ` does not support :meth:" +"`get_data `." msgstr "" -"如果無法定位或載入套件,或者它使用不支援 :meth:`get_data " -"` 的 :term:`loader` 則回傳 ``None``。" -"特別是\\ :term:`命名空間套件 `\\ 的 :term:`loader` 不支" -"援 :meth:`get_data `。" +"如果無法定位或載入套件,或者它使用不支援 :meth:`get_data ` 的 :term:`loader` 則回傳 ``None``。特別是\\ :term:`" +"命名空間套件 `\\ 的 :term:`loader` 不支援 :meth:`get_data " +"`。" #: ../../library/pkgutil.rst:215 msgid "Resolve a name to an object." @@ -329,9 +328,9 @@ msgstr "將名稱解析為物件。" #: ../../library/pkgutil.rst:217 msgid "" -"This functionality is used in numerous places in the standard library " -"(see :issue:`12915`) - and equivalent functionality is also in widely used " -"third-party packages such as setuptools, Django and Pyramid." +"This functionality is used in numerous places in the standard library (see :" +"issue:`12915`) - and equivalent functionality is also in widely used third-" +"party packages such as setuptools, Django and Pyramid." msgstr "" "標準函式庫中的許多地方都使用了此功能(請參閱 :issue:`12915`),且相同功能也被" "用於擁有廣大使用者的第三方套件,如 setuptools、Django 和 Pyramid。" diff --git a/library/re.po b/library/re.po index f62cafba70..7b0935d915 100644 --- a/library/re.po +++ b/library/re.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-11 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-09-16 14:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -169,7 +169,7 @@ msgstr "" msgid "The special characters are:" msgstr "" -#: ../../library/re.rst:101 ../../library/re.rst:1658 +#: ../../library/re.rst:101 ../../library/re.rst:1660 msgid "``.``" msgstr "``.``" @@ -1239,8 +1239,8 @@ msgstr "" #: ../../library/re.rst:896 ../../library/re.rst:928 ../../library/re.rst:946 #: ../../library/re.rst:957 ../../library/re.rst:1003 ../../library/re.rst:1037 -#: ../../library/re.rst:1052 ../../library/re.rst:1111 -#: ../../library/re.rst:1147 +#: ../../library/re.rst:1052 ../../library/re.rst:1114 +#: ../../library/re.rst:1149 msgid "" "The expression's behaviour can be modified by specifying a *flags* value. " "Values can be any of the `flags`_ variables, combined using bitwise OR (the " @@ -1393,9 +1393,9 @@ msgstr "如此一來,分隔符號元件始終可以在結果串列中的相同 #: ../../library/re.rst:991 msgid "" -"Empty matches for the pattern split the string only when not adjacent to a " -"previous empty match." -msgstr "只有當與先前的空匹配不相鄰時,模式的空匹配才會拆分字串。" +"Adjacent empty matches are not possible, but an empty match can occur " +"immediately after a non-empty match." +msgstr "" #: ../../library/re.rst:994 msgid "" @@ -1415,7 +1415,7 @@ msgstr "" "['', '...', '', '', 'w', '', 'o', '', 'r', '', 'd', '', 's', '...', '', '', " "'']" -#: ../../library/re.rst:1007 ../../library/re.rst:1115 +#: ../../library/re.rst:1007 ../../library/re.rst:1118 msgid "Added the optional flags argument." msgstr "新增可選的旗標引數。" @@ -1541,15 +1541,19 @@ msgstr "此模式可以是字串或 :class:`~re.Pattern`。" msgid "" "The optional argument *count* is the maximum number of pattern occurrences " "to be replaced; *count* must be a non-negative integer. If omitted or zero, " -"all occurrences will be replaced. Empty matches for the pattern are replaced " -"only when not adjacent to a previous empty match, so ``sub('x*', '-', " -"'abxd')`` returns ``'-a-b--d-'``." +"all occurrences will be replaced." msgstr "" "可選引數 *count* 是要替換的模式出現的最大次數;*count* 必須是非負整數。如果省" -"略或為零,則所有出現的內容都將被替換。只有當與先前的空匹配不相鄰時,模式的空" -"匹配才會被替換,因此 ``sub('x*', '-', 'abxd')`` 會回傳 ``'-a-b--d -'``。" +"略或為零,則所有出現的內容都將被替換。" + +#: ../../library/re.rst:1097 +msgid "" +"Adjacent empty matches are not possible, but an empty match can occur " +"immediately after a non-empty match. As a result, ``sub('x*', '-', 'abxd')`` " +"returns ``'-a-b--d-'`` instead of ``'-a-b-d-'``." +msgstr "" -#: ../../library/re.rst:1101 +#: ../../library/re.rst:1104 msgid "" "In string-type *repl* arguments, in addition to the character escapes and " "backreferences described above, ``\\g`` will use the substring matched " @@ -1568,27 +1572,26 @@ msgstr "" "群組 20 的參照,而不是對後面跟著字面字元 ``'0'`` 的群組 2 的參照。反向參照 " "``\\g<0>`` 會取代以 RE 所匹配到的整個子字串。" -#: ../../library/re.rst:1118 ../../library/re.rst:1396 +#: ../../library/re.rst:1121 ../../library/re.rst:1398 msgid "Unmatched groups are replaced with an empty string." msgstr "不匹配的群組將被替換為空字串。" -#: ../../library/re.rst:1121 +#: ../../library/re.rst:1124 msgid "" "Unknown escapes in *pattern* consisting of ``'\\'`` and an ASCII letter now " "are errors." msgstr "" "在由 ``'\\'`` 和一個 ASCII 字母組成之 *pattern* 中的未知轉義符現在為錯誤。" -#: ../../library/re.rst:1125 +#: ../../library/re.rst:1128 msgid "" "Unknown escapes in *repl* consisting of ``'\\'`` and an ASCII letter now are " -"errors. Empty matches for the pattern are replaced when adjacent to a " -"previous non-empty match." +"errors. An empty match can occur immediately after a non-empty match." msgstr "" -"由 ``'\\'`` 和一個 ASCII 字母組成之 *repl* 中的未知轉義符現在為錯誤。當與先前" -"的非空匹配相鄰時,模式的空匹配將被替換。" +"由 ``'\\'`` 和一個 ASCII 字母組成之 *repl* 中的未知轉義符現在為錯誤。" +"非空匹配後可以緊接著出現空匹配。" -#: ../../library/re.rst:1131 +#: ../../library/re.rst:1133 msgid "" "Group *id* can only contain ASCII digits. In :class:`bytes` replacement " "strings, group *name* can only contain bytes in the ASCII range " @@ -1597,7 +1600,7 @@ msgstr "" "群組 *id* 只能包含 ASCII 數字。在 :class:`bytes` 替換字串中,群組 *name* 只能" "包含 ASCII 範圍內的位元組 (``b'\\x00'``-``b'\\x7f'``)。" -#: ../../library/re.rst:1136 +#: ../../library/re.rst:1138 msgid "" "Passing *count* and *flags* as positional arguments is deprecated. In future " "Python versions they will be :ref:`keyword-only parameters `。" -#: ../../library/re.rst:1144 +#: ../../library/re.rst:1146 msgid "" "Perform the same operation as :func:`sub`, but return a tuple ``(new_string, " "number_of_subs_made)``." @@ -1614,7 +1617,7 @@ msgstr "" "執行與 :func:`sub` 相同的操作,但回傳一個元組 ``(new_string, " "number_of_subs_made)``。" -#: ../../library/re.rst:1154 +#: ../../library/re.rst:1156 msgid "" "Escape special characters in *pattern*. This is useful if you want to match " "an arbitrary literal string that may have regular expression metacharacters " @@ -1623,7 +1626,7 @@ msgstr "" "對 *pattern* 中的特殊字元進行轉義。如果你想要匹配其中可能包含正規表示式元字" "元 (metacharacter) 的任意文本字串,這會非常有用。例如: ::" -#: ../../library/re.rst:1158 +#: ../../library/re.rst:1160 msgid "" ">>> print(re.escape('https://www.python.org'))\n" "https://www\\.python\\.org\n" @@ -1649,7 +1652,7 @@ msgstr "" ">>> print('|'.join(map(re.escape, sorted(operators, reverse=True))))\n" "/|\\-|\\+|\\*\\*|\\*" -#: ../../library/re.rst:1169 +#: ../../library/re.rst:1171 msgid "" "This function must not be used for the replacement string in :func:`sub` " "and :func:`subn`, only backslashes should be escaped. For example::" @@ -1657,7 +1660,7 @@ msgstr "" "此函式不得用於 :func:`sub` 和 :func:`subn` 中的替換字串,僅應轉義反斜線。例" "如: ::" -#: ../../library/re.rst:1172 +#: ../../library/re.rst:1174 msgid "" ">>> digits_re = r'\\d+'\n" ">>> sample = '/usr/sbin/sendmail - 0 errors, 12 warnings'\n" @@ -1669,11 +1672,11 @@ msgstr "" ">>> print(re.sub(digits_re, digits_re.replace('\\\\', r'\\\\'), sample))\n" "/usr/sbin/sendmail - \\d+ errors, \\d+ warnings" -#: ../../library/re.rst:1177 +#: ../../library/re.rst:1179 msgid "The ``'_'`` character is no longer escaped." msgstr "``'_'`` 字元不再被轉義。" -#: ../../library/re.rst:1180 +#: ../../library/re.rst:1182 msgid "" "Only characters that can have special meaning in a regular expression are " "escaped. As a result, ``'!'``, ``'\"'``, ``'%'``, ``\"'\"``, ``','``, " @@ -1681,15 +1684,15 @@ msgid "" "are no longer escaped." msgstr "" -#: ../../library/re.rst:1189 +#: ../../library/re.rst:1191 msgid "Clear the regular expression cache." msgstr "清除正規表示式快取。" -#: ../../library/re.rst:1193 +#: ../../library/re.rst:1195 msgid "Exceptions" msgstr "例外" -#: ../../library/re.rst:1197 +#: ../../library/re.rst:1199 msgid "" "Exception raised when a string passed to one of the functions here is not a " "valid regular expression (for example, it might contain unmatched " @@ -1702,52 +1705,52 @@ msgstr "" "或在編譯或匹配期間發生某些其他錯誤時,將引發例外。如果字串不包含模式匹配項," "則絕不是錯誤。``PatternError`` 實例具有以下附加屬性:" -#: ../../library/re.rst:1205 +#: ../../library/re.rst:1207 msgid "The unformatted error message." msgstr "未格式化的錯誤訊息。" -#: ../../library/re.rst:1209 +#: ../../library/re.rst:1211 msgid "The regular expression pattern." msgstr "正規表示式模式。" -#: ../../library/re.rst:1213 +#: ../../library/re.rst:1215 msgid "The index in *pattern* where compilation failed (may be ``None``)." msgstr "*pattern* 中編譯失敗的索引(可能是 ``None``)。" -#: ../../library/re.rst:1217 +#: ../../library/re.rst:1219 msgid "The line corresponding to *pos* (may be ``None``)." msgstr "對應 *pos* 的列(可能是 ``None``)。" -#: ../../library/re.rst:1221 +#: ../../library/re.rst:1223 msgid "The column corresponding to *pos* (may be ``None``)." msgstr "對應 *pos* 的欄(可能是 ``None``)。" -#: ../../library/re.rst:1223 +#: ../../library/re.rst:1225 msgid "Added additional attributes." msgstr "新增額外屬性。" -#: ../../library/re.rst:1226 +#: ../../library/re.rst:1228 msgid "" "``PatternError`` was originally named ``error``; the latter is kept as an " "alias for backward compatibility." msgstr "" "``PatternError`` 最初被命名為 ``error``;後者為了向後相容性而被保留為別名。" -#: ../../library/re.rst:1233 +#: ../../library/re.rst:1235 msgid "Regular Expression Objects" msgstr "" -#: ../../library/re.rst:1237 +#: ../../library/re.rst:1239 msgid "Compiled regular expression object returned by :func:`re.compile`." msgstr "" -#: ../../library/re.rst:1239 +#: ../../library/re.rst:1241 msgid "" ":py:class:`re.Pattern` supports ``[]`` to indicate a Unicode (str) or bytes " "pattern. See :ref:`types-genericalias`." msgstr "" -#: ../../library/re.rst:1245 +#: ../../library/re.rst:1247 msgid "" "Scan through *string* looking for the first location where this regular " "expression produces a match, and return a corresponding :class:`~re.Match`. " @@ -1756,7 +1759,7 @@ msgid "" "string." msgstr "" -#: ../../library/re.rst:1250 +#: ../../library/re.rst:1252 msgid "" "The optional second parameter *pos* gives an index in the string where the " "search is to start; it defaults to ``0``. This is not completely equivalent " @@ -1765,7 +1768,7 @@ msgid "" "necessarily at the index where the search is to start." msgstr "" -#: ../../library/re.rst:1256 +#: ../../library/re.rst:1258 msgid "" "The optional parameter *endpos* limits how far the string will be searched; " "it will be as if the string is *endpos* characters long, so only the " @@ -1775,7 +1778,7 @@ msgid "" "equivalent to ``rx.search(string[:50], 0)``. ::" msgstr "" -#: ../../library/re.rst:1263 +#: ../../library/re.rst:1265 msgid "" ">>> pattern = re.compile(\"d\")\n" ">>> pattern.search(\"dog\") # Match at index 0\n" @@ -1783,7 +1786,7 @@ msgid "" ">>> pattern.search(\"dog\", 1) # No match; search doesn't include the \"d\"" msgstr "" -#: ../../library/re.rst:1271 +#: ../../library/re.rst:1273 msgid "" "If zero or more characters at the *beginning* of *string* match this regular " "expression, return a corresponding :class:`~re.Match`. Return ``None`` if " @@ -1791,13 +1794,13 @@ msgid "" "zero-length match." msgstr "" -#: ../../library/re.rst:1276 ../../library/re.rst:1294 +#: ../../library/re.rst:1278 ../../library/re.rst:1296 msgid "" "The optional *pos* and *endpos* parameters have the same meaning as for the :" "meth:`~Pattern.search` method. ::" msgstr "" -#: ../../library/re.rst:1279 +#: ../../library/re.rst:1281 msgid "" ">>> pattern = re.compile(\"o\")\n" ">>> pattern.match(\"dog\") # No match as \"o\" is not at the start of " @@ -1807,20 +1810,20 @@ msgid "" "" msgstr "" -#: ../../library/re.rst:1284 +#: ../../library/re.rst:1286 msgid "" "If you want to locate a match anywhere in *string*, use :meth:`~Pattern." "search` instead (see also :ref:`search-vs-match`)." msgstr "" -#: ../../library/re.rst:1290 +#: ../../library/re.rst:1292 msgid "" "If the whole *string* matches this regular expression, return a " "corresponding :class:`~re.Match`. Return ``None`` if the string does not " "match the pattern; note that this is different from a zero-length match." msgstr "" -#: ../../library/re.rst:1297 +#: ../../library/re.rst:1299 msgid "" ">>> pattern = re.compile(\"o[gh]\")\n" ">>> pattern.fullmatch(\"dog\") # No match as \"o\" is not at the start " @@ -1831,72 +1834,72 @@ msgid "" "" msgstr "" -#: ../../library/re.rst:1308 +#: ../../library/re.rst:1310 msgid "Identical to the :func:`split` function, using the compiled pattern." msgstr "" -#: ../../library/re.rst:1313 +#: ../../library/re.rst:1315 msgid "" "Similar to the :func:`findall` function, using the compiled pattern, but " "also accepts optional *pos* and *endpos* parameters that limit the search " "region like for :meth:`search`." msgstr "" -#: ../../library/re.rst:1320 +#: ../../library/re.rst:1322 msgid "" "Similar to the :func:`finditer` function, using the compiled pattern, but " "also accepts optional *pos* and *endpos* parameters that limit the search " "region like for :meth:`search`." msgstr "" -#: ../../library/re.rst:1327 +#: ../../library/re.rst:1329 msgid "Identical to the :func:`sub` function, using the compiled pattern." msgstr "" -#: ../../library/re.rst:1332 +#: ../../library/re.rst:1334 msgid "Identical to the :func:`subn` function, using the compiled pattern." msgstr "" -#: ../../library/re.rst:1337 +#: ../../library/re.rst:1339 msgid "" "The regex matching flags. This is a combination of the flags given to :func:" "`.compile`, any ``(?...)`` inline flags in the pattern, and implicit flags " "such as :py:const:`~re.UNICODE` if the pattern is a Unicode string." msgstr "" -#: ../../library/re.rst:1344 +#: ../../library/re.rst:1346 msgid "The number of capturing groups in the pattern." msgstr "" -#: ../../library/re.rst:1349 +#: ../../library/re.rst:1351 msgid "" "A dictionary mapping any symbolic group names defined by ``(?P)`` to " "group numbers. The dictionary is empty if no symbolic groups were used in " "the pattern." msgstr "" -#: ../../library/re.rst:1356 +#: ../../library/re.rst:1358 msgid "The pattern string from which the pattern object was compiled." msgstr "" -#: ../../library/re.rst:1359 +#: ../../library/re.rst:1361 msgid "" "Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Compiled " "regular expression objects are considered atomic." msgstr "" -#: ../../library/re.rst:1367 +#: ../../library/re.rst:1369 msgid "Match Objects" msgstr "" -#: ../../library/re.rst:1369 +#: ../../library/re.rst:1371 msgid "" "Match objects always have a boolean value of ``True``. Since :meth:`~Pattern." "match` and :meth:`~Pattern.search` return ``None`` when there is no match, " "you can test whether there was a match with a simple ``if`` statement::" msgstr "" -#: ../../library/re.rst:1374 +#: ../../library/re.rst:1376 msgid "" "match = re.search(pattern, string)\n" "if match:\n" @@ -1906,17 +1909,17 @@ msgstr "" "if match:\n" " process(match)" -#: ../../library/re.rst:1380 +#: ../../library/re.rst:1382 msgid "Match object returned by successful ``match``\\ es and ``search``\\ es." msgstr "" -#: ../../library/re.rst:1382 +#: ../../library/re.rst:1384 msgid "" ":py:class:`re.Match` supports ``[]`` to indicate a Unicode (str) or bytes " "match. See :ref:`types-genericalias`." msgstr "" -#: ../../library/re.rst:1388 +#: ../../library/re.rst:1390 msgid "" "Return the string obtained by doing backslash substitution on the template " "string *template*, as done by the :meth:`~Pattern.sub` method. Escapes such " @@ -1926,7 +1929,7 @@ msgid "" "backreference ``\\g<0>`` will be replaced by the entire match." msgstr "" -#: ../../library/re.rst:1401 +#: ../../library/re.rst:1403 msgid "" "Returns one or more subgroups of the match. If there is a single argument, " "the result is a single string; if there are multiple arguments, the result " @@ -1941,7 +1944,7 @@ msgid "" "the pattern that matched multiple times, the last match is returned. ::" msgstr "" -#: ../../library/re.rst:1413 +#: ../../library/re.rst:1415 msgid "" ">>> m = re.match(r\"(\\w+) (\\w+)\", \"Isaac Newton, physicist\")\n" ">>> m.group(0) # The entire match\n" @@ -1954,7 +1957,7 @@ msgid "" "('Isaac', 'Newton')" msgstr "" -#: ../../library/re.rst:1423 +#: ../../library/re.rst:1425 msgid "" "If the regular expression uses the ``(?P...)`` syntax, the *groupN* " "arguments may also be strings identifying groups by their group name. If a " @@ -1962,11 +1965,11 @@ msgid "" "`IndexError` exception is raised." msgstr "" -#: ../../library/re.rst:1428 +#: ../../library/re.rst:1430 msgid "A moderately complicated example::" msgstr "" -#: ../../library/re.rst:1430 +#: ../../library/re.rst:1432 msgid "" ">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Malcolm " "Reynolds\")\n" @@ -1982,11 +1985,11 @@ msgstr "" ">>> m.group('last_name')\n" "'Reynolds'" -#: ../../library/re.rst:1436 +#: ../../library/re.rst:1438 msgid "Named groups can also be referred to by their index::" msgstr "" -#: ../../library/re.rst:1438 +#: ../../library/re.rst:1440 msgid "" ">>> m.group(1)\n" "'Malcolm'\n" @@ -1998,24 +2001,24 @@ msgstr "" ">>> m.group(2)\n" "'Reynolds'" -#: ../../library/re.rst:1443 +#: ../../library/re.rst:1445 msgid "If a group matches multiple times, only the last match is accessible::" msgstr "" -#: ../../library/re.rst:1445 +#: ../../library/re.rst:1447 msgid "" ">>> m = re.match(r\"(..)+\", \"a1b2c3\") # Matches 3 times.\n" ">>> m.group(1) # Returns only the last match.\n" "'c3'" msgstr "" -#: ../../library/re.rst:1452 +#: ../../library/re.rst:1454 msgid "" "This is identical to ``m.group(g)``. This allows easier access to an " "individual group from a match::" msgstr "" -#: ../../library/re.rst:1455 +#: ../../library/re.rst:1457 msgid "" ">>> m = re.match(r\"(\\w+) (\\w+)\", \"Isaac Newton, physicist\")\n" ">>> m[0] # The entire match\n" @@ -2026,11 +2029,11 @@ msgid "" "'Newton'" msgstr "" -#: ../../library/re.rst:1463 +#: ../../library/re.rst:1465 msgid "Named groups are supported as well::" msgstr "" -#: ../../library/re.rst:1465 +#: ../../library/re.rst:1467 msgid "" ">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Isaac " "Newton\")\n" @@ -2046,18 +2049,18 @@ msgstr "" ">>> m['last_name']\n" "'Newton'" -#: ../../library/re.rst:1476 +#: ../../library/re.rst:1478 msgid "" "Return a tuple containing all the subgroups of the match, from 1 up to " "however many groups are in the pattern. The *default* argument is used for " "groups that did not participate in the match; it defaults to ``None``." msgstr "" -#: ../../library/re.rst:1480 ../../library/re.rst:1705 +#: ../../library/re.rst:1482 ../../library/re.rst:1707 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/re.rst:1482 +#: ../../library/re.rst:1484 msgid "" ">>> m = re.match(r\"(\\d+)\\.(\\d+)\", \"24.1632\")\n" ">>> m.groups()\n" @@ -2067,14 +2070,14 @@ msgstr "" ">>> m.groups()\n" "('24', '1632')" -#: ../../library/re.rst:1486 +#: ../../library/re.rst:1488 msgid "" "If we make the decimal place and everything after it optional, not all " "groups might participate in the match. These groups will default to " "``None`` unless the *default* argument is given::" msgstr "" -#: ../../library/re.rst:1490 +#: ../../library/re.rst:1492 msgid "" ">>> m = re.match(r\"(\\d+)\\.?(\\d+)?\", \"24\")\n" ">>> m.groups() # Second group defaults to None.\n" @@ -2083,14 +2086,14 @@ msgid "" "('24', '0')" msgstr "" -#: ../../library/re.rst:1499 +#: ../../library/re.rst:1501 msgid "" "Return a dictionary containing all the *named* subgroups of the match, keyed " "by the subgroup name. The *default* argument is used for groups that did " "not participate in the match; it defaults to ``None``. For example::" msgstr "" -#: ../../library/re.rst:1503 +#: ../../library/re.rst:1505 msgid "" ">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Malcolm " "Reynolds\")\n" @@ -2102,7 +2105,7 @@ msgstr "" ">>> m.groupdict()\n" "{'first_name': 'Malcolm', 'last_name': 'Reynolds'}" -#: ../../library/re.rst:1511 +#: ../../library/re.rst:1513 msgid "" "Return the indices of the start and end of the substring matched by *group*; " "*group* defaults to zero (meaning the whole matched substring). Return " @@ -2111,11 +2114,11 @@ msgid "" "matched by group *g* (equivalent to ``m.group(g)``) is ::" msgstr "" -#: ../../library/re.rst:1517 +#: ../../library/re.rst:1519 msgid "m.string[m.start(g):m.end(g)]" msgstr "m.string[m.start(g):m.end(g)]" -#: ../../library/re.rst:1519 +#: ../../library/re.rst:1521 msgid "" "Note that ``m.start(group)`` will equal ``m.end(group)`` if *group* matched " "a null string. For example, after ``m = re.search('b(c?)', 'cba')``, ``m." @@ -2123,11 +2126,11 @@ msgid "" "2, and ``m.start(2)`` raises an :exc:`IndexError` exception." msgstr "" -#: ../../library/re.rst:1524 +#: ../../library/re.rst:1526 msgid "An example that will remove *remove_this* from email addresses::" msgstr "" -#: ../../library/re.rst:1526 +#: ../../library/re.rst:1528 msgid "" ">>> email = \"tony@tiremove_thisger.net\"\n" ">>> m = re.search(\"remove_this\", email)\n" @@ -2139,28 +2142,28 @@ msgstr "" ">>> email[:m.start()] + email[m.end():]\n" "'tony@tiger.net'" -#: ../../library/re.rst:1534 +#: ../../library/re.rst:1536 msgid "" "For a match *m*, return the 2-tuple ``(m.start(group), m.end(group))``. Note " "that if *group* did not contribute to the match, this is ``(-1, -1)``. " "*group* defaults to zero, the entire match." msgstr "" -#: ../../library/re.rst:1541 +#: ../../library/re.rst:1543 msgid "" "The value of *pos* which was passed to the :meth:`~Pattern.search` or :meth:" "`~Pattern.match` method of a :ref:`regex object `. This is the " "index into the string at which the RE engine started looking for a match." msgstr "" -#: ../../library/re.rst:1548 +#: ../../library/re.rst:1550 msgid "" "The value of *endpos* which was passed to the :meth:`~Pattern.search` or :" "meth:`~Pattern.match` method of a :ref:`regex object `. This is " "the index into the string beyond which the RE engine will not go." msgstr "" -#: ../../library/re.rst:1555 +#: ../../library/re.rst:1557 msgid "" "The integer index of the last matched capturing group, or ``None`` if no " "group was matched at all. For example, the expressions ``(a)b``, ``((a)" @@ -2169,43 +2172,43 @@ msgid "" "applied to the same string." msgstr "" -#: ../../library/re.rst:1564 +#: ../../library/re.rst:1566 msgid "" "The name of the last matched capturing group, or ``None`` if the group " "didn't have a name, or if no group was matched at all." msgstr "" -#: ../../library/re.rst:1570 +#: ../../library/re.rst:1572 msgid "" "The :ref:`regular expression object ` whose :meth:`~Pattern." "match` or :meth:`~Pattern.search` method produced this match instance." msgstr "" -#: ../../library/re.rst:1576 +#: ../../library/re.rst:1578 msgid "The string passed to :meth:`~Pattern.match` or :meth:`~Pattern.search`." msgstr "" -#: ../../library/re.rst:1579 +#: ../../library/re.rst:1581 msgid "" "Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Match objects " "are considered atomic." msgstr "" -#: ../../library/re.rst:1587 +#: ../../library/re.rst:1589 msgid "Regular Expression Examples" msgstr "" -#: ../../library/re.rst:1591 +#: ../../library/re.rst:1593 msgid "Checking for a Pair" msgstr "" -#: ../../library/re.rst:1593 +#: ../../library/re.rst:1595 msgid "" "In this example, we'll use the following helper function to display match " "objects a little more gracefully::" msgstr "" -#: ../../library/re.rst:1596 +#: ../../library/re.rst:1598 msgid "" "def displaymatch(match):\n" " if match is None:\n" @@ -2217,7 +2220,7 @@ msgstr "" " return None\n" " return '' % (match.group(), match.groups())" -#: ../../library/re.rst:1601 +#: ../../library/re.rst:1603 msgid "" "Suppose you are writing a poker program where a player's hand is represented " "as a 5-character string with each character representing a card, \"a\" for " @@ -2225,11 +2228,11 @@ msgid "" "\"2\" through \"9\" representing the card with that value." msgstr "" -#: ../../library/re.rst:1606 +#: ../../library/re.rst:1608 msgid "To see if a given string is a valid hand, one could do the following::" msgstr "" -#: ../../library/re.rst:1608 +#: ../../library/re.rst:1610 msgid "" ">>> valid = re.compile(r\"^[a2-9tjqk]{5}$\")\n" ">>> displaymatch(valid.match(\"akt5q\")) # Valid.\n" @@ -2240,14 +2243,14 @@ msgid "" "\"\"" msgstr "" -#: ../../library/re.rst:1616 +#: ../../library/re.rst:1618 msgid "" "That last hand, ``\"727ak\"``, contained a pair, or two of the same valued " "cards. To match this with a regular expression, one could use backreferences " "as such::" msgstr "" -#: ../../library/re.rst:1619 +#: ../../library/re.rst:1621 msgid "" ">>> pair = re.compile(r\".*(.).*\\1\")\n" ">>> displaymatch(pair.match(\"717ak\")) # Pair of 7s.\n" @@ -2257,13 +2260,13 @@ msgid "" "\"\"" msgstr "" -#: ../../library/re.rst:1626 +#: ../../library/re.rst:1628 msgid "" "To find out what card the pair consists of, one could use the :meth:`~Match." "group` method of the match object in the following manner::" msgstr "" -#: ../../library/re.rst:1629 +#: ../../library/re.rst:1631 msgid "" ">>> pair = re.compile(r\".*(.).*\\1\")\n" ">>> pair.match(\"717ak\").group(1)\n" @@ -2281,11 +2284,11 @@ msgid "" "'a'" msgstr "" -#: ../../library/re.rst:1645 +#: ../../library/re.rst:1647 msgid "Simulating scanf()" msgstr "模擬 scanf()" -#: ../../library/re.rst:1649 +#: ../../library/re.rst:1651 msgid "" "Python does not currently have an equivalent to :c:func:`!scanf`. Regular " "expressions are generally more powerful, though also more verbose, than :c:" @@ -2294,130 +2297,130 @@ msgid "" "expressions." msgstr "" -#: ../../library/re.rst:1656 +#: ../../library/re.rst:1658 msgid ":c:func:`!scanf` Token" msgstr "" -#: ../../library/re.rst:1656 +#: ../../library/re.rst:1658 msgid "Regular Expression" msgstr "" -#: ../../library/re.rst:1658 +#: ../../library/re.rst:1660 msgid "``%c``" msgstr "``%c``" -#: ../../library/re.rst:1660 +#: ../../library/re.rst:1662 msgid "``%5c``" msgstr "``%5c``" -#: ../../library/re.rst:1660 +#: ../../library/re.rst:1662 msgid "``.{5}``" msgstr "``.{5}``" -#: ../../library/re.rst:1662 +#: ../../library/re.rst:1664 msgid "``%d``" msgstr "``%d``" -#: ../../library/re.rst:1662 +#: ../../library/re.rst:1664 msgid "``[-+]?\\d+``" msgstr "``[-+]?\\d+``" -#: ../../library/re.rst:1664 +#: ../../library/re.rst:1666 msgid "``%e``, ``%E``, ``%f``, ``%g``" msgstr "``%e``, ``%E``, ``%f``, ``%g``" -#: ../../library/re.rst:1664 +#: ../../library/re.rst:1666 msgid "``[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?``" msgstr "``[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?``" -#: ../../library/re.rst:1666 +#: ../../library/re.rst:1668 msgid "``%i``" msgstr "``%i``" -#: ../../library/re.rst:1666 +#: ../../library/re.rst:1668 msgid "``[-+]?(0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)``" msgstr "``[-+]?(0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)``" -#: ../../library/re.rst:1668 +#: ../../library/re.rst:1670 msgid "``%o``" msgstr "``%o``" -#: ../../library/re.rst:1668 +#: ../../library/re.rst:1670 msgid "``[-+]?[0-7]+``" msgstr "``[-+]?[0-7]+``" -#: ../../library/re.rst:1670 +#: ../../library/re.rst:1672 msgid "``%s``" msgstr "``%s``" -#: ../../library/re.rst:1670 +#: ../../library/re.rst:1672 msgid "``\\S+``" msgstr "``\\S+``" -#: ../../library/re.rst:1672 +#: ../../library/re.rst:1674 msgid "``%u``" msgstr "``%u``" -#: ../../library/re.rst:1672 +#: ../../library/re.rst:1674 msgid "``\\d+``" msgstr "``\\d+``" -#: ../../library/re.rst:1674 +#: ../../library/re.rst:1676 msgid "``%x``, ``%X``" msgstr "``%x``、``%X``" -#: ../../library/re.rst:1674 +#: ../../library/re.rst:1676 msgid "``[-+]?(0[xX])?[\\dA-Fa-f]+``" msgstr "``[-+]?(0[xX])?[\\dA-Fa-f]+``" -#: ../../library/re.rst:1677 +#: ../../library/re.rst:1679 msgid "To extract the filename and numbers from a string like ::" msgstr "" -#: ../../library/re.rst:1679 +#: ../../library/re.rst:1681 msgid "/usr/sbin/sendmail - 0 errors, 4 warnings" msgstr "/usr/sbin/sendmail - 0 errors, 4 warnings" -#: ../../library/re.rst:1681 +#: ../../library/re.rst:1683 msgid "you would use a :c:func:`!scanf` format like ::" msgstr "" -#: ../../library/re.rst:1683 +#: ../../library/re.rst:1685 msgid "%s - %d errors, %d warnings" msgstr "" -#: ../../library/re.rst:1685 +#: ../../library/re.rst:1687 msgid "The equivalent regular expression would be ::" msgstr "" -#: ../../library/re.rst:1687 +#: ../../library/re.rst:1689 msgid "(\\S+) - (\\d+) errors, (\\d+) warnings" msgstr "" -#: ../../library/re.rst:1693 +#: ../../library/re.rst:1695 msgid "search() vs. match()" msgstr "search() vs. match()" -#: ../../library/re.rst:1697 +#: ../../library/re.rst:1699 msgid "" "Python offers different primitive operations based on regular expressions:" msgstr "" -#: ../../library/re.rst:1699 +#: ../../library/re.rst:1701 msgid ":func:`re.match` checks for a match only at the beginning of the string" msgstr "" -#: ../../library/re.rst:1700 +#: ../../library/re.rst:1702 msgid "" ":func:`re.search` checks for a match anywhere in the string (this is what " "Perl does by default)" msgstr "" -#: ../../library/re.rst:1702 +#: ../../library/re.rst:1704 msgid ":func:`re.fullmatch` checks for entire string to be a match" msgstr "" -#: ../../library/re.rst:1707 +#: ../../library/re.rst:1709 msgid "" ">>> re.match(\"c\", \"abcdef\") # No match\n" ">>> re.search(\"c\", \"abcdef\") # Match\n" @@ -2427,13 +2430,13 @@ msgid "" ">>> re.fullmatch(\"r.*n\", \"python\") # No match" msgstr "" -#: ../../library/re.rst:1714 +#: ../../library/re.rst:1716 msgid "" "Regular expressions beginning with ``'^'`` can be used with :func:`search` " "to restrict the match at the beginning of the string::" msgstr "" -#: ../../library/re.rst:1717 +#: ../../library/re.rst:1719 msgid "" ">>> re.match(\"c\", \"abcdef\") # No match\n" ">>> re.search(\"^c\", \"abcdef\") # No match\n" @@ -2441,7 +2444,7 @@ msgid "" "" msgstr "" -#: ../../library/re.rst:1722 +#: ../../library/re.rst:1724 msgid "" "Note however that in :const:`MULTILINE` mode :func:`match` only matches at " "the beginning of the string, whereas using :func:`search` with a regular " @@ -2449,18 +2452,18 @@ msgid "" "line. ::" msgstr "" -#: ../../library/re.rst:1726 +#: ../../library/re.rst:1728 msgid "" ">>> re.match(\"X\", \"A\\nB\\nX\", re.MULTILINE) # No match\n" ">>> re.search(\"^X\", \"A\\nB\\nX\", re.MULTILINE) # Match\n" "" msgstr "" -#: ../../library/re.rst:1732 +#: ../../library/re.rst:1734 msgid "Making a Phonebook" msgstr "" -#: ../../library/re.rst:1734 +#: ../../library/re.rst:1736 msgid "" ":func:`split` splits a string into a list delimited by the passed pattern. " "The method is invaluable for converting textual data into data structures " @@ -2468,13 +2471,13 @@ msgid "" "following example that creates a phonebook." msgstr "" -#: ../../library/re.rst:1739 +#: ../../library/re.rst:1741 msgid "" "First, here is the input. Normally it may come from a file, here we are " "using triple-quoted string syntax" msgstr "" -#: ../../library/re.rst:1742 +#: ../../library/re.rst:1744 msgid "" ">>> text = \"\"\"Ross McFluff: 834.345.1254 155 Elm Street\n" "...\n" @@ -2492,13 +2495,13 @@ msgstr "" "...\n" "... Heather Albrecht: 548.326.4584 919 Park Place\"\"\"" -#: ../../library/re.rst:1752 +#: ../../library/re.rst:1754 msgid "" "The entries are separated by one or more newlines. Now we convert the string " "into a list with each nonempty line having its own entry:" msgstr "" -#: ../../library/re.rst:1755 +#: ../../library/re.rst:1757 msgid "" ">>> entries = re.split(\"\\n+\", text)\n" ">>> entries\n" @@ -2514,14 +2517,14 @@ msgstr "" "'Frank Burger: 925.541.7625 662 South Dogwood Way',\n" "'Heather Albrecht: 548.326.4584 919 Park Place']" -#: ../../library/re.rst:1765 +#: ../../library/re.rst:1767 msgid "" "Finally, split each entry into a list with first name, last name, telephone " "number, and address. We use the ``maxsplit`` parameter of :func:`split` " "because the address has spaces, our splitting pattern, in it:" msgstr "" -#: ../../library/re.rst:1769 +#: ../../library/re.rst:1771 msgid "" ">>> [re.split(\":? \", entry, maxsplit=3) for entry in entries]\n" "[['Ross', 'McFluff', '834.345.1254', '155 Elm Street'],\n" @@ -2535,14 +2538,14 @@ msgstr "" "['Frank', 'Burger', '925.541.7625', '662 South Dogwood Way'],\n" "['Heather', 'Albrecht', '548.326.4584', '919 Park Place']]" -#: ../../library/re.rst:1778 +#: ../../library/re.rst:1780 msgid "" "The ``:?`` pattern matches the colon after the last name, so that it does " "not occur in the result list. With a ``maxsplit`` of ``4``, we could " "separate the house number from the street name:" msgstr "" -#: ../../library/re.rst:1782 +#: ../../library/re.rst:1784 msgid "" ">>> [re.split(\":? \", entry, maxsplit=4) for entry in entries]\n" "[['Ross', 'McFluff', '834.345.1254', '155', 'Elm Street'],\n" @@ -2556,11 +2559,11 @@ msgstr "" "['Frank', 'Burger', '925.541.7625', '662', 'South Dogwood Way'],\n" "['Heather', 'Albrecht', '548.326.4584', '919', 'Park Place']]" -#: ../../library/re.rst:1793 +#: ../../library/re.rst:1795 msgid "Text Munging" msgstr "" -#: ../../library/re.rst:1795 +#: ../../library/re.rst:1797 msgid "" ":func:`sub` replaces every occurrence of a pattern with a string or the " "result of a function. This example demonstrates using :func:`sub` with a " @@ -2568,7 +2571,7 @@ msgid "" "each word of a sentence except for the first and last characters::" msgstr "" -#: ../../library/re.rst:1800 +#: ../../library/re.rst:1802 msgid "" ">>> def repl(m):\n" "... inner_word = list(m.group(2))\n" @@ -2592,11 +2595,11 @@ msgstr "" ">>> re.sub(r\"(\\w)(\\w+)(\\w)\", repl, text)\n" "'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.'" -#: ../../library/re.rst:1813 +#: ../../library/re.rst:1815 msgid "Finding all Adverbs" msgstr "" -#: ../../library/re.rst:1815 +#: ../../library/re.rst:1817 msgid "" ":func:`findall` matches *all* occurrences of a pattern, not just the first " "one as :func:`search` does. For example, if a writer wanted to find all of " @@ -2604,7 +2607,7 @@ msgid "" "manner::" msgstr "" -#: ../../library/re.rst:1820 +#: ../../library/re.rst:1822 msgid "" ">>> text = \"He was carefully disguised but captured quickly by police.\"\n" ">>> re.findall(r\"\\w+ly\\b\", text)\n" @@ -2614,11 +2617,11 @@ msgstr "" ">>> re.findall(r\"\\w+ly\\b\", text)\n" "['carefully', 'quickly']" -#: ../../library/re.rst:1826 +#: ../../library/re.rst:1828 msgid "Finding all Adverbs and their Positions" msgstr "" -#: ../../library/re.rst:1828 +#: ../../library/re.rst:1830 msgid "" "If one wants more information about all matches of a pattern than the " "matched text, :func:`finditer` is useful as it provides :class:`~re.Match` " @@ -2627,7 +2630,7 @@ msgid "" "they would use :func:`finditer` in the following manner::" msgstr "" -#: ../../library/re.rst:1834 +#: ../../library/re.rst:1836 msgid "" ">>> text = \"He was carefully disguised but captured quickly by police.\"\n" ">>> for m in re.finditer(r\"\\w+ly\\b\", text):\n" @@ -2641,11 +2644,11 @@ msgstr "" "07-16: carefully\n" "40-47: quickly" -#: ../../library/re.rst:1842 +#: ../../library/re.rst:1844 msgid "Raw String Notation" msgstr "" -#: ../../library/re.rst:1844 +#: ../../library/re.rst:1846 msgid "" "Raw string notation (``r\"text\"``) keeps regular expressions sane. Without " "it, every backslash (``'\\'``) in a regular expression would have to be " @@ -2653,7 +2656,7 @@ msgid "" "lines of code are functionally identical::" msgstr "" -#: ../../library/re.rst:1849 +#: ../../library/re.rst:1851 msgid "" ">>> re.match(r\"\\W(.)\\1\\W\", \" ff \")\n" "\n" @@ -2665,7 +2668,7 @@ msgstr "" ">>> re.match(\"\\\\W(.)\\\\1\\\\W\", \" ff \")\n" "" -#: ../../library/re.rst:1854 +#: ../../library/re.rst:1856 msgid "" "When one wants to match a literal backslash, it must be escaped in the " "regular expression. With raw string notation, this means ``r\"\\\\\"``. " @@ -2673,7 +2676,7 @@ msgid "" "following lines of code functionally identical::" msgstr "" -#: ../../library/re.rst:1859 +#: ../../library/re.rst:1861 msgid "" ">>> re.match(r\"\\\\\", r\"\\\\\")\n" "\n" @@ -2685,25 +2688,25 @@ msgstr "" ">>> re.match(\"\\\\\\\\\", r\"\\\\\")\n" "" -#: ../../library/re.rst:1866 +#: ../../library/re.rst:1868 msgid "Writing a Tokenizer" msgstr "" -#: ../../library/re.rst:1868 +#: ../../library/re.rst:1870 msgid "" "A `tokenizer or scanner `_ " "analyzes a string to categorize groups of characters. This is a useful " "first step in writing a compiler or interpreter." msgstr "" -#: ../../library/re.rst:1872 +#: ../../library/re.rst:1874 msgid "" "The text categories are specified with regular expressions. The technique " "is to combine those into a single master regular expression and to loop over " "successive matches::" msgstr "" -#: ../../library/re.rst:1876 +#: ../../library/re.rst:1878 msgid "" "from typing import NamedTuple\n" "import re\n" @@ -2759,11 +2762,11 @@ msgid "" " print(token)" msgstr "" -#: ../../library/re.rst:1928 +#: ../../library/re.rst:1930 msgid "The tokenizer produces the following output::" msgstr "" -#: ../../library/re.rst:1930 +#: ../../library/re.rst:1932 msgid "" "Token(type='IF', value='IF', line=2, column=4)\n" "Token(type='ID', value='quantity', line=2, column=7)\n" @@ -2805,7 +2808,7 @@ msgstr "" "Token(type='ENDIF', value='ENDIF', line=5, column=4)\n" "Token(type='END', value=';', line=5, column=9)" -#: ../../library/re.rst:1951 +#: ../../library/re.rst:1953 msgid "" "Friedl, Jeffrey. Mastering Regular Expressions. 3rd ed., O'Reilly Media, " "2009. The third edition of the book no longer covers Python at all, but the " @@ -2830,7 +2833,7 @@ msgstr ". (點)" #: ../../library/re.rst:590 ../../library/re.rst:606 ../../library/re.rst:614 #: ../../library/re.rst:628 ../../library/re.rst:636 ../../library/re.rst:653 #: ../../library/re.rst:667 ../../library/re.rst:672 ../../library/re.rst:863 -#: ../../library/re.rst:1099 +#: ../../library/re.rst:1102 msgid "in regular expressions" msgstr "於正規表示式中" @@ -3030,13 +3033,18 @@ msgstr "\\\\" msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/re.rst:1099 +#: ../../library/re.rst:1102 msgid "\\g" msgstr "\\g" -#: ../../library/re.rst:1647 +#: ../../library/re.rst:1649 msgid "scanf (C function)" msgstr "scanf(C 函式)" +#~ msgid "" +#~ "Empty matches for the pattern split the string only when not adjacent to " +#~ "a previous empty match." +#~ msgstr "只有當與先前的空匹配不相鄰時,模式的空匹配才會拆分字串。" + #~ msgid "scanf()" #~ msgstr "scanf()" diff --git a/library/shutil.po b/library/shutil.po index c90e1f7a6c..145efa74ff 100644 --- a/library/shutil.po +++ b/library/shutil.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-11 00:17+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -115,7 +115,7 @@ msgstr "" #: ../../library/shutil.rst:81 ../../library/shutil.rst:185 #: ../../library/shutil.rst:217 ../../library/shutil.rst:287 -#: ../../library/shutil.rst:396 +#: ../../library/shutil.rst:400 msgid "" "Platform-specific fast-copy syscalls may be used internally in order to copy " "the file more efficiently. See :ref:`shutil-platform-dependent-efficient-" @@ -421,7 +421,13 @@ msgid "" "parameter it receives is the tuple returned from :func:`sys.exc_info`." msgstr "" -#: ../../library/shutil.rst:330 +#: ../../library/shutil.rst:331 +msgid "" +":ref:`shutil-rmtree-example` for an example of handling the removal of a " +"directory tree that contains read-only files." +msgstr "" + +#: ../../library/shutil.rst:334 msgid "" "Raises an :ref:`auditing event ` ``shutil.rmtree`` with arguments " "``path``, ``dir_fd``." @@ -429,60 +435,60 @@ msgstr "" "引發一個附帶引數 ``path``、``dir_fd`` 的\\ :ref:`稽核事件 ` " "``shutil.rmtree``。" -#: ../../library/shutil.rst:332 +#: ../../library/shutil.rst:336 msgid "" "Added a symlink attack resistant version that is used automatically if " "platform supports fd-based functions." msgstr "" -#: ../../library/shutil.rst:336 +#: ../../library/shutil.rst:340 msgid "" "On Windows, will no longer delete the contents of a directory junction " "before removing the junction." msgstr "" -#: ../../library/shutil.rst:340 +#: ../../library/shutil.rst:344 msgid "Added the *dir_fd* parameter." msgstr "新增 *dir_fd* 參數。" -#: ../../library/shutil.rst:343 +#: ../../library/shutil.rst:347 msgid "Added the *onexc* parameter, deprecated *onerror*." msgstr "新增 *onexc* 參數並棄用 *onerror*。" -#: ../../library/shutil.rst:346 +#: ../../library/shutil.rst:350 msgid "" ":func:`!rmtree` now ignores :exc:`FileNotFoundError` exceptions for all but " "the top-level path. Exceptions other than :exc:`OSError` and subclasses of :" "exc:`!OSError` are now always propagated to the caller." msgstr "" -#: ../../library/shutil.rst:354 +#: ../../library/shutil.rst:358 msgid "" "Indicates whether the current platform and implementation provides a symlink " "attack resistant version of :func:`rmtree`. Currently this is only true for " "platforms supporting fd-based directory access functions." msgstr "" -#: ../../library/shutil.rst:363 +#: ../../library/shutil.rst:367 msgid "" "Recursively move a file or directory (*src*) to another location and return " "the destination." msgstr "" -#: ../../library/shutil.rst:366 +#: ../../library/shutil.rst:370 msgid "" "If *dst* is an existing directory or a symlink to a directory, then *src* is " "moved inside that directory. The destination path in that directory must not " "already exist." msgstr "" -#: ../../library/shutil.rst:370 +#: ../../library/shutil.rst:374 msgid "" "If *dst* already exists but is not a directory, it may be overwritten " "depending on :func:`os.rename` semantics." msgstr "" -#: ../../library/shutil.rst:373 +#: ../../library/shutil.rst:377 msgid "" "If the destination is on the current filesystem, then :func:`os.rename` is " "used. Otherwise, *src* is copied to the destination using *copy_function* " @@ -490,7 +496,7 @@ msgid "" "of *src* will be created as the destination and *src* will be removed." msgstr "" -#: ../../library/shutil.rst:378 +#: ../../library/shutil.rst:382 msgid "" "If *copy_function* is given, it must be a callable that takes two arguments, " "*src* and the destination, and will be used to copy *src* to the destination " @@ -501,7 +507,7 @@ msgid "" "copy the metadata, at the expense of not copying any of the metadata." msgstr "" -#: ../../library/shutil.rst:386 +#: ../../library/shutil.rst:390 msgid "" "Raises an :ref:`auditing event ` ``shutil.move`` with arguments " "``src``, ``dst``." @@ -509,57 +515,57 @@ msgstr "" "引發一個附帶引數 ``src``、``dst`` 的\\ :ref:`稽核事件 ` ``shutil." "move``。" -#: ../../library/shutil.rst:388 +#: ../../library/shutil.rst:392 msgid "" "Added explicit symlink handling for foreign filesystems, thus adapting it to " "the behavior of GNU's :program:`mv`. Now returns *dst*." msgstr "" -#: ../../library/shutil.rst:393 +#: ../../library/shutil.rst:397 msgid "Added the *copy_function* keyword argument." msgstr "新增 *copy_function* 關鍵字引數。" -#: ../../library/shutil.rst:401 +#: ../../library/shutil.rst:405 msgid "Accepts a :term:`path-like object` for both *src* and *dst*." msgstr "" -#: ../../library/shutil.rst:406 +#: ../../library/shutil.rst:410 msgid "" "Return disk usage statistics about the given path as a :term:`named tuple` " "with the attributes *total*, *used* and *free*, which are the amount of " "total, used and free space, in bytes. *path* may be a file or a directory." msgstr "" -#: ../../library/shutil.rst:413 +#: ../../library/shutil.rst:417 msgid "" "On Unix filesystems, *path* must point to a path within a **mounted** " "filesystem partition. On those platforms, CPython doesn't attempt to " "retrieve disk usage information from non-mounted filesystems." msgstr "" -#: ../../library/shutil.rst:419 +#: ../../library/shutil.rst:423 msgid "On Windows, *path* can now be a file or directory." msgstr "" -#: ../../library/shutil.rst:422 ../../library/shutil.rst:436 +#: ../../library/shutil.rst:426 ../../library/shutil.rst:440 msgid "Availability" msgstr "" -#: ../../library/shutil.rst:427 +#: ../../library/shutil.rst:431 msgid "Change owner *user* and/or *group* of the given *path*." msgstr "" -#: ../../library/shutil.rst:429 +#: ../../library/shutil.rst:433 msgid "" "*user* can be a system user name or a uid; the same applies to *group*. At " "least one argument is required." msgstr "" -#: ../../library/shutil.rst:432 +#: ../../library/shutil.rst:436 msgid "See also :func:`os.chown`, the underlying function." msgstr "" -#: ../../library/shutil.rst:434 +#: ../../library/shutil.rst:438 msgid "" "Raises an :ref:`auditing event ` ``shutil.chown`` with arguments " "``path``, ``user``, ``group``." @@ -567,23 +573,23 @@ msgstr "" "引發一個附帶引數 ``path``、``user``、``group`` 的\\ :ref:`稽核事件 " "` ``shutil.chown``。" -#: ../../library/shutil.rst:440 +#: ../../library/shutil.rst:444 msgid "Added *dir_fd* and *follow_symlinks* parameters." msgstr "新增 *dir_fd* 和 *follow_symlinks* 參數。" -#: ../../library/shutil.rst:446 +#: ../../library/shutil.rst:450 msgid "" "Return the path to an executable which would be run if the given *cmd* was " "called. If no *cmd* would be called, return ``None``." msgstr "" -#: ../../library/shutil.rst:449 +#: ../../library/shutil.rst:453 msgid "" "*mode* is a permission mask passed to :func:`os.access`, by default " "determining if the file exists and is executable." msgstr "" -#: ../../library/shutil.rst:452 +#: ../../library/shutil.rst:456 msgid "" "*path* is a \"``PATH`` string\" specifying the directories to look in, " "delimited by :data:`os.pathsep`. When no *path* is specified, the :envvar:" @@ -591,14 +597,14 @@ msgid "" "to :data:`os.defpath` if it is not set." msgstr "" -#: ../../library/shutil.rst:457 +#: ../../library/shutil.rst:461 msgid "" "If *cmd* contains a directory component, :func:`!which` only checks the " "specified path directly and does not search the directories listed in *path* " "or in the system's :envvar:`PATH` environment variable." msgstr "" -#: ../../library/shutil.rst:461 +#: ../../library/shutil.rst:465 msgid "" "On Windows, the current directory is prepended to the *path* if *mode* does " "not include ``os.X_OK``. When the *mode* does include ``os.X_OK``, the " @@ -608,7 +614,7 @@ msgid "" "environment variable ``NoDefaultCurrentDirectoryInExePath``." msgstr "" -#: ../../library/shutil.rst:468 +#: ../../library/shutil.rst:472 msgid "" "Also on Windows, the :envvar:`PATHEXT` environment variable is used to " "resolve commands that may not already include an extension. For example, if " @@ -617,7 +623,7 @@ msgid "" "directories. For example, on Windows::" msgstr "" -#: ../../library/shutil.rst:474 +#: ../../library/shutil.rst:478 msgid "" ">>> shutil.which(\"python\")\n" "'C:\\\\Python33\\\\python.EXE'" @@ -625,13 +631,13 @@ msgstr "" ">>> shutil.which(\"python\")\n" "'C:\\\\Python33\\\\python.EXE'" -#: ../../library/shutil.rst:477 +#: ../../library/shutil.rst:481 msgid "" "This is also applied when *cmd* is a path that contains a directory " "component::" msgstr "" -#: ../../library/shutil.rst:480 +#: ../../library/shutil.rst:484 msgid "" ">>> shutil.which(\"C:\\\\Python33\\\\python\")\n" "'C:\\\\Python33\\\\python.EXE'" @@ -639,13 +645,13 @@ msgstr "" ">>> shutil.which(\"C:\\\\Python33\\\\python\")\n" "'C:\\\\Python33\\\\python.EXE'" -#: ../../library/shutil.rst:485 +#: ../../library/shutil.rst:489 msgid "" "The :class:`bytes` type is now accepted. If *cmd* type is :class:`bytes`, " "the result type is also :class:`bytes`." msgstr "" -#: ../../library/shutil.rst:489 +#: ../../library/shutil.rst:493 msgid "" "On Windows, the current directory is no longer prepended to the search path " "if *mode* includes ``os.X_OK`` and WinAPI " @@ -656,18 +662,18 @@ msgid "" "now be found." msgstr "" -#: ../../library/shutil.rst:500 +#: ../../library/shutil.rst:504 msgid "" "This exception collects exceptions that are raised during a multi-file " "operation. For :func:`copytree`, the exception argument is a list of 3-" "tuples (*srcname*, *dstname*, *exception*)." msgstr "" -#: ../../library/shutil.rst:507 +#: ../../library/shutil.rst:511 msgid "Platform-dependent efficient copy operations" msgstr "" -#: ../../library/shutil.rst:509 +#: ../../library/shutil.rst:513 msgid "" "Starting from Python 3.8, all functions involving a file copy (:func:" "`copyfile`, :func:`~shutil.copy`, :func:`copy2`, :func:`copytree`, and :func:" @@ -677,37 +683,37 @@ msgid "" "buffers in Python as in \"``outfd.write(infd.read())``\"." msgstr "" -#: ../../library/shutil.rst:517 +#: ../../library/shutil.rst:521 msgid "On macOS `fcopyfile`_ is used to copy the file content (not metadata)." msgstr "" -#: ../../library/shutil.rst:519 +#: ../../library/shutil.rst:523 msgid "On Linux :func:`os.sendfile` is used." msgstr "" -#: ../../library/shutil.rst:521 +#: ../../library/shutil.rst:525 msgid "" "On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB " "instead of 64 KiB) and a :func:`memoryview`-based variant of :func:`shutil." "copyfileobj` is used." msgstr "" -#: ../../library/shutil.rst:525 +#: ../../library/shutil.rst:529 msgid "" "If the fast-copy operation fails and no data was written in the destination " "file then shutil will silently fallback on using less efficient :func:" "`copyfileobj` function internally." msgstr "" -#: ../../library/shutil.rst:534 +#: ../../library/shutil.rst:538 msgid "copytree example" msgstr "copytree 範例" -#: ../../library/shutil.rst:536 +#: ../../library/shutil.rst:540 msgid "An example that uses the :func:`ignore_patterns` helper::" msgstr "" -#: ../../library/shutil.rst:538 +#: ../../library/shutil.rst:542 msgid "" "from shutil import copytree, ignore_patterns\n" "\n" @@ -717,17 +723,17 @@ msgstr "" "\n" "copytree(source, destination, ignore=ignore_patterns('*.pyc', 'tmp*'))" -#: ../../library/shutil.rst:542 +#: ../../library/shutil.rst:546 msgid "" "This will copy everything except ``.pyc`` files and files or directories " "whose name starts with ``tmp``." msgstr "" -#: ../../library/shutil.rst:545 +#: ../../library/shutil.rst:549 msgid "Another example that uses the *ignore* argument to add a logging call::" msgstr "" -#: ../../library/shutil.rst:547 +#: ../../library/shutil.rst:551 msgid "" "from shutil import copytree\n" "import logging\n" @@ -739,11 +745,11 @@ msgid "" "copytree(source, destination, ignore=_logpath)" msgstr "" -#: ../../library/shutil.rst:560 +#: ../../library/shutil.rst:564 msgid "rmtree example" msgstr "rmtree 範例" -#: ../../library/shutil.rst:562 +#: ../../library/shutil.rst:566 msgid "" "This example shows how to remove a directory tree on Windows where some of " "the files have their read-only bit set. It uses the onexc callback to clear " @@ -751,7 +757,7 @@ msgid "" "propagate. ::" msgstr "" -#: ../../library/shutil.rst:567 +#: ../../library/shutil.rst:571 msgid "" "import os, stat\n" "import shutil\n" @@ -764,31 +770,31 @@ msgid "" "shutil.rmtree(directory, onexc=remove_readonly)" msgstr "" -#: ../../library/shutil.rst:580 +#: ../../library/shutil.rst:584 msgid "Archiving operations" msgstr "" -#: ../../library/shutil.rst:584 +#: ../../library/shutil.rst:588 msgid "Added support for the *xztar* format." msgstr "新增 *xztar* 格式的支援。" -#: ../../library/shutil.rst:588 +#: ../../library/shutil.rst:592 msgid "" "High-level utilities to create and read compressed and archived files are " "also provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules." msgstr "" -#: ../../library/shutil.rst:593 +#: ../../library/shutil.rst:597 msgid "Create an archive file (such as zip or tar) and return its name." msgstr "" -#: ../../library/shutil.rst:595 +#: ../../library/shutil.rst:599 msgid "" "*base_name* is the name of the file to create, including the path, minus any " "format-specific extension." msgstr "" -#: ../../library/shutil.rst:598 +#: ../../library/shutil.rst:602 msgid "" "*format* is the archive format: one of \"zip\" (if the :mod:`zlib` module is " "available), \"tar\", \"gztar\" (if the :mod:`zlib` module is available), " @@ -796,14 +802,14 @@ msgid "" "`lzma` module is available)." msgstr "" -#: ../../library/shutil.rst:603 +#: ../../library/shutil.rst:607 msgid "" "*root_dir* is a directory that will be the root directory of the archive, " "all paths in the archive will be relative to it; for example, we typically " "chdir into *root_dir* before creating the archive." msgstr "" -#: ../../library/shutil.rst:607 +#: ../../library/shutil.rst:611 msgid "" "*base_dir* is the directory where we start archiving from; i.e. *base_dir* " "will be the common prefix of all files and directories in the archive. " @@ -811,33 +817,33 @@ msgid "" "example-with-basedir` for how to use *base_dir* and *root_dir* together." msgstr "" -#: ../../library/shutil.rst:613 +#: ../../library/shutil.rst:617 msgid "*root_dir* and *base_dir* both default to the current directory." msgstr "" -#: ../../library/shutil.rst:615 +#: ../../library/shutil.rst:619 msgid "" "If *dry_run* is true, no archive is created, but the operations that would " "be executed are logged to *logger*." msgstr "" -#: ../../library/shutil.rst:618 +#: ../../library/shutil.rst:622 msgid "" "*owner* and *group* are used when creating a tar archive. By default, uses " "the current owner and group." msgstr "" -#: ../../library/shutil.rst:621 +#: ../../library/shutil.rst:625 msgid "" "*logger* must be an object compatible with :pep:`282`, usually an instance " "of :class:`logging.Logger`." msgstr "" -#: ../../library/shutil.rst:624 +#: ../../library/shutil.rst:628 msgid "The *verbose* argument is unused and deprecated." msgstr "" -#: ../../library/shutil.rst:626 +#: ../../library/shutil.rst:630 msgid "" "Raises an :ref:`auditing event ` ``shutil.make_archive`` with " "arguments ``base_name``, ``format``, ``root_dir``, ``base_dir``." @@ -845,7 +851,7 @@ msgstr "" "引發一個附帶引數 ``base_name``、``format``、``root_dir``、``base_dir`` 的\\ :" "ref:`稽核事件 ` ``shutil.make_archive``。" -#: ../../library/shutil.rst:630 +#: ../../library/shutil.rst:634 msgid "" "This function is not thread-safe when custom archivers registered with :func:" "`register_archive_format` do not support the *root_dir* argument. In this " @@ -853,60 +859,60 @@ msgid "" "*root_dir* to perform archiving." msgstr "" -#: ../../library/shutil.rst:636 +#: ../../library/shutil.rst:640 msgid "" "The modern pax (POSIX.1-2001) format is now used instead of the legacy GNU " "format for archives created with ``format=\"tar\"``." msgstr "" -#: ../../library/shutil.rst:640 +#: ../../library/shutil.rst:644 msgid "" "This function is now made thread-safe during creation of standard ``.zip`` " "and tar archives." msgstr "" -#: ../../library/shutil.rst:646 +#: ../../library/shutil.rst:650 msgid "" "Return a list of supported formats for archiving. Each element of the " "returned sequence is a tuple ``(name, description)``." msgstr "" -#: ../../library/shutil.rst:649 ../../library/shutil.rst:760 +#: ../../library/shutil.rst:653 ../../library/shutil.rst:764 msgid "By default :mod:`shutil` provides these formats:" msgstr "" -#: ../../library/shutil.rst:651 +#: ../../library/shutil.rst:655 msgid "*zip*: ZIP file (if the :mod:`zlib` module is available)." msgstr "" -#: ../../library/shutil.rst:652 +#: ../../library/shutil.rst:656 msgid "" "*tar*: Uncompressed tar file. Uses POSIX.1-2001 pax format for new archives." msgstr "" -#: ../../library/shutil.rst:653 ../../library/shutil.rst:765 +#: ../../library/shutil.rst:657 ../../library/shutil.rst:769 msgid "*gztar*: gzip'ed tar-file (if the :mod:`zlib` module is available)." msgstr "" -#: ../../library/shutil.rst:654 ../../library/shutil.rst:766 +#: ../../library/shutil.rst:658 ../../library/shutil.rst:770 msgid "*bztar*: bzip2'ed tar-file (if the :mod:`bz2` module is available)." msgstr "" -#: ../../library/shutil.rst:655 ../../library/shutil.rst:767 +#: ../../library/shutil.rst:659 ../../library/shutil.rst:771 msgid "*xztar*: xz'ed tar-file (if the :mod:`lzma` module is available)." msgstr "" -#: ../../library/shutil.rst:657 +#: ../../library/shutil.rst:661 msgid "" "You can register new formats or provide your own archiver for any existing " "formats, by using :func:`register_archive_format`." msgstr "" -#: ../../library/shutil.rst:663 +#: ../../library/shutil.rst:667 msgid "Register an archiver for the format *name*." msgstr "" -#: ../../library/shutil.rst:665 +#: ../../library/shutil.rst:669 msgid "" "*function* is the callable that will be used to unpack archives. The " "callable will receive the *base_name* of the file to create, followed by the " @@ -915,7 +921,7 @@ msgid "" "*dry_run* and *logger* (as passed in :func:`make_archive`)." msgstr "" -#: ../../library/shutil.rst:671 +#: ../../library/shutil.rst:675 msgid "" "If *function* has the custom attribute ``function.supports_root_dir`` set to " "``True``, the *root_dir* argument is passed as a keyword argument. Otherwise " @@ -924,37 +930,37 @@ msgid "" "not thread-safe." msgstr "" -#: ../../library/shutil.rst:677 +#: ../../library/shutil.rst:681 msgid "" "If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be " "used as extra keywords arguments when the archiver callable is used." msgstr "" -#: ../../library/shutil.rst:680 +#: ../../library/shutil.rst:684 msgid "" "*description* is used by :func:`get_archive_formats` which returns the list " "of archivers. Defaults to an empty string." msgstr "" -#: ../../library/shutil.rst:683 +#: ../../library/shutil.rst:687 msgid "Added support for functions supporting the *root_dir* argument." msgstr "" -#: ../../library/shutil.rst:689 +#: ../../library/shutil.rst:693 msgid "Remove the archive format *name* from the list of supported formats." msgstr "" -#: ../../library/shutil.rst:694 +#: ../../library/shutil.rst:698 msgid "Unpack an archive. *filename* is the full path of the archive." msgstr "" -#: ../../library/shutil.rst:696 +#: ../../library/shutil.rst:700 msgid "" "*extract_dir* is the name of the target directory where the archive is " "unpacked. If not provided, the current working directory is used." msgstr "" -#: ../../library/shutil.rst:699 +#: ../../library/shutil.rst:703 msgid "" "*format* is the archive format: one of \"zip\", \"tar\", \"gztar\", " "\"bztar\", or \"xztar\". Or any other format registered with :func:" @@ -963,7 +969,7 @@ msgid "" "that extension. In case none is found, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/shutil.rst:706 +#: ../../library/shutil.rst:710 msgid "" "The keyword-only *filter* argument is passed to the underlying unpacking " "function. For zip files, *filter* is not accepted. For tar files, it is " @@ -973,7 +979,7 @@ msgid "" "Python 3.14." msgstr "" -#: ../../library/shutil.rst:714 +#: ../../library/shutil.rst:718 msgid "" "Raises an :ref:`auditing event ` ``shutil.unpack_archive`` with " "arguments ``filename``, ``extract_dir``, ``format``." @@ -981,7 +987,7 @@ msgstr "" "引發一個附帶引數 ``filename``、``extract_dir``、``format`` 的\\ :ref:`稽核事" "件 ` ``shutil.unpack_archive``。" -#: ../../library/shutil.rst:718 +#: ../../library/shutil.rst:722 msgid "" "Never extract archives from untrusted sources without prior inspection. It " "is possible that files are created outside of the path specified in the " @@ -989,91 +995,91 @@ msgid "" "with \"/\" or filenames with two dots \"..\"." msgstr "" -#: ../../library/shutil.rst:723 +#: ../../library/shutil.rst:727 msgid "Accepts a :term:`path-like object` for *filename* and *extract_dir*." msgstr "" -#: ../../library/shutil.rst:726 +#: ../../library/shutil.rst:730 msgid "Added the *filter* argument." msgstr "新增 *filter* 引數。" -#: ../../library/shutil.rst:731 +#: ../../library/shutil.rst:735 msgid "" "Registers an unpack format. *name* is the name of the format and " "*extensions* is a list of extensions corresponding to the format, like ``." "zip`` for Zip files." msgstr "" -#: ../../library/shutil.rst:735 +#: ../../library/shutil.rst:739 msgid "" "*function* is the callable that will be used to unpack archives. The " "callable will receive:" msgstr "" -#: ../../library/shutil.rst:738 +#: ../../library/shutil.rst:742 msgid "the path of the archive, as a positional argument;" msgstr "" -#: ../../library/shutil.rst:739 +#: ../../library/shutil.rst:743 msgid "" "the directory the archive must be extracted to, as a positional argument;" msgstr "" -#: ../../library/shutil.rst:740 +#: ../../library/shutil.rst:744 msgid "" "possibly a *filter* keyword argument, if it was given to :func:" "`unpack_archive`;" msgstr "" -#: ../../library/shutil.rst:742 +#: ../../library/shutil.rst:746 msgid "" "additional keyword arguments, specified by *extra_args* as a sequence of " "``(name, value)`` tuples." msgstr "" -#: ../../library/shutil.rst:745 +#: ../../library/shutil.rst:749 msgid "" "*description* can be provided to describe the format, and will be returned " "by the :func:`get_unpack_formats` function." msgstr "" -#: ../../library/shutil.rst:751 +#: ../../library/shutil.rst:755 msgid "Unregister an unpack format. *name* is the name of the format." msgstr "" -#: ../../library/shutil.rst:756 +#: ../../library/shutil.rst:760 msgid "" "Return a list of all registered formats for unpacking. Each element of the " "returned sequence is a tuple ``(name, extensions, description)``." msgstr "" -#: ../../library/shutil.rst:762 +#: ../../library/shutil.rst:766 msgid "" "*zip*: ZIP file (unpacking compressed files works only if the corresponding " "module is available)." msgstr "" -#: ../../library/shutil.rst:764 +#: ../../library/shutil.rst:768 msgid "*tar*: uncompressed tar file." msgstr "" -#: ../../library/shutil.rst:769 +#: ../../library/shutil.rst:773 msgid "" "You can register new formats or provide your own unpacker for any existing " "formats, by using :func:`register_unpack_format`." msgstr "" -#: ../../library/shutil.rst:776 +#: ../../library/shutil.rst:780 msgid "Archiving example" msgstr "" -#: ../../library/shutil.rst:778 +#: ../../library/shutil.rst:782 msgid "" "In this example, we create a gzip'ed tar-file archive containing all files " "found in the :file:`.ssh` directory of the user::" msgstr "" -#: ../../library/shutil.rst:781 +#: ../../library/shutil.rst:785 msgid "" ">>> from shutil import make_archive\n" ">>> import os\n" @@ -1083,11 +1089,11 @@ msgid "" "'/Users/tarek/myarchive.tar.gz'" msgstr "" -#: ../../library/shutil.rst:788 +#: ../../library/shutil.rst:792 msgid "The resulting archive contains:" msgstr "" -#: ../../library/shutil.rst:790 +#: ../../library/shutil.rst:794 msgid "" "$ tar -tzvf /Users/tarek/myarchive.tar.gz\n" "drwx------ tarek/staff 0 2010-02-01 16:23:40 ./\n" @@ -1109,18 +1115,18 @@ msgstr "" "-rw-r--r-- tarek/staff 397 2008-06-09 13:26:54 ./id_rsa.pub\n" "-rw-r--r-- tarek/staff 37192 2010-02-06 18:23:10 ./known_hosts" -#: ../../library/shutil.rst:806 +#: ../../library/shutil.rst:810 msgid "Archiving example with *base_dir*" msgstr "" -#: ../../library/shutil.rst:808 +#: ../../library/shutil.rst:812 msgid "" "In this example, similar to the `one above `_, we " "show how to use :func:`make_archive`, but this time with the usage of " "*base_dir*. We now have the following directory structure:" msgstr "" -#: ../../library/shutil.rst:812 +#: ../../library/shutil.rst:816 msgid "" "$ tree tmp\n" "tmp\n" @@ -1138,13 +1144,13 @@ msgstr "" " └── please_add.txt\n" " └── do_not_add.txt" -#: ../../library/shutil.rst:822 +#: ../../library/shutil.rst:826 msgid "" "In the final archive, :file:`please_add.txt` should be included, but :file:" "`do_not_add.txt` should not. Therefore we use the following::" msgstr "" -#: ../../library/shutil.rst:825 +#: ../../library/shutil.rst:829 msgid "" ">>> from shutil import make_archive\n" ">>> import os\n" @@ -1168,11 +1174,11 @@ msgstr "" "... )\n" "'/Users/tarek/my_archive.tar'" -#: ../../library/shutil.rst:836 +#: ../../library/shutil.rst:840 msgid "Listing the files in the resulting archive gives us:" msgstr "" -#: ../../library/shutil.rst:838 +#: ../../library/shutil.rst:842 msgid "" "$ python -m tarfile -l /Users/tarek/myarchive.tar\n" "structure/content/\n" @@ -1182,29 +1188,29 @@ msgstr "" "structure/content/\n" "structure/content/please_add.txt" -#: ../../library/shutil.rst:846 +#: ../../library/shutil.rst:850 msgid "Querying the size of the output terminal" msgstr "" -#: ../../library/shutil.rst:850 +#: ../../library/shutil.rst:854 msgid "Get the size of the terminal window." msgstr "" -#: ../../library/shutil.rst:852 +#: ../../library/shutil.rst:856 msgid "" "For each of the two dimensions, the environment variable, ``COLUMNS`` and " "``LINES`` respectively, is checked. If the variable is defined and the value " "is a positive integer, it is used." msgstr "" -#: ../../library/shutil.rst:856 +#: ../../library/shutil.rst:860 msgid "" "When ``COLUMNS`` or ``LINES`` is not defined, which is the common case, the " "terminal connected to :data:`sys.__stdout__` is queried by invoking :func:" "`os.get_terminal_size`." msgstr "" -#: ../../library/shutil.rst:860 +#: ../../library/shutil.rst:864 msgid "" "If the terminal size cannot be successfully queried, either because the " "system doesn't support querying, or because we are not connected to a " @@ -1213,17 +1219,17 @@ msgid "" "emulators." msgstr "" -#: ../../library/shutil.rst:866 +#: ../../library/shutil.rst:870 msgid "The value returned is a named tuple of type :class:`os.terminal_size`." msgstr "" -#: ../../library/shutil.rst:868 +#: ../../library/shutil.rst:872 msgid "" "See also: The Single UNIX Specification, Version 2, `Other Environment " "Variables`_." msgstr "" -#: ../../library/shutil.rst:873 +#: ../../library/shutil.rst:877 msgid "" "The ``fallback`` values are also used if :func:`os.get_terminal_size` " "returns zeroes." diff --git a/library/socket.po b/library/socket.po index 3f6e8c5fc1..8578ad1a93 100644 --- a/library/socket.po +++ b/library/socket.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-19 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2024-12-30 23:45+0800\n" "Last-Translator: Jay \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -87,8 +87,8 @@ msgid "" "call and library interface for sockets to Python's object-oriented style: " "the :func:`~socket.socket` function returns a :dfn:`socket object` whose " "methods implement the various socket system calls. Parameter types are " -"somewhat higher-level than in the C interface: as with :meth:`read` " -"and :meth:`write` operations on Python files, buffer allocation on receive " +"somewhat higher-level than in the C interface: as with :meth:`read` and :" +"meth:`write` operations on Python files, buffer allocation on receive " "operations is automatic, and buffer length is implicit on send operations." msgstr "" "Python 的介面是將 Unix 的系統呼叫和 socket 函式庫介面直接轉換成 Python 的物件" @@ -164,10 +164,10 @@ msgstr "" msgid "" "For IPv4 addresses, two special forms are accepted instead of a host " "address: ``''`` represents :const:`INADDR_ANY`, which is used to bind to all " -"interfaces, and the string ``''`` " -"represents :const:`INADDR_BROADCAST`. This behavior is not compatible with " -"IPv6, therefore, you may want to avoid these if you intend to support IPv6 " -"with your Python programs." +"interfaces, and the string ``''`` represents :const:" +"`INADDR_BROADCAST`. This behavior is not compatible with IPv6, therefore, " +"you may want to avoid these if you intend to support IPv6 with your Python " +"programs." msgstr "" #: ../../library/socket.rst:83 @@ -502,8 +502,8 @@ msgstr "" #: ../../library/socket.rst:277 msgid "" "Non-blocking mode is supported through :meth:`~socket.setblocking`. A " -"generalization of this based on timeouts is supported " -"through :meth:`~socket.settimeout`." +"generalization of this based on timeouts is supported through :meth:`~socket." +"settimeout`." msgstr "" #: ../../library/socket.rst:283 @@ -529,12 +529,11 @@ msgstr "" #: ../../library/socket.rst:301 msgid "" "A subclass of :exc:`OSError`, this exception is raised for address-related " -"errors, i.e. for functions that use *h_errno* in the POSIX C API, " -"including :func:`gethostbyname_ex` and :func:`gethostbyaddr`. The " -"accompanying value is a pair ``(h_errno, string)`` representing an error " -"returned by a library call. *h_errno* is a numeric value, while *string* " -"represents the description of *h_errno*, as returned by " -"the :c:func:`hstrerror` C function." +"errors, i.e. for functions that use *h_errno* in the POSIX C API, including :" +"func:`gethostbyname_ex` and :func:`gethostbyaddr`. The accompanying value is " +"a pair ``(h_errno, string)`` representing an error returned by a library " +"call. *h_errno* is a numeric value, while *string* represents the " +"description of *h_errno*, as returned by the :c:func:`hstrerror` C function." msgstr "" #: ../../library/socket.rst:309 ../../library/socket.rst:322 @@ -559,10 +558,10 @@ msgstr "" #: ../../library/socket.rst:329 msgid "" "A subclass of :exc:`OSError`, this exception is raised when a timeout occurs " -"on a socket which has had timeouts enabled via a prior call " -"to :meth:`~socket.settimeout` (or implicitly " -"through :func:`~socket.setdefaulttimeout`). The accompanying value is a " -"string whose value is currently always \"timed out\"." +"on a socket which has had timeouts enabled via a prior call to :meth:" +"`~socket.settimeout` (or implicitly through :func:`~socket." +"setdefaulttimeout`). The accompanying value is a string whose value is " +"currently always \"timed out\"." msgstr "" #: ../../library/socket.rst:338 @@ -575,8 +574,8 @@ msgstr "常數" #: ../../library/socket.rst:345 msgid "" -"The AF_* and SOCK_* constants are now :class:`AddressFamily` " -"and :class:`SocketKind` :class:`.IntEnum` collections." +"The AF_* and SOCK_* constants are now :class:`AddressFamily` and :class:" +"`SocketKind` :class:`.IntEnum` collections." msgstr "" #: ../../library/socket.rst:354 @@ -596,8 +595,8 @@ msgstr "" #: ../../library/socket.rst:371 msgid "" -"These constants represent the socket types, used for the second argument " -"to :func:`~socket.socket`. More constants may be available depending on the " +"These constants represent the socket types, used for the second argument to :" +"func:`~socket.socket`. More constants may be available depending on the " "system. (Only :const:`SOCK_STREAM` and :const:`SOCK_DGRAM` appear to be " "generally useful.)" msgstr "" @@ -611,18 +610,18 @@ msgstr "" #: ../../library/socket.rst:385 msgid "" -"`Secure File Descriptor Handling `_ for a more thorough explanation." +"`Secure File Descriptor Handling `_ for a more thorough explanation." msgstr "" #: ../../library/socket.rst:409 msgid "" "Many constants of these forms, documented in the Unix documentation on " "sockets and/or the IP protocol, are also defined in the socket module. They " -"are generally used in arguments to the :meth:`~socket.setsockopt` " -"and :meth:`~socket.getsockopt` methods of socket objects. In most cases, " -"only those symbols that are defined in the Unix header files are defined; " -"for a few symbols, default values are provided." +"are generally used in arguments to the :meth:`~socket.setsockopt` and :meth:" +"`~socket.getsockopt` methods of socket objects. In most cases, only those " +"symbols that are defined in the Unix header files are defined; for a few " +"symbols, default values are provided." msgstr "" #: ../../library/socket.rst:416 @@ -816,8 +815,8 @@ msgstr "" #: ../../library/socket.rst:669 msgid "" -"Constant to optimize CPU locality, to be used in conjunction " -"with :data:`SO_REUSEPORT`." +"Constant to optimize CPU locality, to be used in conjunction with :data:" +"`SO_REUSEPORT`." msgstr "" #: ../../library/socket.rst:689 @@ -852,14 +851,14 @@ msgstr "" #: ../../library/socket.rst:729 msgid "" "Create a new socket using the given address family, socket type and protocol " -"number. The address family should be :const:`AF_INET` (the " -"default), :const:`AF_INET6`, :const:`AF_UNIX`, :const:`AF_CAN`, :const:`AF_PACKET`, " -"or :const:`AF_RDS`. The socket type should be :const:`SOCK_STREAM` (the " -"default), :const:`SOCK_DGRAM`, :const:`SOCK_RAW` or perhaps one of the other " -"``SOCK_`` constants. The protocol number is usually zero and may be omitted " -"or in the case where the address family is :const:`AF_CAN` the protocol " -"should be one of :const:`CAN_RAW`, :const:`CAN_BCM`, :const:`CAN_ISOTP` " -"or :const:`CAN_J1939`." +"number. The address family should be :const:`AF_INET` (the default), :const:" +"`AF_INET6`, :const:`AF_UNIX`, :const:`AF_CAN`, :const:`AF_PACKET`, or :const:" +"`AF_RDS`. The socket type should be :const:`SOCK_STREAM` (the default), :" +"const:`SOCK_DGRAM`, :const:`SOCK_RAW` or perhaps one of the other ``SOCK_`` " +"constants. The protocol number is usually zero and may be omitted or in the " +"case where the address family is :const:`AF_CAN` the protocol should be one " +"of :const:`CAN_RAW`, :const:`CAN_BCM`, :const:`CAN_ISOTP` or :const:" +"`CAN_J1939`." msgstr "" #: ../../library/socket.rst:739 @@ -868,9 +867,9 @@ msgid "" "auto-detected from the specified file descriptor. Auto-detection can be " "overruled by calling the function with explicit *family*, *type*, or *proto* " "arguments. This only affects how Python represents e.g. the return value " -"of :meth:`socket.getpeername` but not the actual OS resource. " -"Unlike :func:`socket.fromfd`, *fileno* will return the same socket and not a " -"duplicate. This may help close a detached socket using :meth:`socket.close`." +"of :meth:`socket.getpeername` but not the actual OS resource. Unlike :func:" +"`socket.fromfd`, *fileno* will return the same socket and not a duplicate. " +"This may help close a detached socket using :meth:`socket.close`." msgstr "" #: ../../library/socket.rst:748 ../../library/socket.rst:894 @@ -1011,8 +1010,8 @@ msgstr "" msgid "" "*family* should be either :data:`AF_INET` or :data:`AF_INET6`. *backlog* is " "the queue size passed to :meth:`socket.listen`; if not specified , a default " -"reasonable value is chosen. *reuse_port* dictates whether to set " -"the :data:`SO_REUSEPORT` socket option." +"reasonable value is chosen. *reuse_port* dictates whether to set the :data:" +"`SO_REUSEPORT` socket option." msgstr "" #: ../../library/socket.rst:848 @@ -1065,12 +1064,12 @@ msgstr "" msgid "" "Duplicate the file descriptor *fd* (an integer as returned by a file " "object's :meth:`~io.IOBase.fileno` method) and build a socket object from " -"the result. Address family, socket type and protocol number are as for " -"the :func:`~socket.socket` function above. The file descriptor should refer " -"to a socket, but this is not checked --- subsequent operations on the object " -"may fail if the file descriptor is invalid. This function is rarely needed, " -"but can be used to get or set socket options on a socket passed to a program " -"as standard input or output (such as a server started by the Unix inet " +"the result. Address family, socket type and protocol number are as for the :" +"func:`~socket.socket` function above. The file descriptor should refer to a " +"socket, but this is not checked --- subsequent operations on the object may " +"fail if the file descriptor is invalid. This function is rarely needed, but " +"can be used to get or set socket options on a socket passed to a program as " +"standard input or output (such as a server started by the Unix inet " "daemon). The socket is assumed to be in blocking mode." msgstr "" @@ -1127,9 +1126,9 @@ msgstr "" #: ../../library/socket.rst:946 msgid "" "The *flags* argument can be one or several of the ``AI_*`` constants, and " -"will influence how results are computed and returned. For " -"example, :const:`AI_NUMERICHOST` will disable domain name resolution and " -"will raise an error if *host* is a domain name." +"will influence how results are computed and returned. For example, :const:" +"`AI_NUMERICHOST` will disable domain name resolution and will raise an error " +"if *host* is a domain name." msgstr "" #: ../../library/socket.rst:951 @@ -1144,13 +1143,12 @@ msgstr "``(family, type, proto, canonname, sockaddr)``" msgid "" "In these tuples, *family*, *type*, *proto* are all integers and are meant to " "be passed to the :func:`~socket.socket` function. *canonname* will be a " -"string representing the canonical name of the *host* " -"if :const:`AI_CANONNAME` is part of the *flags* argument; else *canonname* " -"will be empty. *sockaddr* is a tuple describing a socket address, whose " -"format depends on the returned *family* (a ``(address, port)`` 2-tuple " -"for :const:`AF_INET`, a ``(address, port, flowinfo, scope_id)`` 4-tuple " -"for :const:`AF_INET6`), and is meant to be passed to " -"the :meth:`socket.connect` method." +"string representing the canonical name of the *host* if :const:" +"`AI_CANONNAME` is part of the *flags* argument; else *canonname* will be " +"empty. *sockaddr* is a tuple describing a socket address, whose format " +"depends on the returned *family* (a ``(address, port)`` 2-tuple for :const:" +"`AF_INET`, a ``(address, port, flowinfo, scope_id)`` 4-tuple for :const:" +"`AF_INET6`), and is meant to be passed to the :meth:`socket.connect` method." msgstr "" #: ../../library/socket.rst:967 @@ -1250,8 +1248,8 @@ msgid "" "Raises an :ref:`auditing event ` ``socket.gethostbyname`` with " "argument ``hostname``." msgstr "" -"引發一個附帶引數 ``hostname`` 的\\ :ref:`稽核事件 ` " -"``socket.gethostbyname``。" +"引發一個附帶引數 ``hostname`` 的\\ :ref:`稽核事件 ` ``socket." +"gethostbyname``。" #: ../../library/socket.rst:1035 msgid "" @@ -1291,8 +1289,8 @@ msgid "" "(possibly empty) list of alternative host names for the same address, and " "*ipaddrlist* is a list of IPv4/v6 addresses for the same interface on the " "same host (most likely containing only a single address). To find the fully " -"qualified domain name, use the " -"function :func:`getfqdn`. :func:`gethostbyaddr` supports both IPv4 and IPv6." +"qualified domain name, use the function :func:`getfqdn`. :func:" +"`gethostbyaddr` supports both IPv4 and IPv6." msgstr "" #: ../../library/socket.rst:1072 @@ -1300,8 +1298,8 @@ msgid "" "Raises an :ref:`auditing event ` ``socket.gethostbyaddr`` with " "argument ``ip_address``." msgstr "" -"引發一個附帶引數 ``ip_address`` 的\\ :ref:`稽核事件 ` " -"``socket.gethostbyaddr``。" +"引發一個附帶引數 ``ip_address`` 的\\ :ref:`稽核事件 ` ``socket." +"gethostbyaddr``。" #: ../../library/socket.rst:1079 msgid "" @@ -1327,17 +1325,16 @@ msgid "" "Raises an :ref:`auditing event ` ``socket.getnameinfo`` with " "argument ``sockaddr``." msgstr "" -"引發一個附帶引數 ``sockaddr`` 的\\ :ref:`稽核事件 ` " -"``socket.getnameinfo``。" +"引發一個附帶引數 ``sockaddr`` 的\\ :ref:`稽核事件 ` ``socket." +"getnameinfo``。" #: ../../library/socket.rst:1096 msgid "" "Translate an internet protocol name (for example, ``'icmp'``) to a constant " -"suitable for passing as the (optional) third argument to " -"the :func:`~socket.socket` function. This is usually only needed for " -"sockets opened in \"raw\" mode (:const:`SOCK_RAW`); for the normal socket " -"modes, the correct protocol is chosen automatically if the protocol is " -"omitted or zero." +"suitable for passing as the (optional) third argument to the :func:`~socket." +"socket` function. This is usually only needed for sockets opened in \"raw\" " +"mode (:const:`SOCK_RAW`); for the normal socket modes, the correct protocol " +"is chosen automatically if the protocol is omitted or zero." msgstr "" #: ../../library/socket.rst:1107 @@ -1420,9 +1417,9 @@ msgstr "" #: ../../library/socket.rst:1174 msgid "" -"If the IPv4 address string passed to this function is " -"invalid, :exc:`OSError` will be raised. Note that exactly what is valid " -"depends on the underlying C implementation of :c:func:`inet_aton`." +"If the IPv4 address string passed to this function is invalid, :exc:" +"`OSError` will be raised. Note that exactly what is valid depends on the " +"underlying C implementation of :c:func:`inet_aton`." msgstr "" #: ../../library/socket.rst:1178 @@ -1453,17 +1450,17 @@ msgstr "" msgid "" "Convert an IP address from its family-specific string format to a packed, " "binary format. :func:`inet_pton` is useful when a library or network " -"protocol calls for an object of type :c:struct:`in_addr` (similar " -"to :func:`inet_aton`) or :c:struct:`in6_addr`." +"protocol calls for an object of type :c:struct:`in_addr` (similar to :func:" +"`inet_aton`) or :c:struct:`in6_addr`." msgstr "" #: ../../library/socket.rst:1207 msgid "" -"Supported values for *address_family* are currently :const:`AF_INET` " -"and :const:`AF_INET6`. If the IP address string *ip_string* is " -"invalid, :exc:`OSError` will be raised. Note that exactly what is valid " -"depends on both the value of *address_family* and the underlying " -"implementation of :c:func:`inet_pton`." +"Supported values for *address_family* are currently :const:`AF_INET` and :" +"const:`AF_INET6`. If the IP address string *ip_string* is invalid, :exc:" +"`OSError` will be raised. Note that exactly what is valid depends on both " +"the value of *address_family* and the underlying implementation of :c:func:" +"`inet_pton`." msgstr "" #: ../../library/socket.rst:1215 ../../library/socket.rst:1235 @@ -1481,11 +1478,10 @@ msgstr "" #: ../../library/socket.rst:1228 msgid "" -"Supported values for *address_family* are currently :const:`AF_INET` " -"and :const:`AF_INET6`. If the bytes object *packed_ip* is not the correct " -"length for the specified address family, :exc:`ValueError` will be " -"raised. :exc:`OSError` is raised for errors from the call " -"to :func:`inet_ntop`." +"Supported values for *address_family* are currently :const:`AF_INET` and :" +"const:`AF_INET6`. If the bytes object *packed_ip* is not the correct length " +"for the specified address family, :exc:`ValueError` will be raised. :exc:" +"`OSError` is raised for errors from the call to :func:`inet_ntop`." msgstr "" #: ../../library/socket.rst:1250 @@ -1493,10 +1489,10 @@ msgid "" "Return the total length, without trailing padding, of an ancillary data item " "with associated data of the given *length*. This value can often be used as " "the buffer size for :meth:`~socket.recvmsg` to receive a single item of " -"ancillary data, but :rfc:`3542` requires portable applications to " -"use :func:`CMSG_SPACE` and thus include space for padding, even when the " -"item will be the last in the buffer. Raises :exc:`OverflowError` if " -"*length* is outside the permissible range of values." +"ancillary data, but :rfc:`3542` requires portable applications to use :func:" +"`CMSG_SPACE` and thus include space for padding, even when the item will be " +"the last in the buffer. Raises :exc:`OverflowError` if *length* is outside " +"the permissible range of values." msgstr "" #: ../../library/socket.rst:1261 ../../library/socket.rst:1748 @@ -1536,9 +1532,8 @@ msgstr "" #: ../../library/socket.rst:1298 msgid "" "Set the default timeout in seconds (float) for new socket objects. When the " -"socket module is first imported, the default is ``None``. " -"See :meth:`~socket.settimeout` for possible values and their respective " -"meanings." +"socket module is first imported, the default is ``None``. See :meth:" +"`~socket.settimeout` for possible values and their respective meanings." msgstr "" #: ../../library/socket.rst:1306 @@ -1552,8 +1547,8 @@ msgid "" "Raises an :ref:`auditing event ` ``socket.sethostname`` with " "argument ``name``." msgstr "" -"引發一個附帶引數 ``name`` 的\\ :ref:`稽核事件 ` " -"``socket.sethostname``。" +"引發一個附帶引數 ``name`` 的\\ :ref:`稽核事件 ` ``socket." +"sethostname``。" #: ../../library/socket.rst:1318 msgid "" @@ -1596,8 +1591,8 @@ msgstr "" #: ../../library/socket.rst:1345 msgid "" -"Return a network interface index number corresponding to an interface " -"name. :exc:`OSError` if no interface with the given name exists." +"Return a network interface index number corresponding to an interface name. :" +"exc:`OSError` if no interface with the given name exists." msgstr "" #: ../../library/socket.rst:1357 ../../library/socket.rst:1374 @@ -1606,18 +1601,18 @@ msgstr "" #: ../../library/socket.rst:1362 msgid "" -"Return a network interface name corresponding to an interface index " -"number. :exc:`OSError` if no interface with the given index exists." +"Return a network interface name corresponding to an interface index number. :" +"exc:`OSError` if no interface with the given index exists." msgstr "" #: ../../library/socket.rst:1379 msgid "" "Send the list of file descriptors *fds* over an :const:`AF_UNIX` socket " -"*sock*. The *fds* parameter is a sequence of file descriptors. " -"Consult :meth:`~socket.sendmsg` for the documentation of these parameters." +"*sock*. The *fds* parameter is a sequence of file descriptors. Consult :meth:" +"`~socket.sendmsg` for the documentation of these parameters." msgstr "" -#: ../../library/socket.rst:1385 ../../library/socket.rst:1399 +#: ../../library/socket.rst:1385 msgid "" "Unix platforms supporting :meth:`~socket.sendmsg` and :const:`SCM_RIGHTS` " "mechanism." @@ -1626,8 +1621,14 @@ msgstr "" #: ../../library/socket.rst:1393 msgid "" "Receive up to *maxfds* file descriptors from an :const:`AF_UNIX` socket " -"*sock*. Return ``(msg, list(fds), flags, addr)``. " -"Consult :meth:`~socket.recvmsg` for the documentation of these parameters." +"*sock*. Return ``(msg, list(fds), flags, addr)``. Consult :meth:`~socket." +"recvmsg` for the documentation of these parameters." +msgstr "" + +#: ../../library/socket.rst:1399 +msgid "" +"Unix platforms supporting :meth:`~socket.recvmsg` and :const:`SCM_RIGHTS` " +"mechanism." msgstr "" #: ../../library/socket.rst:1406 @@ -1640,9 +1641,8 @@ msgstr "Socket 物件" #: ../../library/socket.rst:1414 msgid "" -"Socket objects have the following methods. Except " -"for :meth:`~socket.makefile`, these correspond to Unix system calls " -"applicable to sockets." +"Socket objects have the following methods. Except for :meth:`~socket." +"makefile`, these correspond to Unix system calls applicable to sockets." msgstr "" #: ../../library/socket.rst:1418 @@ -1670,8 +1670,8 @@ msgstr "" #: ../../library/socket.rst:1861 ../../library/socket.rst:1906 msgid "" "If the system call is interrupted and the signal handler does not raise an " -"exception, the method now retries the system call instead of raising " -"an :exc:`InterruptedError` exception (see :pep:`475` for the rationale)." +"exception, the method now retries the system call instead of raising an :exc:" +"`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" #: ../../library/socket.rst:1443 @@ -1706,8 +1706,8 @@ msgstr "" #: ../../library/socket.rst:1463 msgid "" -":exc:`OSError` is now raised if an error occurs when the " -"underlying :c:func:`close` call is made." +":exc:`OSError` is now raised if an error occurs when the underlying :c:func:" +"`close` call is made." msgstr "" #: ../../library/socket.rst:1469 @@ -1728,9 +1728,9 @@ msgid "" "If the connection is interrupted by a signal, the method waits until the " "connection completes, or raise a :exc:`TimeoutError` on timeout, if the " "signal handler doesn't raise an exception and the socket is blocking or has " -"a timeout. For non-blocking sockets, the method raises " -"an :exc:`InterruptedError` exception if the connection is interrupted by a " -"signal (or the exception raised by the signal handler)." +"a timeout. For non-blocking sockets, the method raises an :exc:" +"`InterruptedError` exception if the connection is interrupted by a signal " +"(or the exception raised by the signal handler)." msgstr "" #: ../../library/socket.rst:1487 ../../library/socket.rst:1507 @@ -1743,8 +1743,8 @@ msgstr "" #: ../../library/socket.rst:1489 msgid "" -"The method now waits until the connection completes instead of raising " -"an :exc:`InterruptedError` exception if the connection is interrupted by a " +"The method now waits until the connection completes instead of raising an :" +"exc:`InterruptedError` exception if the connection is interrupted by a " "signal, the signal handler doesn't raise an exception and the socket is " "blocking or has a timeout (see the :pep:`475` for the rationale)." msgstr "" @@ -1807,15 +1807,15 @@ msgstr "" #: ../../library/socket.rst:1567 msgid "" -"Return the value of the given socket option (see the Unix man " -"page :manpage:`getsockopt(2)`). The needed symbolic constants (:ref:`SO_\\* " -"etc. `) are defined in this module. If *buflen* is " -"absent, an integer option is assumed and its integer value is returned by " -"the function. If *buflen* is present, it specifies the maximum length of " -"the buffer used to receive the option in, and this buffer is returned as a " -"bytes object. It is up to the caller to decode the contents of the buffer " -"(see the optional built-in module :mod:`struct` for a way to decode C " -"structures encoded as byte strings)." +"Return the value of the given socket option (see the Unix man page :manpage:" +"`getsockopt(2)`). The needed symbolic constants (:ref:`SO_\\* etc. `) are defined in this module. If *buflen* is absent, an " +"integer option is assumed and its integer value is returned by the " +"function. If *buflen* is present, it specifies the maximum length of the " +"buffer used to receive the option in, and this buffer is returned as a bytes " +"object. It is up to the caller to decode the contents of the buffer (see " +"the optional built-in module :mod:`struct` for a way to decode C structures " +"encoded as byte strings)." msgstr "" #: ../../library/socket.rst:1581 @@ -1830,8 +1830,8 @@ msgstr "這等同於檢查 ``socket.gettimeout() != 0``。" #: ../../library/socket.rst:1591 msgid "" "Return the timeout in seconds (float) associated with socket operations, or " -"``None`` if no timeout is set. This reflects the last call " -"to :meth:`setblocking` or :meth:`settimeout`." +"``None`` if no timeout is set. This reflects the last call to :meth:" +"`setblocking` or :meth:`settimeout`." msgstr "" #: ../../library/socket.rst:0 @@ -1845,9 +1845,8 @@ msgstr "Windows" #: ../../library/socket.rst:1600 msgid "" "The :meth:`ioctl` method is a limited interface to the WSAIoctl system " -"interface. Please refer to the `Win32 documentation `_ for more " -"information." +"interface. Please refer to the `Win32 documentation `_ for more information." msgstr "" #: ../../library/socket.rst:1605 @@ -1893,8 +1892,8 @@ msgstr "" #: ../../library/socket.rst:1642 msgid "" "Closing the file object returned by :meth:`makefile` won't close the " -"original socket unless all other file objects have been closed " -"and :meth:`socket.close` has been called on the socket object." +"original socket unless all other file objects have been closed and :meth:" +"`socket.close` has been called on the socket object." msgstr "" #: ../../library/socket.rst:1648 @@ -1909,9 +1908,9 @@ msgid "" "Receive data from the socket. The return value is a bytes object " "representing the data received. The maximum amount of data to be received " "at once is specified by *bufsize*. A returned empty bytes object indicates " -"that the client has disconnected. See the Unix manual " -"page :manpage:`recv(2)` for the meaning of the optional argument *flags*; it " -"defaults to zero." +"that the client has disconnected. See the Unix manual page :manpage:" +"`recv(2)` for the meaning of the optional argument *flags*; it defaults to " +"zero." msgstr "" #: ../../library/socket.rst:1669 @@ -1927,8 +1926,8 @@ msgstr "" #: ../../library/socket.rst:1680 msgid "" "For multicast IPv6 address, first item of *address* does not contain " -"``%scope_id`` part anymore. In order to get full IPv6 address " -"use :func:`getnameinfo`." +"``%scope_id`` part anymore. In order to get full IPv6 address use :func:" +"`getnameinfo`." msgstr "" #: ../../library/socket.rst:1687 @@ -1963,21 +1962,20 @@ msgid "" "file descriptors between processes over an :const:`AF_UNIX` socket. When " "this facility is used (it is often restricted to :const:`SOCK_STREAM` " "sockets), :meth:`recvmsg` will return, in its ancillary data, items of the " -"form ``(socket.SOL_SOCKET, socket.SCM_RIGHTS, fds)``, where *fds* is " -"a :class:`bytes` object representing the new file descriptors as a binary " -"array of the native C :c:expr:`int` type. If :meth:`recvmsg` raises an " -"exception after the system call returns, it will first attempt to close any " -"file descriptors received via this mechanism." +"form ``(socket.SOL_SOCKET, socket.SCM_RIGHTS, fds)``, where *fds* is a :" +"class:`bytes` object representing the new file descriptors as a binary array " +"of the native C :c:expr:`int` type. If :meth:`recvmsg` raises an exception " +"after the system call returns, it will first attempt to close any file " +"descriptors received via this mechanism." msgstr "" #: ../../library/socket.rst:1722 msgid "" "Some systems do not indicate the truncated length of ancillary data items " "which have been only partially received. If an item appears to extend " -"beyond the end of the buffer, :meth:`recvmsg` will issue " -"a :exc:`RuntimeWarning`, and will return the part of it which is inside the " -"buffer provided it has not been truncated before the start of its associated " -"data." +"beyond the end of the buffer, :meth:`recvmsg` will issue a :exc:" +"`RuntimeWarning`, and will return the part of it which is inside the buffer " +"provided it has not been truncated before the start of its associated data." msgstr "" #: ../../library/socket.rst:1729 @@ -1985,8 +1983,8 @@ msgid "" "On systems which support the :const:`SCM_RIGHTS` mechanism, the following " "function will receive up to *maxfds* file descriptors, returning the message " "data and a list containing the descriptors (while ignoring unexpected " -"conditions such as unrelated control messages being received). See " -"also :meth:`sendmsg`. ::" +"conditions such as unrelated control messages being received). See also :" +"meth:`sendmsg`. ::" msgstr "" #: ../../library/socket.rst:1735 @@ -1998,26 +1996,25 @@ msgid "" " msg, ancdata, flags, addr = sock.recvmsg(msglen, socket.CMSG_LEN(maxfds " "* fds.itemsize))\n" " for cmsg_level, cmsg_type, cmsg_data in ancdata:\n" -" if cmsg_level == socket.SOL_SOCKET and cmsg_type == " -"socket.SCM_RIGHTS:\n" +" if cmsg_level == socket.SOL_SOCKET and cmsg_type == socket." +"SCM_RIGHTS:\n" " # Append data, ignoring any truncated integers at the end.\n" -" fds.frombytes(cmsg_data[:len(cmsg_data) - (len(cmsg_data) % " -"fds.itemsize)])\n" +" fds.frombytes(cmsg_data[:len(cmsg_data) - (len(cmsg_data) % fds." +"itemsize)])\n" " return msg, list(fds)" msgstr "" #: ../../library/socket.rst:1760 msgid "" -"Receive normal data and ancillary data from the socket, behaving " -"as :meth:`recvmsg` would, but scatter the non-ancillary data into a series " -"of buffers instead of returning a new bytes object. The *buffers* argument " -"must be an iterable of objects that export writable buffers " -"(e.g. :class:`bytearray` objects); these will be filled with successive " -"chunks of the non-ancillary data until it has all been written or there are " -"no more buffers. The operating system may set a limit (:func:`~os.sysconf` " -"value ``SC_IOV_MAX``) on the number of buffers that can be used. The " -"*ancbufsize* and *flags* arguments have the same meaning as " -"for :meth:`recvmsg`." +"Receive normal data and ancillary data from the socket, behaving as :meth:" +"`recvmsg` would, but scatter the non-ancillary data into a series of buffers " +"instead of returning a new bytes object. The *buffers* argument must be an " +"iterable of objects that export writable buffers (e.g. :class:`bytearray` " +"objects); these will be filled with successive chunks of the non-ancillary " +"data until it has all been written or there are no more buffers. The " +"operating system may set a limit (:func:`~os.sysconf` value ``SC_IOV_MAX``) " +"on the number of buffers that can be used. The *ancbufsize* and *flags* " +"arguments have the same meaning as for :meth:`recvmsg`." msgstr "" #: ../../library/socket.rst:1771 @@ -2124,9 +2121,9 @@ msgstr "" msgid "" "Send normal and ancillary data to the socket, gathering the non-ancillary " "data from a series of buffers and concatenating it into a single message. " -"The *buffers* argument specifies the non-ancillary data as an iterable " -"of :term:`bytes-like objects ` (e.g. :class:`bytes` " -"objects); the operating system may set a limit (:func:`~os.sysconf` value " +"The *buffers* argument specifies the non-ancillary data as an iterable of :" +"term:`bytes-like objects ` (e.g. :class:`bytes` objects); " +"the operating system may set a limit (:func:`~os.sysconf` value " "``SC_IOV_MAX``) on the number of buffers that can be used. The *ancdata* " "argument specifies the ancillary data (control messages) as an iterable of " "zero or more tuples ``(cmsg_level, cmsg_type, cmsg_data)``, where " @@ -2142,8 +2139,8 @@ msgstr "" #: ../../library/socket.rst:1889 msgid "" -"The following function sends the list of file descriptors *fds* over " -"an :const:`AF_UNIX` socket, on systems which support the :const:`SCM_RIGHTS` " +"The following function sends the list of file descriptors *fds* over an :" +"const:`AF_UNIX` socket, on systems which support the :const:`SCM_RIGHTS` " "mechanism. See also :meth:`recvmsg`. ::" msgstr "" @@ -2152,14 +2149,14 @@ msgid "" "import socket, array\n" "\n" "def send_fds(sock, msg, fds):\n" -" return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, " -"array.array(\"i\", fds))])" +" return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array." +"array(\"i\", fds))])" msgstr "" "import socket, array\n" "\n" "def send_fds(sock, msg, fds):\n" -" return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, " -"array.array(\"i\", fds))])" +" return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array." +"array(\"i\", fds))])" #: ../../library/socket.rst:1902 msgid "" @@ -2178,17 +2175,16 @@ msgstr "" #: ../../library/socket.rst:1922 msgid "" -"Send a file until EOF is reached by using high-" -"performance :mod:`os.sendfile` and return the total number of bytes which " -"were sent. *file* must be a regular file object opened in binary mode. " -"If :mod:`os.sendfile` is not available (e.g. Windows) or *file* is not a " -"regular file :meth:`send` will be used instead. *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 until EOF is reached. File " -"position is updated on return or also in case of error in which " -"case :meth:`file.tell() ` can be used to figure out the " -"number of bytes which were sent. The socket must be of :const:`SOCK_STREAM` " -"type. Non-blocking sockets are not supported." +"Send a file until EOF is reached by using high-performance :mod:`os." +"sendfile` and return the total number of bytes which were sent. *file* must " +"be a regular file object opened in binary mode. If :mod:`os.sendfile` is not " +"available (e.g. Windows) or *file* is not a regular file :meth:`send` will " +"be used instead. *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 until EOF is reached. File position is updated on return or " +"also in case of error in which case :meth:`file.tell() ` can " +"be used to figure out the number of bytes which were sent. The socket must " +"be of :const:`SOCK_STREAM` type. Non-blocking sockets are not supported." msgstr "" #: ../../library/socket.rst:1938 @@ -2218,17 +2214,17 @@ msgstr "``sock.setblocking(False)`` 等價於 ``sock.settimeout(0.0)``" #: ../../library/socket.rst:1955 msgid "" -"The method no longer applies :const:`SOCK_NONBLOCK` flag " -"on :attr:`socket.type`." +"The method no longer applies :const:`SOCK_NONBLOCK` flag on :attr:`socket." +"type`." msgstr "" #: ../../library/socket.rst:1962 msgid "" "Set a timeout on blocking socket operations. The *value* argument can be a " "nonnegative floating-point number expressing seconds, or ``None``. If a non-" -"zero value is given, subsequent socket operations will raise " -"a :exc:`timeout` exception if the timeout period *value* has elapsed before " -"the operation has completed. If zero is given, the socket is put in non-" +"zero value is given, subsequent socket operations will raise a :exc:" +"`timeout` exception if the timeout period *value* has elapsed before the " +"operation has completed. If zero is given, the socket is put in non-" "blocking mode. If ``None`` is given, the socket is put in blocking mode." msgstr "" @@ -2240,22 +2236,21 @@ msgstr "" #: ../../library/socket.rst:1971 msgid "" -"The method no longer toggles :const:`SOCK_NONBLOCK` flag " -"on :attr:`socket.type`." +"The method no longer toggles :const:`SOCK_NONBLOCK` flag on :attr:`socket." +"type`." msgstr "" #: ../../library/socket.rst:1984 msgid "" -"Set the value of the given socket option (see the Unix manual " -"page :manpage:`setsockopt(2)`). The needed symbolic constants are defined " -"in this module (:ref:`!SO_\\* etc. `). The value can " -"be an integer, ``None`` or a :term:`bytes-like object` representing a " -"buffer. In the later case it is up to the caller to ensure that the " -"bytestring contains the proper bits (see the optional built-in " -"module :mod:`struct` for a way to encode C structures as bytestrings). When " -"*value* is set to ``None``, *optlen* argument is required. It's equivalent " -"to call :c:func:`setsockopt` C function with ``optval=NULL`` and " -"``optlen=optlen``." +"Set the value of the given socket option (see the Unix manual page :manpage:" +"`setsockopt(2)`). The needed symbolic constants are defined in this module " +"(:ref:`!SO_\\* etc. `). The value can be an integer, " +"``None`` or a :term:`bytes-like object` representing a buffer. In the later " +"case it is up to the caller to ensure that the bytestring contains the " +"proper bits (see the optional built-in module :mod:`struct` for a way to " +"encode C structures as bytestrings). When *value* is set to ``None``, " +"*optlen* argument is required. It's equivalent to call :c:func:`setsockopt` " +"C function with ``optval=NULL`` and ``optlen=optlen``." msgstr "" #: ../../library/socket.rst:1997 @@ -2264,10 +2259,10 @@ msgstr "" #: ../../library/socket.rst:2005 msgid "" -"Shut down one or both halves of the connection. If *how* " -"is :const:`SHUT_RD`, further receives are disallowed. If *how* " -"is :const:`SHUT_WR`, further sends are disallowed. If *how* " -"is :const:`SHUT_RDWR`, further sends and receives are disallowed." +"Shut down one or both halves of the connection. If *how* is :const:" +"`SHUT_RD`, further receives are disallowed. If *how* is :const:`SHUT_WR`, " +"further sends are disallowed. If *how* is :const:`SHUT_RDWR`, further sends " +"and receives are disallowed." msgstr "" #: ../../library/socket.rst:2015 @@ -2275,17 +2270,16 @@ msgid "" "Duplicate a socket and prepare it for sharing with a target process. The " "target process must be provided with *process_id*. The resulting bytes " "object can then be passed to the target process using some form of " -"interprocess communication and the socket can be recreated there " -"using :func:`fromshare`. Once this method has been called, it is safe to " -"close the socket since the operating system has already duplicated it for " -"the target process." +"interprocess communication and the socket can be recreated there using :func:" +"`fromshare`. Once this method has been called, it is safe to close the " +"socket since the operating system has already duplicated it for the target " +"process." msgstr "" #: ../../library/socket.rst:2027 msgid "" -"Note that there are no methods :meth:`read` or :meth:`write`; " -"use :meth:`~socket.recv` and :meth:`~socket.send` without *flags* argument " -"instead." +"Note that there are no methods :meth:`read` or :meth:`write`; use :meth:" +"`~socket.recv` and :meth:`~socket.send` without *flags* argument instead." msgstr "" #: ../../library/socket.rst:2030 @@ -2355,10 +2349,10 @@ msgstr "" msgid "" "The :meth:`~socket.connect` operation is also subject to the timeout " "setting, and in general it is recommended to call :meth:`~socket.settimeout` " -"before calling :meth:`~socket.connect` or pass a timeout parameter " -"to :meth:`create_connection`. However, the system network stack may also " -"return a connection timeout error of its own regardless of any Python socket " -"timeout setting." +"before calling :meth:`~socket.connect` or pass a timeout parameter to :meth:" +"`create_connection`. However, the system network stack may also return a " +"connection timeout error of its own regardless of any Python socket timeout " +"setting." msgstr "" #: ../../library/socket.rst:2089 @@ -2367,9 +2361,9 @@ msgstr "" #: ../../library/socket.rst:2091 msgid "" -"If :func:`getdefaulttimeout` is not :const:`None`, sockets returned by " -"the :meth:`~socket.accept` method inherit that timeout. Otherwise, the " -"behaviour depends on settings of the listening socket:" +"If :func:`getdefaulttimeout` is not :const:`None`, sockets returned by the :" +"meth:`~socket.accept` method inherit that timeout. Otherwise, the behaviour " +"depends on settings of the listening socket:" msgstr "" #: ../../library/socket.rst:2095 @@ -2394,14 +2388,13 @@ msgstr "範例" msgid "" "Here are four minimal example programs using the TCP/IP protocol: a server " "that echoes all data that it receives back (servicing only one client), and " -"a client using it. Note that a server must perform the " -"sequence :func:`~socket.socket`, :meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` " -"(possibly repeating the :meth:`~socket.accept` to service more than one " -"client), while a client only needs the " -"sequence :func:`~socket.socket`, :meth:`~socket.connect`. Also note that " -"the server does not :meth:`~socket.sendall`/:meth:`~socket.recv` on the " -"socket it is listening on but on the new socket returned " -"by :meth:`~socket.accept`." +"a client using it. Note that a server must perform the sequence :func:" +"`~socket.socket`, :meth:`~socket.bind`, :meth:`~socket.listen`, :meth:" +"`~socket.accept` (possibly repeating the :meth:`~socket.accept` to service " +"more than one client), while a client only needs the sequence :func:`~socket." +"socket`, :meth:`~socket.connect`. Also note that the server does not :meth:" +"`~socket.sendall`/:meth:`~socket.recv` on the socket it is listening on but " +"on the new socket returned by :meth:`~socket.accept`." msgstr "" #: ../../library/socket.rst:2119 @@ -2497,8 +2490,8 @@ msgid "" "HOST = 'daring.cwi.nl' # The remote host\n" "PORT = 50007 # The same port as used by the server\n" "s = None\n" -"for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, " -"socket.SOCK_STREAM):\n" +"for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket." +"SOCK_STREAM):\n" " af, socktype, proto, canonname, sa = res\n" " try:\n" " s = socket.socket(af, socktype, proto)\n" @@ -2634,8 +2627,8 @@ msgstr "" #: ../../library/socket.rst:2305 msgid "" -"There is a :mod:`socket` flag to set, in order to prevent " -"this, :const:`socket.SO_REUSEADDR`::" +"There is a :mod:`socket` flag to set, in order to prevent this, :const:" +"`socket.SO_REUSEADDR`::" msgstr "" #: ../../library/socket.rst:2308 diff --git a/library/socketserver.po b/library/socketserver.po index 31b914a9a2..e3c9cf6c81 100644 --- a/library/socketserver.po +++ b/library/socketserver.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-09 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -635,7 +635,7 @@ msgstr "" msgid "" "The difference is that the ``readline()`` call in the second handler will " "call ``recv()`` multiple times until it encounters a newline character, " -"while the the first handler had to use a ``recv()`` loop to accumulate data " +"while the first handler had to use a ``recv()`` loop to accumulate data " "until a newline itself. If it had just used a single ``recv()`` without the " "loop it would just have returned what has been received so far from the " "client. TCP is stream based: data arrives in the order it was sent, but " diff --git a/library/stdtypes.po b/library/stdtypes.po index 760f2937ed..47a6ffbbe8 100644 --- a/library/stdtypes.po +++ b/library/stdtypes.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-10 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-06-12 15:22+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -65,24 +65,22 @@ msgstr "真值檢測" #: ../../library/stdtypes.rst:41 msgid "" -"Any object can be tested for truth value, for use in an :keyword:`if` " -"or :keyword:`while` condition or as operand of the Boolean operations below." +"Any object can be tested for truth value, for use in an :keyword:`if` or :" +"keyword:`while` condition or as operand of the Boolean operations below." msgstr "" -"任何物件都可以進行檢測以判斷是否為真值,以便在 :keyword:`if` " -"或 :keyword:`while` 條件中使用,或是作為如下所述 boolean(布林)運算之運算元" -"所用。" +"任何物件都可以進行檢測以判斷是否為真值,以便在 :keyword:`if` 或 :keyword:" +"`while` 條件中使用,或是作為如下所述 boolean(布林)運算之運算元所用。" #: ../../library/stdtypes.rst:46 msgid "" -"By default, an object is considered true unless its class defines either " -"a :meth:`~object.__bool__` method that returns ``False`` or " -"a :meth:`~object.__len__` method that returns zero, when called with the " -"object. [1]_ Here are most of the built-in objects considered false:" +"By default, an object is considered true unless its class defines either a :" +"meth:`~object.__bool__` method that returns ``False`` or a :meth:`~object." +"__len__` method that returns zero, when called with the object. [1]_ Here " +"are most of the built-in objects considered false:" msgstr "" -"預設情況下,一個物件會被視為真值,除非它的 class 定義了會回傳 ``False`` " -"的 :meth:`~object.__bool__` method 或是定義了會回傳零" -"的 :meth:`~object.__len__` method。[1]_ 以下列出了大部分會被視為 false 的內建" -"物件:" +"預設情況下,一個物件會被視為真值,除非它的 class 定義了會回傳 ``False`` 的 :" +"meth:`~object.__bool__` method 或是定義了會回傳零的 :meth:`~object.__len__` " +"method。[1]_ 以下列出了大部分會被視為 false 的內建物件:" #: ../../library/stdtypes.rst:56 msgid "constants defined to be false: ``None`` and ``False``" @@ -125,20 +123,20 @@ msgstr "下方為 Boolean 運算,按優先順序排序:" #: ../../library/stdtypes.rst:86 ../../library/stdtypes.rst:144 #: ../../library/stdtypes.rst:276 ../../library/stdtypes.rst:366 #: ../../library/stdtypes.rst:416 ../../library/stdtypes.rst:965 -#: ../../library/stdtypes.rst:1170 +#: ../../library/stdtypes.rst:1173 msgid "Operation" msgstr "運算" #: ../../library/stdtypes.rst:86 ../../library/stdtypes.rst:276 #: ../../library/stdtypes.rst:366 ../../library/stdtypes.rst:416 -#: ../../library/stdtypes.rst:965 ../../library/stdtypes.rst:1170 +#: ../../library/stdtypes.rst:965 ../../library/stdtypes.rst:1173 msgid "Result" msgstr "結果" #: ../../library/stdtypes.rst:86 ../../library/stdtypes.rst:276 #: ../../library/stdtypes.rst:416 ../../library/stdtypes.rst:965 -#: ../../library/stdtypes.rst:1170 ../../library/stdtypes.rst:2578 -#: ../../library/stdtypes.rst:3797 +#: ../../library/stdtypes.rst:1173 ../../library/stdtypes.rst:2634 +#: ../../library/stdtypes.rst:3853 msgid "Notes" msgstr "註解" @@ -151,8 +149,8 @@ msgid "if *x* is true, then *x*, else *y*" msgstr "假如 *x* 為真,則 *x*,否則 *y*" #: ../../library/stdtypes.rst:88 ../../library/stdtypes.rst:967 -#: ../../library/stdtypes.rst:970 ../../library/stdtypes.rst:1181 -#: ../../library/stdtypes.rst:2584 ../../library/stdtypes.rst:3803 +#: ../../library/stdtypes.rst:970 ../../library/stdtypes.rst:1186 +#: ../../library/stdtypes.rst:2640 ../../library/stdtypes.rst:3859 msgid "\\(1)" msgstr "\\(1)" @@ -165,9 +163,9 @@ msgid "if *x* is false, then *x*, else *y*" msgstr "假如 *x* 為假,則 *x*,否則 *y*" #: ../../library/stdtypes.rst:91 ../../library/stdtypes.rst:289 -#: ../../library/stdtypes.rst:309 ../../library/stdtypes.rst:1209 -#: ../../library/stdtypes.rst:2588 ../../library/stdtypes.rst:2590 -#: ../../library/stdtypes.rst:3807 ../../library/stdtypes.rst:3809 +#: ../../library/stdtypes.rst:309 ../../library/stdtypes.rst:1214 +#: ../../library/stdtypes.rst:2644 ../../library/stdtypes.rst:2646 +#: ../../library/stdtypes.rst:3863 ../../library/stdtypes.rst:3865 msgid "\\(2)" msgstr "\\(2)" @@ -179,19 +177,18 @@ msgstr "``not x``" msgid "if *x* is false, then ``True``, else ``False``" msgstr "假如 *x* 為假,則 ``True``,否則 ``False``" -#: ../../library/stdtypes.rst:94 ../../library/stdtypes.rst:979 -#: ../../library/stdtypes.rst:1212 ../../library/stdtypes.rst:2592 -#: ../../library/stdtypes.rst:2594 ../../library/stdtypes.rst:2596 -#: ../../library/stdtypes.rst:2598 ../../library/stdtypes.rst:3811 -#: ../../library/stdtypes.rst:3813 ../../library/stdtypes.rst:3815 -#: ../../library/stdtypes.rst:3817 +#: ../../library/stdtypes.rst:94 ../../library/stdtypes.rst:1217 +#: ../../library/stdtypes.rst:2648 ../../library/stdtypes.rst:2650 +#: ../../library/stdtypes.rst:2652 ../../library/stdtypes.rst:2654 +#: ../../library/stdtypes.rst:3867 ../../library/stdtypes.rst:3869 +#: ../../library/stdtypes.rst:3871 ../../library/stdtypes.rst:3873 msgid "\\(3)" msgstr "\\(3)" #: ../../library/stdtypes.rst:103 ../../library/stdtypes.rst:320 #: ../../library/stdtypes.rst:434 ../../library/stdtypes.rst:1016 -#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:2624 -#: ../../library/stdtypes.rst:3847 +#: ../../library/stdtypes.rst:1226 ../../library/stdtypes.rst:2680 +#: ../../library/stdtypes.rst:3903 msgid "Notes:" msgstr "註解:" @@ -238,9 +235,9 @@ msgstr "" msgid "This table summarizes the comparison operations:" msgstr "這個表格統整所有比較運算:" -#: ../../library/stdtypes.rst:144 ../../library/stdtypes.rst:2410 -#: ../../library/stdtypes.rst:2555 ../../library/stdtypes.rst:2578 -#: ../../library/stdtypes.rst:3774 ../../library/stdtypes.rst:3797 +#: ../../library/stdtypes.rst:144 ../../library/stdtypes.rst:2466 +#: ../../library/stdtypes.rst:2611 ../../library/stdtypes.rst:2634 +#: ../../library/stdtypes.rst:3830 ../../library/stdtypes.rst:3853 msgid "Meaning" msgstr "含義" @@ -327,24 +324,23 @@ msgid "" "Non-identical instances of a class normally compare as non-equal unless the " "class defines the :meth:`~object.__eq__` method." msgstr "" -"一個 class 的非相同實例通常會比較為不相等,除非 class 有定" -"義 :meth:`~object.__eq__` method。" +"一個 class 的非相同實例通常會比較為不相等,除非 class 有定義 :meth:`~object." +"__eq__` method。" #: ../../library/stdtypes.rst:184 msgid "" "Instances of a class cannot be ordered with respect to other instances of " "the same class, or other types of object, unless the class defines enough of " -"the " -"methods :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, " -"and :meth:`~object.__ge__` (in general, :meth:`~object.__lt__` " -"and :meth:`~object.__eq__` are sufficient, if you want the conventional " -"meanings of the comparison operators)." +"the methods :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object." +"__gt__`, and :meth:`~object.__ge__` (in general, :meth:`~object.__lt__` and :" +"meth:`~object.__eq__` are sufficient, if you want the conventional meanings " +"of the comparison operators)." msgstr "" "一個 class 的實例不可以與其他相同 class 的實例或其他物件型別進行排序,除非 " -"class 定義足夠的 method ,包" -"含 :meth:`~object.__lt__`、:meth:`~object.__le__`、:meth:`~object.__gt__` " -"及 :meth:`~object.__ge__`\\ (一般來說,使用 :meth:`~object.__lt__` " -"及 :meth:`~object.__eq__` 就可以滿足常規意義上的比較運算子)。" +"class 定義足夠的 method ,包含 :meth:`~object.__lt__`、:meth:`~object." +"__le__`、:meth:`~object.__gt__` 及 :meth:`~object.__ge__`\\ (一般來說,使" +"用 :meth:`~object.__lt__` 及 :meth:`~object.__eq__` 就可以滿足常規意義上的比" +"較運算子)。" #: ../../library/stdtypes.rst:191 msgid "" @@ -357,8 +353,8 @@ msgstr "" #: ../../library/stdtypes.rst:199 msgid "" -"Two more operations with the same syntactic priority, :keyword:`in` " -"and :keyword:`not in`, are supported by types that are :term:`iterable` or " +"Two more operations with the same syntactic priority, :keyword:`in` and :" +"keyword:`not in`, are supported by types that are :term:`iterable` or " "implement the :meth:`~object.__contains__` method." msgstr "" "此外,擁有相同的語法優先序的 :keyword:`in` 及 :keyword:`not in` 兩種運算皆被" @@ -376,21 +372,20 @@ msgid "" "subtype of integers. Integers have unlimited precision. Floating-point " "numbers are usually implemented using :c:expr:`double` in C; information " "about the precision and internal representation of floating-point numbers " -"for the machine on which your program is running is available " -"in :data:`sys.float_info`. Complex numbers have a real and imaginary part, " -"which are each a floating-point number. To extract these parts from a " -"complex number *z*, use ``z.real`` and ``z.imag``. (The standard library " -"includes the additional numeric types :mod:`fractions.Fraction`, for " -"rationals, and :mod:`decimal.Decimal`, for floating-point numbers with user-" -"definable precision.)" +"for the machine on which your program is running is available in :data:`sys." +"float_info`. Complex numbers have a real and imaginary part, which are each " +"a floating-point number. To extract these parts from a complex number *z*, " +"use ``z.real`` and ``z.imag``. (The standard library includes the additional " +"numeric types :mod:`fractions.Fraction`, for rationals, and :mod:`decimal." +"Decimal`, for floating-point numbers with user-definable precision.)" msgstr "" "數值型別共有三種::dfn:`整數`、:dfn:`浮點數` 及 :dfn:`複數`。此外,Boolean 為" -"整數中的一個子型別。整數有無限的精度。浮點數通常使用 C 裡面" -"的 :c:expr:`double` 實作。關於在你程式所運作的機器上之浮點數的精度及內部表示" -"法可以在 :data:`sys.float_info` 進行查找。複數包含實數及虛數的部分,這兩部分" -"各自是一個浮點數。若要從一個複數 *z* 提取這兩部分,需使用 ``z.real`` 及 " -"``z.imag``。(標準函式庫包含額外的數值型別,像是 :mod:`fractions.Fraction` 表" -"示有理數,而 :mod:`decimal.Decimal` 表示可由使用者制定精度的浮點數。)" +"整數中的一個子型別。整數有無限的精度。浮點數通常使用 C 裡面的 :c:expr:" +"`double` 實作。關於在你程式所運作的機器上之浮點數的精度及內部表示法可以在 :" +"data:`sys.float_info` 進行查找。複數包含實數及虛數的部分,這兩部分各自是一個" +"浮點數。若要從一個複數 *z* 提取這兩部分,需使用 ``z.real`` 及 ``z.imag``。" +"(標準函式庫包含額外的數值型別,像是 :mod:`fractions.Fraction` 表示有理數," +"而 :mod:`decimal.Decimal` 表示可由使用者制定精度的浮點數。)" #: ../../library/stdtypes.rst:238 msgid "" @@ -433,8 +428,8 @@ msgid "" "All numeric types (except complex) support the following operations (for " "priorities of the operations, see :ref:`operator-summary`):" msgstr "" -"所有數值型別(除複數外)皆支援以下的運算(有關運算的先後順序,詳" -"見 :ref:`operator-summary`):" +"所有數值型別(除複數外)皆支援以下的運算(有關運算的先後順序,詳見 :ref:" +"`operator-summary`):" #: ../../library/stdtypes.rst:276 msgid "Full documentation" @@ -562,8 +557,8 @@ msgid "" "zero." msgstr "一個複數,其實部為 *re*,虛部為 *im*。*im* 預設為零。" -#: ../../library/stdtypes.rst:302 ../../library/stdtypes.rst:1202 -#: ../../library/stdtypes.rst:2586 ../../library/stdtypes.rst:3834 +#: ../../library/stdtypes.rst:302 ../../library/stdtypes.rst:1207 +#: ../../library/stdtypes.rst:2642 ../../library/stdtypes.rst:3890 msgid "\\(6)" msgstr "\\(6)" @@ -600,10 +595,10 @@ msgid "*x* to the power *y*" msgstr "*x* 的 *y* 次方" #: ../../library/stdtypes.rst:311 ../../library/stdtypes.rst:313 -#: ../../library/stdtypes.rst:1191 ../../library/stdtypes.rst:1194 -#: ../../library/stdtypes.rst:2611 ../../library/stdtypes.rst:2614 -#: ../../library/stdtypes.rst:2617 ../../library/stdtypes.rst:3830 -#: ../../library/stdtypes.rst:3837 +#: ../../library/stdtypes.rst:1196 ../../library/stdtypes.rst:1199 +#: ../../library/stdtypes.rst:2667 ../../library/stdtypes.rst:2670 +#: ../../library/stdtypes.rst:2673 ../../library/stdtypes.rst:3886 +#: ../../library/stdtypes.rst:3893 msgid "\\(5)" msgstr "\\(5)" @@ -624,11 +619,11 @@ msgid "" "always rounded towards minus infinity: ``1//2`` is ``0``, ``(-1)//2`` is " "``-1``, ``1//(-2)`` is ``-1``, and ``(-1)//(-2)`` is ``0``." msgstr "" -"也被稱為整數除法。對於型別為 :class:`int` 的運算元來說,結果之型別會" -"是 :class:`int`。對於型別為 :class:`float` 的運算元來說,結果之型別會" -"是 :class:`float`。一般來說,結果會是一個整數,但其型別不一定會" -"是 :class:`int`。結果總是會往負無窮大的方向取整數值: ``1//2`` 為 ``0``、" -"``(-1)//2`` 為 ``-1``、``1//(-2)`` 為 ``-1`` 及 ``(-1)//(-2)`` 為 ``0``。" +"也被稱為整數除法。對於型別為 :class:`int` 的運算元來說,結果之型別會是 :" +"class:`int`。對於型別為 :class:`float` 的運算元來說,結果之型別會是 :class:" +"`float`。一般來說,結果會是一個整數,但其型別不一定會是 :class:`int`。結果總" +"是會往負無窮大的方向取整數值: ``1//2`` 為 ``0``、``(-1)//2`` 為 ``-1``、" +"``1//(-2)`` 為 ``-1`` 及 ``(-1)//(-2)`` 為 ``0``。" #: ../../library/stdtypes.rst:331 msgid "" @@ -642,8 +637,8 @@ msgid "" "fractional part. See functions :func:`math.floor` and :func:`math.ceil` for " "alternative conversions." msgstr "" -"從 :class:`float` 轉換為 :class:`int` 會導致截斷並排除小數部分。詳" -"見 :func:`math.floor` 及 :func:`math.ceil` 以了解更多轉換方式。" +"從 :class:`float` 轉換為 :class:`int` 會導致截斷並排除小數部分。詳見 :func:" +"`math.floor` 及 :func:`math.ceil` 以了解更多轉換方式。" #: ../../library/stdtypes.rst:347 msgid "" @@ -761,9 +756,9 @@ msgid "bitwise :dfn:`or` of *x* and *y*" msgstr "*x* 及 *y* 的位元 :dfn:`或`" #: ../../library/stdtypes.rst:418 ../../library/stdtypes.rst:421 -#: ../../library/stdtypes.rst:424 ../../library/stdtypes.rst:1216 -#: ../../library/stdtypes.rst:2600 ../../library/stdtypes.rst:2604 -#: ../../library/stdtypes.rst:3819 ../../library/stdtypes.rst:3823 +#: ../../library/stdtypes.rst:424 ../../library/stdtypes.rst:1221 +#: ../../library/stdtypes.rst:2656 ../../library/stdtypes.rst:2660 +#: ../../library/stdtypes.rst:3875 ../../library/stdtypes.rst:3879 msgid "\\(4)" msgstr "\\(4)" @@ -833,13 +828,13 @@ msgstr "向右移動 *n* 個位元等同於向下除法除以 ``pow(2, n)``。" #: ../../library/stdtypes.rst:446 msgid "" "Performing these calculations with at least one extra sign extension bit in " -"a finite two's complement representation (a working bit-width of ``1 + " -"max(x.bit_length(), y.bit_length())`` or more) is sufficient to get the same " +"a finite two's complement representation (a working bit-width of ``1 + max(x." +"bit_length(), y.bit_length())`` or more) is sufficient to get the same " "result as if there were an infinite number of sign bits." msgstr "" -"在有限的二的補數表示法中執行這些計算(一個有效位元寬度為 ``1 + " -"max(x.bit_length(), y.bit_length())`` 或以上)並至少有一個額外的符號擴展位" -"元,便足以得到與無窮多個符號位元相同的結果。" +"在有限的二的補數表示法中執行這些計算(一個有效位元寬度為 ``1 + max(x." +"bit_length(), y.bit_length())`` 或以上)並至少有一個額外的符號擴展位元,便足" +"以得到與無窮多個符號位元相同的結果。" #: ../../library/stdtypes.rst:453 msgid "Additional Methods on Integer Types" @@ -878,13 +873,13 @@ msgid "" "More precisely, if ``x`` is nonzero, then ``x.bit_length()`` is the unique " "positive integer ``k`` such that ``2**(k-1) <= abs(x) < 2**k``. " "Equivalently, when ``abs(x)`` is small enough to have a correctly rounded " -"logarithm, then ``k = 1 + int(log(abs(x), 2))``. If ``x`` is zero, then " -"``x.bit_length()`` returns ``0``." +"logarithm, then ``k = 1 + int(log(abs(x), 2))``. If ``x`` is zero, then ``x." +"bit_length()`` returns ``0``." msgstr "" "更準確來說,若 ``x`` 非為零,則 ``x.bit_length()`` 會得出滿足 ``2**(k-1) <= " "abs(x) < 2**k`` 的單一正整數 ``k``。同樣地,當 ``abs(x)`` 足夠小到能正確地取" -"得捨入的對數,則 ``k = 1 + int(log(abs(x), 2))``。若 ``x`` 為零,則 " -"``x.bit_length()`` 會回傳 ``0``。" +"得捨入的對數,則 ``k = 1 + int(log(abs(x), 2))``。若 ``x`` 為零,則 ``x." +"bit_length()`` 會回傳 ``0``。" #: ../../library/stdtypes.rst:475 ../../library/stdtypes.rst:498 #: ../../library/stdtypes.rst:543 ../../library/stdtypes.rst:587 @@ -937,9 +932,9 @@ msgstr "回傳表示一個整數的一列位元組。" #: ../../library/stdtypes.rst:519 msgid "" -"The integer is represented using *length* bytes, and defaults to 1. " -"An :exc:`OverflowError` is raised if the integer is not representable with " -"the given number of bytes." +"The integer is represented using *length* bytes, and defaults to 1. An :exc:" +"`OverflowError` is raised if the integer is not representable with the given " +"number of bytes." msgstr "" "此整數會使用 *length* 位元組表示,並且預設為 1。如果該整數無法用給定的位元組" "數來表示,則會引發 :exc:`OverflowError`。" @@ -985,8 +980,8 @@ msgid "" "However, when using the default arguments, don't try to convert a value " "greater than 255 or you'll get an :exc:`OverflowError`." msgstr "" -"然而,使用預設引數時,不要嘗試轉換大於 255 的值,否則你將會得到一" -"個 :exc:`OverflowError`。" +"然而,使用預設引數時,不要嘗試轉換大於 255 的值,否則你將會得到一個 :exc:" +"`OverflowError`。" #: ../../library/stdtypes.rst:545 msgid "" @@ -1032,8 +1027,8 @@ msgid "" "integer, and defaults to ``\"big\"``. If *byteorder* is ``\"big\"``, the " "most significant byte is at the beginning of the byte array. If *byteorder* " "is ``\"little\"``, the most significant byte is at the end of the byte " -"array. To request the native byte order of the host system, " -"use :data:`sys.byteorder` as the byte order value." +"array. To request the native byte order of the host system, use :data:`sys." +"byteorder` as the byte order value." msgstr "" "*byteorder* 引數決定了用來表示整數的位元組順序並且預設為 ``\"big\"``。如果 " "*byteorder* 是 ``\"big\"``,最重要的位元組位於位元組陣列的開頭。如果 " @@ -1091,8 +1086,8 @@ msgstr "" #: ../../library/stdtypes.rst:618 msgid "" -"Returns ``True``. Exists for duck type compatibility " -"with :meth:`float.is_integer`." +"Returns ``True``. Exists for duck type compatibility with :meth:`float." +"is_integer`." msgstr "回傳 ``True``。為了與 :meth:`float.is_integer` 的鴨子型別相容而存在。" #: ../../library/stdtypes.rst:623 @@ -1110,8 +1105,8 @@ msgstr "" #: ../../library/stdtypes.rst:630 msgid "" "Return a pair of integers whose ratio is exactly equal to the original " -"float. The ratio is in lowest terms and has a positive denominator. " -"Raises :exc:`OverflowError` on infinities and a :exc:`ValueError` on NaNs." +"float. The ratio is in lowest terms and has a positive denominator. Raises :" +"exc:`OverflowError` on infinities and a :exc:`ValueError` on NaNs." msgstr "" "回傳一對整數,其比率完全等於原始浮點數。比率是在最低條件下並且有一個正分母。" "在無窮大時引發 :exc:`OverflowError`,在 NaN 時引發 :exc:`ValueError`。" @@ -1168,8 +1163,8 @@ msgstr "" #: ../../library/stdtypes.rst:669 msgid "" -"Note that :meth:`float.hex` is an instance method, " -"while :meth:`float.fromhex` is a class method." +"Note that :meth:`float.hex` is an instance method, while :meth:`float." +"fromhex` is a class method." msgstr "" "請注意 :meth:`float.hex` 是一個實例 method,而 :meth:`float.fromhex` 是一個 " "class method。" @@ -1198,10 +1193,10 @@ msgstr "" "其中可選的 ``sign`` 可以是 ``+`` 或 ``-``,``integer`` 和 ``fraction`` 是十六" "進位數字的字串,而 ``exponent`` 是一個十進位整數並且有一個可選的前導符號。大" "小寫不重要,並且整數或小數部分至少有一個十六進位數字。這個語法與 C99 標準的" -"第 6.4.4.2 節指定的語法相似,也與 Java 1.5 以後的語法相似。特別" -"是 :meth:`float.hex` 的輸出可用作 C 或 Java 程式碼中的十六進位浮點數文字,並" -"且 C 的 ``%a`` 格式字元或 Java 的 ``Double.toHexString`` 產生的十六進位字串可" -"被 :meth:`float.fromhex` 接受。" +"第 6.4.4.2 節指定的語法相似,也與 Java 1.5 以後的語法相似。特別是 :meth:" +"`float.hex` 的輸出可用作 C 或 Java 程式碼中的十六進位浮點數文字,並且 C 的 " +"``%a`` 格式字元或 Java 的 ``Double.toHexString`` 產生的十六進位字串可被 :" +"meth:`float.fromhex` 接受。" #: ../../library/stdtypes.rst:689 msgid "" @@ -1244,29 +1239,27 @@ msgstr "數值型別的雜湊" #: ../../library/stdtypes.rst:711 msgid "" "For numbers ``x`` and ``y``, possibly of different types, it's a requirement " -"that ``hash(x) == hash(y)`` whenever ``x == y`` (see " -"the :meth:`~object.__hash__` method documentation for more details). For " -"ease of implementation and efficiency across a variety of numeric types " -"(including :class:`int`, :class:`float`, :class:`decimal.Decimal` " -"and :class:`fractions.Fraction`) Python's hash for numeric types is based on " -"a single mathematical function that's defined for any rational number, and " -"hence applies to all instances of :class:`int` " -"and :class:`fractions.Fraction`, and all finite instances of :class:`float` " -"and :class:`decimal.Decimal`. Essentially, this function is given by " -"reduction modulo ``P`` for a fixed prime ``P``. The value of ``P`` is made " -"available to Python as the :attr:`~sys.hash_info.modulus` attribute " -"of :data:`sys.hash_info`." +"that ``hash(x) == hash(y)`` whenever ``x == y`` (see the :meth:`~object." +"__hash__` method documentation for more details). For ease of " +"implementation and efficiency across a variety of numeric types (including :" +"class:`int`, :class:`float`, :class:`decimal.Decimal` and :class:`fractions." +"Fraction`) Python's hash for numeric types is based on a single mathematical " +"function that's defined for any rational number, and hence applies to all " +"instances of :class:`int` and :class:`fractions.Fraction`, and all finite " +"instances of :class:`float` and :class:`decimal.Decimal`. Essentially, this " +"function is given by reduction modulo ``P`` for a fixed prime ``P``. The " +"value of ``P`` is made available to Python as the :attr:`~sys.hash_info." +"modulus` attribute of :data:`sys.hash_info`." msgstr "" "對於數字 ``x`` 和 ``y``,可能是不同型別,當 ``x == y`` 時,``hash(x) == " "hash(y)`` 是一個要求( 詳見 :meth:`~object.__hash__` method 的文件以獲得更多" -"細節)。為了實作的便利性和效率跨越各種數值型別(包" -"括 :class:`int`、:class:`float`、:class:`decimal.Decimal` " -"和 :class:`fractions.Fraction`)Python 的數值型別的雜湊是基於一個數學函式,它" -"對於任何有理數都是定義的,因此適用於所有 :class:`int` " -"和 :class:`fractions.Fraction` 的實例,以及所有有限的 :class:`float` " -"和 :class:`decimal.Decimal` 的實例。基本上,這個函式是由簡化的 modulo(模" -"數) ``P`` 給出的一個固定的質數 ``P``。``P`` 的值作為 :data:`sys.hash_info` " -"的 :attr:`~sys.hash_info.modulus` 屬性提供給 Python。" +"細節)。為了實作的便利性和效率跨越各種數值型別(包括 :class:`int`、:class:" +"`float`、:class:`decimal.Decimal` 和 :class:`fractions.Fraction`)Python 的數" +"值型別的雜湊是基於一個數學函式,它對於任何有理數都是定義的,因此適用於所有 :" +"class:`int` 和 :class:`fractions.Fraction` 的實例,以及所有有限的 :class:" +"`float` 和 :class:`decimal.Decimal` 的實例。基本上,這個函式是由簡化的 modulo" +"(模數) ``P`` 給出的一個固定的質數 ``P``。``P`` 的值作為 :data:`sys." +"hash_info` 的 :attr:`~sys.hash_info.modulus` 屬性提供給 Python。" #: ../../library/stdtypes.rst:726 msgid "" @@ -1321,23 +1314,21 @@ msgstr "" #: ../../library/stdtypes.rst:748 msgid "" "For a :class:`complex` number ``z``, the hash values of the real and " -"imaginary parts are combined by computing ``hash(z.real) + " -"sys.hash_info.imag * hash(z.imag)``, reduced modulo " -"``2**sys.hash_info.width`` so that it lies in " -"``range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width - 1))``. " -"Again, if the result is ``-1``, it's replaced with ``-2``." +"imaginary parts are combined by computing ``hash(z.real) + sys.hash_info." +"imag * hash(z.imag)``, reduced modulo ``2**sys.hash_info.width`` so that it " +"lies in ``range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width - " +"1))``. Again, if the result is ``-1``, it's replaced with ``-2``." msgstr "" "對於一個 :class:`complex` 值 ``z``,實部和虛部的雜湊值藉由 ``hash(z.real) + " -"sys.hash_info.imag * hash(z.imag)`` 的計算進行組合,對 " -"``2**sys.hash_info.width`` 取模數使其介於 ``range(-2**(sys.hash_info.width - " -"1), 2**(sys.hash_info.width - 1))``。同樣地,如果結果是 ``-1``,則將其替換為 " -"``-2``。" +"sys.hash_info.imag * hash(z.imag)`` 的計算進行組合,對 ``2**sys.hash_info." +"width`` 取模數使其介於 ``range(-2**(sys.hash_info.width - 1), 2**(sys." +"hash_info.width - 1))``。同樣地,如果結果是 ``-1``,則將其替換為 ``-2``。" #: ../../library/stdtypes.rst:756 msgid "" "To clarify the above rules, here's some example Python code, equivalent to " -"the built-in hash, for computing the hash of a rational " -"number, :class:`float`, or :class:`complex`::" +"the built-in hash, for computing the hash of a rational number, :class:" +"`float`, or :class:`complex`::" msgstr "" "為了闡明上述規則,這裡有一些 Python 程式碼範例,等同於內建的雜湊,用於計算有" "理數、:class:`float` 或 :class:`complex` 的雜湊: ::" @@ -1384,8 +1375,8 @@ msgid "" "def hash_complex(z):\n" " \"\"\"Compute the hash of a complex number z.\"\"\"\n" "\n" -" hash_value = hash_float(z.real) + sys.hash_info.imag * " -"hash_float(z.imag)\n" +" hash_value = hash_float(z.real) + sys.hash_info.imag * hash_float(z." +"imag)\n" " # do a signed reduction modulo 2**sys.hash_info.width\n" " M = 2**(sys.hash_info.width - 1)\n" " hash_value = (hash_value & (M - 1)) - (hash_value & M)\n" @@ -1461,8 +1452,8 @@ msgstr "" #: ../../library/stdtypes.rst:858 msgid "" -"One method needs to be defined for container objects to " -"provide :term:`iterable` support:" +"One method needs to be defined for container objects to provide :term:" +"`iterable` support:" msgstr "" "需要為容器物件定義一個 method 來提供\\ :term:`可疊代物件 `\\ 支援:" @@ -1473,15 +1464,15 @@ msgid "" "of iteration, additional methods can be provided to specifically request " "iterators for those iteration types. (An example of an object supporting " "multiple forms of iteration would be a tree structure which supports both " -"breadth-first and depth-first traversal.) This method corresponds to " -"the :c:member:`~PyTypeObject.tp_iter` slot of the type structure for Python " -"objects in the Python/C API." +"breadth-first and depth-first traversal.) This method corresponds to the :c:" +"member:`~PyTypeObject.tp_iter` slot of the type structure for Python objects " +"in the Python/C API." msgstr "" "回傳一個\\ :term:`疊代器 `\\ 物件。該物件需要支援下述的疊代器協定。" "如果一個容器支援不同型別的疊代,則可以提供額外的 methods 來專門請求這些疊代型" "別的疊代器。(支援多種形式疊代的物件的一個例子是支援廣度優先和深度優先遍歷的" -"樹結構。)此 method 對應 Python/C API 中 Python 物件的型別結構" -"的 :c:member:`~PyTypeObject.tp_iter` 插槽。" +"樹結構。)此 method 對應 Python/C API 中 Python 物件的型別結構的 :c:member:" +"`~PyTypeObject.tp_iter` 插槽。" #: ../../library/stdtypes.rst:874 msgid "" @@ -1493,10 +1484,9 @@ msgstr "" #: ../../library/stdtypes.rst:880 msgid "" "Return the :term:`iterator` object itself. This is required to allow both " -"containers and iterators to be used with the :keyword:`for` " -"and :keyword:`in` statements. This method corresponds to " -"the :c:member:`~PyTypeObject.tp_iter` slot of the type structure for Python " -"objects in the Python/C API." +"containers and iterators to be used with the :keyword:`for` and :keyword:" +"`in` statements. This method corresponds to the :c:member:`~PyTypeObject." +"tp_iter` slot of the type structure for Python objects in the Python/C API." msgstr "" "回傳\\ :term:`疊代器 `\\ 物件本身。這是為了允許容器和疊代器都可以" "與 :keyword:`for` 和 :keyword:`in` 在陳述式中使用。此 method 對應於 Python/C " @@ -1509,9 +1499,9 @@ msgid "" "the :c:member:`~PyTypeObject.tp_iternext` slot of the type structure for " "Python objects in the Python/C API." msgstr "" -"從\\ :term:`疊代器 `\\ 回傳下一個項目。如果沒有更多項目,則引" -"發 :exc:`StopIteration` 例外。此 method 對應於 Python/C API 中Python 物件的型" -"別結構的 :c:member:`~PyTypeObject.tp_iternext` 插槽。" +"從\\ :term:`疊代器 `\\ 回傳下一個項目。如果沒有更多項目,則引發 :" +"exc:`StopIteration` 例外。此 method 對應於 Python/C API 中Python 物件的型別結" +"構的 :c:member:`~PyTypeObject.tp_iternext` 插槽。" #: ../../library/stdtypes.rst:894 msgid "" @@ -1525,8 +1515,8 @@ msgstr "" #: ../../library/stdtypes.rst:899 msgid "" -"Once an iterator's :meth:`~iterator.__next__` method " -"raises :exc:`StopIteration`, it must continue to do so on subsequent calls. " +"Once an iterator's :meth:`~iterator.__next__` method raises :exc:" +"`StopIteration`, it must continue to do so on subsequent calls. " "Implementations that do not obey this property are deemed broken." msgstr "" "一旦疊代器的 :meth:`~iterator.__next__` method 引發 :exc:`StopIteration`,則" @@ -1541,10 +1531,10 @@ msgid "" "Python's :term:`generator`\\s provide a convenient way to implement the " "iterator protocol. If a container object's :meth:`~object.__iter__` method " "is implemented as a generator, it will automatically return an iterator " -"object (technically, a generator object) supplying " -"the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods. More " -"information about generators can be found in :ref:`the documentation for the " -"yield expression `." +"object (technically, a generator object) supplying the :meth:`~iterator." +"__iter__` and :meth:`~generator.__next__` methods. More information about " +"generators can be found in :ref:`the documentation for the yield expression " +"`." msgstr "" #: ../../library/stdtypes.rst:921 @@ -1635,6 +1625,10 @@ msgstr "``s[i]``" msgid "*i*\\ th item of *s*, origin 0" msgstr "*s* 的第 *i* 項,起始為 0" +#: ../../library/stdtypes.rst:979 +msgid "(3)(9)" +msgstr "(3)(9)" + #: ../../library/stdtypes.rst:981 msgid "``s[i:j]``" msgstr "``s[i:j]``" @@ -1693,7 +1687,7 @@ msgid "" "before index *j*)" msgstr "" -#: ../../library/stdtypes.rst:992 ../../library/stdtypes.rst:3805 +#: ../../library/stdtypes.rst:992 ../../library/stdtypes.rst:3861 msgid "\\(8)" msgstr "\\(8)" @@ -1718,9 +1712,9 @@ msgstr "" msgid "" "Forward and reversed iterators over mutable sequences access values using an " "index. That index will continue to march forward (or backward) even if the " -"underlying sequence is mutated. The iterator terminates only when " -"an :exc:`IndexError` or a :exc:`StopIteration` is encountered (or when the " -"index drops below zero)." +"underlying sequence is mutated. The iterator terminates only when an :exc:" +"`IndexError` or a :exc:`StopIteration` is encountered (or when the index " +"drops below zero)." msgstr "" #: ../../library/stdtypes.rst:1019 @@ -1832,17 +1826,17 @@ msgstr "" #: ../../library/stdtypes.rst:1084 msgid "" -"if concatenating :class:`str` objects, you can build a list and " -"use :meth:`str.join` at the end or else write to an :class:`io.StringIO` " -"instance and retrieve its value when complete" +"if concatenating :class:`str` objects, you can build a list and use :meth:" +"`str.join` at the end or else write to an :class:`io.StringIO` instance and " +"retrieve its value when complete" msgstr "" #: ../../library/stdtypes.rst:1088 msgid "" -"if concatenating :class:`bytes` objects, you can similarly " -"use :meth:`bytes.join` or :class:`io.BytesIO`, or you can do in-place " -"concatenation with a :class:`bytearray` object. :class:`bytearray` objects " -"are mutable and have an efficient overallocation mechanism" +"if concatenating :class:`bytes` objects, you can similarly use :meth:`bytes." +"join` or :class:`io.BytesIO`, or you can do in-place concatenation with a :" +"class:`bytearray` object. :class:`bytearray` objects are mutable and have " +"an efficient overallocation mechanism" msgstr "" #: ../../library/stdtypes.rst:1093 @@ -1870,42 +1864,46 @@ msgid "" "start of the sequence rather than the start of the slice." msgstr "" -#: ../../library/stdtypes.rst:1115 +#: ../../library/stdtypes.rst:1112 +msgid "An :exc:`IndexError` is raised if *i* is outside the sequence range." +msgstr "" + +#: ../../library/stdtypes.rst:1118 msgid "Immutable Sequence Types" msgstr "" -#: ../../library/stdtypes.rst:1122 +#: ../../library/stdtypes.rst:1125 msgid "" "The only operation that immutable sequence types generally implement that is " -"not also implemented by mutable sequence types is support for " -"the :func:`hash` built-in." +"not also implemented by mutable sequence types is support for the :func:" +"`hash` built-in." msgstr "" -#: ../../library/stdtypes.rst:1126 +#: ../../library/stdtypes.rst:1129 msgid "" "This support allows immutable sequences, such as :class:`tuple` instances, " -"to be used as :class:`dict` keys and stored in :class:`set` " -"and :class:`frozenset` instances." +"to be used as :class:`dict` keys and stored in :class:`set` and :class:" +"`frozenset` instances." msgstr "" -#: ../../library/stdtypes.rst:1130 +#: ../../library/stdtypes.rst:1133 msgid "" "Attempting to hash an immutable sequence that contains unhashable values " "will result in :exc:`TypeError`." msgstr "" -#: ../../library/stdtypes.rst:1137 +#: ../../library/stdtypes.rst:1140 msgid "Mutable Sequence Types" msgstr "" -#: ../../library/stdtypes.rst:1144 +#: ../../library/stdtypes.rst:1147 msgid "" "The operations in the following table are defined on mutable sequence types. " "The :class:`collections.abc.MutableSequence` ABC is provided to make it " "easier to correctly implement these operations on custom sequence types." msgstr "" -#: ../../library/stdtypes.rst:1148 +#: ../../library/stdtypes.rst:1151 msgid "" "In the table *s* is an instance of a mutable sequence type, *t* is any " "iterable object and *x* is an arbitrary object that meets any type and value " @@ -1913,201 +1911,208 @@ msgid "" "integers that meet the value restriction ``0 <= x <= 255``)." msgstr "" -#: ../../library/stdtypes.rst:1172 +#: ../../library/stdtypes.rst:1175 msgid "``s[i] = x``" msgstr "``s[i] = x``" -#: ../../library/stdtypes.rst:1172 +#: ../../library/stdtypes.rst:1175 msgid "item *i* of *s* is replaced by *x*" msgstr "" -#: ../../library/stdtypes.rst:1175 +#: ../../library/stdtypes.rst:1178 +msgid "``del s[i]``" +msgstr "``del s[i]``" + +#: ../../library/stdtypes.rst:1178 +msgid "removes item *i* of *s*" +msgstr "移除 *s* 中的項目 *i*" + +#: ../../library/stdtypes.rst:1180 msgid "``s[i:j] = t``" msgstr "``s[i:j] = t``" -#: ../../library/stdtypes.rst:1175 +#: ../../library/stdtypes.rst:1180 msgid "" "slice of *s* from *i* to *j* is replaced by the contents of the iterable *t*" msgstr "" -#: ../../library/stdtypes.rst:1179 +#: ../../library/stdtypes.rst:1184 msgid "``del s[i:j]``" msgstr "``del s[i:j]``" -#: ../../library/stdtypes.rst:1179 +#: ../../library/stdtypes.rst:1184 msgid "same as ``s[i:j] = []``" -msgstr "" +msgstr "和 ``s[i:j] = []`` 相同" -#: ../../library/stdtypes.rst:1181 +#: ../../library/stdtypes.rst:1186 msgid "``s[i:j:k] = t``" msgstr "``s[i:j:k] = t``" -#: ../../library/stdtypes.rst:1181 +#: ../../library/stdtypes.rst:1186 msgid "the elements of ``s[i:j:k]`` are replaced by those of *t*" -msgstr "" +msgstr "``s[i:j:k]`` 的元素被 *t* 的元素取代" -#: ../../library/stdtypes.rst:1184 +#: ../../library/stdtypes.rst:1189 msgid "``del s[i:j:k]``" msgstr "``del s[i:j:k]``" -#: ../../library/stdtypes.rst:1184 +#: ../../library/stdtypes.rst:1189 msgid "removes the elements of ``s[i:j:k]`` from the list" -msgstr "" +msgstr "移除串列中 ``s[i:j:k]`` 的元素" -#: ../../library/stdtypes.rst:1187 +#: ../../library/stdtypes.rst:1192 msgid "``s.append(x)``" msgstr "``s.append(x)``" -#: ../../library/stdtypes.rst:1187 +#: ../../library/stdtypes.rst:1192 msgid "" "appends *x* to the end of the sequence (same as ``s[len(s):len(s)] = [x]``)" msgstr "" -#: ../../library/stdtypes.rst:1191 +#: ../../library/stdtypes.rst:1196 msgid "``s.clear()``" msgstr "``s.clear()``" -#: ../../library/stdtypes.rst:1191 +#: ../../library/stdtypes.rst:1196 msgid "removes all items from *s* (same as ``del s[:]``)" -msgstr "" +msgstr "移除 *s* 中的所有項目(和 ``del s[:]`` 相同)" -#: ../../library/stdtypes.rst:1194 +#: ../../library/stdtypes.rst:1199 msgid "``s.copy()``" msgstr "``s.copy()``" -#: ../../library/stdtypes.rst:1194 +#: ../../library/stdtypes.rst:1199 msgid "creates a shallow copy of *s* (same as ``s[:]``)" -msgstr "" +msgstr "建立 *s* 的淺層複製(和 ``s[:]`` 相同)" -#: ../../library/stdtypes.rst:1197 +#: ../../library/stdtypes.rst:1202 msgid "``s.extend(t)`` or ``s += t``" msgstr "``s.extend(t)`` 或 ``s += t``" -#: ../../library/stdtypes.rst:1197 +#: ../../library/stdtypes.rst:1202 msgid "" "extends *s* with the contents of *t* (for the most part the same as " "``s[len(s):len(s)] = t``)" msgstr "" -#: ../../library/stdtypes.rst:1202 +#: ../../library/stdtypes.rst:1207 msgid "``s *= n``" msgstr "``s *= n``" -#: ../../library/stdtypes.rst:1202 +#: ../../library/stdtypes.rst:1207 msgid "updates *s* with its contents repeated *n* times" msgstr "" -#: ../../library/stdtypes.rst:1205 +#: ../../library/stdtypes.rst:1210 msgid "``s.insert(i, x)``" msgstr "``s.insert(i, x)``" -#: ../../library/stdtypes.rst:1205 +#: ../../library/stdtypes.rst:1210 msgid "" "inserts *x* into *s* at the index given by *i* (same as ``s[i:i] = [x]``)" msgstr "" -#: ../../library/stdtypes.rst:1209 +#: ../../library/stdtypes.rst:1214 msgid "``s.pop()`` or ``s.pop(i)``" msgstr "``s.pop()`` 或 ``s.pop(i)``" -#: ../../library/stdtypes.rst:1209 +#: ../../library/stdtypes.rst:1214 msgid "retrieves the item at *i* and also removes it from *s*" msgstr "" -#: ../../library/stdtypes.rst:1212 +#: ../../library/stdtypes.rst:1217 msgid "``s.remove(x)``" msgstr "``s.remove(x)``" -#: ../../library/stdtypes.rst:1212 +#: ../../library/stdtypes.rst:1217 msgid "removes the first item from *s* where ``s[i]`` is equal to *x*" msgstr "" -#: ../../library/stdtypes.rst:1216 +#: ../../library/stdtypes.rst:1221 msgid "``s.reverse()``" msgstr "``s.reverse()``" -#: ../../library/stdtypes.rst:1216 +#: ../../library/stdtypes.rst:1221 msgid "reverses the items of *s* in place" msgstr "" -#: ../../library/stdtypes.rst:1224 +#: ../../library/stdtypes.rst:1229 msgid "" "If *k* is not equal to ``1``, *t* must have the same length as the slice it " "is replacing." msgstr "" -#: ../../library/stdtypes.rst:1227 +#: ../../library/stdtypes.rst:1232 msgid "" "The optional argument *i* defaults to ``-1``, so that by default the last " "item is removed and returned." msgstr "" -#: ../../library/stdtypes.rst:1231 +#: ../../library/stdtypes.rst:1236 msgid ":meth:`remove` raises :exc:`ValueError` when *x* is not found in *s*." msgstr "" -#: ../../library/stdtypes.rst:1234 +#: ../../library/stdtypes.rst:1239 msgid "" "The :meth:`reverse` method modifies the sequence in place for economy of " "space when reversing a large sequence. To remind users that it operates by " "side effect, it does not return the reversed sequence." msgstr "" -#: ../../library/stdtypes.rst:1239 +#: ../../library/stdtypes.rst:1244 msgid "" ":meth:`clear` and :meth:`!copy` are included for consistency with the " "interfaces of mutable containers that don't support slicing operations (such " -"as :class:`dict` and :class:`set`). :meth:`!copy` is not part of " -"the :class:`collections.abc.MutableSequence` ABC, but most concrete mutable " -"sequence classes provide it." +"as :class:`dict` and :class:`set`). :meth:`!copy` is not part of the :class:" +"`collections.abc.MutableSequence` ABC, but most concrete mutable sequence " +"classes provide it." msgstr "" -#: ../../library/stdtypes.rst:1245 +#: ../../library/stdtypes.rst:1250 msgid ":meth:`clear` and :meth:`!copy` methods." -msgstr "" +msgstr ":meth:`clear` 和 :meth:`!copy` 方法。" -#: ../../library/stdtypes.rst:1249 +#: ../../library/stdtypes.rst:1254 msgid "" -"The value *n* is an integer, or an object " -"implementing :meth:`~object.__index__`. Zero and negative values of *n* " -"clear the sequence. Items in the sequence are not copied; they are " -"referenced multiple times, as explained for ``s * n`` under :ref:`typesseq-" -"common`." +"The value *n* is an integer, or an object implementing :meth:`~object." +"__index__`. Zero and negative values of *n* clear the sequence. Items in " +"the sequence are not copied; they are referenced multiple times, as " +"explained for ``s * n`` under :ref:`typesseq-common`." msgstr "" -#: ../../library/stdtypes.rst:1258 +#: ../../library/stdtypes.rst:1263 msgid "Lists" msgstr "List(串列)" -#: ../../library/stdtypes.rst:1262 +#: ../../library/stdtypes.rst:1267 msgid "" "Lists are mutable sequences, typically used to store collections of " "homogeneous items (where the precise degree of similarity will vary by " "application)." msgstr "" -#: ../../library/stdtypes.rst:1268 +#: ../../library/stdtypes.rst:1273 msgid "Lists may be constructed in several ways:" msgstr "" -#: ../../library/stdtypes.rst:1270 +#: ../../library/stdtypes.rst:1275 msgid "Using a pair of square brackets to denote the empty list: ``[]``" msgstr "" -#: ../../library/stdtypes.rst:1271 +#: ../../library/stdtypes.rst:1276 msgid "" "Using square brackets, separating items with commas: ``[a]``, ``[a, b, c]``" msgstr "" -#: ../../library/stdtypes.rst:1272 +#: ../../library/stdtypes.rst:1277 msgid "Using a list comprehension: ``[x for x in iterable]``" msgstr "" -#: ../../library/stdtypes.rst:1273 +#: ../../library/stdtypes.rst:1278 msgid "Using the type constructor: ``list()`` or ``list(iterable)``" msgstr "" -#: ../../library/stdtypes.rst:1275 +#: ../../library/stdtypes.rst:1280 msgid "" "The constructor builds a list whose items are the same and in the same order " "as *iterable*'s items. *iterable* may be either a sequence, a container " @@ -2118,20 +2123,20 @@ msgid "" "new empty list, ``[]``." msgstr "" -#: ../../library/stdtypes.rst:1284 +#: ../../library/stdtypes.rst:1289 msgid "" "Many other operations also produce lists, including the :func:`sorted` built-" "in." msgstr "" -#: ../../library/stdtypes.rst:1287 +#: ../../library/stdtypes.rst:1292 msgid "" "Lists implement all of the :ref:`common ` and :ref:`mutable " "` sequence operations. Lists also provide the following " "additional method:" msgstr "" -#: ../../library/stdtypes.rst:1293 +#: ../../library/stdtypes.rst:1298 msgid "" "This method sorts the list in place, using only ``<`` comparisons between " "items. Exceptions are not suppressed - if any comparison operations fail, " @@ -2139,13 +2144,13 @@ msgid "" "partially modified state)." msgstr "" -#: ../../library/stdtypes.rst:1298 +#: ../../library/stdtypes.rst:1303 msgid "" -":meth:`sort` accepts two arguments that can only be passed by keyword " -"(:ref:`keyword-only arguments `):" +":meth:`sort` accepts two arguments that can only be passed by keyword (:ref:" +"`keyword-only arguments `):" msgstr "" -#: ../../library/stdtypes.rst:1301 +#: ../../library/stdtypes.rst:1306 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each list element (for example, ``key=str.lower``). The " @@ -2154,19 +2159,19 @@ msgid "" "list items are sorted directly without calculating a separate key value." msgstr "" -#: ../../library/stdtypes.rst:1308 +#: ../../library/stdtypes.rst:1313 msgid "" "The :func:`functools.cmp_to_key` utility is available to convert a 2.x style " "*cmp* function to a *key* function." msgstr "" -#: ../../library/stdtypes.rst:1311 +#: ../../library/stdtypes.rst:1316 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../library/stdtypes.rst:1314 +#: ../../library/stdtypes.rst:1319 msgid "" "This method modifies the sequence in place for economy of space when sorting " "a large sequence. To remind users that it operates by side effect, it does " @@ -2174,7 +2179,7 @@ msgid "" "new sorted list instance)." msgstr "" -#: ../../library/stdtypes.rst:1319 +#: ../../library/stdtypes.rst:1324 msgid "" "The :meth:`sort` method is guaranteed to be stable. A sort is stable if it " "guarantees not to change the relative order of elements that compare equal " @@ -2182,12 +2187,12 @@ msgid "" "department, then by salary grade)." msgstr "" -#: ../../library/stdtypes.rst:1324 +#: ../../library/stdtypes.rst:1329 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/stdtypes.rst:1328 +#: ../../library/stdtypes.rst:1333 msgid "" "While a list is being sorted, the effect of attempting to mutate, or even " "inspect, the list is undefined. The C implementation of Python makes the " @@ -2195,40 +2200,40 @@ msgid "" "detect that the list has been mutated during a sort." msgstr "" -#: ../../library/stdtypes.rst:1337 +#: ../../library/stdtypes.rst:1342 msgid "Tuples" msgstr "" -#: ../../library/stdtypes.rst:1341 +#: ../../library/stdtypes.rst:1346 msgid "" "Tuples are immutable sequences, typically used to store collections of " "heterogeneous data (such as the 2-tuples produced by the :func:`enumerate` " "built-in). Tuples are also used for cases where an immutable sequence of " -"homogeneous data is needed (such as allowing storage in a :class:`set` " -"or :class:`dict` instance)." +"homogeneous data is needed (such as allowing storage in a :class:`set` or :" +"class:`dict` instance)." msgstr "" -#: ../../library/stdtypes.rst:1349 +#: ../../library/stdtypes.rst:1354 msgid "Tuples may be constructed in a number of ways:" msgstr "" -#: ../../library/stdtypes.rst:1351 +#: ../../library/stdtypes.rst:1356 msgid "Using a pair of parentheses to denote the empty tuple: ``()``" msgstr "" -#: ../../library/stdtypes.rst:1352 +#: ../../library/stdtypes.rst:1357 msgid "Using a trailing comma for a singleton tuple: ``a,`` or ``(a,)``" msgstr "" -#: ../../library/stdtypes.rst:1353 +#: ../../library/stdtypes.rst:1358 msgid "Separating items with commas: ``a, b, c`` or ``(a, b, c)``" msgstr "" -#: ../../library/stdtypes.rst:1354 +#: ../../library/stdtypes.rst:1359 msgid "Using the :func:`tuple` built-in: ``tuple()`` or ``tuple(iterable)``" msgstr "" -#: ../../library/stdtypes.rst:1356 +#: ../../library/stdtypes.rst:1361 msgid "" "The constructor builds a tuple whose items are the same and in the same " "order as *iterable*'s items. *iterable* may be either a sequence, a " @@ -2239,7 +2244,7 @@ msgid "" "``()``." msgstr "" -#: ../../library/stdtypes.rst:1364 +#: ../../library/stdtypes.rst:1369 msgid "" "Note that it is actually the comma which makes a tuple, not the parentheses. " "The parentheses are optional, except in the empty tuple case, or when they " @@ -2248,70 +2253,70 @@ msgid "" "call with a 3-tuple as the sole argument." msgstr "" -#: ../../library/stdtypes.rst:1370 +#: ../../library/stdtypes.rst:1375 msgid "" "Tuples implement all of the :ref:`common ` sequence " "operations." msgstr "" -#: ../../library/stdtypes.rst:1373 +#: ../../library/stdtypes.rst:1378 msgid "" "For heterogeneous collections of data where access by name is clearer than " "access by index, :func:`collections.namedtuple` may be a more appropriate " "choice than a simple tuple object." msgstr "" -#: ../../library/stdtypes.rst:1381 +#: ../../library/stdtypes.rst:1386 msgid "Ranges" msgstr "" -#: ../../library/stdtypes.rst:1385 +#: ../../library/stdtypes.rst:1390 msgid "" "The :class:`range` type represents an immutable sequence of numbers and is " "commonly used for looping a specific number of times in :keyword:`for` loops." msgstr "" -#: ../../library/stdtypes.rst:1392 +#: ../../library/stdtypes.rst:1397 msgid "" -"The arguments to the range constructor must be integers (either built-" -"in :class:`int` or any object that implements the :meth:`~object.__index__` " +"The arguments to the range constructor must be integers (either built-in :" +"class:`int` or any object that implements the :meth:`~object.__index__` " "special method). If the *step* argument is omitted, it defaults to ``1``. " "If the *start* argument is omitted, it defaults to ``0``. If *step* is " "zero, :exc:`ValueError` is raised." msgstr "" -#: ../../library/stdtypes.rst:1398 +#: ../../library/stdtypes.rst:1403 msgid "" "For a positive *step*, the contents of a range ``r`` are determined by the " "formula ``r[i] = start + step*i`` where ``i >= 0`` and ``r[i] < stop``." msgstr "" -#: ../../library/stdtypes.rst:1402 +#: ../../library/stdtypes.rst:1407 msgid "" "For a negative *step*, the contents of the range are still determined by the " "formula ``r[i] = start + step*i``, but the constraints are ``i >= 0`` and " "``r[i] > stop``." msgstr "" -#: ../../library/stdtypes.rst:1406 +#: ../../library/stdtypes.rst:1411 msgid "" "A range object will be empty if ``r[0]`` does not meet the value constraint. " "Ranges do support negative indices, but these are interpreted as indexing " "from the end of the sequence determined by the positive indices." msgstr "" -#: ../../library/stdtypes.rst:1411 +#: ../../library/stdtypes.rst:1416 msgid "" "Ranges containing absolute values larger than :data:`sys.maxsize` are " -"permitted but some features (such as :func:`len`) may " -"raise :exc:`OverflowError`." +"permitted but some features (such as :func:`len`) may raise :exc:" +"`OverflowError`." msgstr "" -#: ../../library/stdtypes.rst:1415 +#: ../../library/stdtypes.rst:1420 msgid "Range examples::" msgstr "" -#: ../../library/stdtypes.rst:1417 +#: ../../library/stdtypes.rst:1422 msgid "" ">>> list(range(10))\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" @@ -2343,7 +2348,7 @@ msgstr "" ">>> list(range(1, 0))\n" "[]" -#: ../../library/stdtypes.rst:1432 +#: ../../library/stdtypes.rst:1437 msgid "" "Ranges implement all of the :ref:`common ` sequence " "operations except concatenation and repetition (due to the fact that range " @@ -2351,39 +2356,39 @@ msgid "" "repetition and concatenation will usually violate that pattern)." msgstr "" -#: ../../library/stdtypes.rst:1439 +#: ../../library/stdtypes.rst:1444 msgid "" "The value of the *start* parameter (or ``0`` if the parameter was not " "supplied)" msgstr "" -#: ../../library/stdtypes.rst:1444 +#: ../../library/stdtypes.rst:1449 msgid "The value of the *stop* parameter" msgstr "" -#: ../../library/stdtypes.rst:1448 +#: ../../library/stdtypes.rst:1453 msgid "" "The value of the *step* parameter (or ``1`` if the parameter was not " "supplied)" msgstr "" -#: ../../library/stdtypes.rst:1451 +#: ../../library/stdtypes.rst:1456 msgid "" -"The advantage of the :class:`range` type over a regular :class:`list` " -"or :class:`tuple` is that a :class:`range` object will always take the same " +"The advantage of the :class:`range` type over a regular :class:`list` or :" +"class:`tuple` is that a :class:`range` object will always take the same " "(small) amount of memory, no matter the size of the range it represents (as " "it only stores the ``start``, ``stop`` and ``step`` values, calculating " "individual items and subranges as needed)." msgstr "" -#: ../../library/stdtypes.rst:1457 +#: ../../library/stdtypes.rst:1462 msgid "" "Range objects implement the :class:`collections.abc.Sequence` ABC, and " "provide features such as containment tests, element index lookup, slicing " "and support for negative indices (see :ref:`typesseq`):" msgstr "" -#: ../../library/stdtypes.rst:1477 +#: ../../library/stdtypes.rst:1482 msgid "" "Testing range objects for equality with ``==`` and ``!=`` compares them as " "sequences. That is, two range objects are considered equal if they " @@ -2393,133 +2398,133 @@ msgid "" "3)`` or ``range(0, 3, 2) == range(0, 4, 2)``.)" msgstr "" -#: ../../library/stdtypes.rst:1484 +#: ../../library/stdtypes.rst:1489 msgid "" -"Implement the Sequence ABC. Support slicing and negative indices. " -"Test :class:`int` objects for membership in constant time instead of " -"iterating through all items." +"Implement the Sequence ABC. Support slicing and negative indices. Test :" +"class:`int` objects for membership in constant time instead of iterating " +"through all items." msgstr "" -#: ../../library/stdtypes.rst:1490 +#: ../../library/stdtypes.rst:1495 msgid "" "Define '==' and '!=' to compare range objects based on the sequence of " "values they define (instead of comparing based on object identity)." msgstr "" -#: ../../library/stdtypes.rst:1495 +#: ../../library/stdtypes.rst:1500 msgid "" "Added the :attr:`~range.start`, :attr:`~range.stop` and :attr:`~range.step` " "attributes." msgstr "" -#: ../../library/stdtypes.rst:1500 +#: ../../library/stdtypes.rst:1505 msgid "" "The `linspace recipe `_ shows how to implement a lazy version of range " "suitable for floating-point applications." msgstr "" -#: ../../library/stdtypes.rst:1512 +#: ../../library/stdtypes.rst:1517 msgid "Text Sequence Type --- :class:`str`" msgstr "" -#: ../../library/stdtypes.rst:1514 +#: ../../library/stdtypes.rst:1519 msgid "" -"Textual data in Python is handled with :class:`str` objects, " -"or :dfn:`strings`. Strings are immutable :ref:`sequences ` of " -"Unicode code points. String literals are written in a variety of ways:" +"Textual data in Python is handled with :class:`str` objects, or :dfn:" +"`strings`. Strings are immutable :ref:`sequences ` of Unicode code " +"points. String literals are written in a variety of ways:" msgstr "" -#: ../../library/stdtypes.rst:1519 +#: ../../library/stdtypes.rst:1524 msgid "Single quotes: ``'allows embedded \"double\" quotes'``" msgstr "" -#: ../../library/stdtypes.rst:1520 +#: ../../library/stdtypes.rst:1525 msgid "Double quotes: ``\"allows embedded 'single' quotes\"``" msgstr "" -#: ../../library/stdtypes.rst:1521 +#: ../../library/stdtypes.rst:1526 msgid "" "Triple quoted: ``'''Three single quotes'''``, ``\"\"\"Three double " "quotes\"\"\"``" msgstr "" -#: ../../library/stdtypes.rst:1523 +#: ../../library/stdtypes.rst:1528 msgid "" "Triple quoted strings may span multiple lines - all associated whitespace " "will be included in the string literal." msgstr "" -#: ../../library/stdtypes.rst:1526 +#: ../../library/stdtypes.rst:1531 msgid "" "String literals that are part of a single expression and have only " "whitespace between them will be implicitly converted to a single string " "literal. That is, ``(\"spam \" \"eggs\") == \"spam eggs\"``." msgstr "" -#: ../../library/stdtypes.rst:1530 +#: ../../library/stdtypes.rst:1535 msgid "" "See :ref:`strings` for more about the various forms of string literal, " "including supported :ref:`escape sequences `, and the " "``r`` (\"raw\") prefix that disables most escape sequence processing." msgstr "" -#: ../../library/stdtypes.rst:1534 +#: ../../library/stdtypes.rst:1539 msgid "" "Strings may also be created from other objects using the :class:`str` " "constructor." msgstr "" -#: ../../library/stdtypes.rst:1537 +#: ../../library/stdtypes.rst:1542 msgid "" "Since there is no separate \"character\" type, indexing a string produces " "strings of length 1. That is, for a non-empty string *s*, ``s[0] == s[0:1]``." msgstr "" -#: ../../library/stdtypes.rst:1543 +#: ../../library/stdtypes.rst:1548 msgid "" -"There is also no mutable string type, but :meth:`str.join` " -"or :class:`io.StringIO` can be used to efficiently construct strings from " -"multiple fragments." +"There is also no mutable string type, but :meth:`str.join` or :class:`io." +"StringIO` can be used to efficiently construct strings from multiple " +"fragments." msgstr "" -#: ../../library/stdtypes.rst:1547 +#: ../../library/stdtypes.rst:1552 msgid "" "For backwards compatibility with the Python 2 series, the ``u`` prefix is " "once again permitted on string literals. It has no effect on the meaning of " "string literals and cannot be combined with the ``r`` prefix." msgstr "" -#: ../../library/stdtypes.rst:1559 +#: ../../library/stdtypes.rst:1564 msgid "" "Return a :ref:`string ` version of *object*. If *object* is not " "provided, returns the empty string. Otherwise, the behavior of ``str()`` " "depends on whether *encoding* or *errors* is given, as follows." msgstr "" -#: ../../library/stdtypes.rst:1563 +#: ../../library/stdtypes.rst:1568 msgid "" -"If neither *encoding* nor *errors* is given, ``str(object)`` " -"returns :meth:`type(object).__str__(object) `, which is the " -"\"informal\" or nicely printable string representation of *object*. For " -"string objects, this is the string itself. If *object* does not have " -"a :meth:`~object.__str__` method, then :func:`str` falls back to " -"returning :func:`repr(object) `." +"If neither *encoding* nor *errors* is given, ``str(object)`` returns :meth:" +"`type(object).__str__(object) `, which is the \"informal\" " +"or nicely printable string representation of *object*. For string objects, " +"this is the string itself. If *object* does not have a :meth:`~object." +"__str__` method, then :func:`str` falls back to returning :func:" +"`repr(object) `." msgstr "" -#: ../../library/stdtypes.rst:1575 +#: ../../library/stdtypes.rst:1580 msgid "" -"If at least one of *encoding* or *errors* is given, *object* should be " -"a :term:`bytes-like object` (e.g. :class:`bytes` or :class:`bytearray`). In " +"If at least one of *encoding* or *errors* is given, *object* should be a :" +"term:`bytes-like object` (e.g. :class:`bytes` or :class:`bytearray`). In " "this case, if *object* is a :class:`bytes` (or :class:`bytearray`) object, " -"then ``str(bytes, encoding, errors)`` is equivalent " -"to :meth:`bytes.decode(encoding, errors) `. Otherwise, the " -"bytes object underlying the buffer object is obtained before " -"calling :meth:`bytes.decode`. See :ref:`binaryseq` and :ref:`bufferobjects` " -"for information on buffer objects." +"then ``str(bytes, encoding, errors)`` is equivalent to :meth:`bytes." +"decode(encoding, errors) `. Otherwise, the bytes object " +"underlying the buffer object is obtained before calling :meth:`bytes." +"decode`. See :ref:`binaryseq` and :ref:`bufferobjects` for information on " +"buffer objects." msgstr "" -#: ../../library/stdtypes.rst:1584 +#: ../../library/stdtypes.rst:1589 msgid "" "Passing a :class:`bytes` object to :func:`str` without the *encoding* or " "*errors* arguments falls under the first case of returning the informal " @@ -2527,7 +2532,7 @@ msgid "" "Python). For example::" msgstr "" -#: ../../library/stdtypes.rst:1589 +#: ../../library/stdtypes.rst:1594 msgid "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" @@ -2535,141 +2540,191 @@ msgstr "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" -#: ../../library/stdtypes.rst:1592 +#: ../../library/stdtypes.rst:1597 msgid "" -"For more information on the ``str`` class and its methods, " -"see :ref:`textseq` and the :ref:`string-methods` section below. To output " -"formatted strings, see the :ref:`f-strings` and :ref:`formatstrings` " -"sections. In addition, see the :ref:`stringservices` section." +"For more information on the ``str`` class and its methods, see :ref:" +"`textseq` and the :ref:`string-methods` section below. To output formatted " +"strings, see the :ref:`f-strings` and :ref:`formatstrings` sections. In " +"addition, see the :ref:`stringservices` section." msgstr "" -#: ../../library/stdtypes.rst:1604 +#: ../../library/stdtypes.rst:1609 msgid "String Methods" msgstr "" -#: ../../library/stdtypes.rst:1609 +#: ../../library/stdtypes.rst:1614 msgid "" "Strings implement all of the :ref:`common ` sequence " "operations, along with the additional methods described below." msgstr "" -#: ../../library/stdtypes.rst:1612 +#: ../../library/stdtypes.rst:1617 msgid "" "Strings also support two styles of string formatting, one providing a large " -"degree of flexibility and customization " -"(see :meth:`str.format`, :ref:`formatstrings` and :ref:`string-formatting`) " -"and the other based on C ``printf`` style formatting that handles a narrower " -"range of types and is slightly harder to use correctly, but is often faster " -"for the cases it can handle (:ref:`old-string-formatting`)." +"degree of flexibility and customization (see :meth:`str.format`, :ref:" +"`formatstrings` and :ref:`string-formatting`) and the other based on C " +"``printf`` style formatting that handles a narrower range of types and is " +"slightly harder to use correctly, but is often faster for the cases it can " +"handle (:ref:`old-string-formatting`)." msgstr "" -#: ../../library/stdtypes.rst:1619 +#: ../../library/stdtypes.rst:1624 msgid "" "The :ref:`textservices` section of the standard library covers a number of " "other modules that provide various text related utilities (including regular " "expression support in the :mod:`re` module)." msgstr "" -#: ../../library/stdtypes.rst:1625 +#: ../../library/stdtypes.rst:1630 msgid "" "Return a copy of the string with its first character capitalized and the " "rest lowercased." msgstr "" -#: ../../library/stdtypes.rst:1628 +#: ../../library/stdtypes.rst:1633 msgid "" "The first character is now put into titlecase rather than uppercase. This " "means that characters like digraphs will only have their first letter " "capitalized, instead of the full character." msgstr "" -#: ../../library/stdtypes.rst:1635 +#: ../../library/stdtypes.rst:1640 msgid "" "Return a casefolded copy of the string. Casefolded strings may be used for " "caseless matching." msgstr "" -#: ../../library/stdtypes.rst:1638 +#: ../../library/stdtypes.rst:1643 msgid "" "Casefolding is similar to lowercasing but more aggressive because it is " "intended to remove all case distinctions in a string. For example, the " "German lowercase letter ``'ß'`` is equivalent to ``\"ss\"``. Since it is " -"already lowercase, :meth:`lower` would do nothing to " -"``'ß'``; :meth:`casefold` converts it to ``\"ss\"``." +"already lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:" +"`casefold` converts it to ``\"ss\"``." msgstr "" -#: ../../library/stdtypes.rst:1644 +#: ../../library/stdtypes.rst:1649 msgid "" "The casefolding algorithm is `described in section 3.13 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" -#: ../../library/stdtypes.rst:1653 +#: ../../library/stdtypes.rst:1658 msgid "" "Return centered in a string of length *width*. Padding is done using the " "specified *fillchar* (default is an ASCII space). The original string is " -"returned if *width* is less than or equal to ``len(s)``." +"returned if *width* is less than or equal to ``len(s)``. For example::" msgstr "" -#: ../../library/stdtypes.rst:1661 +#: ../../library/stdtypes.rst:1662 +msgid "" +">>> 'Python'.center(10)\n" +"' Python '\n" +">>> 'Python'.center(10, '-')\n" +"'--Python--'\n" +">>> 'Python'.center(4)\n" +"'Python'" +msgstr "" + +#: ../../library/stdtypes.rst:1672 msgid "" "Return the number of non-overlapping occurrences of substring *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../library/stdtypes.rst:1665 +#: ../../library/stdtypes.rst:1676 msgid "" "If *sub* is empty, returns the number of empty strings between characters " -"which is the length of the string plus one." +"which is the length of the string plus one. For example::" +msgstr "" + +#: ../../library/stdtypes.rst:1679 +msgid "" +">>> 'spam, spam, spam'.count('spam')\n" +"3\n" +">>> 'spam, spam, spam'.count('spam', 5)\n" +"2\n" +">>> 'spam, spam, spam'.count('spam', 5, 10)\n" +"1\n" +">>> 'spam, spam, spam'.count('eggs')\n" +"0\n" +">>> 'spam, spam, spam'.count('')\n" +"17" msgstr "" -#: ../../library/stdtypes.rst:1671 +#: ../../library/stdtypes.rst:1692 msgid "Return the string encoded to :class:`bytes`." msgstr "" -#: ../../library/stdtypes.rst:1673 ../../library/stdtypes.rst:2970 +#: ../../library/stdtypes.rst:1694 ../../library/stdtypes.rst:3026 msgid "" "*encoding* defaults to ``'utf-8'``; see :ref:`standard-encodings` for " "possible values." msgstr "" -#: ../../library/stdtypes.rst:1676 +#: ../../library/stdtypes.rst:1697 msgid "" "*errors* controls how encoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " "are ``'ignore'``, ``'replace'``, ``'xmlcharrefreplace'``, " -"``'backslashreplace'`` and any other name registered " -"via :func:`codecs.register_error`. See :ref:`error-handlers` for details." +"``'backslashreplace'`` and any other name registered via :func:`codecs." +"register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../library/stdtypes.rst:1683 +#: ../../library/stdtypes.rst:1704 msgid "" "For performance reasons, the value of *errors* is not checked for validity " -"unless an encoding error actually occurs, :ref:`devmode` is enabled or " -"a :ref:`debug build ` is used." +"unless an encoding error actually occurs, :ref:`devmode` is enabled or a :" +"ref:`debug build ` is used. For example::" +msgstr "" + +#: ../../library/stdtypes.rst:1710 +msgid "" +">>> encoded_str_to_bytes = 'Python'.encode()\n" +">>> type(encoded_str_to_bytes)\n" +"\n" +">>> encoded_str_to_bytes\n" +"b'Python'" msgstr "" -#: ../../library/stdtypes.rst:1688 ../../library/stdtypes.rst:2989 +#: ../../library/stdtypes.rst:1717 ../../library/stdtypes.rst:3045 msgid "Added support for keyword arguments." msgstr "新增關鍵字引數的支援。" -#: ../../library/stdtypes.rst:1691 ../../library/stdtypes.rst:2992 +#: ../../library/stdtypes.rst:1720 ../../library/stdtypes.rst:3048 msgid "" -"The value of the *errors* argument is now checked in :ref:`devmode` and " -"in :ref:`debug mode `." +"The value of the *errors* argument is now checked in :ref:`devmode` and in :" +"ref:`debug mode `." msgstr "" -#: ../../library/stdtypes.rst:1698 +#: ../../library/stdtypes.rst:1727 msgid "" "Return ``True`` if the string ends with the specified *suffix*, otherwise " "return ``False``. *suffix* can also be a tuple of suffixes to look for. " "With optional *start*, test beginning at that position. With optional " -"*end*, stop comparing at that position." +"*end*, stop comparing at that position. Using *start* and *end* is " +"equivalent to ``str[start:end].endswith(suffix)``. For example::" +msgstr "" + +#: ../../library/stdtypes.rst:1733 +msgid "" +">>> 'Python'.endswith('on')\n" +"True\n" +">>> 'a tuple of suffixes'.endswith(('at', 'in'))\n" +"False\n" +">>> 'a tuple of suffixes'.endswith(('at', 'es'))\n" +"True\n" +">>> 'Python is amazing'.endswith('is', 0, 9)\n" +"True" msgstr "" -#: ../../library/stdtypes.rst:1706 +#: ../../library/stdtypes.rst:1742 +msgid "See also :meth:`startswith` and :meth:`removesuffix`." +msgstr "" + +#: ../../library/stdtypes.rst:1747 msgid "" "Return a copy of the string where all tab characters are replaced by one or " "more spaces, depending on the current column and the given tab size. Tab " @@ -2682,24 +2737,40 @@ msgid "" "(``\\n``) or return (``\\r``), it is copied and the current column is reset " "to zero. Any other character is copied unchanged and the current column is " "incremented by one regardless of how the character is represented when " -"printed." +"printed. For example::" msgstr "" -#: ../../library/stdtypes.rst:1727 +#: ../../library/stdtypes.rst:1760 +#, fuzzy +msgid "" +">>> '01\\t012\\t0123\\t01234'.expandtabs()\n" +"'01 012 0123 01234'\n" +">>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n" +"'01 012 0123 01234'\n" +">>> print('01\\t012\\n0123\\t01234'.expandtabs(4))\n" +"01 012\n" +"0123 01234" +msgstr "" +">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" +"b'01 012 0123 01234'\n" +">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" +"b'01 012 0123 01234'" + +#: ../../library/stdtypes.rst:1771 msgid "" "Return the lowest index in the string where substring *sub* is found within " "the slice ``s[start:end]``. Optional arguments *start* and *end* are " "interpreted as in slice notation. Return ``-1`` if *sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:1733 +#: ../../library/stdtypes.rst:1777 msgid "" "The :meth:`~str.find` method should be used only if you need to know the " -"position of *sub*. To check if *sub* is a substring or not, use " -"the :keyword:`in` operator::" +"position of *sub*. To check if *sub* is a substring or not, use the :" +"keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:1737 +#: ../../library/stdtypes.rst:1781 msgid "" ">>> 'Py' in 'Python'\n" "True" @@ -2707,7 +2778,7 @@ msgstr "" ">>> 'Py' in 'Python'\n" "True" -#: ../../library/stdtypes.rst:1743 +#: ../../library/stdtypes.rst:1787 msgid "" "Perform a string formatting operation. The string on which this method is " "called can contain literal text or replacement fields delimited by braces " @@ -2717,71 +2788,70 @@ msgid "" "the corresponding argument." msgstr "" -#: ../../library/stdtypes.rst:1753 +#: ../../library/stdtypes.rst:1797 msgid "" "See :ref:`formatstrings` for a description of the various formatting options " "that can be specified in format strings." msgstr "" -#: ../../library/stdtypes.rst:1757 +#: ../../library/stdtypes.rst:1801 msgid "" -"When formatting a number " -"(:class:`int`, :class:`float`, :class:`complex`, :class:`decimal.Decimal` " -"and subclasses) with the ``n`` type (ex: ``'{:n}'.format(1234)``), the " -"function temporarily sets the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` " -"locale to decode ``decimal_point`` and ``thousands_sep`` fields " -"of :c:func:`localeconv` if they are non-ASCII or longer than 1 byte, and the " -"``LC_NUMERIC`` locale is different than the ``LC_CTYPE`` locale. This " -"temporary change affects other threads." +"When formatting a number (:class:`int`, :class:`float`, :class:`complex`, :" +"class:`decimal.Decimal` and subclasses) with the ``n`` type (ex: ``'{:n}'." +"format(1234)``), the function temporarily sets the ``LC_CTYPE`` locale to " +"the ``LC_NUMERIC`` locale to decode ``decimal_point`` and ``thousands_sep`` " +"fields of :c:func:`localeconv` if they are non-ASCII or longer than 1 byte, " +"and the ``LC_NUMERIC`` locale is different than the ``LC_CTYPE`` locale. " +"This temporary change affects other threads." msgstr "" -#: ../../library/stdtypes.rst:1766 +#: ../../library/stdtypes.rst:1810 msgid "" "When formatting a number with the ``n`` type, the function sets temporarily " "the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` locale in some cases." msgstr "" -#: ../../library/stdtypes.rst:1774 +#: ../../library/stdtypes.rst:1818 msgid "" "Similar to ``str.format(**mapping)``, except that ``mapping`` is used " "directly and not copied to a :class:`dict`. This is useful if for example " "``mapping`` is a dict subclass:" msgstr "" -#: ../../library/stdtypes.rst:1790 +#: ../../library/stdtypes.rst:1834 msgid "" "Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is " "not found." msgstr "" -#: ../../library/stdtypes.rst:1796 +#: ../../library/stdtypes.rst:1840 msgid "" "Return ``True`` if all characters in the string are alphanumeric and there " "is at least one character, ``False`` otherwise. A character ``c`` is " -"alphanumeric if one of the following returns ``True``: ``c.isalpha()``, " -"``c.isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``." +"alphanumeric if one of the following returns ``True``: ``c.isalpha()``, ``c." +"isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``." msgstr "" -#: ../../library/stdtypes.rst:1804 +#: ../../library/stdtypes.rst:1848 msgid "" "Return ``True`` if all characters in the string are alphabetic and there is " "at least one character, ``False`` otherwise. Alphabetic characters are " -"those characters defined in the Unicode character database as \"Letter\", " -"i.e., those with general category property being one of \"Lm\", \"Lt\", " +"those characters defined in the Unicode character database as \"Letter\", i." +"e., those with general category property being one of \"Lm\", \"Lt\", " "\"Lu\", \"Ll\", or \"Lo\". Note that this is different from the `Alphabetic " "property defined in the section 4.10 'Letters, Alphabetic, and Ideographic' " -"of the Unicode Standard `_." +"of the Unicode Standard `_." msgstr "" -#: ../../library/stdtypes.rst:1815 +#: ../../library/stdtypes.rst:1859 msgid "" "Return ``True`` if the string is empty or all characters in the string are " "ASCII, ``False`` otherwise. ASCII characters have code points in the range " "U+0000-U+007F." msgstr "" -#: ../../library/stdtypes.rst:1824 +#: ../../library/stdtypes.rst:1868 msgid "" "Return ``True`` if all characters in the string are decimal characters and " "there is at least one character, ``False`` otherwise. Decimal characters are " @@ -2790,7 +2860,7 @@ msgid "" "General Category \"Nd\"." msgstr "" -#: ../../library/stdtypes.rst:1834 +#: ../../library/stdtypes.rst:1878 msgid "" "Return ``True`` if all characters in the string are digits and there is at " "least one character, ``False`` otherwise. Digits include decimal characters " @@ -2800,23 +2870,23 @@ msgid "" "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" -#: ../../library/stdtypes.rst:1844 +#: ../../library/stdtypes.rst:1888 msgid "" "Return ``True`` if the string is a valid identifier according to the " "language definition, section :ref:`identifiers`." msgstr "" -#: ../../library/stdtypes.rst:1847 +#: ../../library/stdtypes.rst:1891 msgid "" ":func:`keyword.iskeyword` can be used to test whether string ``s`` is a " "reserved identifier, such as :keyword:`def` and :keyword:`class`." msgstr "" -#: ../../library/stdtypes.rst:1850 +#: ../../library/stdtypes.rst:1894 msgid "Example: ::" msgstr "範例: ::" -#: ../../library/stdtypes.rst:1853 +#: ../../library/stdtypes.rst:1897 msgid "" ">>> from keyword import iskeyword\n" "\n" @@ -2832,13 +2902,13 @@ msgstr "" ">>> 'def'.isidentifier(), iskeyword('def')\n" "(True, True)" -#: ../../library/stdtypes.rst:1863 +#: ../../library/stdtypes.rst:1907 msgid "" "Return ``True`` if all cased characters [4]_ in the string are lowercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:1869 +#: ../../library/stdtypes.rst:1913 msgid "" "Return ``True`` if all characters in the string are numeric characters, and " "there is at least one character, ``False`` otherwise. Numeric characters " @@ -2848,13 +2918,13 @@ msgid "" "Numeric_Type=Decimal or Numeric_Type=Numeric." msgstr "" -#: ../../library/stdtypes.rst:1879 +#: ../../library/stdtypes.rst:1923 msgid "" "Return ``True`` if all characters in the string are printable, ``False`` if " "it contains at least one non-printable character." msgstr "" -#: ../../library/stdtypes.rst:1882 +#: ../../library/stdtypes.rst:1926 msgid "" "Here \"printable\" means the character is suitable for :func:`repr` to use " "in its output; \"non-printable\" means that :func:`repr` on built-in types " @@ -2862,7 +2932,7 @@ msgid "" "written to :data:`sys.stdout` or :data:`sys.stderr`." msgstr "" -#: ../../library/stdtypes.rst:1887 +#: ../../library/stdtypes.rst:1931 msgid "" "The printable characters are those which in the Unicode character database " "(see :mod:`unicodedata`) have a general category in group Letter, Mark, " @@ -2871,21 +2941,20 @@ msgid "" "C), except the ASCII space." msgstr "" -#: ../../library/stdtypes.rst:1896 +#: ../../library/stdtypes.rst:1940 msgid "" "Return ``True`` if there are only whitespace characters in the string and " "there is at least one character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:1899 +#: ../../library/stdtypes.rst:1943 msgid "" -"A character is *whitespace* if in the Unicode character database " -"(see :mod:`unicodedata`), either its general category is ``Zs`` " -"(\"Separator, space\"), or its bidirectional class is one of ``WS``, ``B``, " -"or ``S``." +"A character is *whitespace* if in the Unicode character database (see :mod:" +"`unicodedata`), either its general category is ``Zs`` (\"Separator, " +"space\"), or its bidirectional class is one of ``WS``, ``B``, or ``S``." msgstr "" -#: ../../library/stdtypes.rst:1907 +#: ../../library/stdtypes.rst:1951 msgid "" "Return ``True`` if the string is a titlecased string and there is at least " "one character, for example uppercase characters may only follow uncased " @@ -2893,41 +2962,41 @@ msgid "" "otherwise." msgstr "" -#: ../../library/stdtypes.rst:1914 +#: ../../library/stdtypes.rst:1958 msgid "" "Return ``True`` if all cased characters [4]_ in the string are uppercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:1932 +#: ../../library/stdtypes.rst:1976 msgid "" -"Return a string which is the concatenation of the strings in *iterable*. " -"A :exc:`TypeError` will be raised if there are any non-string values in " +"Return a string which is the concatenation of the strings in *iterable*. A :" +"exc:`TypeError` will be raised if there are any non-string values in " "*iterable*, including :class:`bytes` objects. The separator between " "elements is the string providing this method." msgstr "" -#: ../../library/stdtypes.rst:1940 +#: ../../library/stdtypes.rst:1984 msgid "" "Return the string left justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:1947 +#: ../../library/stdtypes.rst:1991 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "lowercase." msgstr "" -#: ../../library/stdtypes.rst:1950 +#: ../../library/stdtypes.rst:1994 msgid "" "The lowercasing algorithm used is `described in section 3.13 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" -#: ../../library/stdtypes.rst:1957 +#: ../../library/stdtypes.rst:2001 msgid "" "Return a copy of the string with leading characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -2936,7 +3005,7 @@ msgid "" "are stripped::" msgstr "" -#: ../../library/stdtypes.rst:1962 +#: ../../library/stdtypes.rst:2006 msgid "" ">>> ' spacious '.lstrip()\n" "'spacious '\n" @@ -2948,13 +3017,13 @@ msgstr "" ">>> 'www.example.com'.lstrip('cmowz.')\n" "'example.com'" -#: ../../library/stdtypes.rst:1967 +#: ../../library/stdtypes.rst:2011 msgid "" "See :meth:`str.removeprefix` for a method that will remove a single prefix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:1970 +#: ../../library/stdtypes.rst:2014 msgid "" ">>> 'Arthur: three!'.lstrip('Arthur: ')\n" "'ee!'\n" @@ -2966,13 +3035,13 @@ msgstr "" ">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" "'three!'" -#: ../../library/stdtypes.rst:1978 +#: ../../library/stdtypes.rst:2022 msgid "" -"This static method returns a translation table usable " -"for :meth:`str.translate`." +"This static method returns a translation table usable for :meth:`str." +"translate`." msgstr "" -#: ../../library/stdtypes.rst:1980 +#: ../../library/stdtypes.rst:2024 msgid "" "If there is only one argument, it must be a dictionary mapping Unicode " "ordinals (integers) or characters (strings of length 1) to Unicode ordinals, " @@ -2980,7 +3049,7 @@ msgid "" "converted to ordinals." msgstr "" -#: ../../library/stdtypes.rst:1985 +#: ../../library/stdtypes.rst:2029 msgid "" "If there are two arguments, they must be strings of equal length, and in the " "resulting dictionary, each character in x will be mapped to the character at " @@ -2988,7 +3057,7 @@ msgid "" "whose characters will be mapped to ``None`` in the result." msgstr "" -#: ../../library/stdtypes.rst:1993 +#: ../../library/stdtypes.rst:2037 msgid "" "Split the string at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -2996,13 +3065,13 @@ msgid "" "containing the string itself, followed by two empty strings." msgstr "" -#: ../../library/stdtypes.rst:2001 +#: ../../library/stdtypes.rst:2045 msgid "" "If the string starts with the *prefix* string, return " "``string[len(prefix):]``. Otherwise, return a copy of the original string::" msgstr "" -#: ../../library/stdtypes.rst:2005 +#: ../../library/stdtypes.rst:2049 msgid "" ">>> 'TestHook'.removeprefix('Test')\n" "'Hook'\n" @@ -3014,14 +3083,14 @@ msgstr "" ">>> 'BaseTestCase'.removeprefix('Test')\n" "'BaseTestCase'" -#: ../../library/stdtypes.rst:2015 +#: ../../library/stdtypes.rst:2059 msgid "" "If the string ends with the *suffix* string and that *suffix* is not empty, " "return ``string[:-len(suffix)]``. Otherwise, return a copy of the original " "string::" msgstr "" -#: ../../library/stdtypes.rst:2019 +#: ../../library/stdtypes.rst:2063 msgid "" ">>> 'MiscTests'.removesuffix('Tests')\n" "'Misc'\n" @@ -3033,7 +3102,7 @@ msgstr "" ">>> 'TmpDirMixin'.removesuffix('Tests')\n" "'TmpDirMixin'" -#: ../../library/stdtypes.rst:2029 +#: ../../library/stdtypes.rst:2073 msgid "" "Return a copy of the string with all occurrences of substring *old* replaced " "by *new*. If *count* is given, only the first *count* occurrences are " @@ -3041,31 +3110,31 @@ msgid "" "replaced." msgstr "" -#: ../../library/stdtypes.rst:2033 +#: ../../library/stdtypes.rst:2077 msgid "*count* is now supported as a keyword argument." msgstr "*count* 現在作為關鍵字引數被支援。" -#: ../../library/stdtypes.rst:2039 +#: ../../library/stdtypes.rst:2083 msgid "" "Return the highest index in the string where substring *sub* is found, such " "that *sub* is contained within ``s[start:end]``. Optional arguments *start* " "and *end* are interpreted as in slice notation. Return ``-1`` on failure." msgstr "" -#: ../../library/stdtypes.rst:2046 +#: ../../library/stdtypes.rst:2090 msgid "" "Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is " "not found." msgstr "" -#: ../../library/stdtypes.rst:2052 +#: ../../library/stdtypes.rst:2096 msgid "" "Return the string right justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2059 +#: ../../library/stdtypes.rst:2103 msgid "" "Split the string at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -3073,7 +3142,7 @@ msgid "" "containing two empty strings, followed by the string itself." msgstr "" -#: ../../library/stdtypes.rst:2067 +#: ../../library/stdtypes.rst:2111 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done, the " @@ -3082,7 +3151,7 @@ msgid "" "behaves like :meth:`split` which is described in detail below." msgstr "" -#: ../../library/stdtypes.rst:2076 +#: ../../library/stdtypes.rst:2120 msgid "" "Return a copy of the string with trailing characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -3091,7 +3160,7 @@ msgid "" "are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2081 +#: ../../library/stdtypes.rst:2125 msgid "" ">>> ' spacious '.rstrip()\n" "' spacious'\n" @@ -3103,13 +3172,13 @@ msgstr "" ">>> 'mississippi'.rstrip('ipz')\n" "'mississ'" -#: ../../library/stdtypes.rst:2086 +#: ../../library/stdtypes.rst:2130 msgid "" "See :meth:`str.removesuffix` for a method that will remove a single suffix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:2089 +#: ../../library/stdtypes.rst:2133 msgid "" ">>> 'Monty Python'.rstrip(' Python')\n" "'M'\n" @@ -3121,7 +3190,7 @@ msgstr "" ">>> 'Monty Python'.removesuffix(' Python')\n" "'Monty'" -#: ../../library/stdtypes.rst:2096 +#: ../../library/stdtypes.rst:2140 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, " @@ -3130,30 +3199,30 @@ msgid "" "possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:2102 +#: ../../library/stdtypes.rst:2146 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns " "``['1', '', '2']``). The *sep* argument may consist of multiple characters " -"as a single delimiter (to split with multiple delimiters, " -"use :func:`re.split`). Splitting an empty string with a specified separator " -"returns ``['']``." -msgstr "" - -#: ../../library/stdtypes.rst:2109 ../../library/stdtypes.rst:2127 -#: ../../library/stdtypes.rst:2179 ../../library/stdtypes.rst:2247 -#: ../../library/stdtypes.rst:2315 ../../library/stdtypes.rst:3307 -#: ../../library/stdtypes.rst:3325 ../../library/stdtypes.rst:3416 -#: ../../library/stdtypes.rst:3432 ../../library/stdtypes.rst:3457 -#: ../../library/stdtypes.rst:3471 ../../library/stdtypes.rst:3499 -#: ../../library/stdtypes.rst:3513 ../../library/stdtypes.rst:3531 -#: ../../library/stdtypes.rst:3558 ../../library/stdtypes.rst:3581 -#: ../../library/stdtypes.rst:3608 ../../library/stdtypes.rst:3650 -#: ../../library/stdtypes.rst:3674 +"as a single delimiter (to split with multiple delimiters, use :func:`re." +"split`). Splitting an empty string with a specified separator returns " +"``['']``." +msgstr "" + +#: ../../library/stdtypes.rst:2153 ../../library/stdtypes.rst:2171 +#: ../../library/stdtypes.rst:2183 ../../library/stdtypes.rst:2235 +#: ../../library/stdtypes.rst:2303 ../../library/stdtypes.rst:2371 +#: ../../library/stdtypes.rst:3363 ../../library/stdtypes.rst:3381 +#: ../../library/stdtypes.rst:3472 ../../library/stdtypes.rst:3488 +#: ../../library/stdtypes.rst:3513 ../../library/stdtypes.rst:3527 +#: ../../library/stdtypes.rst:3555 ../../library/stdtypes.rst:3569 +#: ../../library/stdtypes.rst:3587 ../../library/stdtypes.rst:3614 +#: ../../library/stdtypes.rst:3637 ../../library/stdtypes.rst:3664 +#: ../../library/stdtypes.rst:3706 ../../library/stdtypes.rst:3730 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/stdtypes.rst:2111 +#: ../../library/stdtypes.rst:2155 msgid "" ">>> '1,2,3'.split(',')\n" "['1', '2', '3']\n" @@ -3173,7 +3242,7 @@ msgstr "" ">>> '1<>2<>3<4'.split('<>')\n" "['1', '2', '3<4']" -#: ../../library/stdtypes.rst:2120 +#: ../../library/stdtypes.rst:2164 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive whitespace are regarded as a single separator, " @@ -3183,7 +3252,7 @@ msgid "" "returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:2129 +#: ../../library/stdtypes.rst:2173 msgid "" ">>> '1 2 3'.split()\n" "['1', '2', '3']\n" @@ -3199,120 +3268,136 @@ msgstr "" ">>> ' 1 2 3 '.split()\n" "['1', '2', '3']" -#: ../../library/stdtypes.rst:2142 +#: ../../library/stdtypes.rst:2180 +msgid "" +"If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only " +"leading runs of consecutive whitespace are considered." +msgstr "" + +#: ../../library/stdtypes.rst:2185 +msgid "" +">>> \"\".split(None, 0)\n" +"[]\n" +">>> \" \".split(None, 0)\n" +"[]\n" +">>> \" foo \".split(maxsplit=0)\n" +"['foo ']" +msgstr "" + +#: ../../library/stdtypes.rst:2198 msgid "" "Return a list of the lines in the string, breaking at line boundaries. Line " "breaks are not included in the resulting list unless *keepends* is given and " "true." msgstr "" -#: ../../library/stdtypes.rst:2146 +#: ../../library/stdtypes.rst:2202 msgid "" "This method splits on the following line boundaries. In particular, the " "boundaries are a superset of :term:`universal newlines`." msgstr "" -#: ../../library/stdtypes.rst:2150 +#: ../../library/stdtypes.rst:2206 msgid "Representation" msgstr "" -#: ../../library/stdtypes.rst:2150 +#: ../../library/stdtypes.rst:2206 msgid "Description" msgstr "描述" -#: ../../library/stdtypes.rst:2152 +#: ../../library/stdtypes.rst:2208 msgid "``\\n``" msgstr "``\\n``" -#: ../../library/stdtypes.rst:2152 +#: ../../library/stdtypes.rst:2208 msgid "Line Feed" msgstr "" -#: ../../library/stdtypes.rst:2154 +#: ../../library/stdtypes.rst:2210 msgid "``\\r``" msgstr "``\\r``" -#: ../../library/stdtypes.rst:2154 +#: ../../library/stdtypes.rst:2210 msgid "Carriage Return" msgstr "" -#: ../../library/stdtypes.rst:2156 +#: ../../library/stdtypes.rst:2212 msgid "``\\r\\n``" msgstr "``\\r\\n``" -#: ../../library/stdtypes.rst:2156 +#: ../../library/stdtypes.rst:2212 msgid "Carriage Return + Line Feed" msgstr "" -#: ../../library/stdtypes.rst:2158 +#: ../../library/stdtypes.rst:2214 msgid "``\\v`` or ``\\x0b``" msgstr "``\\v`` 或 ``\\x0b``" -#: ../../library/stdtypes.rst:2158 +#: ../../library/stdtypes.rst:2214 msgid "Line Tabulation" msgstr "" -#: ../../library/stdtypes.rst:2160 +#: ../../library/stdtypes.rst:2216 msgid "``\\f`` or ``\\x0c``" msgstr "``\\f`` 或 ``\\x0c``" -#: ../../library/stdtypes.rst:2160 +#: ../../library/stdtypes.rst:2216 msgid "Form Feed" msgstr "" -#: ../../library/stdtypes.rst:2162 +#: ../../library/stdtypes.rst:2218 msgid "``\\x1c``" msgstr "``\\x1c``" -#: ../../library/stdtypes.rst:2162 +#: ../../library/stdtypes.rst:2218 msgid "File Separator" msgstr "" -#: ../../library/stdtypes.rst:2164 +#: ../../library/stdtypes.rst:2220 msgid "``\\x1d``" msgstr "``\\x1d``" -#: ../../library/stdtypes.rst:2164 +#: ../../library/stdtypes.rst:2220 msgid "Group Separator" msgstr "" -#: ../../library/stdtypes.rst:2166 +#: ../../library/stdtypes.rst:2222 msgid "``\\x1e``" msgstr "``\\x1e``" -#: ../../library/stdtypes.rst:2166 +#: ../../library/stdtypes.rst:2222 msgid "Record Separator" msgstr "" -#: ../../library/stdtypes.rst:2168 +#: ../../library/stdtypes.rst:2224 msgid "``\\x85``" msgstr "``\\x85``" -#: ../../library/stdtypes.rst:2168 +#: ../../library/stdtypes.rst:2224 msgid "Next Line (C1 Control Code)" msgstr "" -#: ../../library/stdtypes.rst:2170 +#: ../../library/stdtypes.rst:2226 msgid "``\\u2028``" msgstr "``\\u2028``" -#: ../../library/stdtypes.rst:2170 +#: ../../library/stdtypes.rst:2226 msgid "Line Separator" msgstr "" -#: ../../library/stdtypes.rst:2172 +#: ../../library/stdtypes.rst:2228 msgid "``\\u2029``" msgstr "``\\u2029``" -#: ../../library/stdtypes.rst:2172 +#: ../../library/stdtypes.rst:2228 msgid "Paragraph Separator" msgstr "" -#: ../../library/stdtypes.rst:2177 +#: ../../library/stdtypes.rst:2233 msgid "``\\v`` and ``\\f`` added to list of line boundaries." msgstr "" -#: ../../library/stdtypes.rst:2181 +#: ../../library/stdtypes.rst:2237 msgid "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "['ab c', '', 'de fg', 'kl']\n" @@ -3324,14 +3409,14 @@ msgstr "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" -#: ../../library/stdtypes.rst:2186 +#: ../../library/stdtypes.rst:2242 msgid "" "Unlike :meth:`~str.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:2190 +#: ../../library/stdtypes.rst:2246 msgid "" ">>> \"\".splitlines()\n" "[]\n" @@ -3343,11 +3428,11 @@ msgstr "" ">>> \"One line\\n\".splitlines()\n" "['One line']" -#: ../../library/stdtypes.rst:2195 +#: ../../library/stdtypes.rst:2251 msgid "For comparison, ``split('\\n')`` gives::" msgstr "" -#: ../../library/stdtypes.rst:2197 +#: ../../library/stdtypes.rst:2253 msgid "" ">>> ''.split('\\n')\n" "['']\n" @@ -3359,7 +3444,7 @@ msgstr "" ">>> 'Two lines\\n'.split('\\n')\n" "['Two lines', '']" -#: ../../library/stdtypes.rst:2205 +#: ../../library/stdtypes.rst:2261 msgid "" "Return ``True`` if string starts with the *prefix*, otherwise return " "``False``. *prefix* can also be a tuple of prefixes to look for. With " @@ -3367,7 +3452,7 @@ msgid "" "*end*, stop comparing string at that position." msgstr "" -#: ../../library/stdtypes.rst:2213 +#: ../../library/stdtypes.rst:2269 msgid "" "Return a copy of the string with the leading and trailing characters " "removed. The *chars* argument is a string specifying the set of characters " @@ -3376,7 +3461,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2219 +#: ../../library/stdtypes.rst:2275 msgid "" ">>> ' spacious '.strip()\n" "'spacious'\n" @@ -3388,7 +3473,7 @@ msgstr "" ">>> 'www.example.com'.strip('cmowz.')\n" "'example'" -#: ../../library/stdtypes.rst:2224 +#: ../../library/stdtypes.rst:2280 msgid "" "The outermost leading and trailing *chars* argument values are stripped from " "the string. Characters are removed from the leading end until reaching a " @@ -3396,7 +3481,7 @@ msgid "" "A similar action takes place on the trailing end. For example::" msgstr "" -#: ../../library/stdtypes.rst:2230 +#: ../../library/stdtypes.rst:2286 msgid "" ">>> comment_string = '#....... Section 3.2.1 Issue #32 .......'\n" ">>> comment_string.strip('.#! ')\n" @@ -3406,20 +3491,20 @@ msgstr "" ">>> comment_string.strip('.#! ')\n" "'Section 3.2.1 Issue #32'" -#: ../../library/stdtypes.rst:2237 +#: ../../library/stdtypes.rst:2293 msgid "" "Return a copy of the string with uppercase characters converted to lowercase " -"and vice versa. Note that it is not necessarily true that " -"``s.swapcase().swapcase() == s``." +"and vice versa. Note that it is not necessarily true that ``s.swapcase()." +"swapcase() == s``." msgstr "" -#: ../../library/stdtypes.rst:2244 +#: ../../library/stdtypes.rst:2300 msgid "" "Return a titlecased version of the string where words start with an " "uppercase character and the remaining characters are lowercase." msgstr "" -#: ../../library/stdtypes.rst:2249 +#: ../../library/stdtypes.rst:2305 msgid "" ">>> 'Hello world'.title()\n" "'Hello World'" @@ -3427,7 +3512,7 @@ msgstr "" ">>> 'Hello world'.title()\n" "'Hello World'" -#: ../../library/stdtypes.rst:2252 ../../library/stdtypes.rst:3618 +#: ../../library/stdtypes.rst:2308 ../../library/stdtypes.rst:3674 msgid "" "The algorithm uses a simple language-independent definition of a word as " "groups of consecutive letters. The definition works in many contexts but it " @@ -3435,7 +3520,7 @@ msgid "" "which may not be the desired result::" msgstr "" -#: ../../library/stdtypes.rst:2257 +#: ../../library/stdtypes.rst:2313 msgid "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" @@ -3443,19 +3528,19 @@ msgstr "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" -#: ../../library/stdtypes.rst:2260 +#: ../../library/stdtypes.rst:2316 msgid "" "The :func:`string.capwords` function does not have this problem, as it " "splits words on spaces only." msgstr "" -#: ../../library/stdtypes.rst:2263 +#: ../../library/stdtypes.rst:2319 msgid "" "Alternatively, a workaround for apostrophes can be constructed using regular " "expressions::" msgstr "" -#: ../../library/stdtypes.rst:2266 +#: ../../library/stdtypes.rst:2322 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -3475,31 +3560,31 @@ msgstr "" ">>> titlecase(\"they're bill's friends.\")\n" "\"They're Bill's Friends.\"" -#: ../../library/stdtypes.rst:2278 +#: ../../library/stdtypes.rst:2334 msgid "" "Return a copy of the string in which each character has been mapped through " "the given translation table. The table must be an object that implements " -"indexing via :meth:`~object.__getitem__`, typically a :term:`mapping` " -"or :term:`sequence`. When indexed by a Unicode ordinal (an integer), the " -"table object can do any of the following: return a Unicode ordinal or a " -"string, to map the character to one or more other characters; return " -"``None``, to delete the character from the return string; or raise " -"a :exc:`LookupError` exception, to map the character to itself." +"indexing via :meth:`~object.__getitem__`, typically a :term:`mapping` or :" +"term:`sequence`. When indexed by a Unicode ordinal (an integer), the table " +"object can do any of the following: return a Unicode ordinal or a string, to " +"map the character to one or more other characters; return ``None``, to " +"delete the character from the return string; or raise a :exc:`LookupError` " +"exception, to map the character to itself." msgstr "" -#: ../../library/stdtypes.rst:2287 +#: ../../library/stdtypes.rst:2343 msgid "" "You can use :meth:`str.maketrans` to create a translation map from character-" "to-character mappings in different formats." msgstr "" -#: ../../library/stdtypes.rst:2290 +#: ../../library/stdtypes.rst:2346 msgid "" "See also the :mod:`codecs` module for a more flexible approach to custom " "character mappings." msgstr "" -#: ../../library/stdtypes.rst:2296 +#: ../../library/stdtypes.rst:2352 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s`` " @@ -3508,14 +3593,14 @@ msgid "" "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:2302 +#: ../../library/stdtypes.rst:2358 msgid "" "The uppercasing algorithm used is `described in section 3.13 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" -#: ../../library/stdtypes.rst:2309 +#: ../../library/stdtypes.rst:2365 msgid "" "Return a copy of the string left filled with ASCII ``'0'`` digits to make a " "string of length *width*. A leading sign prefix (``'+'``/``'-'``) is handled " @@ -3523,7 +3608,7 @@ msgid "" "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2317 +#: ../../library/stdtypes.rst:2373 msgid "" ">>> \"42\".zfill(5)\n" "'00042'\n" @@ -3535,27 +3620,27 @@ msgstr "" ">>> \"-42\".zfill(5)\n" "'-0042'" -#: ../../library/stdtypes.rst:2338 +#: ../../library/stdtypes.rst:2394 msgid "Formatted String Literals (f-strings)" msgstr "" -#: ../../library/stdtypes.rst:2341 +#: ../../library/stdtypes.rst:2397 msgid "" "The :keyword:`await` and :keyword:`async for` can be used in expressions " "within f-strings." msgstr "" -#: ../../library/stdtypes.rst:2344 +#: ../../library/stdtypes.rst:2400 msgid "Added the debugging operator (``=``)" msgstr "" -#: ../../library/stdtypes.rst:2346 +#: ../../library/stdtypes.rst:2402 msgid "" "Many restrictions on expressions within f-strings have been removed. " "Notably, nested strings, comments, and backslashes are now permitted." msgstr "" -#: ../../library/stdtypes.rst:2350 +#: ../../library/stdtypes.rst:2406 msgid "" "An :dfn:`f-string` (formally a :dfn:`formatted string literal`) is a string " "literal that is prefixed with ``f`` or ``F``. This type of string literal " @@ -3565,7 +3650,7 @@ msgid "" "into regular :class:`str` objects. For example:" msgstr "" -#: ../../library/stdtypes.rst:2358 +#: ../../library/stdtypes.rst:2414 msgid "" ">>> who = 'nobody'\n" ">>> nationality = 'Spanish'\n" @@ -3577,11 +3662,11 @@ msgstr "" ">>> f'{who.title()} expects the {nationality} Inquisition!'\n" "'Nobody expects the Spanish Inquisition!'" -#: ../../library/stdtypes.rst:2365 +#: ../../library/stdtypes.rst:2421 msgid "It is also possible to use a multi line f-string:" msgstr "" -#: ../../library/stdtypes.rst:2367 +#: ../../library/stdtypes.rst:2423 msgid "" ">>> f'''This is a string\n" "... on two lines'''\n" @@ -3591,13 +3676,13 @@ msgstr "" "... on two lines'''\n" "'This is a string\\non two lines'" -#: ../../library/stdtypes.rst:2373 +#: ../../library/stdtypes.rst:2429 msgid "" "A single opening curly bracket, ``'{'``, marks a *replacement field* that " "can contain any Python expression:" msgstr "" -#: ../../library/stdtypes.rst:2376 +#: ../../library/stdtypes.rst:2432 msgid "" ">>> nationality = 'Spanish'\n" ">>> f'The {nationality} Inquisition!'\n" @@ -3607,11 +3692,11 @@ msgstr "" ">>> f'The {nationality} Inquisition!'\n" "'The Spanish Inquisition!'" -#: ../../library/stdtypes.rst:2382 +#: ../../library/stdtypes.rst:2438 msgid "To include a literal ``{`` or ``}``, use a double bracket:" msgstr "" -#: ../../library/stdtypes.rst:2384 +#: ../../library/stdtypes.rst:2440 msgid "" ">>> x = 42\n" ">>> f'{{x}} is {x}'\n" @@ -3621,12 +3706,12 @@ msgstr "" ">>> f'{{x}} is {x}'\n" "'{x} is 42'" -#: ../../library/stdtypes.rst:2390 +#: ../../library/stdtypes.rst:2446 msgid "" "Functions can also be used, and :ref:`format specifiers `:" msgstr "" -#: ../../library/stdtypes.rst:2392 +#: ../../library/stdtypes.rst:2448 msgid "" ">>> from math import sqrt\n" ">>> f'√2 \\N{ALMOST EQUAL TO} {sqrt(2):.5f}'\n" @@ -3636,11 +3721,11 @@ msgstr "" ">>> f'√2 \\N{ALMOST EQUAL TO} {sqrt(2):.5f}'\n" "'√2 ≈ 1.41421'" -#: ../../library/stdtypes.rst:2398 +#: ../../library/stdtypes.rst:2454 msgid "Any non-string expression is converted using :func:`str`, by default:" msgstr "" -#: ../../library/stdtypes.rst:2400 +#: ../../library/stdtypes.rst:2456 msgid "" ">>> from fractions import Fraction\n" ">>> f'{Fraction(1, 3)}'\n" @@ -3650,46 +3735,46 @@ msgstr "" ">>> f'{Fraction(1, 3)}'\n" "'1/3'" -#: ../../library/stdtypes.rst:2406 +#: ../../library/stdtypes.rst:2462 msgid "" "To use an explicit conversion, use the ``!`` (exclamation mark) operator, " "followed by any of the valid formats, which are:" msgstr "" -#: ../../library/stdtypes.rst:2410 ../../library/stdtypes.rst:2578 -#: ../../library/stdtypes.rst:3797 +#: ../../library/stdtypes.rst:2466 ../../library/stdtypes.rst:2634 +#: ../../library/stdtypes.rst:3853 msgid "Conversion" msgstr "" -#: ../../library/stdtypes.rst:2412 +#: ../../library/stdtypes.rst:2468 msgid "``!a``" msgstr "``!a``" -#: ../../library/stdtypes.rst:2412 +#: ../../library/stdtypes.rst:2468 msgid ":func:`ascii`" msgstr ":func:`ascii`" -#: ../../library/stdtypes.rst:2413 +#: ../../library/stdtypes.rst:2469 msgid "``!r``" msgstr "``!r``" -#: ../../library/stdtypes.rst:2413 +#: ../../library/stdtypes.rst:2469 msgid ":func:`repr`" msgstr ":func:`repr`" -#: ../../library/stdtypes.rst:2414 +#: ../../library/stdtypes.rst:2470 msgid "``!s``" msgstr "``!s``" -#: ../../library/stdtypes.rst:2414 +#: ../../library/stdtypes.rst:2470 msgid ":func:`str`" msgstr ":func:`str`" -#: ../../library/stdtypes.rst:2417 +#: ../../library/stdtypes.rst:2473 msgid "For example:" msgstr "舉例來說:" -#: ../../library/stdtypes.rst:2419 +#: ../../library/stdtypes.rst:2475 msgid "" ">>> from fractions import Fraction\n" ">>> f'{Fraction(1, 3)!s}'\n" @@ -3709,7 +3794,7 @@ msgstr "" ">>> print(f'{question!a}')\n" "'\\xbfD\\xf3nde est\\xe1 el Presidente?'" -#: ../../library/stdtypes.rst:2430 +#: ../../library/stdtypes.rst:2486 msgid "" "While debugging it may be helpful to see both the expression and its value, " "by using the equals sign (``=``) after the expression. This preserves spaces " @@ -3717,7 +3802,7 @@ msgid "" "debugging operator uses the :func:`repr` (``!r``) conversion. For example:" msgstr "" -#: ../../library/stdtypes.rst:2436 +#: ../../library/stdtypes.rst:2492 msgid "" ">>> from fractions import Fraction\n" ">>> calculation = Fraction(1, 3)\n" @@ -3737,7 +3822,7 @@ msgstr "" ">>> f'{calculation = !s}'\n" "'calculation = 1/3'" -#: ../../library/stdtypes.rst:2447 +#: ../../library/stdtypes.rst:2503 msgid "" "Once the output has been evaluated, it can be formatted using a :ref:`format " "specifier ` following a colon (``':'``). After the expression " @@ -3747,7 +3832,7 @@ msgid "" "used as the final value for the replacement field. For example:" msgstr "" -#: ../../library/stdtypes.rst:2455 +#: ../../library/stdtypes.rst:2511 msgid "" ">>> from fractions import Fraction\n" ">>> f'{Fraction(1, 7):.6f}'\n" @@ -3756,11 +3841,11 @@ msgid "" "'___+1/7___'" msgstr "" -#: ../../library/stdtypes.rst:2467 +#: ../../library/stdtypes.rst:2523 msgid "``printf``-style String Formatting" msgstr "" -#: ../../library/stdtypes.rst:2480 +#: ../../library/stdtypes.rst:2536 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -3771,7 +3856,7 @@ msgid "" "or extensibility." msgstr "" -#: ../../library/stdtypes.rst:2488 +#: ../../library/stdtypes.rst:2544 msgid "" "String objects have one unique built-in operation: the ``%`` operator " "(modulo). This is also known as the string *formatting* or *interpolation* " @@ -3781,13 +3866,13 @@ msgid "" "function in the C language. For example:" msgstr "" -#: ../../library/stdtypes.rst:2495 +#: ../../library/stdtypes.rst:2551 msgid "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." msgstr "" -#: ../../library/stdtypes.rst:2500 +#: ../../library/stdtypes.rst:2556 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -3795,36 +3880,36 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:2510 ../../library/stdtypes.rst:3729 +#: ../../library/stdtypes.rst:2566 ../../library/stdtypes.rst:3785 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../library/stdtypes.rst:2513 ../../library/stdtypes.rst:3732 +#: ../../library/stdtypes.rst:2569 ../../library/stdtypes.rst:3788 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../library/stdtypes.rst:2515 ../../library/stdtypes.rst:3734 +#: ../../library/stdtypes.rst:2571 ../../library/stdtypes.rst:3790 msgid "" "Mapping key (optional), consisting of a parenthesised sequence of characters " "(for example, ``(somename)``)." msgstr "" -#: ../../library/stdtypes.rst:2518 ../../library/stdtypes.rst:3737 +#: ../../library/stdtypes.rst:2574 ../../library/stdtypes.rst:3793 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../library/stdtypes.rst:2521 ../../library/stdtypes.rst:3740 +#: ../../library/stdtypes.rst:2577 ../../library/stdtypes.rst:3796 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is read from the next element of the tuple in *values*, and the " "object to convert comes after the minimum field width and optional precision." msgstr "" -#: ../../library/stdtypes.rst:2525 ../../library/stdtypes.rst:3744 +#: ../../library/stdtypes.rst:2581 ../../library/stdtypes.rst:3800 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. " "If specified as ``'*'`` (an asterisk), the actual precision is read from the " @@ -3832,15 +3917,15 @@ msgid "" "the precision." msgstr "" -#: ../../library/stdtypes.rst:2530 ../../library/stdtypes.rst:3749 +#: ../../library/stdtypes.rst:2586 ../../library/stdtypes.rst:3805 msgid "Length modifier (optional)." msgstr "" -#: ../../library/stdtypes.rst:2532 ../../library/stdtypes.rst:3751 +#: ../../library/stdtypes.rst:2588 ../../library/stdtypes.rst:3807 msgid "Conversion type." msgstr "" -#: ../../library/stdtypes.rst:2534 +#: ../../library/stdtypes.rst:2590 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the string *must* include a parenthesised mapping key into that " @@ -3848,293 +3933,293 @@ msgid "" "selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:2543 ../../library/stdtypes.rst:3762 +#: ../../library/stdtypes.rst:2599 ../../library/stdtypes.rst:3818 msgid "" "In this case no ``*`` specifiers may occur in a format (since they require a " "sequential parameter list)." msgstr "" -#: ../../library/stdtypes.rst:2546 ../../library/stdtypes.rst:3765 +#: ../../library/stdtypes.rst:2602 ../../library/stdtypes.rst:3821 msgid "The conversion flag characters are:" msgstr "" -#: ../../library/stdtypes.rst:2555 ../../library/stdtypes.rst:3774 +#: ../../library/stdtypes.rst:2611 ../../library/stdtypes.rst:3830 msgid "Flag" msgstr "" -#: ../../library/stdtypes.rst:2557 ../../library/stdtypes.rst:3776 +#: ../../library/stdtypes.rst:2613 ../../library/stdtypes.rst:3832 msgid "``'#'``" msgstr "``'#'``" -#: ../../library/stdtypes.rst:2557 ../../library/stdtypes.rst:3776 +#: ../../library/stdtypes.rst:2613 ../../library/stdtypes.rst:3832 msgid "" "The value conversion will use the \"alternate form\" (where defined below)." msgstr "" -#: ../../library/stdtypes.rst:2560 ../../library/stdtypes.rst:3779 +#: ../../library/stdtypes.rst:2616 ../../library/stdtypes.rst:3835 msgid "``'0'``" msgstr "``'0'``" -#: ../../library/stdtypes.rst:2560 ../../library/stdtypes.rst:3779 +#: ../../library/stdtypes.rst:2616 ../../library/stdtypes.rst:3835 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../library/stdtypes.rst:2562 ../../library/stdtypes.rst:3781 +#: ../../library/stdtypes.rst:2618 ../../library/stdtypes.rst:3837 msgid "``'-'``" msgstr "``'-'``" -#: ../../library/stdtypes.rst:2562 ../../library/stdtypes.rst:3781 +#: ../../library/stdtypes.rst:2618 ../../library/stdtypes.rst:3837 msgid "" "The converted value is left adjusted (overrides the ``'0'`` conversion if " "both are given)." msgstr "" -#: ../../library/stdtypes.rst:2565 ../../library/stdtypes.rst:3784 +#: ../../library/stdtypes.rst:2621 ../../library/stdtypes.rst:3840 msgid "``' '``" msgstr "``' '``" -#: ../../library/stdtypes.rst:2565 ../../library/stdtypes.rst:3784 +#: ../../library/stdtypes.rst:2621 ../../library/stdtypes.rst:3840 msgid "" "(a space) A blank should be left before a positive number (or empty string) " "produced by a signed conversion." msgstr "" -#: ../../library/stdtypes.rst:2568 ../../library/stdtypes.rst:3787 +#: ../../library/stdtypes.rst:2624 ../../library/stdtypes.rst:3843 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/stdtypes.rst:2568 ../../library/stdtypes.rst:3787 +#: ../../library/stdtypes.rst:2624 ../../library/stdtypes.rst:3843 msgid "" "A sign character (``'+'`` or ``'-'``) will precede the conversion (overrides " "a \"space\" flag)." msgstr "" -#: ../../library/stdtypes.rst:2572 ../../library/stdtypes.rst:3791 +#: ../../library/stdtypes.rst:2628 ../../library/stdtypes.rst:3847 msgid "" "A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as " "it is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``." msgstr "" -#: ../../library/stdtypes.rst:2575 ../../library/stdtypes.rst:3794 +#: ../../library/stdtypes.rst:2631 ../../library/stdtypes.rst:3850 msgid "The conversion types are:" msgstr "" -#: ../../library/stdtypes.rst:2580 ../../library/stdtypes.rst:3799 +#: ../../library/stdtypes.rst:2636 ../../library/stdtypes.rst:3855 msgid "``'d'``" msgstr "``'d'``" -#: ../../library/stdtypes.rst:2580 ../../library/stdtypes.rst:2582 -#: ../../library/stdtypes.rst:3799 ../../library/stdtypes.rst:3801 +#: ../../library/stdtypes.rst:2636 ../../library/stdtypes.rst:2638 +#: ../../library/stdtypes.rst:3855 ../../library/stdtypes.rst:3857 msgid "Signed integer decimal." msgstr "" -#: ../../library/stdtypes.rst:2582 ../../library/stdtypes.rst:3801 +#: ../../library/stdtypes.rst:2638 ../../library/stdtypes.rst:3857 msgid "``'i'``" msgstr "``'i'``" -#: ../../library/stdtypes.rst:2584 ../../library/stdtypes.rst:3803 +#: ../../library/stdtypes.rst:2640 ../../library/stdtypes.rst:3859 msgid "``'o'``" msgstr "``'o'``" -#: ../../library/stdtypes.rst:2584 ../../library/stdtypes.rst:3803 +#: ../../library/stdtypes.rst:2640 ../../library/stdtypes.rst:3859 msgid "Signed octal value." msgstr "" -#: ../../library/stdtypes.rst:2586 ../../library/stdtypes.rst:3805 +#: ../../library/stdtypes.rst:2642 ../../library/stdtypes.rst:3861 msgid "``'u'``" msgstr "``'u'``" -#: ../../library/stdtypes.rst:2586 ../../library/stdtypes.rst:3805 +#: ../../library/stdtypes.rst:2642 ../../library/stdtypes.rst:3861 msgid "Obsolete type -- it is identical to ``'d'``." msgstr "" -#: ../../library/stdtypes.rst:2588 ../../library/stdtypes.rst:3807 +#: ../../library/stdtypes.rst:2644 ../../library/stdtypes.rst:3863 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/stdtypes.rst:2588 ../../library/stdtypes.rst:3807 +#: ../../library/stdtypes.rst:2644 ../../library/stdtypes.rst:3863 msgid "Signed hexadecimal (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:2590 ../../library/stdtypes.rst:3809 +#: ../../library/stdtypes.rst:2646 ../../library/stdtypes.rst:3865 msgid "``'X'``" msgstr "``'X'``" -#: ../../library/stdtypes.rst:2590 ../../library/stdtypes.rst:3809 +#: ../../library/stdtypes.rst:2646 ../../library/stdtypes.rst:3865 msgid "Signed hexadecimal (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:2592 ../../library/stdtypes.rst:3811 +#: ../../library/stdtypes.rst:2648 ../../library/stdtypes.rst:3867 msgid "``'e'``" msgstr "``'e'``" -#: ../../library/stdtypes.rst:2592 ../../library/stdtypes.rst:3811 +#: ../../library/stdtypes.rst:2648 ../../library/stdtypes.rst:3867 msgid "Floating-point exponential format (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:2594 ../../library/stdtypes.rst:3813 +#: ../../library/stdtypes.rst:2650 ../../library/stdtypes.rst:3869 msgid "``'E'``" msgstr "``'E'``" -#: ../../library/stdtypes.rst:2594 ../../library/stdtypes.rst:3813 +#: ../../library/stdtypes.rst:2650 ../../library/stdtypes.rst:3869 msgid "Floating-point exponential format (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:2596 ../../library/stdtypes.rst:3815 +#: ../../library/stdtypes.rst:2652 ../../library/stdtypes.rst:3871 msgid "``'f'``" msgstr "``'f'``" -#: ../../library/stdtypes.rst:2596 ../../library/stdtypes.rst:2598 -#: ../../library/stdtypes.rst:3815 ../../library/stdtypes.rst:3817 +#: ../../library/stdtypes.rst:2652 ../../library/stdtypes.rst:2654 +#: ../../library/stdtypes.rst:3871 ../../library/stdtypes.rst:3873 msgid "Floating-point decimal format." msgstr "" -#: ../../library/stdtypes.rst:2598 ../../library/stdtypes.rst:3817 +#: ../../library/stdtypes.rst:2654 ../../library/stdtypes.rst:3873 msgid "``'F'``" msgstr "``'F'``" -#: ../../library/stdtypes.rst:2600 ../../library/stdtypes.rst:3819 +#: ../../library/stdtypes.rst:2656 ../../library/stdtypes.rst:3875 msgid "``'g'``" msgstr "``'g'``" -#: ../../library/stdtypes.rst:2600 ../../library/stdtypes.rst:3819 +#: ../../library/stdtypes.rst:2656 ../../library/stdtypes.rst:3875 msgid "" "Floating-point format. Uses lowercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:2604 ../../library/stdtypes.rst:3823 +#: ../../library/stdtypes.rst:2660 ../../library/stdtypes.rst:3879 msgid "``'G'``" msgstr "``'G'``" -#: ../../library/stdtypes.rst:2604 ../../library/stdtypes.rst:3823 +#: ../../library/stdtypes.rst:2660 ../../library/stdtypes.rst:3879 msgid "" "Floating-point format. Uses uppercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:2608 ../../library/stdtypes.rst:3827 +#: ../../library/stdtypes.rst:2664 ../../library/stdtypes.rst:3883 msgid "``'c'``" msgstr "``'c'``" -#: ../../library/stdtypes.rst:2608 +#: ../../library/stdtypes.rst:2664 msgid "Single character (accepts integer or single character string)." msgstr "" -#: ../../library/stdtypes.rst:2611 ../../library/stdtypes.rst:3840 +#: ../../library/stdtypes.rst:2667 ../../library/stdtypes.rst:3896 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/stdtypes.rst:2611 +#: ../../library/stdtypes.rst:2667 msgid "String (converts any Python object using :func:`repr`)." msgstr "" -#: ../../library/stdtypes.rst:2614 ../../library/stdtypes.rst:3834 +#: ../../library/stdtypes.rst:2670 ../../library/stdtypes.rst:3890 msgid "``'s'``" msgstr "``'s'``" -#: ../../library/stdtypes.rst:2614 +#: ../../library/stdtypes.rst:2670 msgid "String (converts any Python object using :func:`str`)." msgstr "" -#: ../../library/stdtypes.rst:2617 ../../library/stdtypes.rst:3837 +#: ../../library/stdtypes.rst:2673 ../../library/stdtypes.rst:3893 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/stdtypes.rst:2617 +#: ../../library/stdtypes.rst:2673 msgid "String (converts any Python object using :func:`ascii`)." msgstr "" -#: ../../library/stdtypes.rst:2620 ../../library/stdtypes.rst:3843 +#: ../../library/stdtypes.rst:2676 ../../library/stdtypes.rst:3899 msgid "``'%'``" msgstr "``'%'``" -#: ../../library/stdtypes.rst:2620 ../../library/stdtypes.rst:3843 +#: ../../library/stdtypes.rst:2676 ../../library/stdtypes.rst:3899 msgid "No argument is converted, results in a ``'%'`` character in the result." msgstr "" -#: ../../library/stdtypes.rst:2627 ../../library/stdtypes.rst:3850 +#: ../../library/stdtypes.rst:2683 ../../library/stdtypes.rst:3906 msgid "" "The alternate form causes a leading octal specifier (``'0o'``) to be " "inserted before the first digit." msgstr "" -#: ../../library/stdtypes.rst:2631 ../../library/stdtypes.rst:3854 +#: ../../library/stdtypes.rst:2687 ../../library/stdtypes.rst:3910 msgid "" "The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on " "whether the ``'x'`` or ``'X'`` format was used) to be inserted before the " "first digit." msgstr "" -#: ../../library/stdtypes.rst:2635 ../../library/stdtypes.rst:3858 +#: ../../library/stdtypes.rst:2691 ../../library/stdtypes.rst:3914 msgid "" "The alternate form causes the result to always contain a decimal point, even " "if no digits follow it." msgstr "" -#: ../../library/stdtypes.rst:2638 ../../library/stdtypes.rst:3861 +#: ../../library/stdtypes.rst:2694 ../../library/stdtypes.rst:3917 msgid "" "The precision determines the number of digits after the decimal point and " "defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:2642 ../../library/stdtypes.rst:3865 +#: ../../library/stdtypes.rst:2698 ../../library/stdtypes.rst:3921 msgid "" "The alternate form causes the result to always contain a decimal point, and " "trailing zeroes are not removed as they would otherwise be." msgstr "" -#: ../../library/stdtypes.rst:2645 ../../library/stdtypes.rst:3868 +#: ../../library/stdtypes.rst:2701 ../../library/stdtypes.rst:3924 msgid "" "The precision determines the number of significant digits before and after " "the decimal point and defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:2649 ../../library/stdtypes.rst:3872 +#: ../../library/stdtypes.rst:2705 ../../library/stdtypes.rst:3928 msgid "If precision is ``N``, the output is truncated to ``N`` characters." msgstr "" -#: ../../library/stdtypes.rst:2652 ../../library/stdtypes.rst:3881 +#: ../../library/stdtypes.rst:2708 ../../library/stdtypes.rst:3937 msgid "See :pep:`237`." msgstr "參閱 :pep:`237`。" -#: ../../library/stdtypes.rst:2654 +#: ../../library/stdtypes.rst:2710 msgid "" "Since Python strings have an explicit length, ``%s`` conversions do not " "assume that ``'\\0'`` is the end of the string." msgstr "" -#: ../../library/stdtypes.rst:2659 +#: ../../library/stdtypes.rst:2715 msgid "" "``%f`` conversions for numbers whose absolute value is over 1e50 are no " "longer replaced by ``%g`` conversions." msgstr "" -#: ../../library/stdtypes.rst:2670 +#: ../../library/stdtypes.rst:2726 msgid "" -"Binary Sequence Types " -"--- :class:`bytes`, :class:`bytearray`, :class:`memoryview`" +"Binary Sequence Types --- :class:`bytes`, :class:`bytearray`, :class:" +"`memoryview`" msgstr "" -#: ../../library/stdtypes.rst:2678 +#: ../../library/stdtypes.rst:2734 msgid "" -"The core built-in types for manipulating binary data are :class:`bytes` " -"and :class:`bytearray`. They are supported by :class:`memoryview` which uses " -"the :ref:`buffer protocol ` to access the memory of other " -"binary objects without needing to make a copy." +"The core built-in types for manipulating binary data are :class:`bytes` and :" +"class:`bytearray`. They are supported by :class:`memoryview` which uses the :" +"ref:`buffer protocol ` to access the memory of other binary " +"objects without needing to make a copy." msgstr "" -#: ../../library/stdtypes.rst:2683 +#: ../../library/stdtypes.rst:2739 msgid "" "The :mod:`array` module supports efficient storage of basic data types like " "32-bit integers and IEEE754 double-precision floating values." msgstr "" -#: ../../library/stdtypes.rst:2689 +#: ../../library/stdtypes.rst:2745 msgid "Bytes Objects" msgstr "" -#: ../../library/stdtypes.rst:2693 +#: ../../library/stdtypes.rst:2749 msgid "" "Bytes objects are immutable sequences of single bytes. Since many major " "binary protocols are based on the ASCII text encoding, bytes objects offer " @@ -4142,40 +4227,40 @@ msgid "" "and are closely related to string objects in a variety of other ways." msgstr "" -#: ../../library/stdtypes.rst:2700 +#: ../../library/stdtypes.rst:2756 msgid "" "Firstly, the syntax for bytes literals is largely the same as that for " "string literals, except that a ``b`` prefix is added:" msgstr "" -#: ../../library/stdtypes.rst:2703 +#: ../../library/stdtypes.rst:2759 msgid "Single quotes: ``b'still allows embedded \"double\" quotes'``" msgstr "" -#: ../../library/stdtypes.rst:2704 +#: ../../library/stdtypes.rst:2760 msgid "Double quotes: ``b\"still allows embedded 'single' quotes\"``" msgstr "" -#: ../../library/stdtypes.rst:2705 +#: ../../library/stdtypes.rst:2761 msgid "" "Triple quoted: ``b'''3 single quotes'''``, ``b\"\"\"3 double quotes\"\"\"``" msgstr "" -#: ../../library/stdtypes.rst:2707 +#: ../../library/stdtypes.rst:2763 msgid "" "Only ASCII characters are permitted in bytes literals (regardless of the " "declared source code encoding). Any binary values over 127 must be entered " "into bytes literals using the appropriate escape sequence." msgstr "" -#: ../../library/stdtypes.rst:2711 +#: ../../library/stdtypes.rst:2767 msgid "" "As with string literals, bytes literals may also use a ``r`` prefix to " "disable processing of escape sequences. See :ref:`strings` for more about " "the various forms of bytes literal, including supported escape sequences." msgstr "" -#: ../../library/stdtypes.rst:2715 +#: ../../library/stdtypes.rst:2771 msgid "" "While bytes literals and representations are based on ASCII text, bytes " "objects actually behave like immutable sequences of integers, with each " @@ -4188,29 +4273,29 @@ msgid "" "compatible will usually lead to data corruption)." msgstr "" -#: ../../library/stdtypes.rst:2725 +#: ../../library/stdtypes.rst:2781 msgid "" "In addition to the literal forms, bytes objects can be created in a number " "of other ways:" msgstr "" -#: ../../library/stdtypes.rst:2728 +#: ../../library/stdtypes.rst:2784 msgid "A zero-filled bytes object of a specified length: ``bytes(10)``" msgstr "" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2785 msgid "From an iterable of integers: ``bytes(range(20))``" msgstr "" -#: ../../library/stdtypes.rst:2730 +#: ../../library/stdtypes.rst:2786 msgid "Copying existing binary data via the buffer protocol: ``bytes(obj)``" msgstr "" -#: ../../library/stdtypes.rst:2732 +#: ../../library/stdtypes.rst:2788 msgid "Also see the :ref:`bytes ` built-in." msgstr "另見內建的 :ref:`bytes `。" -#: ../../library/stdtypes.rst:2734 +#: ../../library/stdtypes.rst:2790 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -4218,32 +4303,32 @@ msgid "" "that format:" msgstr "" -#: ../../library/stdtypes.rst:2740 +#: ../../library/stdtypes.rst:2796 msgid "" "This :class:`bytes` class method returns a bytes object, decoding the given " "string object. The string must contain two hexadecimal digits per byte, " "with ASCII whitespace being ignored." msgstr "" -#: ../../library/stdtypes.rst:2747 +#: ../../library/stdtypes.rst:2803 msgid "" ":meth:`bytes.fromhex` now skips all ASCII whitespace in the string, not just " "spaces." msgstr "" -#: ../../library/stdtypes.rst:2751 +#: ../../library/stdtypes.rst:2807 msgid "" "A reverse conversion function exists to transform a bytes object into its " "hexadecimal representation." msgstr "" -#: ../../library/stdtypes.rst:2756 ../../library/stdtypes.rst:2841 +#: ../../library/stdtypes.rst:2812 ../../library/stdtypes.rst:2897 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the instance." msgstr "" -#: ../../library/stdtypes.rst:2762 +#: ../../library/stdtypes.rst:2818 msgid "" "If you want to make the hex string easier to read, you can specify a single " "character separator *sep* parameter to include in the output. By default, " @@ -4252,13 +4337,13 @@ msgid "" "the separator position from the right, negative values from the left." msgstr "" -#: ../../library/stdtypes.rst:2779 +#: ../../library/stdtypes.rst:2835 msgid "" ":meth:`bytes.hex` now supports optional *sep* and *bytes_per_sep* parameters " "to insert separators between bytes in the hex output." msgstr "" -#: ../../library/stdtypes.rst:2783 +#: ../../library/stdtypes.rst:2839 msgid "" "Since bytes objects are sequences of integers (akin to a tuple), for a bytes " "object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes " @@ -4266,58 +4351,58 @@ msgid "" "and slicing will produce a string of length 1)" msgstr "" -#: ../../library/stdtypes.rst:2788 +#: ../../library/stdtypes.rst:2844 msgid "" "The representation of bytes objects uses the literal format (``b'...'``) " "since it is often more useful than e.g. ``bytes([46, 46, 46])``. You can " "always convert a bytes object into a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:2796 +#: ../../library/stdtypes.rst:2852 msgid "Bytearray Objects" msgstr "Bytearray 物件" -#: ../../library/stdtypes.rst:2800 +#: ../../library/stdtypes.rst:2856 msgid "" ":class:`bytearray` objects are a mutable counterpart to :class:`bytes` " "objects." msgstr "" -#: ../../library/stdtypes.rst:2805 +#: ../../library/stdtypes.rst:2861 msgid "" "There is no dedicated literal syntax for bytearray objects, instead they are " "always created by calling the constructor:" msgstr "" -#: ../../library/stdtypes.rst:2808 +#: ../../library/stdtypes.rst:2864 msgid "Creating an empty instance: ``bytearray()``" msgstr "建立一個空的實例:``bytearray()``" -#: ../../library/stdtypes.rst:2809 +#: ../../library/stdtypes.rst:2865 msgid "Creating a zero-filled instance with a given length: ``bytearray(10)``" msgstr "" -#: ../../library/stdtypes.rst:2810 +#: ../../library/stdtypes.rst:2866 msgid "From an iterable of integers: ``bytearray(range(20))``" msgstr "" -#: ../../library/stdtypes.rst:2811 +#: ../../library/stdtypes.rst:2867 msgid "" "Copying existing binary data via the buffer protocol: ``bytearray(b'Hi!')``" msgstr "" -#: ../../library/stdtypes.rst:2813 +#: ../../library/stdtypes.rst:2869 msgid "" "As bytearray objects are mutable, they support the :ref:`mutable ` sequence operations in addition to the common bytes and bytearray " "operations described in :ref:`bytes-methods`." msgstr "" -#: ../../library/stdtypes.rst:2817 +#: ../../library/stdtypes.rst:2873 msgid "Also see the :ref:`bytearray ` built-in." msgstr "另見內建的 :ref:`bytearray `。" -#: ../../library/stdtypes.rst:2819 +#: ../../library/stdtypes.rst:2875 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -4325,33 +4410,33 @@ msgid "" "in that format:" msgstr "" -#: ../../library/stdtypes.rst:2825 +#: ../../library/stdtypes.rst:2881 msgid "" "This :class:`bytearray` class method returns bytearray object, decoding the " "given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" -#: ../../library/stdtypes.rst:2832 +#: ../../library/stdtypes.rst:2888 msgid "" ":meth:`bytearray.fromhex` now skips all ASCII whitespace in the string, not " "just spaces." msgstr "" -#: ../../library/stdtypes.rst:2836 +#: ../../library/stdtypes.rst:2892 msgid "" "A reverse conversion function exists to transform a bytearray object into " "its hexadecimal representation." msgstr "" -#: ../../library/stdtypes.rst:2849 +#: ../../library/stdtypes.rst:2905 msgid "" "Similar to :meth:`bytes.hex`, :meth:`bytearray.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:2854 +#: ../../library/stdtypes.rst:2910 msgid "" "Since bytearray objects are sequences of integers (akin to a list), for a " "bytearray object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be " @@ -4359,7 +4444,7 @@ msgid "" "both indexing and slicing will produce a string of length 1)" msgstr "" -#: ../../library/stdtypes.rst:2859 +#: ../../library/stdtypes.rst:2915 msgid "" "The representation of bytearray objects uses the bytes literal format " "(``bytearray(b'...')``) since it is often more useful than e.g. " @@ -4367,11 +4452,11 @@ msgid "" "a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:2868 +#: ../../library/stdtypes.rst:2924 msgid "Bytes and Bytearray Operations" msgstr "Bytes 和 Bytearray 的操作" -#: ../../library/stdtypes.rst:2873 +#: ../../library/stdtypes.rst:2929 msgid "" "Both bytes and bytearray objects support the :ref:`common ` " "sequence operations. They interoperate not just with operands of the same " @@ -4380,14 +4465,14 @@ msgid "" "return type of the result may depend on the order of operands." msgstr "" -#: ../../library/stdtypes.rst:2881 +#: ../../library/stdtypes.rst:2937 msgid "" "The methods on bytes and bytearray objects don't accept strings as their " "arguments, just as the methods on strings don't accept bytes as their " "arguments. For example, you have to write::" msgstr "" -#: ../../library/stdtypes.rst:2885 +#: ../../library/stdtypes.rst:2941 msgid "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" @@ -4395,11 +4480,11 @@ msgstr "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" -#: ../../library/stdtypes.rst:2888 +#: ../../library/stdtypes.rst:2944 msgid "and::" msgstr "和: ::" -#: ../../library/stdtypes.rst:2890 +#: ../../library/stdtypes.rst:2946 msgid "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" @@ -4407,60 +4492,60 @@ msgstr "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" -#: ../../library/stdtypes.rst:2893 +#: ../../library/stdtypes.rst:2949 msgid "" "Some bytes and bytearray operations assume the use of ASCII compatible " "binary formats, and hence should be avoided when working with arbitrary " "binary data. These restrictions are covered below." msgstr "" -#: ../../library/stdtypes.rst:2898 +#: ../../library/stdtypes.rst:2954 msgid "" "Using these ASCII based operations to manipulate binary data that is not " "stored in an ASCII based format may lead to data corruption." msgstr "" -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:2957 msgid "" "The following methods on bytes and bytearray objects can be used with " "arbitrary binary data." msgstr "" -#: ../../library/stdtypes.rst:2907 +#: ../../library/stdtypes.rst:2963 msgid "" "Return the number of non-overlapping occurrences of subsequence *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../library/stdtypes.rst:2911 ../../library/stdtypes.rst:3016 -#: ../../library/stdtypes.rst:3038 ../../library/stdtypes.rst:3104 -#: ../../library/stdtypes.rst:3117 +#: ../../library/stdtypes.rst:2967 ../../library/stdtypes.rst:3072 +#: ../../library/stdtypes.rst:3094 ../../library/stdtypes.rst:3160 +#: ../../library/stdtypes.rst:3173 msgid "" "The subsequence to search for may be any :term:`bytes-like object` or an " "integer in the range 0 to 255." msgstr "" -#: ../../library/stdtypes.rst:2914 +#: ../../library/stdtypes.rst:2970 msgid "" "If *sub* is empty, returns the number of empty slices between characters " "which is the length of the bytes object plus one." msgstr "" -#: ../../library/stdtypes.rst:2917 ../../library/stdtypes.rst:3028 -#: ../../library/stdtypes.rst:3041 ../../library/stdtypes.rst:3107 -#: ../../library/stdtypes.rst:3120 +#: ../../library/stdtypes.rst:2973 ../../library/stdtypes.rst:3084 +#: ../../library/stdtypes.rst:3097 ../../library/stdtypes.rst:3163 +#: ../../library/stdtypes.rst:3176 msgid "Also accept an integer in the range 0 to 255 as the subsequence." msgstr "" -#: ../../library/stdtypes.rst:2924 +#: ../../library/stdtypes.rst:2980 msgid "" "If the binary data starts with the *prefix* string, return " "``bytes[len(prefix):]``. Otherwise, return a copy of the original binary " "data::" msgstr "" -#: ../../library/stdtypes.rst:2928 +#: ../../library/stdtypes.rst:2984 msgid "" ">>> b'TestHook'.removeprefix(b'Test')\n" "b'Hook'\n" @@ -4472,32 +4557,32 @@ msgstr "" ">>> b'BaseTestCase'.removeprefix(b'Test')\n" "b'BaseTestCase'" -#: ../../library/stdtypes.rst:2933 +#: ../../library/stdtypes.rst:2989 msgid "The *prefix* may be any :term:`bytes-like object`." msgstr "*prefix* 可以是任何的 :term:`bytes-like object`。" -#: ../../library/stdtypes.rst:2937 ../../library/stdtypes.rst:2959 -#: ../../library/stdtypes.rst:3092 ../../library/stdtypes.rst:3185 -#: ../../library/stdtypes.rst:3199 ../../library/stdtypes.rst:3230 -#: ../../library/stdtypes.rst:3244 ../../library/stdtypes.rst:3286 -#: ../../library/stdtypes.rst:3357 ../../library/stdtypes.rst:3375 -#: ../../library/stdtypes.rst:3403 ../../library/stdtypes.rst:3542 -#: ../../library/stdtypes.rst:3597 ../../library/stdtypes.rst:3640 -#: ../../library/stdtypes.rst:3661 ../../library/stdtypes.rst:3683 -#: ../../library/stdtypes.rst:3885 +#: ../../library/stdtypes.rst:2993 ../../library/stdtypes.rst:3015 +#: ../../library/stdtypes.rst:3148 ../../library/stdtypes.rst:3241 +#: ../../library/stdtypes.rst:3255 ../../library/stdtypes.rst:3286 +#: ../../library/stdtypes.rst:3300 ../../library/stdtypes.rst:3342 +#: ../../library/stdtypes.rst:3413 ../../library/stdtypes.rst:3431 +#: ../../library/stdtypes.rst:3459 ../../library/stdtypes.rst:3598 +#: ../../library/stdtypes.rst:3653 ../../library/stdtypes.rst:3696 +#: ../../library/stdtypes.rst:3717 ../../library/stdtypes.rst:3739 +#: ../../library/stdtypes.rst:3941 msgid "" "The bytearray version of this method does *not* operate in place - it always " "produces a new object, even if no changes were made." msgstr "" -#: ../../library/stdtypes.rst:2946 +#: ../../library/stdtypes.rst:3002 msgid "" "If the binary data ends with the *suffix* string and that *suffix* is not " "empty, return ``bytes[:-len(suffix)]``. Otherwise, return a copy of the " "original binary data::" msgstr "" -#: ../../library/stdtypes.rst:2950 +#: ../../library/stdtypes.rst:3006 msgid "" ">>> b'MiscTests'.removesuffix(b'Tests')\n" "b'Misc'\n" @@ -4509,37 +4594,37 @@ msgstr "" ">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" "b'TmpDirMixin'" -#: ../../library/stdtypes.rst:2955 +#: ../../library/stdtypes.rst:3011 msgid "The *suffix* may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:2968 +#: ../../library/stdtypes.rst:3024 msgid "Return the bytes decoded to a :class:`str`." msgstr "" -#: ../../library/stdtypes.rst:2973 +#: ../../library/stdtypes.rst:3029 msgid "" "*errors* controls how decoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " -"are ``'ignore'``, ``'replace'``, and any other name registered " -"via :func:`codecs.register_error`. See :ref:`error-handlers` for details." +"are ``'ignore'``, ``'replace'``, and any other name registered via :func:" +"`codecs.register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../library/stdtypes.rst:2979 +#: ../../library/stdtypes.rst:3035 msgid "" "For performance reasons, the value of *errors* is not checked for validity " -"unless a decoding error actually occurs, :ref:`devmode` is enabled or " -"a :ref:`debug build ` is used." +"unless a decoding error actually occurs, :ref:`devmode` is enabled or a :ref:" +"`debug build ` is used." msgstr "" -#: ../../library/stdtypes.rst:2985 +#: ../../library/stdtypes.rst:3041 msgid "" -"Passing the *encoding* argument to :class:`str` allows decoding " -"any :term:`bytes-like object` directly, without needing to make a " -"temporary :class:`!bytes` or :class:`!bytearray` object." +"Passing the *encoding* argument to :class:`str` allows decoding any :term:" +"`bytes-like object` directly, without needing to make a temporary :class:`!" +"bytes` or :class:`!bytearray` object." msgstr "" -#: ../../library/stdtypes.rst:3000 +#: ../../library/stdtypes.rst:3056 msgid "" "Return ``True`` if the binary data ends with the specified *suffix*, " "otherwise return ``False``. *suffix* can also be a tuple of suffixes to " @@ -4547,11 +4632,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:3005 +#: ../../library/stdtypes.rst:3061 msgid "The suffix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3011 +#: ../../library/stdtypes.rst:3067 msgid "" "Return the lowest index in the data where the subsequence *sub* is found, " "such that *sub* is contained in the slice ``s[start:end]``. Optional " @@ -4559,14 +4644,14 @@ msgid "" "``-1`` if *sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:3021 +#: ../../library/stdtypes.rst:3077 msgid "" "The :meth:`~bytes.find` method should be used only if you need to know the " -"position of *sub*. To check if *sub* is a substring or not, use " -"the :keyword:`in` operator::" +"position of *sub*. To check if *sub* is a substring or not, use the :" +"keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:3025 +#: ../../library/stdtypes.rst:3081 msgid "" ">>> b'Py' in b'Python'\n" "True" @@ -4574,13 +4659,13 @@ msgstr "" ">>> b'Py' in b'Python'\n" "True" -#: ../../library/stdtypes.rst:3035 +#: ../../library/stdtypes.rst:3091 msgid "" "Like :meth:`~bytes.find`, but raise :exc:`ValueError` when the subsequence " "is not found." msgstr "" -#: ../../library/stdtypes.rst:3048 +#: ../../library/stdtypes.rst:3104 msgid "" "Return a bytes or bytearray object which is the concatenation of the binary " "data sequences in *iterable*. A :exc:`TypeError` will be raised if there " @@ -4590,15 +4675,15 @@ msgid "" "method." msgstr "" -#: ../../library/stdtypes.rst:3059 +#: ../../library/stdtypes.rst:3115 msgid "" -"This static method returns a translation table usable " -"for :meth:`bytes.translate` that will map each character in *from* into the " -"character at the same position in *to*; *from* and *to* must both " -"be :term:`bytes-like objects ` and have the same length." +"This static method returns a translation table usable for :meth:`bytes." +"translate` that will map each character in *from* into the character at the " +"same position in *to*; *from* and *to* must both be :term:`bytes-like " +"objects ` and have the same length." msgstr "" -#: ../../library/stdtypes.rst:3070 +#: ../../library/stdtypes.rst:3126 msgid "" "Split the sequence at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -4607,24 +4692,24 @@ msgid "" "by two empty bytes or bytearray objects." msgstr "" -#: ../../library/stdtypes.rst:3077 ../../library/stdtypes.rst:3134 +#: ../../library/stdtypes.rst:3133 ../../library/stdtypes.rst:3190 msgid "The separator to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3083 +#: ../../library/stdtypes.rst:3139 msgid "" "Return a copy of the sequence with all occurrences of subsequence *old* " "replaced by *new*. If the optional argument *count* is given, only the " "first *count* occurrences are replaced." msgstr "" -#: ../../library/stdtypes.rst:3087 +#: ../../library/stdtypes.rst:3143 msgid "" "The subsequence to search for and its replacement may be any :term:`bytes-" "like object`." msgstr "" -#: ../../library/stdtypes.rst:3099 +#: ../../library/stdtypes.rst:3155 msgid "" "Return the highest index in the sequence where the subsequence *sub* is " "found, such that *sub* is contained within ``s[start:end]``. Optional " @@ -4632,13 +4717,13 @@ msgid "" "``-1`` on failure." msgstr "" -#: ../../library/stdtypes.rst:3114 +#: ../../library/stdtypes.rst:3170 msgid "" "Like :meth:`~bytes.rfind` but raises :exc:`ValueError` when the subsequence " "*sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:3127 +#: ../../library/stdtypes.rst:3183 msgid "" "Split the sequence at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -4647,7 +4732,7 @@ msgid "" "followed by a copy of the original sequence." msgstr "" -#: ../../library/stdtypes.rst:3140 +#: ../../library/stdtypes.rst:3196 msgid "" "Return ``True`` if the binary data starts with the specified *prefix*, " "otherwise return ``False``. *prefix* can also be a tuple of prefixes to " @@ -4655,11 +4740,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:3145 +#: ../../library/stdtypes.rst:3201 msgid "The prefix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3151 +#: ../../library/stdtypes.rst:3207 msgid "" "Return a copy of the bytes or bytearray object where all bytes occurring in " "the optional argument *delete* are removed, and the remaining bytes have " @@ -4667,18 +4752,18 @@ msgid "" "object of length 256." msgstr "" -#: ../../library/stdtypes.rst:3156 +#: ../../library/stdtypes.rst:3212 msgid "" "You can use the :func:`bytes.maketrans` method to create a translation table." msgstr "" -#: ../../library/stdtypes.rst:3159 +#: ../../library/stdtypes.rst:3215 msgid "" "Set the *table* argument to ``None`` for translations that only delete " "characters::" msgstr "" -#: ../../library/stdtypes.rst:3162 +#: ../../library/stdtypes.rst:3218 msgid "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" @@ -4686,11 +4771,11 @@ msgstr "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" -#: ../../library/stdtypes.rst:3165 +#: ../../library/stdtypes.rst:3221 msgid "*delete* is now supported as a keyword argument." msgstr "支援 *delete* 關鍵字引數。" -#: ../../library/stdtypes.rst:3169 +#: ../../library/stdtypes.rst:3225 msgid "" "The following methods on bytes and bytearray objects have default behaviours " "that assume the use of ASCII compatible binary formats, but can still be " @@ -4699,7 +4784,7 @@ msgid "" "instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3178 +#: ../../library/stdtypes.rst:3234 msgid "" "Return a copy of the object centered in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -4707,7 +4792,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3192 +#: ../../library/stdtypes.rst:3248 msgid "" "Return a copy of the object left justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -4715,7 +4800,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3206 +#: ../../library/stdtypes.rst:3262 msgid "" "Return a copy of the sequence with specified leading bytes removed. The " "*chars* argument is a binary sequence specifying the set of byte values to " @@ -4725,7 +4810,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3213 +#: ../../library/stdtypes.rst:3269 msgid "" ">>> b' spacious '.lstrip()\n" "b'spacious '\n" @@ -4737,14 +4822,14 @@ msgstr "" ">>> b'www.example.com'.lstrip(b'cmowz.')\n" "b'example.com'" -#: ../../library/stdtypes.rst:3218 +#: ../../library/stdtypes.rst:3274 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removeprefix` for a method that will remove a " "single prefix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3223 +#: ../../library/stdtypes.rst:3279 msgid "" ">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" "b'ee!'\n" @@ -4756,7 +4841,7 @@ msgstr "" ">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" "b'three!'" -#: ../../library/stdtypes.rst:3237 +#: ../../library/stdtypes.rst:3293 msgid "" "Return a copy of the object right justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -4764,7 +4849,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3251 +#: ../../library/stdtypes.rst:3307 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are " @@ -4774,7 +4859,7 @@ msgid "" "described in detail below." msgstr "" -#: ../../library/stdtypes.rst:3262 +#: ../../library/stdtypes.rst:3318 msgid "" "Return a copy of the sequence with specified trailing bytes removed. The " "*chars* argument is a binary sequence specifying the set of byte values to " @@ -4784,7 +4869,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3269 +#: ../../library/stdtypes.rst:3325 msgid "" ">>> b' spacious '.rstrip()\n" "b' spacious'\n" @@ -4796,14 +4881,14 @@ msgstr "" ">>> b'mississippi'.rstrip(b'ipz')\n" "b'mississ'" -#: ../../library/stdtypes.rst:3274 +#: ../../library/stdtypes.rst:3330 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removesuffix` for a method that will remove a " "single suffix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3279 +#: ../../library/stdtypes.rst:3335 msgid "" ">>> b'Monty Python'.rstrip(b' Python')\n" "b'M'\n" @@ -4815,7 +4900,7 @@ msgstr "" ">>> b'Monty Python'.removesuffix(b' Python')\n" "b'Monty'" -#: ../../library/stdtypes.rst:3293 +#: ../../library/stdtypes.rst:3349 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given and non-negative, at most " @@ -4824,7 +4909,7 @@ msgid "" "limit on the number of splits (all possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:3299 +#: ../../library/stdtypes.rst:3355 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty subsequences (for example, ``b'1,,2'.split(b',')`` " @@ -4835,7 +4920,7 @@ msgid "" "like object`." msgstr "" -#: ../../library/stdtypes.rst:3309 +#: ../../library/stdtypes.rst:3365 msgid "" ">>> b'1,2,3'.split(b',')\n" "[b'1', b'2', b'3']\n" @@ -4855,7 +4940,7 @@ msgstr "" ">>> b'1<>2<>3<4'.split(b'<>')\n" "[b'1', b'2', b'3<4']" -#: ../../library/stdtypes.rst:3318 +#: ../../library/stdtypes.rst:3374 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive ASCII whitespace are regarded as a single " @@ -4865,7 +4950,7 @@ msgid "" "without a specified separator returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:3328 +#: ../../library/stdtypes.rst:3384 msgid "" ">>> b'1 2 3'.split()\n" "[b'1', b'2', b'3']\n" @@ -4881,7 +4966,7 @@ msgstr "" ">>> b' 1 2 3 '.split()\n" "[b'1', b'2', b'3']" -#: ../../library/stdtypes.rst:3339 +#: ../../library/stdtypes.rst:3395 msgid "" "Return a copy of the sequence with specified leading and trailing bytes " "removed. The *chars* argument is a binary sequence specifying the set of " @@ -4891,7 +4976,7 @@ msgid "" "a prefix or suffix; rather, all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3347 +#: ../../library/stdtypes.rst:3403 msgid "" ">>> b' spacious '.strip()\n" "b'spacious'\n" @@ -4903,13 +4988,13 @@ msgstr "" ">>> b'www.example.com'.strip(b'cmowz.')\n" "b'example'" -#: ../../library/stdtypes.rst:3352 +#: ../../library/stdtypes.rst:3408 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`." msgstr "" -#: ../../library/stdtypes.rst:3361 +#: ../../library/stdtypes.rst:3417 msgid "" "The following methods on bytes and bytearray objects assume the use of ASCII " "compatible binary formats and should not be applied to arbitrary binary " @@ -4917,14 +5002,14 @@ msgid "" "operate in place, and instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3369 +#: ../../library/stdtypes.rst:3425 msgid "" "Return a copy of the sequence with each byte interpreted as an ASCII " "character, and the first byte capitalized and the rest lowercased. Non-ASCII " "byte values are passed through unchanged." msgstr "" -#: ../../library/stdtypes.rst:3382 +#: ../../library/stdtypes.rst:3438 msgid "" "Return a copy of the sequence where all ASCII tab characters are replaced by " "one or more ASCII spaces, depending on the current column and the given tab " @@ -4940,7 +5025,7 @@ msgid "" "by one regardless of how the byte value is represented when printed::" msgstr "" -#: ../../library/stdtypes.rst:3396 +#: ../../library/stdtypes.rst:3452 msgid "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" "b'01 012 0123 01234'\n" @@ -4952,7 +5037,7 @@ msgstr "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" "b'01 012 0123 01234'" -#: ../../library/stdtypes.rst:3410 +#: ../../library/stdtypes.rst:3466 msgid "" "Return ``True`` if all bytes in the sequence are alphabetical ASCII " "characters or ASCII decimal digits and the sequence is not empty, ``False`` " @@ -4961,7 +5046,7 @@ msgid "" "digits are those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:3418 +#: ../../library/stdtypes.rst:3474 msgid "" ">>> b'ABCabc1'.isalnum()\n" "True\n" @@ -4973,7 +5058,7 @@ msgstr "" ">>> b'ABC abc1'.isalnum()\n" "False" -#: ../../library/stdtypes.rst:3427 +#: ../../library/stdtypes.rst:3483 msgid "" "Return ``True`` if all bytes in the sequence are alphabetic ASCII characters " "and the sequence is not empty, ``False`` otherwise. Alphabetic ASCII " @@ -4981,7 +5066,7 @@ msgid "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:3434 +#: ../../library/stdtypes.rst:3490 msgid "" ">>> b'ABCabc'.isalpha()\n" "True\n" @@ -4993,20 +5078,20 @@ msgstr "" ">>> b'ABCabc1'.isalpha()\n" "False" -#: ../../library/stdtypes.rst:3443 +#: ../../library/stdtypes.rst:3499 msgid "" "Return ``True`` if the sequence is empty or all bytes in the sequence are " "ASCII, ``False`` otherwise. ASCII bytes are in the range 0-0x7F." msgstr "" -#: ../../library/stdtypes.rst:3453 +#: ../../library/stdtypes.rst:3509 msgid "" "Return ``True`` if all bytes in the sequence are ASCII decimal digits and " "the sequence is not empty, ``False`` otherwise. ASCII decimal digits are " "those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:3459 +#: ../../library/stdtypes.rst:3515 msgid "" ">>> b'1234'.isdigit()\n" "True\n" @@ -5018,13 +5103,13 @@ msgstr "" ">>> b'1.23'.isdigit()\n" "False" -#: ../../library/stdtypes.rst:3468 +#: ../../library/stdtypes.rst:3524 msgid "" "Return ``True`` if there is at least one lowercase ASCII character in the " "sequence and no uppercase ASCII characters, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:3473 +#: ../../library/stdtypes.rst:3529 msgid "" ">>> b'hello world'.islower()\n" "True\n" @@ -5036,16 +5121,16 @@ msgstr "" ">>> b'Hello world'.islower()\n" "False" -#: ../../library/stdtypes.rst:3478 ../../library/stdtypes.rst:3520 -#: ../../library/stdtypes.rst:3536 ../../library/stdtypes.rst:3586 -#: ../../library/stdtypes.rst:3655 +#: ../../library/stdtypes.rst:3534 ../../library/stdtypes.rst:3576 +#: ../../library/stdtypes.rst:3592 ../../library/stdtypes.rst:3642 +#: ../../library/stdtypes.rst:3711 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " "values in the sequence ``b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:3486 +#: ../../library/stdtypes.rst:3542 msgid "" "Return ``True`` if all bytes in the sequence are ASCII whitespace and the " "sequence is not empty, ``False`` otherwise. ASCII whitespace characters are " @@ -5053,14 +5138,14 @@ msgid "" "newline, carriage return, vertical tab, form feed)." msgstr "" -#: ../../library/stdtypes.rst:3495 +#: ../../library/stdtypes.rst:3551 msgid "" "Return ``True`` if the sequence is ASCII titlecase and the sequence is not " "empty, ``False`` otherwise. See :meth:`bytes.title` for more details on the " "definition of \"titlecase\"." msgstr "" -#: ../../library/stdtypes.rst:3501 +#: ../../library/stdtypes.rst:3557 msgid "" ">>> b'Hello World'.istitle()\n" "True\n" @@ -5072,14 +5157,14 @@ msgstr "" ">>> b'Hello world'.istitle()\n" "False" -#: ../../library/stdtypes.rst:3510 +#: ../../library/stdtypes.rst:3566 msgid "" "Return ``True`` if there is at least one uppercase alphabetic ASCII " "character in the sequence and no lowercase ASCII characters, ``False`` " "otherwise." msgstr "" -#: ../../library/stdtypes.rst:3515 +#: ../../library/stdtypes.rst:3571 msgid "" ">>> b'HELLO WORLD'.isupper()\n" "True\n" @@ -5091,13 +5176,13 @@ msgstr "" ">>> b'Hello world'.isupper()\n" "False" -#: ../../library/stdtypes.rst:3528 +#: ../../library/stdtypes.rst:3584 msgid "" "Return a copy of the sequence with all the uppercase ASCII characters " "converted to their corresponding lowercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:3533 +#: ../../library/stdtypes.rst:3589 msgid "" ">>> b'Hello World'.lower()\n" "b'hello world'" @@ -5105,7 +5190,7 @@ msgstr "" ">>> b'Hello World'.lower()\n" "b'hello world'" -#: ../../library/stdtypes.rst:3553 +#: ../../library/stdtypes.rst:3609 msgid "" "Return a list of the lines in the binary sequence, breaking at ASCII line " "boundaries. This method uses the :term:`universal newlines` approach to " @@ -5113,7 +5198,7 @@ msgid "" "*keepends* is given and true." msgstr "" -#: ../../library/stdtypes.rst:3560 +#: ../../library/stdtypes.rst:3616 msgid "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "[b'ab c', b'', b'de fg', b'kl']\n" @@ -5125,14 +5210,14 @@ msgstr "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" -#: ../../library/stdtypes.rst:3565 +#: ../../library/stdtypes.rst:3621 msgid "" "Unlike :meth:`~bytes.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:3569 +#: ../../library/stdtypes.rst:3625 msgid "" ">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" "([b''], [b'Two lines', b''])\n" @@ -5144,13 +5229,13 @@ msgstr "" ">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" "([], [b'One line'])" -#: ../../library/stdtypes.rst:3578 +#: ../../library/stdtypes.rst:3634 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart and vice-versa." msgstr "" -#: ../../library/stdtypes.rst:3583 +#: ../../library/stdtypes.rst:3639 msgid "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" @@ -5158,22 +5243,22 @@ msgstr "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" -#: ../../library/stdtypes.rst:3590 +#: ../../library/stdtypes.rst:3646 msgid "" -"Unlike :func:`str.swapcase`, it is always the case that " -"``bin.swapcase().swapcase() == bin`` for the binary versions. Case " -"conversions are symmetrical in ASCII, even though that is not generally true " -"for arbitrary Unicode code points." +"Unlike :func:`str.swapcase`, it is always the case that ``bin.swapcase()." +"swapcase() == bin`` for the binary versions. Case conversions are " +"symmetrical in ASCII, even though that is not generally true for arbitrary " +"Unicode code points." msgstr "" -#: ../../library/stdtypes.rst:3604 +#: ../../library/stdtypes.rst:3660 msgid "" "Return a titlecased version of the binary sequence where words start with an " "uppercase ASCII character and the remaining characters are lowercase. " "Uncased byte values are left unmodified." msgstr "" -#: ../../library/stdtypes.rst:3610 +#: ../../library/stdtypes.rst:3666 msgid "" ">>> b'Hello world'.title()\n" "b'Hello World'" @@ -5181,7 +5266,7 @@ msgstr "" ">>> b'Hello world'.title()\n" "b'Hello World'" -#: ../../library/stdtypes.rst:3613 +#: ../../library/stdtypes.rst:3669 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " @@ -5189,7 +5274,7 @@ msgid "" "values are uncased." msgstr "" -#: ../../library/stdtypes.rst:3623 +#: ../../library/stdtypes.rst:3679 msgid "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" @@ -5197,12 +5282,12 @@ msgstr "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" -#: ../../library/stdtypes.rst:3626 +#: ../../library/stdtypes.rst:3682 msgid "" "A workaround for apostrophes can be constructed using regular expressions::" msgstr "" -#: ../../library/stdtypes.rst:3628 +#: ../../library/stdtypes.rst:3684 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -5224,13 +5309,13 @@ msgstr "" ">>> titlecase(b\"they're bill's friends.\")\n" "b\"They're Bill's Friends.\"" -#: ../../library/stdtypes.rst:3647 +#: ../../library/stdtypes.rst:3703 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:3652 +#: ../../library/stdtypes.rst:3708 msgid "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" @@ -5238,7 +5323,7 @@ msgstr "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" -#: ../../library/stdtypes.rst:3668 +#: ../../library/stdtypes.rst:3724 msgid "" "Return a copy of the sequence left filled with ASCII ``b'0'`` digits to make " "a sequence of length *width*. A leading sign prefix (``b'+'``/ ``b'-'``) is " @@ -5247,7 +5332,7 @@ msgid "" "*width* is less than or equal to ``len(seq)``." msgstr "" -#: ../../library/stdtypes.rst:3676 +#: ../../library/stdtypes.rst:3732 msgid "" ">>> b\"42\".zfill(5)\n" "b'00042'\n" @@ -5259,11 +5344,11 @@ msgstr "" ">>> b\"-42\".zfill(5)\n" "b'-0042'" -#: ../../library/stdtypes.rst:3690 +#: ../../library/stdtypes.rst:3746 msgid "``printf``-style Bytes Formatting" msgstr "" -#: ../../library/stdtypes.rst:3707 +#: ../../library/stdtypes.rst:3763 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -5271,17 +5356,17 @@ msgid "" "dictionary, wrap it in a tuple." msgstr "" -#: ../../library/stdtypes.rst:3712 +#: ../../library/stdtypes.rst:3768 msgid "" "Bytes objects (``bytes``/``bytearray``) have one unique built-in operation: " "the ``%`` operator (modulo). This is also known as the bytes *formatting* or " "*interpolation* operator. Given ``format % values`` (where *format* is a " "bytes object), ``%`` conversion specifications in *format* are replaced with " -"zero or more elements of *values*. The effect is similar to using " -"the :c:func:`sprintf` in the C language." +"zero or more elements of *values*. The effect is similar to using the :c:" +"func:`sprintf` in the C language." msgstr "" -#: ../../library/stdtypes.rst:3719 +#: ../../library/stdtypes.rst:3775 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -5289,7 +5374,7 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:3753 +#: ../../library/stdtypes.rst:3809 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the bytes object *must* include a parenthesised mapping key into " @@ -5297,73 +5382,73 @@ msgid "" "mapping key selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:3827 +#: ../../library/stdtypes.rst:3883 msgid "Single byte (accepts integer or single byte objects)." msgstr "" -#: ../../library/stdtypes.rst:3830 +#: ../../library/stdtypes.rst:3886 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/stdtypes.rst:3830 +#: ../../library/stdtypes.rst:3886 msgid "" "Bytes (any object that follows the :ref:`buffer protocol ` or " "has :meth:`~object.__bytes__`)." msgstr "" -#: ../../library/stdtypes.rst:3834 +#: ../../library/stdtypes.rst:3890 msgid "" "``'s'`` is an alias for ``'b'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:3837 +#: ../../library/stdtypes.rst:3893 msgid "" "Bytes (converts any Python object using ``repr(obj).encode('ascii', " "'backslashreplace')``)." msgstr "" -#: ../../library/stdtypes.rst:3840 +#: ../../library/stdtypes.rst:3896 msgid "" "``'r'`` is an alias for ``'a'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:3840 +#: ../../library/stdtypes.rst:3896 msgid "\\(7)" msgstr "\\(7)" -#: ../../library/stdtypes.rst:3875 +#: ../../library/stdtypes.rst:3931 msgid "``b'%s'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%s'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../library/stdtypes.rst:3878 +#: ../../library/stdtypes.rst:3934 msgid "``b'%r'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%r'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../library/stdtypes.rst:3890 +#: ../../library/stdtypes.rst:3946 msgid ":pep:`461` - Adding % formatting to bytes and bytearray" msgstr "" -#: ../../library/stdtypes.rst:3897 +#: ../../library/stdtypes.rst:3953 msgid "Memory Views" msgstr "" -#: ../../library/stdtypes.rst:3899 +#: ../../library/stdtypes.rst:3955 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " "copying." msgstr "" -#: ../../library/stdtypes.rst:3905 +#: ../../library/stdtypes.rst:3961 msgid "" "Create a :class:`memoryview` that references *object*. *object* must " "support the buffer protocol. Built-in objects that support the buffer " "protocol include :class:`bytes` and :class:`bytearray`." msgstr "" -#: ../../library/stdtypes.rst:3909 +#: ../../library/stdtypes.rst:3965 msgid "" "A :class:`memoryview` has the notion of an *element*, which is the atomic " "memory unit handled by the originating *object*. For many simple types such " @@ -5371,32 +5456,32 @@ msgid "" "other types such as :class:`array.array` may have bigger elements." msgstr "" -#: ../../library/stdtypes.rst:3914 +#: ../../library/stdtypes.rst:3970 msgid "" "``len(view)`` is equal to the length of :class:`~memoryview.tolist`, which " "is the nested list representation of the view. If ``view.ndim = 1``, this is " "equal to the number of elements in the view." msgstr "" -#: ../../library/stdtypes.rst:3918 +#: ../../library/stdtypes.rst:3974 msgid "" "If ``view.ndim == 0``, ``len(view)`` now raises :exc:`TypeError` instead of " "returning 1." msgstr "" -#: ../../library/stdtypes.rst:3921 +#: ../../library/stdtypes.rst:3977 msgid "" "The :class:`~memoryview.itemsize` attribute will give you the number of " "bytes in a single element." msgstr "" -#: ../../library/stdtypes.rst:3924 +#: ../../library/stdtypes.rst:3980 msgid "" "A :class:`memoryview` supports slicing and indexing to expose its data. One-" "dimensional slicing will result in a subview::" msgstr "" -#: ../../library/stdtypes.rst:3927 +#: ../../library/stdtypes.rst:3983 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> v[1]\n" @@ -5418,7 +5503,7 @@ msgstr "" ">>> bytes(v[1:4])\n" "b'bce'" -#: ../../library/stdtypes.rst:3937 +#: ../../library/stdtypes.rst:3993 msgid "" "If :class:`~memoryview.format` is one of the native format specifiers from " "the :mod:`struct` module, indexing with an integer or a tuple of integers is " @@ -5429,11 +5514,11 @@ msgid "" "memoryviews can be indexed with the empty tuple." msgstr "" -#: ../../library/stdtypes.rst:3946 +#: ../../library/stdtypes.rst:4002 msgid "Here is an example with a non-byte format::" msgstr "" -#: ../../library/stdtypes.rst:3948 +#: ../../library/stdtypes.rst:4004 msgid "" ">>> import array\n" ">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" @@ -5455,13 +5540,13 @@ msgstr "" ">>> m[::2].tolist()\n" "[-11111111, -33333333]" -#: ../../library/stdtypes.rst:3958 +#: ../../library/stdtypes.rst:4014 msgid "" "If the underlying object is writable, the memoryview supports one-" "dimensional slice assignment. Resizing is not allowed::" msgstr "" -#: ../../library/stdtypes.rst:3961 +#: ../../library/stdtypes.rst:4017 msgid "" ">>> data = bytearray(b'abcefg')\n" ">>> v = memoryview(data)\n" @@ -5501,14 +5586,14 @@ msgstr "" ">>> data\n" "bytearray(b'z1spam')" -#: ../../library/stdtypes.rst:3979 +#: ../../library/stdtypes.rst:4035 msgid "" "One-dimensional memoryviews of :term:`hashable` (read-only) types with " "formats 'B', 'b' or 'c' are also hashable. The hash is defined as ``hash(m) " "== hash(m.tobytes())``::" msgstr "" -#: ../../library/stdtypes.rst:3983 +#: ../../library/stdtypes.rst:4039 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> hash(v) == hash(b'abcefg')\n" @@ -5526,41 +5611,40 @@ msgstr "" ">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" "True" -#: ../../library/stdtypes.rst:3991 +#: ../../library/stdtypes.rst:4047 msgid "" "One-dimensional memoryviews can now be sliced. One-dimensional memoryviews " "with formats 'B', 'b' or 'c' are now :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:3995 +#: ../../library/stdtypes.rst:4051 msgid "" -"memoryview is now registered automatically " -"with :class:`collections.abc.Sequence`" +"memoryview is now registered automatically with :class:`collections.abc." +"Sequence`" msgstr "" -#: ../../library/stdtypes.rst:3999 +#: ../../library/stdtypes.rst:4055 msgid "memoryviews can now be indexed with tuple of integers." msgstr "" -#: ../../library/stdtypes.rst:4002 +#: ../../library/stdtypes.rst:4058 msgid ":class:`memoryview` has several methods:" msgstr ":class:`memoryview` 有幾個方法:" -#: ../../library/stdtypes.rst:4006 +#: ../../library/stdtypes.rst:4062 msgid "" "A memoryview and a :pep:`3118` exporter are equal if their shapes are " "equivalent and if all corresponding values are equal when the operands' " "respective format codes are interpreted using :mod:`struct` syntax." msgstr "" -#: ../../library/stdtypes.rst:4010 +#: ../../library/stdtypes.rst:4066 msgid "" -"For the subset of :mod:`struct` format strings currently supported " -"by :meth:`tolist`, ``v`` and ``w`` are equal if ``v.tolist() == " -"w.tolist()``::" +"For the subset of :mod:`struct` format strings currently supported by :meth:" +"`tolist`, ``v`` and ``w`` are equal if ``v.tolist() == w.tolist()``::" msgstr "" -#: ../../library/stdtypes.rst:4013 +#: ../../library/stdtypes.rst:4069 msgid "" ">>> import array\n" ">>> a = array.array('I', [1, 2, 3, 4, 5])\n" @@ -5594,14 +5678,14 @@ msgstr "" ">>> z.tolist() == c.tolist()\n" "True" -#: ../../library/stdtypes.rst:4029 +#: ../../library/stdtypes.rst:4085 msgid "" "If either format string is not supported by the :mod:`struct` module, then " "the objects will always compare as unequal (even if the format strings and " "buffer contents are identical)::" msgstr "" -#: ../../library/stdtypes.rst:4033 +#: ../../library/stdtypes.rst:4089 msgid "" ">>> from ctypes import BigEndianStructure, c_long\n" ">>> class BEPoint(BigEndianStructure):\n" @@ -5627,25 +5711,25 @@ msgstr "" ">>> a == b\n" "False" -#: ../../library/stdtypes.rst:4045 +#: ../../library/stdtypes.rst:4101 msgid "" "Note that, as with floating-point numbers, ``v is w`` does *not* imply ``v " "== w`` for memoryview objects." msgstr "" -#: ../../library/stdtypes.rst:4048 +#: ../../library/stdtypes.rst:4104 msgid "" "Previous versions compared the raw memory disregarding the item format and " "the logical array structure." msgstr "" -#: ../../library/stdtypes.rst:4054 +#: ../../library/stdtypes.rst:4110 msgid "" "Return the data in the buffer as a bytestring. This is equivalent to " "calling the :class:`bytes` constructor on the memoryview. ::" msgstr "" -#: ../../library/stdtypes.rst:4057 +#: ../../library/stdtypes.rst:4113 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.tobytes()\n" @@ -5659,7 +5743,7 @@ msgstr "" ">>> bytes(m)\n" "b'abc'" -#: ../../library/stdtypes.rst:4063 +#: ../../library/stdtypes.rst:4119 msgid "" "For non-contiguous arrays the result is equal to the flattened list " "representation with all elements converted to bytes. :meth:`tobytes` " @@ -5667,7 +5751,7 @@ msgid "" "module syntax." msgstr "" -#: ../../library/stdtypes.rst:4068 +#: ../../library/stdtypes.rst:4124 msgid "" "*order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data of the " "original array is converted to C or Fortran order. For contiguous views, 'A' " @@ -5676,13 +5760,13 @@ msgid "" "to C first. *order=None* is the same as *order='C'*." msgstr "" -#: ../../library/stdtypes.rst:4077 +#: ../../library/stdtypes.rst:4133 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the buffer. ::" msgstr "" -#: ../../library/stdtypes.rst:4080 +#: ../../library/stdtypes.rst:4136 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.hex()\n" @@ -5692,18 +5776,18 @@ msgstr "" ">>> m.hex()\n" "'616263'" -#: ../../library/stdtypes.rst:4086 +#: ../../library/stdtypes.rst:4142 msgid "" "Similar to :meth:`bytes.hex`, :meth:`memoryview.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:4093 +#: ../../library/stdtypes.rst:4149 msgid "Return the data in the buffer as a list of elements. ::" msgstr "" -#: ../../library/stdtypes.rst:4095 +#: ../../library/stdtypes.rst:4151 msgid "" ">>> memoryview(b'abc').tolist()\n" "[97, 98, 99]\n" @@ -5721,19 +5805,19 @@ msgstr "" ">>> m.tolist()\n" "[1.1, 2.2, 3.3]" -#: ../../library/stdtypes.rst:4103 +#: ../../library/stdtypes.rst:4159 msgid "" -":meth:`tolist` now supports all single character native formats " -"in :mod:`struct` module syntax as well as multi-dimensional representations." +":meth:`tolist` now supports all single character native formats in :mod:" +"`struct` module syntax as well as multi-dimensional representations." msgstr "" -#: ../../library/stdtypes.rst:4110 +#: ../../library/stdtypes.rst:4166 msgid "" "Return a readonly version of the memoryview object. The original memoryview " "object is unchanged. ::" msgstr "" -#: ../../library/stdtypes.rst:4113 +#: ../../library/stdtypes.rst:4169 msgid "" ">>> m = memoryview(bytearray(b'abc'))\n" ">>> mm = m.toreadonly()\n" @@ -5759,23 +5843,23 @@ msgstr "" ">>> mm.tolist()\n" "[43, 98, 99]" -#: ../../library/stdtypes.rst:4129 +#: ../../library/stdtypes.rst:4185 msgid "" "Release the underlying buffer exposed by the memoryview object. Many " -"objects take special actions when a view is held on them (for example, " -"a :class:`bytearray` would temporarily forbid resizing); therefore, calling " +"objects take special actions when a view is held on them (for example, a :" +"class:`bytearray` would temporarily forbid resizing); therefore, calling " "release() is handy to remove these restrictions (and free any dangling " "resources) as soon as possible." msgstr "" -#: ../../library/stdtypes.rst:4135 +#: ../../library/stdtypes.rst:4191 msgid "" "After this method has been called, any further operation on the view raises " "a :class:`ValueError` (except :meth:`release` itself which can be called " "multiple times)::" msgstr "" -#: ../../library/stdtypes.rst:4139 +#: ../../library/stdtypes.rst:4195 msgid "" ">>> m = memoryview(b'abc')\n" ">>> m.release()\n" @@ -5791,13 +5875,13 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../library/stdtypes.rst:4146 +#: ../../library/stdtypes.rst:4202 msgid "" "The context management protocol can be used for a similar effect, using the " "``with`` statement::" msgstr "" -#: ../../library/stdtypes.rst:4149 +#: ../../library/stdtypes.rst:4205 msgid "" ">>> with memoryview(b'abc') as m:\n" "... m[0]\n" @@ -5817,7 +5901,7 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../library/stdtypes.rst:4162 +#: ../../library/stdtypes.rst:4218 msgid "" "Cast a memoryview to a new format or shape. *shape* defaults to " "``[byte_length//new_itemsize]``, which means that the result view will be " @@ -5826,19 +5910,19 @@ msgid "" "contiguous -> 1D." msgstr "" -#: ../../library/stdtypes.rst:4168 +#: ../../library/stdtypes.rst:4224 msgid "" -"The destination format is restricted to a single element native format " -"in :mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' " -"or 'c'). The byte length of the result must be the same as the original " -"length. Note that all byte lengths may depend on the operating system." +"The destination format is restricted to a single element native format in :" +"mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' or " +"'c'). The byte length of the result must be the same as the original length. " +"Note that all byte lengths may depend on the operating system." msgstr "" -#: ../../library/stdtypes.rst:4174 +#: ../../library/stdtypes.rst:4230 msgid "Cast 1D/long to 1D/unsigned bytes::" msgstr "" -#: ../../library/stdtypes.rst:4176 +#: ../../library/stdtypes.rst:4232 msgid "" ">>> import array\n" ">>> a = array.array('l', [1,2,3])\n" @@ -5882,11 +5966,11 @@ msgstr "" ">>> y.nbytes\n" "24" -#: ../../library/stdtypes.rst:4197 +#: ../../library/stdtypes.rst:4253 msgid "Cast 1D/unsigned bytes to 1D/char::" msgstr "" -#: ../../library/stdtypes.rst:4199 +#: ../../library/stdtypes.rst:4255 msgid "" ">>> b = bytearray(b'zyz')\n" ">>> x = memoryview(b)\n" @@ -5910,11 +5994,11 @@ msgstr "" ">>> b\n" "bytearray(b'ayz')" -#: ../../library/stdtypes.rst:4210 +#: ../../library/stdtypes.rst:4266 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" msgstr "" -#: ../../library/stdtypes.rst:4212 +#: ../../library/stdtypes.rst:4268 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" @@ -5964,11 +6048,11 @@ msgstr "" ">>> z.nbytes\n" "48" -#: ../../library/stdtypes.rst:4236 +#: ../../library/stdtypes.rst:4292 msgid "Cast 1D/unsigned long to 2D/unsigned long::" msgstr "" -#: ../../library/stdtypes.rst:4238 +#: ../../library/stdtypes.rst:4294 msgid "" ">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" ">>> x = memoryview(buf)\n" @@ -5990,19 +6074,19 @@ msgstr "" ">>> y.tolist()\n" "[[0, 1, 2], [3, 4, 5]]" -#: ../../library/stdtypes.rst:4250 +#: ../../library/stdtypes.rst:4306 msgid "The source format is no longer restricted when casting to a byte view." msgstr "" -#: ../../library/stdtypes.rst:4253 +#: ../../library/stdtypes.rst:4309 msgid "There are also several readonly attributes available:" msgstr "" -#: ../../library/stdtypes.rst:4257 +#: ../../library/stdtypes.rst:4313 msgid "The underlying object of the memoryview::" msgstr "" -#: ../../library/stdtypes.rst:4259 +#: ../../library/stdtypes.rst:4315 msgid "" ">>> b = bytearray(b'xyz')\n" ">>> m = memoryview(b)\n" @@ -6014,14 +6098,14 @@ msgstr "" ">>> m.obj is b\n" "True" -#: ../../library/stdtypes.rst:4268 +#: ../../library/stdtypes.rst:4324 msgid "" "``nbytes == product(shape) * itemsize == len(m.tobytes())``. This is the " "amount of space in bytes that the array would use in a contiguous " "representation. It is not necessarily equal to ``len(m)``::" msgstr "" -#: ../../library/stdtypes.rst:4272 +#: ../../library/stdtypes.rst:4328 msgid "" ">>> import array\n" ">>> a = array.array('i', [1,2,3,4,5])\n" @@ -6053,11 +6137,11 @@ msgstr "" ">>> len(y.tobytes())\n" "12" -#: ../../library/stdtypes.rst:4287 +#: ../../library/stdtypes.rst:4343 msgid "Multi-dimensional arrays::" msgstr "" -#: ../../library/stdtypes.rst:4289 +#: ../../library/stdtypes.rst:4345 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" @@ -6081,11 +6165,11 @@ msgstr "" ">>> y.nbytes\n" "96" -#: ../../library/stdtypes.rst:4304 +#: ../../library/stdtypes.rst:4360 msgid "A bool indicating whether the memory is read only." msgstr "" -#: ../../library/stdtypes.rst:4308 +#: ../../library/stdtypes.rst:4364 msgid "" "A string containing the format (in :mod:`struct` module style) for each " "element in the view. A memoryview can be created from exporters with " @@ -6093,17 +6177,17 @@ msgid "" "restricted to native single element formats." msgstr "" -#: ../../library/stdtypes.rst:4313 +#: ../../library/stdtypes.rst:4369 msgid "" "format ``'B'`` is now handled according to the struct module syntax. This " "means that ``memoryview(b'abc')[0] == b'abc'[0] == 97``." msgstr "" -#: ../../library/stdtypes.rst:4319 +#: ../../library/stdtypes.rst:4375 msgid "The size in bytes of each element of the memoryview::" msgstr "" -#: ../../library/stdtypes.rst:4321 +#: ../../library/stdtypes.rst:4377 msgid "" ">>> import array, struct\n" ">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" @@ -6123,59 +6207,59 @@ msgstr "" ">>> struct.calcsize('H') == m.itemsize\n" "True" -#: ../../library/stdtypes.rst:4332 +#: ../../library/stdtypes.rst:4388 msgid "" "An integer indicating how many dimensions of a multi-dimensional array the " "memory represents." msgstr "" -#: ../../library/stdtypes.rst:4337 +#: ../../library/stdtypes.rst:4393 msgid "" "A tuple of integers the length of :attr:`ndim` giving the shape of the " "memory as an N-dimensional array." msgstr "" -#: ../../library/stdtypes.rst:4340 ../../library/stdtypes.rst:4348 +#: ../../library/stdtypes.rst:4396 ../../library/stdtypes.rst:4404 msgid "An empty tuple instead of ``None`` when ndim = 0." msgstr "" -#: ../../library/stdtypes.rst:4345 +#: ../../library/stdtypes.rst:4401 msgid "" "A tuple of integers the length of :attr:`ndim` giving the size in bytes to " "access each element for each dimension of the array." msgstr "" -#: ../../library/stdtypes.rst:4353 +#: ../../library/stdtypes.rst:4409 msgid "Used internally for PIL-style arrays. The value is informational only." msgstr "" -#: ../../library/stdtypes.rst:4357 +#: ../../library/stdtypes.rst:4413 msgid "A bool indicating whether the memory is C-:term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4363 +#: ../../library/stdtypes.rst:4419 msgid "A bool indicating whether the memory is Fortran :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4369 +#: ../../library/stdtypes.rst:4425 msgid "A bool indicating whether the memory is :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4377 +#: ../../library/stdtypes.rst:4433 msgid "Set Types --- :class:`set`, :class:`frozenset`" msgstr "" -#: ../../library/stdtypes.rst:4381 +#: ../../library/stdtypes.rst:4437 msgid "" "A :dfn:`set` object is an unordered collection of distinct :term:`hashable` " "objects. Common uses include membership testing, removing duplicates from a " "sequence, and computing mathematical operations such as intersection, union, " "difference, and symmetric difference. (For other containers see the built-" -"in :class:`dict`, :class:`list`, and :class:`tuple` classes, and " -"the :mod:`collections` module.)" +"in :class:`dict`, :class:`list`, and :class:`tuple` classes, and the :mod:" +"`collections` module.)" msgstr "" -#: ../../library/stdtypes.rst:4388 +#: ../../library/stdtypes.rst:4444 msgid "" "Like other collections, sets support ``x in set``, ``len(set)``, and ``for x " "in set``. Being an unordered collection, sets do not record element " @@ -6183,30 +6267,30 @@ msgid "" "slicing, or other sequence-like behavior." msgstr "" -#: ../../library/stdtypes.rst:4393 +#: ../../library/stdtypes.rst:4449 msgid "" -"There are currently two built-in set types, :class:`set` " -"and :class:`frozenset`. The :class:`set` type is mutable --- the contents " -"can be changed using methods like :meth:`~set.add` and :meth:`~set.remove`. " -"Since it is mutable, it has no hash value and cannot be used as either a " +"There are currently two built-in set types, :class:`set` and :class:" +"`frozenset`. The :class:`set` type is mutable --- the contents can be " +"changed using methods like :meth:`~set.add` and :meth:`~set.remove`. Since " +"it is mutable, it has no hash value and cannot be used as either a " "dictionary key or as an element of another set. The :class:`frozenset` type " "is immutable and :term:`hashable` --- its contents cannot be altered after " "it is created; it can therefore be used as a dictionary key or as an element " "of another set." msgstr "" -#: ../../library/stdtypes.rst:4401 +#: ../../library/stdtypes.rst:4457 msgid "" "Non-empty sets (not frozensets) can be created by placing a comma-separated " "list of elements within braces, for example: ``{'jack', 'sjoerd'}``, in " "addition to the :class:`set` constructor." msgstr "" -#: ../../library/stdtypes.rst:4405 +#: ../../library/stdtypes.rst:4461 msgid "The constructors for both classes work the same:" msgstr "" -#: ../../library/stdtypes.rst:4410 +#: ../../library/stdtypes.rst:4466 msgid "" "Return a new set or frozenset object whose elements are taken from " "*iterable*. The elements of a set must be :term:`hashable`. To represent " @@ -6214,102 +6298,102 @@ msgid "" "*iterable* is not specified, a new empty set is returned." msgstr "" -#: ../../library/stdtypes.rst:4416 +#: ../../library/stdtypes.rst:4472 msgid "Sets can be created by several means:" msgstr "" -#: ../../library/stdtypes.rst:4418 +#: ../../library/stdtypes.rst:4474 msgid "" "Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:4419 +#: ../../library/stdtypes.rst:4475 msgid "" "Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}``" msgstr "" -#: ../../library/stdtypes.rst:4420 +#: ../../library/stdtypes.rst:4476 msgid "" "Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', " "'foo'])``" msgstr "" -#: ../../library/stdtypes.rst:4422 +#: ../../library/stdtypes.rst:4478 msgid "" "Instances of :class:`set` and :class:`frozenset` provide the following " "operations:" msgstr "" -#: ../../library/stdtypes.rst:4427 +#: ../../library/stdtypes.rst:4483 msgid "Return the number of elements in set *s* (cardinality of *s*)." msgstr "" -#: ../../library/stdtypes.rst:4431 +#: ../../library/stdtypes.rst:4487 msgid "Test *x* for membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:4435 +#: ../../library/stdtypes.rst:4491 msgid "Test *x* for non-membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:4439 +#: ../../library/stdtypes.rst:4495 msgid "" "Return ``True`` if the set has no elements in common with *other*. Sets are " "disjoint if and only if their intersection is the empty set." msgstr "" -#: ../../library/stdtypes.rst:4445 +#: ../../library/stdtypes.rst:4501 msgid "Test whether every element in the set is in *other*." msgstr "" -#: ../../library/stdtypes.rst:4449 +#: ../../library/stdtypes.rst:4505 msgid "" "Test whether the set is a proper subset of *other*, that is, ``set <= other " "and set != other``." msgstr "" -#: ../../library/stdtypes.rst:4455 +#: ../../library/stdtypes.rst:4511 msgid "Test whether every element in *other* is in the set." msgstr "" -#: ../../library/stdtypes.rst:4459 +#: ../../library/stdtypes.rst:4515 msgid "" "Test whether the set is a proper superset of *other*, that is, ``set >= " "other and set != other``." msgstr "" -#: ../../library/stdtypes.rst:4465 +#: ../../library/stdtypes.rst:4521 msgid "Return a new set with elements from the set and all others." msgstr "" -#: ../../library/stdtypes.rst:4470 +#: ../../library/stdtypes.rst:4526 msgid "Return a new set with elements common to the set and all others." msgstr "" -#: ../../library/stdtypes.rst:4475 +#: ../../library/stdtypes.rst:4531 msgid "Return a new set with elements in the set that are not in the others." msgstr "" -#: ../../library/stdtypes.rst:4480 +#: ../../library/stdtypes.rst:4536 msgid "" "Return a new set with elements in either the set or *other* but not both." msgstr "" -#: ../../library/stdtypes.rst:4484 +#: ../../library/stdtypes.rst:4540 msgid "Return a shallow copy of the set." msgstr "" -#: ../../library/stdtypes.rst:4487 +#: ../../library/stdtypes.rst:4543 msgid "" -"Note, the non-operator versions " -"of :meth:`union`, :meth:`intersection`, :meth:`difference`, :meth:`symmetric_difference`, :meth:`issubset`, " -"and :meth:`issuperset` methods will accept any iterable as an argument. In " -"contrast, their operator based counterparts require their arguments to be " -"sets. This precludes error-prone constructions like ``set('abc') & 'cbs'`` " -"in favor of the more readable ``set('abc').intersection('cbs')``." +"Note, the non-operator versions of :meth:`union`, :meth:`intersection`, :" +"meth:`difference`, :meth:`symmetric_difference`, :meth:`issubset`, and :meth:" +"`issuperset` methods will accept any iterable as an argument. In contrast, " +"their operator based counterparts require their arguments to be sets. This " +"precludes error-prone constructions like ``set('abc') & 'cbs'`` in favor of " +"the more readable ``set('abc').intersection('cbs')``." msgstr "" -#: ../../library/stdtypes.rst:4494 +#: ../../library/stdtypes.rst:4550 msgid "" "Both :class:`set` and :class:`frozenset` support set to set comparisons. Two " "sets are equal if and only if every element of each set is contained in the " @@ -6319,14 +6403,14 @@ msgid "" "set is a proper superset of the second set (is a superset, but is not equal)." msgstr "" -#: ../../library/stdtypes.rst:4501 +#: ../../library/stdtypes.rst:4557 msgid "" "Instances of :class:`set` are compared to instances of :class:`frozenset` " "based on their members. For example, ``set('abc') == frozenset('abc')`` " "returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``." msgstr "" -#: ../../library/stdtypes.rst:4505 +#: ../../library/stdtypes.rst:4561 msgid "" "The subset and equality comparisons do not generalize to a total ordering " "function. For example, any two nonempty disjoint sets are not equal and are " @@ -6334,136 +6418,134 @@ msgid "" "``ab``." msgstr "" -#: ../../library/stdtypes.rst:4510 +#: ../../library/stdtypes.rst:4566 msgid "" "Since sets only define partial ordering (subset relationships), the output " "of the :meth:`list.sort` method is undefined for lists of sets." msgstr "" -#: ../../library/stdtypes.rst:4513 +#: ../../library/stdtypes.rst:4569 msgid "Set elements, like dictionary keys, must be :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:4515 +#: ../../library/stdtypes.rst:4571 msgid "" "Binary operations that mix :class:`set` instances with :class:`frozenset` " "return the type of the first operand. For example: ``frozenset('ab') | " "set('bc')`` returns an instance of :class:`frozenset`." msgstr "" -#: ../../library/stdtypes.rst:4519 +#: ../../library/stdtypes.rst:4575 msgid "" "The following table lists operations available for :class:`set` that do not " "apply to immutable instances of :class:`frozenset`:" msgstr "" -#: ../../library/stdtypes.rst:4525 +#: ../../library/stdtypes.rst:4581 msgid "Update the set, adding elements from all others." msgstr "" -#: ../../library/stdtypes.rst:4530 +#: ../../library/stdtypes.rst:4586 msgid "Update the set, keeping only elements found in it and all others." msgstr "" -#: ../../library/stdtypes.rst:4535 +#: ../../library/stdtypes.rst:4591 msgid "Update the set, removing elements found in others." msgstr "" -#: ../../library/stdtypes.rst:4540 +#: ../../library/stdtypes.rst:4596 msgid "" "Update the set, keeping only elements found in either set, but not in both." msgstr "" -#: ../../library/stdtypes.rst:4544 +#: ../../library/stdtypes.rst:4600 msgid "Add element *elem* to the set." msgstr "將元素 *elem* 加入集合。" -#: ../../library/stdtypes.rst:4548 +#: ../../library/stdtypes.rst:4604 msgid "" "Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is not " "contained in the set." msgstr "" -#: ../../library/stdtypes.rst:4553 +#: ../../library/stdtypes.rst:4609 msgid "Remove element *elem* from the set if it is present." msgstr "如果 *elem* 存在於集合中則將其移除。" -#: ../../library/stdtypes.rst:4557 +#: ../../library/stdtypes.rst:4613 msgid "" "Remove and return an arbitrary element from the set. Raises :exc:`KeyError` " "if the set is empty." msgstr "" -#: ../../library/stdtypes.rst:4562 +#: ../../library/stdtypes.rst:4618 msgid "Remove all elements from the set." msgstr "從集合中移除所有元素。" -#: ../../library/stdtypes.rst:4565 +#: ../../library/stdtypes.rst:4621 msgid "" -"Note, the non-operator versions of " -"the :meth:`update`, :meth:`intersection_update`, :meth:`difference_update`, " -"and :meth:`symmetric_difference_update` methods will accept any iterable as " -"an argument." +"Note, the non-operator versions of the :meth:`update`, :meth:" +"`intersection_update`, :meth:`difference_update`, and :meth:" +"`symmetric_difference_update` methods will accept any iterable as an " +"argument." msgstr "" -#: ../../library/stdtypes.rst:4570 +#: ../../library/stdtypes.rst:4626 msgid "" -"Note, the *elem* argument to " -"the :meth:`~object.__contains__`, :meth:`remove`, and :meth:`discard` " -"methods may be a set. To support searching for an equivalent frozenset, a " -"temporary one is created from *elem*." +"Note, the *elem* argument to the :meth:`~object.__contains__`, :meth:" +"`remove`, and :meth:`discard` methods may be a set. To support searching " +"for an equivalent frozenset, a temporary one is created from *elem*." msgstr "" -#: ../../library/stdtypes.rst:4579 +#: ../../library/stdtypes.rst:4635 msgid "Mapping Types --- :class:`dict`" msgstr "" -#: ../../library/stdtypes.rst:4589 +#: ../../library/stdtypes.rst:4645 msgid "" "A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. " "Mappings are mutable objects. There is currently only one standard mapping " -"type, the :dfn:`dictionary`. (For other containers see the built-" -"in :class:`list`, :class:`set`, and :class:`tuple` classes, and " -"the :mod:`collections` module.)" +"type, the :dfn:`dictionary`. (For other containers see the built-in :class:" +"`list`, :class:`set`, and :class:`tuple` classes, and the :mod:`collections` " +"module.)" msgstr "" -#: ../../library/stdtypes.rst:4595 +#: ../../library/stdtypes.rst:4651 msgid "" -"A dictionary's keys are *almost* arbitrary values. Values that are " -"not :term:`hashable`, that is, values containing lists, dictionaries or " -"other mutable types (that are compared by value rather than by object " -"identity) may not be used as keys. Values that compare equal (such as ``1``, " -"``1.0``, and ``True``) can be used interchangeably to index the same " -"dictionary entry." +"A dictionary's keys are *almost* arbitrary values. Values that are not :" +"term:`hashable`, that is, values containing lists, dictionaries or other " +"mutable types (that are compared by value rather than by object identity) " +"may not be used as keys. Values that compare equal (such as ``1``, ``1.0``, " +"and ``True``) can be used interchangeably to index the same dictionary entry." msgstr "" -#: ../../library/stdtypes.rst:4606 +#: ../../library/stdtypes.rst:4662 msgid "" "Return a new dictionary initialized from an optional positional argument and " "a possibly empty set of keyword arguments." msgstr "" -#: ../../library/stdtypes.rst:4609 +#: ../../library/stdtypes.rst:4665 msgid "Dictionaries can be created by several means:" msgstr "字典可以用數種方式建立:" -#: ../../library/stdtypes.rst:4611 +#: ../../library/stdtypes.rst:4667 msgid "" "Use a comma-separated list of ``key: value`` pairs within braces: ``{'jack': " "4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:4613 +#: ../../library/stdtypes.rst:4669 msgid "Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``" msgstr "" -#: ../../library/stdtypes.rst:4614 +#: ../../library/stdtypes.rst:4670 msgid "" "Use the type constructor: ``dict()``, ``dict([('foo', 100), ('bar', " "200)])``, ``dict(foo=100, bar=200)``" msgstr "" -#: ../../library/stdtypes.rst:4617 +#: ../../library/stdtypes.rst:4673 msgid "" "If no positional argument is given, an empty dictionary is created. If a " "positional argument is given and it defines a ``keys()`` method, a " @@ -6476,7 +6558,7 @@ msgid "" "that key becomes the corresponding value in the new dictionary." msgstr "" -#: ../../library/stdtypes.rst:4627 +#: ../../library/stdtypes.rst:4683 msgid "" "If keyword arguments are given, the keyword arguments and their values are " "added to the dictionary created from the positional argument. If a key " @@ -6484,13 +6566,13 @@ msgid "" "the value from the positional argument." msgstr "" -#: ../../library/stdtypes.rst:4632 ../../library/stdtypes.rst:4650 +#: ../../library/stdtypes.rst:4688 ../../library/stdtypes.rst:4706 msgid "" "Providing keyword arguments as in the first example only works for keys that " "are valid Python identifiers. Otherwise, any valid keys can be used." msgstr "" -#: ../../library/stdtypes.rst:4635 +#: ../../library/stdtypes.rst:4691 msgid "" "Dictionaries compare equal if and only if they have the same ``(key, " "value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', " @@ -6499,7 +6581,7 @@ msgid "" "``{\"one\": 1, \"two\": 2, \"three\": 3}``::" msgstr "" -#: ../../library/stdtypes.rst:4641 +#: ../../library/stdtypes.rst:4697 msgid "" ">>> a = dict(one=1, two=2, three=3)\n" ">>> b = {'one': 1, 'two': 2, 'three': 3}\n" @@ -6519,13 +6601,13 @@ msgstr "" ">>> a == b == c == d == e == f\n" "True" -#: ../../library/stdtypes.rst:4653 +#: ../../library/stdtypes.rst:4709 msgid "" "Dictionaries preserve insertion order. Note that updating a key does not " "affect the order. Keys added after deletion are inserted at the end. ::" msgstr "" -#: ../../library/stdtypes.rst:4656 +#: ../../library/stdtypes.rst:4712 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -6557,44 +6639,44 @@ msgstr "" ">>> d\n" "{'one': 42, 'three': 3, 'four': 4, 'two': None}" -#: ../../library/stdtypes.rst:4671 +#: ../../library/stdtypes.rst:4727 msgid "" "Dictionary order is guaranteed to be insertion order. This behavior was an " "implementation detail of CPython from 3.6." msgstr "" -#: ../../library/stdtypes.rst:4675 +#: ../../library/stdtypes.rst:4731 msgid "" "These are the operations that dictionaries support (and therefore, custom " "mapping types should support too):" msgstr "" -#: ../../library/stdtypes.rst:4680 +#: ../../library/stdtypes.rst:4736 msgid "Return a list of all the keys used in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:4684 +#: ../../library/stdtypes.rst:4740 msgid "Return the number of items in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:4688 +#: ../../library/stdtypes.rst:4744 msgid "" "Return the item of *d* with key *key*. Raises a :exc:`KeyError` if *key* is " "not in the map." msgstr "" -#: ../../library/stdtypes.rst:4693 +#: ../../library/stdtypes.rst:4749 msgid "" "If a subclass of dict defines a method :meth:`__missing__` and *key* is not " "present, the ``d[key]`` operation calls that method with the key *key* as " "argument. The ``d[key]`` operation then returns or raises whatever is " "returned or raised by the ``__missing__(key)`` call. No other operations or " -"methods invoke :meth:`__missing__`. If :meth:`__missing__` is not " -"defined, :exc:`KeyError` is raised. :meth:`__missing__` must be a method; it " -"cannot be an instance variable::" +"methods invoke :meth:`__missing__`. If :meth:`__missing__` is not defined, :" +"exc:`KeyError` is raised. :meth:`__missing__` must be a method; it cannot be " +"an instance variable::" msgstr "" -#: ../../library/stdtypes.rst:4701 +#: ../../library/stdtypes.rst:4757 msgid "" ">>> class Counter(dict):\n" "... def __missing__(self, key):\n" @@ -6618,51 +6700,51 @@ msgstr "" ">>> c['red']\n" "1" -#: ../../library/stdtypes.rst:4712 +#: ../../library/stdtypes.rst:4768 msgid "" -"The example above shows part of the implementation " -"of :class:`collections.Counter`. A different ``__missing__`` method is used " -"by :class:`collections.defaultdict`." +"The example above shows part of the implementation of :class:`collections." +"Counter`. A different ``__missing__`` method is used by :class:`collections." +"defaultdict`." msgstr "" -#: ../../library/stdtypes.rst:4718 +#: ../../library/stdtypes.rst:4774 msgid "Set ``d[key]`` to *value*." msgstr "將 ``d[key]`` 設為 *value*。" -#: ../../library/stdtypes.rst:4722 +#: ../../library/stdtypes.rst:4778 msgid "" "Remove ``d[key]`` from *d*. Raises a :exc:`KeyError` if *key* is not in the " "map." msgstr "從 *d* 中移除 ``d[key]``。若 *key* 不在對映中則引發 :exc:`KeyError`。" -#: ../../library/stdtypes.rst:4727 +#: ../../library/stdtypes.rst:4783 msgid "Return ``True`` if *d* has a key *key*, else ``False``." msgstr "若 *d* 有鍵 *key* 則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/stdtypes.rst:4731 +#: ../../library/stdtypes.rst:4787 msgid "Equivalent to ``not key in d``." msgstr "等價於 ``not key in d``。" -#: ../../library/stdtypes.rst:4735 +#: ../../library/stdtypes.rst:4791 msgid "" "Return an iterator over the keys of the dictionary. This is a shortcut for " "``iter(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:4740 +#: ../../library/stdtypes.rst:4796 msgid "Remove all items from the dictionary." msgstr "從字典中移除所有項目。" -#: ../../library/stdtypes.rst:4744 +#: ../../library/stdtypes.rst:4800 msgid "Return a shallow copy of the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4748 +#: ../../library/stdtypes.rst:4804 msgid "" "Create a new dictionary with keys from *iterable* and values set to *value*." msgstr "" -#: ../../library/stdtypes.rst:4750 +#: ../../library/stdtypes.rst:4806 msgid "" ":meth:`fromkeys` is a class method that returns a new dictionary. *value* " "defaults to ``None``. All of the values refer to just a single instance, so " @@ -6671,70 +6753,70 @@ msgid "" "` instead." msgstr "" -#: ../../library/stdtypes.rst:4758 +#: ../../library/stdtypes.rst:4814 msgid "" "Return the value for *key* if *key* is in the dictionary, else *default*. If " "*default* is not given, it defaults to ``None``, so that this method never " "raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:4764 +#: ../../library/stdtypes.rst:4820 msgid "" "Return a new view of the dictionary's items (``(key, value)`` pairs). See " "the :ref:`documentation of view objects `." msgstr "" -#: ../../library/stdtypes.rst:4769 +#: ../../library/stdtypes.rst:4825 msgid "" "Return a new view of the dictionary's keys. See the :ref:`documentation of " "view objects `." msgstr "" -#: ../../library/stdtypes.rst:4774 +#: ../../library/stdtypes.rst:4830 msgid "" "If *key* is in the dictionary, remove it and return its value, else return " -"*default*. If *default* is not given and *key* is not in the dictionary, " -"a :exc:`KeyError` is raised." +"*default*. If *default* is not given and *key* is not in the dictionary, a :" +"exc:`KeyError` is raised." msgstr "" -#: ../../library/stdtypes.rst:4780 +#: ../../library/stdtypes.rst:4836 msgid "" "Remove and return a ``(key, value)`` pair from the dictionary. Pairs are " "returned in :abbr:`LIFO (last-in, first-out)` order." msgstr "" -#: ../../library/stdtypes.rst:4783 +#: ../../library/stdtypes.rst:4839 msgid "" ":meth:`popitem` is useful to destructively iterate over a dictionary, as " -"often used in set algorithms. If the dictionary is empty, " -"calling :meth:`popitem` raises a :exc:`KeyError`." +"often used in set algorithms. If the dictionary is empty, calling :meth:" +"`popitem` raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:4787 +#: ../../library/stdtypes.rst:4843 msgid "" "LIFO order is now guaranteed. In prior versions, :meth:`popitem` would " "return an arbitrary key/value pair." msgstr "" -#: ../../library/stdtypes.rst:4793 +#: ../../library/stdtypes.rst:4849 msgid "" "Return a reverse iterator over the keys of the dictionary. This is a " "shortcut for ``reversed(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:4800 +#: ../../library/stdtypes.rst:4856 msgid "" "If *key* is in the dictionary, return its value. If not, insert *key* with " "a value of *default* and return *default*. *default* defaults to ``None``." msgstr "" -#: ../../library/stdtypes.rst:4806 +#: ../../library/stdtypes.rst:4862 msgid "" "Update the dictionary with the key/value pairs from *other*, overwriting " "existing keys. Return ``None``." msgstr "" -#: ../../library/stdtypes.rst:4809 +#: ../../library/stdtypes.rst:4865 msgid "" ":meth:`update` accepts either another object with a ``keys()`` method (in " "which case :meth:`~object.__getitem__` is called with every key returned " @@ -6743,20 +6825,20 @@ msgid "" "is then updated with those key/value pairs: ``d.update(red=1, blue=2)``." msgstr "" -#: ../../library/stdtypes.rst:4817 +#: ../../library/stdtypes.rst:4873 msgid "" "Return a new view of the dictionary's values. See the :ref:`documentation " "of view objects `." msgstr "" -#: ../../library/stdtypes.rst:4820 +#: ../../library/stdtypes.rst:4876 msgid "" "An equality comparison between one ``dict.values()`` view and another will " "always return ``False``. This also applies when comparing ``dict.values()`` " "to itself::" msgstr "" -#: ../../library/stdtypes.rst:4824 +#: ../../library/stdtypes.rst:4880 msgid "" ">>> d = {'a': 1}\n" ">>> d.values() == d.values()\n" @@ -6766,25 +6848,25 @@ msgstr "" ">>> d.values() == d.values()\n" "False" -#: ../../library/stdtypes.rst:4830 +#: ../../library/stdtypes.rst:4886 msgid "" "Create a new dictionary with the merged keys and values of *d* and *other*, " "which must both be dictionaries. The values of *other* take priority when " "*d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:4838 +#: ../../library/stdtypes.rst:4894 msgid "" "Update the dictionary *d* with keys and values from *other*, which may be " "either a :term:`mapping` or an :term:`iterable` of key/value pairs. The " "values of *other* take priority when *d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:4844 +#: ../../library/stdtypes.rst:4900 msgid "Dictionaries and dictionary views are reversible. ::" msgstr "" -#: ../../library/stdtypes.rst:4846 +#: ../../library/stdtypes.rst:4902 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -6806,85 +6888,85 @@ msgstr "" ">>> list(reversed(d.items()))\n" "[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" -#: ../../library/stdtypes.rst:4856 +#: ../../library/stdtypes.rst:4912 msgid "Dictionaries are now reversible." msgstr "" -#: ../../library/stdtypes.rst:4861 +#: ../../library/stdtypes.rst:4917 msgid "" -":class:`types.MappingProxyType` can be used to create a read-only view of " -"a :class:`dict`." +":class:`types.MappingProxyType` can be used to create a read-only view of a :" +"class:`dict`." msgstr "" -#: ../../library/stdtypes.rst:4868 +#: ../../library/stdtypes.rst:4924 msgid "Dictionary view objects" msgstr "字典視圖物件" -#: ../../library/stdtypes.rst:4870 +#: ../../library/stdtypes.rst:4926 msgid "" -"The objects returned by :meth:`dict.keys`, :meth:`dict.values` " -"and :meth:`dict.items` are *view objects*. They provide a dynamic view on " -"the dictionary's entries, which means that when the dictionary changes, the " -"view reflects these changes." +"The objects returned by :meth:`dict.keys`, :meth:`dict.values` and :meth:" +"`dict.items` are *view objects*. They provide a dynamic view on the " +"dictionary's entries, which means that when the dictionary changes, the view " +"reflects these changes." msgstr "" -#: ../../library/stdtypes.rst:4875 +#: ../../library/stdtypes.rst:4931 msgid "" "Dictionary views can be iterated over to yield their respective data, and " "support membership tests:" msgstr "" -#: ../../library/stdtypes.rst:4880 +#: ../../library/stdtypes.rst:4936 msgid "Return the number of entries in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4884 +#: ../../library/stdtypes.rst:4940 msgid "" "Return an iterator over the keys, values or items (represented as tuples of " "``(key, value)``) in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4887 +#: ../../library/stdtypes.rst:4943 msgid "" "Keys and values are iterated over in insertion order. This allows the " -"creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = " -"zip(d.values(), d.keys())``. Another way to create the same list is ``pairs " -"= [(v, k) for (k, v) in d.items()]``." +"creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = zip(d." +"values(), d.keys())``. Another way to create the same list is ``pairs = " +"[(v, k) for (k, v) in d.items()]``." msgstr "" -#: ../../library/stdtypes.rst:4892 +#: ../../library/stdtypes.rst:4948 msgid "" "Iterating views while adding or deleting entries in the dictionary may raise " "a :exc:`RuntimeError` or fail to iterate over all entries." msgstr "" -#: ../../library/stdtypes.rst:4895 +#: ../../library/stdtypes.rst:4951 msgid "Dictionary order is guaranteed to be insertion order." msgstr "" -#: ../../library/stdtypes.rst:4900 +#: ../../library/stdtypes.rst:4956 msgid "" "Return ``True`` if *x* is in the underlying dictionary's keys, values or " "items (in the latter case, *x* should be a ``(key, value)`` tuple)." msgstr "" -#: ../../library/stdtypes.rst:4905 +#: ../../library/stdtypes.rst:4961 msgid "" "Return a reverse iterator over the keys, values or items of the dictionary. " "The view will be iterated in reverse order of the insertion." msgstr "" -#: ../../library/stdtypes.rst:4908 +#: ../../library/stdtypes.rst:4964 msgid "Dictionary views are now reversible." msgstr "" -#: ../../library/stdtypes.rst:4913 +#: ../../library/stdtypes.rst:4969 msgid "" "Return a :class:`types.MappingProxyType` that wraps the original dictionary " "to which the view refers." msgstr "" -#: ../../library/stdtypes.rst:4918 +#: ../../library/stdtypes.rst:4974 msgid "" "Keys views are set-like since their entries are unique and :term:`hashable`. " "Items views also have set-like operations since the (key, value) pairs are " @@ -6898,11 +6980,11 @@ msgid "" "input." msgstr "" -#: ../../library/stdtypes.rst:4930 +#: ../../library/stdtypes.rst:4986 msgid "An example of dictionary view usage::" msgstr "" -#: ../../library/stdtypes.rst:4932 +#: ../../library/stdtypes.rst:4988 msgid "" ">>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}\n" ">>> keys = dishes.keys()\n" @@ -6943,11 +7025,11 @@ msgid "" "500" msgstr "" -#: ../../library/stdtypes.rst:4974 +#: ../../library/stdtypes.rst:5030 msgid "Context Manager Types" msgstr "情境管理器型別" -#: ../../library/stdtypes.rst:4981 +#: ../../library/stdtypes.rst:5037 msgid "" "Python's :keyword:`with` statement supports the concept of a runtime context " "defined by a context manager. This is implemented using a pair of methods " @@ -6958,7 +7040,7 @@ msgstr "" "要使用兩個方法來實作,該方法讓使用者定義類別能夠去定義 runtime 情境,且該情境" "在執行陳述式主體 (statement body) 之前進入、在陳述式結束時退出:" -#: ../../library/stdtypes.rst:4989 +#: ../../library/stdtypes.rst:5045 msgid "" "Enter the runtime context and return either this object or another object " "related to the runtime context. The value returned by this method is bound " @@ -6969,17 +7051,16 @@ msgstr "" "的值有被綁定到使用此情境管理器的 :keyword:`with` 陳述式的 :keyword:`!as` 子句" "中的識別字。" -#: ../../library/stdtypes.rst:4994 +#: ../../library/stdtypes.rst:5050 msgid "" "An example of a context manager that returns itself is a :term:`file " -"object`. File objects return themselves from __enter__() to " -"allow :func:`open` to be used as the context expression in a :keyword:`with` " -"statement." +"object`. File objects return themselves from __enter__() to allow :func:" +"`open` to be used as the context expression in a :keyword:`with` statement." msgstr "" "一個會回傳自己的情境管理器範例是 :term:`file object`。檔案物件從 __enter__() " "回傳自己,以允許將 :func:`open` 用作 :keyword:`with` 陳述式中的情境運算式。" -#: ../../library/stdtypes.rst:4998 +#: ../../library/stdtypes.rst:5054 msgid "" "An example of a context manager that returns a related object is the one " "returned by :func:`decimal.localcontext`. These managers set the active " @@ -6993,7 +7074,7 @@ msgstr "" "本。這允許對 :keyword:`with` 陳述式主體中的目前十進位情境進行更改,而不會影" "響 :keyword:`!with` 陳述式外部的程式碼。" -#: ../../library/stdtypes.rst:5008 +#: ../../library/stdtypes.rst:5064 msgid "" "Exit the runtime context and return a Boolean flag indicating if any " "exception that occurred should be suppressed. If an exception occurred while " @@ -7001,11 +7082,11 @@ msgid "" "the exception type, value and traceback information. Otherwise, all three " "arguments are ``None``." msgstr "" -"退出 runtime 情境並回傳布林旗標以表示是否應抑制曾發生的任何例外。如果在執" -"行 :keyword:`with` 陳述式主體時發生例外,則引數包含例外型別、值和回溯 " +"退出 runtime 情境並回傳布林旗標以表示是否應抑制曾發生的任何例外。如果在執行 :" +"keyword:`with` 陳述式主體時發生例外,則引數包含例外型別、值和回溯 " "(traceback) 資訊。否則,所有三個引數都是 ``None``。" -#: ../../library/stdtypes.rst:5013 +#: ../../library/stdtypes.rst:5069 msgid "" "Returning a true value from this method will cause the :keyword:`with` " "statement to suppress the exception and continue execution with the " @@ -7015,24 +7096,24 @@ msgid "" "replace any exception that occurred in the body of the :keyword:`!with` " "statement." msgstr "" -"從此方法回傳 true 值將導致 :keyword:`with` 陳述式抑制例外並繼續執行緊接" -"著 :keyword:`!with` 陳述式之後的陳述式。否則,該例外將在該方法執行完畢後繼續" -"傳播 (propagate)。執行此方法期間發生的例外會取代 :keyword:`!with` 陳述式主體" -"中發生的任何例外。" +"從此方法回傳 true 值將導致 :keyword:`with` 陳述式抑制例外並繼續執行緊接著 :" +"keyword:`!with` 陳述式之後的陳述式。否則,該例外將在該方法執行完畢後繼續傳播 " +"(propagate)。執行此方法期間發生的例外會取代 :keyword:`!with` 陳述式主體中發生" +"的任何例外。" -#: ../../library/stdtypes.rst:5020 +#: ../../library/stdtypes.rst:5076 msgid "" "The exception passed in should never be reraised explicitly - instead, this " "method should return a false value to indicate that the method completed " "successfully and does not want to suppress the raised exception. This allows " -"context management code to easily detect whether or not " -"an :meth:`~object.__exit__` method has actually failed." +"context management code to easily detect whether or not an :meth:`~object." +"__exit__` method has actually failed." msgstr "" "傳入的例外不應明確重新引發 - 取而代之的是,此方法應回傳 false 值以指示該方法" -"已成功完成且不希望抑制引發的例外。這讓情境管理程式碼能輕鬆檢" -"測 :meth:`__exit__` 方法是否曾實際失敗過。" +"已成功完成且不希望抑制引發的例外。這讓情境管理程式碼能輕鬆檢測 :meth:" +"`__exit__` 方法是否曾實際失敗過。" -#: ../../library/stdtypes.rst:5026 +#: ../../library/stdtypes.rst:5082 msgid "" "Python defines several context managers to support easy thread " "synchronisation, prompt closure of files or other objects, and simpler " @@ -7044,23 +7125,22 @@ msgstr "" "及對有效十進位算術情境的更簡單操作。除了情境管理協定的實作之外,不會對特定型" "別進行特殊處理。更多範例請參閱 :mod:`contextlib` 模組。" -#: ../../library/stdtypes.rst:5032 +#: ../../library/stdtypes.rst:5088 msgid "" "Python's :term:`generator`\\s and the :class:`contextlib.contextmanager` " "decorator provide a convenient way to implement these protocols. If a " "generator function is decorated with the :class:`contextlib.contextmanager` " -"decorator, it will return a context manager implementing the " -"necessary :meth:`~contextmanager.__enter__` " -"and :meth:`~contextmanager.__exit__` methods, rather than the iterator " -"produced by an undecorated generator function." +"decorator, it will return a context manager implementing the necessary :meth:" +"`~contextmanager.__enter__` and :meth:`~contextmanager.__exit__` methods, " +"rather than the iterator produced by an undecorated generator function." msgstr "" "Python 的 :term:`generator` 和 :class:`contextlib.contextmanager` 裝飾器提供" -"了一種便捷的方法來實作這些協定。如果產生器函式" -"以 :class:`contextlib.contextmanager` 裝飾器裝飾,它將回傳一個有實作出需要" -"的 :meth:`~contextmanager.__enter__` 和 :meth:`~contextmanager.__exit__` 方法" -"的情境管理器,而不是由未裝飾產生器函式產生的疊代器。" +"了一種便捷的方法來實作這些協定。如果產生器函式以 :class:`contextlib." +"contextmanager` 裝飾器裝飾,它將回傳一個有實作出需要的 :meth:" +"`~contextmanager.__enter__` 和 :meth:`~contextmanager.__exit__` 方法的情境管" +"理器,而不是由未裝飾產生器函式產生的疊代器。" -#: ../../library/stdtypes.rst:5039 +#: ../../library/stdtypes.rst:5095 msgid "" "Note that there is no specific slot for any of these methods in the type " "structure for Python objects in the Python/C API. Extension types wanting to " @@ -7072,27 +7152,27 @@ msgstr "" "定義這些方法的擴充型別必須將它們作為普通的 Python 可存取方法提供。與設定 " "runtime 情境的開銷相比,單一類別字典查找的開銷可以忽略不計。" -#: ../../library/stdtypes.rst:5047 +#: ../../library/stdtypes.rst:5103 msgid "" -"Type Annotation Types --- :ref:`Generic Alias `, :ref:`Union `" +"Type Annotation Types --- :ref:`Generic Alias `, :ref:" +"`Union `" msgstr "" -"型別註釋的型別 --- :ref:`泛型別名 (Generic Alias) `、:ref:`聯合 (Union) `" +"型別註釋的型別 --- :ref:`泛型別名 (Generic Alias) `、:" +"ref:`聯合 (Union) `" -#: ../../library/stdtypes.rst:5052 +#: ../../library/stdtypes.rst:5108 msgid "" -"The core built-in types for :term:`type annotations ` " -"are :ref:`Generic Alias ` and :ref:`Union `." +"The core built-in types for :term:`type annotations ` are :ref:" +"`Generic Alias ` and :ref:`Union `." msgstr "" ":term:`型別註釋 ` 的核心內建型別是\\ :ref:`泛型別名 `\\ 和\\ :ref:`聯合 `。" -#: ../../library/stdtypes.rst:5059 +#: ../../library/stdtypes.rst:5115 msgid "Generic Alias Type" msgstr "泛型別名型別" -#: ../../library/stdtypes.rst:5065 +#: ../../library/stdtypes.rst:5121 msgid "" "``GenericAlias`` objects are generally created by :ref:`subscripting " "` a class. They are most often used with :ref:`container " @@ -7108,7 +7188,7 @@ msgstr "" "立的。``GenericAlias`` 物件主要會與\\ :term:`型別註釋 ` 一起使" "用。" -#: ../../library/stdtypes.rst:5075 +#: ../../library/stdtypes.rst:5131 msgid "" "It is generally only possible to subscript a class if the class implements " "the special method :meth:`~object.__class_getitem__`." @@ -7116,7 +7196,7 @@ msgstr "" "通常只有當類別有實作特殊方法 :meth:`~object.__class_getitem__` 時才可以去下標" "該類別。" -#: ../../library/stdtypes.rst:5078 +#: ../../library/stdtypes.rst:5134 msgid "" "A ``GenericAlias`` object acts as a proxy for a :term:`generic type`, " "implementing *parameterized generics*." @@ -7124,19 +7204,19 @@ msgstr "" "將一個 ``GenericAlias`` 物件用作 :term:`generic type` 的代理,實作\\ *參數化" "泛型 (parameterized generics)*。" -#: ../../library/stdtypes.rst:5081 +#: ../../library/stdtypes.rst:5137 msgid "" "For a container class, the argument(s) supplied to a :ref:`subscription " "` of the class may indicate the type(s) of the elements an " "object contains. For example, ``set[bytes]`` can be used in type annotations " -"to signify a :class:`set` in which all the elements are of " -"type :class:`bytes`." +"to signify a :class:`set` in which all the elements are of type :class:" +"`bytes`." msgstr "" "對於一個容器類別,提供給該類別的\\ :ref:`下標 `\\ 引數可以代表" -"物件所包含元素的型別。例如 ``set[bytes]`` 可以用於型別註釋來表示一" -"個 :class:`set`,其中所有元素的型別都是 :class:`bytes`。" +"物件所包含元素的型別。例如 ``set[bytes]`` 可以用於型別註釋來表示一個 :class:" +"`set`,其中所有元素的型別都是 :class:`bytes`。" -#: ../../library/stdtypes.rst:5087 +#: ../../library/stdtypes.rst:5143 msgid "" "For a class which defines :meth:`~object.__class_getitem__` but is not a " "container, the argument(s) supplied to a subscription of the class will " @@ -7148,7 +7228,7 @@ msgstr "" "標引數通常會指示物件上有定義的一個或多個方法的回傳型別。例如\\ :mod:`正規表示" "式 `\\ 可以用於 :class:`str` 和 :class:`bytes` 資料型別:" -#: ../../library/stdtypes.rst:5093 +#: ../../library/stdtypes.rst:5149 msgid "" "If ``x = re.search('foo', 'foo')``, ``x`` will be a :ref:`re.Match ` object where the return values of ``x.group(0)`` and ``x[0]`` will " @@ -7160,11 +7240,11 @@ msgstr "" "別。我們就可以用 ``GenericAlias`` ``re.Match[str]`` 在型別註釋中表示這種物" "件。" -#: ../../library/stdtypes.rst:5099 +#: ../../library/stdtypes.rst:5155 msgid "" "If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`), " -"``y`` will also be an instance of ``re.Match``, but the return values of " -"``y.group(0)`` and ``y[0]`` will both be of type :class:`bytes`. In type " +"``y`` will also be an instance of ``re.Match``, but the return values of ``y." +"group(0)`` and ``y[0]`` will both be of type :class:`bytes`. In type " "annotations, we would represent this variety of :ref:`re.Match ` objects with ``re.Match[bytes]``." msgstr "" @@ -7173,26 +7253,26 @@ msgstr "" "別都是 :class:`bytes`。在型別註釋中,我們將用 ``re.Match[bytes]`` 來表示各" "種 :ref:`re.Match ` 物件。" -#: ../../library/stdtypes.rst:5105 +#: ../../library/stdtypes.rst:5161 msgid "" -"``GenericAlias`` objects are instances of the " -"class :class:`types.GenericAlias`, which can also be used to create " -"``GenericAlias`` objects directly." +"``GenericAlias`` objects are instances of the class :class:`types." +"GenericAlias`, which can also be used to create ``GenericAlias`` objects " +"directly." msgstr "" "``GenericAlias`` 物件是 :class:`types.GenericAlias` 類別的實例,也可以用來直" "接建立 ``GenericAlias`` 物件。" -#: ../../library/stdtypes.rst:5111 +#: ../../library/stdtypes.rst:5167 msgid "" "Creates a ``GenericAlias`` representing a type ``T`` parameterized by types " "*X*, *Y*, and more depending on the ``T`` used. For example, a function " "expecting a :class:`list` containing :class:`float` elements::" msgstr "" "建立一個 ``GenericAlias`` 來表示一個型別 ``T``,其以型別 *X*、*Y* 等(取決於" -"所使用的 ``T``)來參數化。例如,一個函式需要一個包含 :class:`float` 元素" -"的 :class:`list`: ::" +"所使用的 ``T``)來參數化。例如,一個函式需要一個包含 :class:`float` 元素的 :" +"class:`list`: ::" -#: ../../library/stdtypes.rst:5116 +#: ../../library/stdtypes.rst:5172 msgid "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" @@ -7200,7 +7280,7 @@ msgstr "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" -#: ../../library/stdtypes.rst:5119 +#: ../../library/stdtypes.rst:5175 msgid "" "Another example for :term:`mapping` objects, using a :class:`dict`, which is " "a generic type expecting two type parameters representing the key type and " @@ -7211,7 +7291,7 @@ msgstr "" "別,需要兩個型別參數,分別表示鍵型別和值型別。在此範例中,函式需要一個 " "``dict``,其帶有 :class:`str` 型別的鍵和 :class:`int` 型別的值: ::" -#: ../../library/stdtypes.rst:5124 +#: ../../library/stdtypes.rst:5180 msgid "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." @@ -7219,7 +7299,7 @@ msgstr "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." -#: ../../library/stdtypes.rst:5127 +#: ../../library/stdtypes.rst:5183 msgid "" "The builtin functions :func:`isinstance` and :func:`issubclass` do not " "accept ``GenericAlias`` types for their second argument::" @@ -7227,7 +7307,7 @@ msgstr "" "內建函式 :func:`isinstance` 和 :func:`issubclass` 不接受 ``GenericAlias`` 型" "別作為第二個引數: ::" -#: ../../library/stdtypes.rst:5130 +#: ../../library/stdtypes.rst:5186 msgid "" ">>> isinstance([1, 2], list[str])\n" "Traceback (most recent call last):\n" @@ -7239,7 +7319,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" -#: ../../library/stdtypes.rst:5135 +#: ../../library/stdtypes.rst:5191 msgid "" "The Python runtime does not enforce :term:`type annotations `. " "This extends to generic types and their type parameters. When creating a " @@ -7251,7 +7331,7 @@ msgstr "" "及其型別參數。當從 ``GenericAlias`` 建立容器物件時,不會檢查容器中元素的型" "別。例如,不鼓勵使用以下程式碼,但 runtime 不會出現錯誤: ::" -#: ../../library/stdtypes.rst:5141 +#: ../../library/stdtypes.rst:5197 msgid "" ">>> t = list[str]\n" ">>> t([1, 2, 3])\n" @@ -7261,13 +7341,13 @@ msgstr "" ">>> t([1, 2, 3])\n" "[1, 2, 3]" -#: ../../library/stdtypes.rst:5145 +#: ../../library/stdtypes.rst:5201 msgid "" "Furthermore, parameterized generics erase type parameters during object " "creation::" msgstr "此外,參數化泛型在物件建立期間會擦除 (erase) 型別參數: ::" -#: ../../library/stdtypes.rst:5148 +#: ../../library/stdtypes.rst:5204 msgid "" ">>> t = list[str]\n" ">>> type(t)\n" @@ -7285,13 +7365,13 @@ msgstr "" ">>> type(l)\n" "" -#: ../../library/stdtypes.rst:5156 +#: ../../library/stdtypes.rst:5212 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" msgstr "在泛型上呼叫 :func:`repr` 或 :func:`str` 會顯示參數化型別: ::" -#: ../../library/stdtypes.rst:5158 +#: ../../library/stdtypes.rst:5214 msgid "" ">>> repr(list[int])\n" "'list[int]'\n" @@ -7305,15 +7385,15 @@ msgstr "" ">>> str(list[int])\n" "'list[int]'" -#: ../../library/stdtypes.rst:5164 +#: ../../library/stdtypes.rst:5220 msgid "" "The :meth:`~object.__getitem__` method of generic containers will raise an " "exception to disallow mistakes like ``dict[str][str]``::" msgstr "" -"為防止像是 ``dict[str][str]`` 的錯誤出現,泛型容器" -"的 :meth:`~object.__getitem__` 方法會在這種情況下引發例外: ::" +"為防止像是 ``dict[str][str]`` 的錯誤出現,泛型容器的 :meth:`~object." +"__getitem__` 方法會在這種情況下引發例外: ::" -#: ../../library/stdtypes.rst:5167 +#: ../../library/stdtypes.rst:5223 msgid "" ">>> dict[str][str]\n" "Traceback (most recent call last):\n" @@ -7325,17 +7405,17 @@ msgstr "" " ...\n" "TypeError: dict[str] is not a generic class" -#: ../../library/stdtypes.rst:5172 +#: ../../library/stdtypes.rst:5228 msgid "" "However, such expressions are valid when :ref:`type variables ` " "are used. The index must have as many elements as there are type variable " "items in the ``GenericAlias`` object's :attr:`~genericalias.__args__`. ::" msgstr "" "然而當使用\\ :ref:`型別變數 (type variable) ` 時,此類運算式是有效" -"的。索引的元素數量必須與 ``GenericAlias`` 物件" -"的 :attr:`~genericalias.__args__` 中的型別變數項目一樣多: ::" +"的。索引的元素數量必須與 ``GenericAlias`` 物件的 :attr:`~genericalias." +"__args__` 中的型別變數項目一樣多: ::" -#: ../../library/stdtypes.rst:5176 +#: ../../library/stdtypes.rst:5232 msgid "" ">>> from typing import TypeVar\n" ">>> Y = TypeVar('Y')\n" @@ -7347,253 +7427,253 @@ msgstr "" ">>> dict[str, Y][int]\n" "dict[str, int]" -#: ../../library/stdtypes.rst:5183 +#: ../../library/stdtypes.rst:5239 msgid "Standard Generic Classes" msgstr "標準泛型類別" -#: ../../library/stdtypes.rst:5185 +#: ../../library/stdtypes.rst:5241 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." msgstr "以下標準函式庫類別有支援參數化泛型。此列表並非詳盡無遺。" -#: ../../library/stdtypes.rst:5188 +#: ../../library/stdtypes.rst:5244 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../library/stdtypes.rst:5189 +#: ../../library/stdtypes.rst:5245 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../library/stdtypes.rst:5190 +#: ../../library/stdtypes.rst:5246 msgid ":class:`dict`" msgstr ":class:`dict`" -#: ../../library/stdtypes.rst:5191 +#: ../../library/stdtypes.rst:5247 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../library/stdtypes.rst:5192 +#: ../../library/stdtypes.rst:5248 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../library/stdtypes.rst:5193 +#: ../../library/stdtypes.rst:5249 msgid ":class:`type`" msgstr ":class:`type`" -#: ../../library/stdtypes.rst:5194 +#: ../../library/stdtypes.rst:5250 msgid ":class:`asyncio.Future`" msgstr ":class:`asyncio.Future`" -#: ../../library/stdtypes.rst:5195 +#: ../../library/stdtypes.rst:5251 msgid ":class:`asyncio.Task`" msgstr ":class:`asyncio.Task`" -#: ../../library/stdtypes.rst:5196 +#: ../../library/stdtypes.rst:5252 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../library/stdtypes.rst:5197 +#: ../../library/stdtypes.rst:5253 msgid ":class:`collections.defaultdict`" msgstr ":class:`collections.defaultdict`" -#: ../../library/stdtypes.rst:5198 +#: ../../library/stdtypes.rst:5254 msgid ":class:`collections.OrderedDict`" msgstr ":class:`collections.OrderedDict`" -#: ../../library/stdtypes.rst:5199 +#: ../../library/stdtypes.rst:5255 msgid ":class:`collections.Counter`" msgstr ":class:`collections.Counter`" -#: ../../library/stdtypes.rst:5200 +#: ../../library/stdtypes.rst:5256 msgid ":class:`collections.ChainMap`" msgstr ":class:`collections.ChainMap`" -#: ../../library/stdtypes.rst:5201 +#: ../../library/stdtypes.rst:5257 msgid ":class:`collections.abc.Awaitable`" msgstr ":class:`collections.abc.Awaitable`" -#: ../../library/stdtypes.rst:5202 +#: ../../library/stdtypes.rst:5258 msgid ":class:`collections.abc.Coroutine`" msgstr ":class:`collections.abc.Coroutine`" -#: ../../library/stdtypes.rst:5203 +#: ../../library/stdtypes.rst:5259 msgid ":class:`collections.abc.AsyncIterable`" msgstr ":class:`collections.abc.AsyncIterable`" -#: ../../library/stdtypes.rst:5204 +#: ../../library/stdtypes.rst:5260 msgid ":class:`collections.abc.AsyncIterator`" msgstr ":class:`collections.abc.AsyncIterator`" -#: ../../library/stdtypes.rst:5205 +#: ../../library/stdtypes.rst:5261 msgid ":class:`collections.abc.AsyncGenerator`" msgstr ":class:`collections.abc.AsyncGenerator`" -#: ../../library/stdtypes.rst:5206 +#: ../../library/stdtypes.rst:5262 msgid ":class:`collections.abc.Iterable`" msgstr ":class:`collections.abc.Iterable`" -#: ../../library/stdtypes.rst:5207 +#: ../../library/stdtypes.rst:5263 msgid ":class:`collections.abc.Iterator`" msgstr ":class:`collections.abc.Iterator`" -#: ../../library/stdtypes.rst:5208 +#: ../../library/stdtypes.rst:5264 msgid ":class:`collections.abc.Generator`" msgstr ":class:`collections.abc.Generator`" -#: ../../library/stdtypes.rst:5209 +#: ../../library/stdtypes.rst:5265 msgid ":class:`collections.abc.Reversible`" msgstr ":class:`collections.abc.Reversible`" -#: ../../library/stdtypes.rst:5210 +#: ../../library/stdtypes.rst:5266 msgid ":class:`collections.abc.Container`" msgstr ":class:`collections.abc.Container`" -#: ../../library/stdtypes.rst:5211 +#: ../../library/stdtypes.rst:5267 msgid ":class:`collections.abc.Collection`" msgstr ":class:`collections.abc.Collection`" -#: ../../library/stdtypes.rst:5212 +#: ../../library/stdtypes.rst:5268 msgid ":class:`collections.abc.Callable`" msgstr ":class:`collections.abc.Callable`" -#: ../../library/stdtypes.rst:5213 +#: ../../library/stdtypes.rst:5269 msgid ":class:`collections.abc.Set`" msgstr ":class:`collections.abc.Set`" -#: ../../library/stdtypes.rst:5214 +#: ../../library/stdtypes.rst:5270 msgid ":class:`collections.abc.MutableSet`" msgstr ":class:`collections.abc.MutableSet`" -#: ../../library/stdtypes.rst:5215 +#: ../../library/stdtypes.rst:5271 msgid ":class:`collections.abc.Mapping`" msgstr ":class:`collections.abc.Mapping`" -#: ../../library/stdtypes.rst:5216 +#: ../../library/stdtypes.rst:5272 msgid ":class:`collections.abc.MutableMapping`" msgstr ":class:`collections.abc.MutableMapping`" -#: ../../library/stdtypes.rst:5217 +#: ../../library/stdtypes.rst:5273 msgid ":class:`collections.abc.Sequence`" msgstr ":class:`collections.abc.Sequence`" -#: ../../library/stdtypes.rst:5218 +#: ../../library/stdtypes.rst:5274 msgid ":class:`collections.abc.MutableSequence`" msgstr ":class:`collections.abc.MutableSequence`" -#: ../../library/stdtypes.rst:5219 +#: ../../library/stdtypes.rst:5275 msgid ":class:`collections.abc.ByteString`" msgstr ":class:`collections.abc.ByteString`" -#: ../../library/stdtypes.rst:5220 +#: ../../library/stdtypes.rst:5276 msgid ":class:`collections.abc.MappingView`" msgstr ":class:`collections.abc.MappingView`" -#: ../../library/stdtypes.rst:5221 +#: ../../library/stdtypes.rst:5277 msgid ":class:`collections.abc.KeysView`" msgstr ":class:`collections.abc.KeysView`" -#: ../../library/stdtypes.rst:5222 +#: ../../library/stdtypes.rst:5278 msgid ":class:`collections.abc.ItemsView`" msgstr ":class:`collections.abc.ItemsView`" -#: ../../library/stdtypes.rst:5223 +#: ../../library/stdtypes.rst:5279 msgid ":class:`collections.abc.ValuesView`" msgstr ":class:`collections.abc.ValuesView`" -#: ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:5280 msgid ":class:`contextlib.AbstractContextManager`" msgstr ":class:`contextlib.AbstractContextManager`" -#: ../../library/stdtypes.rst:5225 +#: ../../library/stdtypes.rst:5281 msgid ":class:`contextlib.AbstractAsyncContextManager`" msgstr ":class:`contextlib.AbstractAsyncContextManager`" -#: ../../library/stdtypes.rst:5226 +#: ../../library/stdtypes.rst:5282 msgid ":class:`dataclasses.Field`" msgstr ":class:`dataclasses.Field`" -#: ../../library/stdtypes.rst:5227 +#: ../../library/stdtypes.rst:5283 msgid ":class:`functools.cached_property`" msgstr ":class:`functools.cached_property`" -#: ../../library/stdtypes.rst:5228 +#: ../../library/stdtypes.rst:5284 msgid ":class:`functools.partialmethod`" msgstr ":class:`functools.partialmethod`" -#: ../../library/stdtypes.rst:5229 +#: ../../library/stdtypes.rst:5285 msgid ":class:`os.PathLike`" msgstr ":class:`os.PathLike`" -#: ../../library/stdtypes.rst:5230 +#: ../../library/stdtypes.rst:5286 msgid ":class:`queue.LifoQueue`" msgstr ":class:`queue.LifoQueue`" -#: ../../library/stdtypes.rst:5231 +#: ../../library/stdtypes.rst:5287 msgid ":class:`queue.Queue`" msgstr ":class:`queue.Queue`" -#: ../../library/stdtypes.rst:5232 +#: ../../library/stdtypes.rst:5288 msgid ":class:`queue.PriorityQueue`" msgstr ":class:`queue.PriorityQueue`" -#: ../../library/stdtypes.rst:5233 +#: ../../library/stdtypes.rst:5289 msgid ":class:`queue.SimpleQueue`" msgstr ":class:`queue.SimpleQueue`" -#: ../../library/stdtypes.rst:5234 +#: ../../library/stdtypes.rst:5290 msgid ":ref:`re.Pattern `" msgstr ":ref:`re.Pattern `" -#: ../../library/stdtypes.rst:5235 +#: ../../library/stdtypes.rst:5291 msgid ":ref:`re.Match `" msgstr ":ref:`re.Match `" -#: ../../library/stdtypes.rst:5236 +#: ../../library/stdtypes.rst:5292 msgid ":class:`shelve.BsdDbShelf`" msgstr ":class:`shelve.BsdDbShelf`" -#: ../../library/stdtypes.rst:5237 +#: ../../library/stdtypes.rst:5293 msgid ":class:`shelve.DbfilenameShelf`" msgstr ":class:`shelve.DbfilenameShelf`" -#: ../../library/stdtypes.rst:5238 +#: ../../library/stdtypes.rst:5294 msgid ":class:`shelve.Shelf`" msgstr ":class:`shelve.Shelf`" -#: ../../library/stdtypes.rst:5239 +#: ../../library/stdtypes.rst:5295 msgid ":class:`types.MappingProxyType`" msgstr ":class:`types.MappingProxyType`" -#: ../../library/stdtypes.rst:5240 +#: ../../library/stdtypes.rst:5296 msgid ":class:`weakref.WeakKeyDictionary`" msgstr ":class:`weakref.WeakKeyDictionary`" -#: ../../library/stdtypes.rst:5241 +#: ../../library/stdtypes.rst:5297 msgid ":class:`weakref.WeakMethod`" msgstr ":class:`weakref.WeakMethod`" -#: ../../library/stdtypes.rst:5242 +#: ../../library/stdtypes.rst:5298 msgid ":class:`weakref.WeakSet`" msgstr ":class:`weakref.WeakSet`" -#: ../../library/stdtypes.rst:5243 +#: ../../library/stdtypes.rst:5299 msgid ":class:`weakref.WeakValueDictionary`" msgstr ":class:`weakref.WeakValueDictionary`" -#: ../../library/stdtypes.rst:5248 +#: ../../library/stdtypes.rst:5304 msgid "Special Attributes of ``GenericAlias`` objects" msgstr "``GenericAlias`` 物件的特殊屬性" -#: ../../library/stdtypes.rst:5250 +#: ../../library/stdtypes.rst:5306 msgid "All parameterized generics implement special read-only attributes." msgstr "所有參數化泛型都有實作特殊的唯讀屬性。" -#: ../../library/stdtypes.rst:5254 +#: ../../library/stdtypes.rst:5310 msgid "This attribute points at the non-parameterized generic class::" msgstr "此屬性指向非參數化泛型類別: ::" -#: ../../library/stdtypes.rst:5256 +#: ../../library/stdtypes.rst:5312 msgid "" ">>> list[int].__origin__\n" "" @@ -7601,16 +7681,16 @@ msgstr "" ">>> list[int].__origin__\n" "" -#: ../../library/stdtypes.rst:5262 +#: ../../library/stdtypes.rst:5318 msgid "" "This attribute is a :class:`tuple` (possibly of length 1) of generic types " "passed to the original :meth:`~object.__class_getitem__` of the generic " "class::" msgstr "" -"此屬性是傳遞給泛型類別之原始 :meth:`~object.__class_getitem__` 的泛型型" -"別 :class:`tuple`\\ (長度可以為 1): ::" +"此屬性是傳遞給泛型類別之原始 :meth:`~object.__class_getitem__` 的泛型型別 :" +"class:`tuple`\\ (長度可以為 1): ::" -#: ../../library/stdtypes.rst:5266 +#: ../../library/stdtypes.rst:5322 msgid "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" @@ -7618,7 +7698,7 @@ msgstr "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" -#: ../../library/stdtypes.rst:5272 +#: ../../library/stdtypes.rst:5328 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" @@ -7626,7 +7706,7 @@ msgstr "" "此屬性是個會被延遲計算 (lazily computed) 的元組(可能為空),包含了在 " "``__args__`` 中找得到的不重複型別變數: ::" -#: ../../library/stdtypes.rst:5275 +#: ../../library/stdtypes.rst:5331 msgid "" ">>> from typing import TypeVar\n" "\n" @@ -7640,90 +7720,89 @@ msgstr "" ">>> list[T].__parameters__\n" "(~T,)" -#: ../../library/stdtypes.rst:5283 +#: ../../library/stdtypes.rst:5339 msgid "" "A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not " -"have correct ``__parameters__`` after substitution " -"because :class:`typing.ParamSpec` is intended primarily for static type " -"checking." +"have correct ``__parameters__`` after substitution because :class:`typing." +"ParamSpec` is intended primarily for static type checking." msgstr "" "具有 :class:`typing.ParamSpec` 參數的一個 ``GenericAlias`` 物件在替換後可能沒" "有正確的 ``__parameters__``,因為 :class:`typing.ParamSpec` 主要用於靜態型別" "檢查。" -#: ../../library/stdtypes.rst:5290 +#: ../../library/stdtypes.rst:5346 msgid "" "A boolean that is true if the alias has been unpacked using the ``*`` " "operator (see :data:`~typing.TypeVarTuple`)." msgstr "" -"如果別名已使用 ``*`` 運算子解包 (unpack) 則為 true 的布林值(請參" -"閱 :data:`~typing.TypeVarTuple`\\ )。" +"如果別名已使用 ``*`` 運算子解包 (unpack) 則為 true 的布林值(請參閱 :data:" +"`~typing.TypeVarTuple`\\ )。" -#: ../../library/stdtypes.rst:5298 +#: ../../library/stdtypes.rst:5354 msgid ":pep:`484` - Type Hints" msgstr ":pep:`484` - 型別提示" -#: ../../library/stdtypes.rst:5299 +#: ../../library/stdtypes.rst:5355 msgid "Introducing Python's framework for type annotations." msgstr "引入 Python 的型別註釋框架。" -#: ../../library/stdtypes.rst:5301 +#: ../../library/stdtypes.rst:5357 msgid ":pep:`585` - Type Hinting Generics In Standard Collections" msgstr ":pep:`585` - 標準集合 (Standard Collections) 中的型別提示泛型" -#: ../../library/stdtypes.rst:5302 +#: ../../library/stdtypes.rst:5358 msgid "" "Introducing the ability to natively parameterize standard-library classes, " -"provided they implement the special class " -"method :meth:`~object.__class_getitem__`." +"provided they implement the special class method :meth:`~object." +"__class_getitem__`." msgstr "" -"引入原生參數化標準函式庫類別的能力,前提是它們有實作特殊的類別方" -"法 :meth:`~object.__class_getitem__`。" +"引入原生參數化標準函式庫類別的能力,前提是它們有實作特殊的類別方法 :meth:" +"`~object.__class_getitem__`。" -#: ../../library/stdtypes.rst:5306 +#: ../../library/stdtypes.rst:5362 msgid "" -":ref:`Generics`, :ref:`user-defined generics ` " -"and :class:`typing.Generic`" +":ref:`Generics`, :ref:`user-defined generics ` and :" +"class:`typing.Generic`" msgstr "" -":ref:`Generics`、:ref:`使用者定義泛型 `\\ " -"和 :class:`typing.Generic`" +":ref:`Generics`、:ref:`使用者定義泛型 `\\ 和 :class:" +"`typing.Generic`" -#: ../../library/stdtypes.rst:5307 +#: ../../library/stdtypes.rst:5363 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" "有關如何實作可以在 runtime 參數化並能被靜態型別檢查器理解的泛型類別的文件。" -#: ../../library/stdtypes.rst:5316 +#: ../../library/stdtypes.rst:5372 msgid "Union Type" msgstr "聯合型別 (Union Type)" -#: ../../library/stdtypes.rst:5322 +#: ../../library/stdtypes.rst:5378 msgid "" "A union object holds the value of the ``|`` (bitwise or) operation on " "multiple :ref:`type objects `. These types are intended " "primarily for :term:`type annotations `. The union type " -"expression enables cleaner type hinting syntax compared " -"to :data:`typing.Union`." +"expression enables cleaner type hinting syntax compared to :data:`typing." +"Union`." msgstr "" "一個聯合物件可以保存多個\\ :ref:`型別物件 (type object) `\\ 之 ``|``\\ (位元 or)運算的值。這些型別主要用於\\ :term:`型別註" "釋 (type annotation) `。與 :data:`typing.Union` 相比,聯合型別運" "算式可以讓型別提示語法更清晰簡潔。" -#: ../../library/stdtypes.rst:5329 +#: ../../library/stdtypes.rst:5385 msgid "" "Defines a union object which holds types *X*, *Y*, and so forth. ``X | Y`` " "means either X or Y. It is equivalent to ``typing.Union[X, Y]``. For " -"example, the following function expects an argument of type :class:`int` " -"or :class:`float`::" +"example, the following function expects an argument of type :class:`int` or :" +"class:`float`::" msgstr "" "定義一個包含 *X*、*Y* 等型別的聯合物件。``X | Y`` 表示 X 或 Y。它相當於 " -"``typing.Union[X, Y]``。舉例來說,下列函式需要一個型別為 :class:`int` " -"或 :class:`float` 的引數: ::" +"``typing.Union[X, Y]``。舉例來說,下列函式需要一個型別為 :class:`int` 或 :" +"class:`float` 的引數: ::" -#: ../../library/stdtypes.rst:5334 +#: ../../library/stdtypes.rst:5390 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" @@ -7731,7 +7810,7 @@ msgstr "" "def square(number: int | float) -> int | float:\n" " return number ** 2" -#: ../../library/stdtypes.rst:5339 +#: ../../library/stdtypes.rst:5395 msgid "" "The ``|`` operand cannot be used at runtime to define unions where one or " "more members is a forward reference. For example, ``int | \"Foo\"``, where " @@ -7744,58 +7823,58 @@ msgstr "" "義類別的參照,將在 runtime 失敗。對於包含向前參照的聯合,請將整個運算式以字串" "呈現,例如 ``\"int | Foo\"``。" -#: ../../library/stdtypes.rst:5347 +#: ../../library/stdtypes.rst:5403 msgid "" "Union objects can be tested for equality with other union objects. Details:" msgstr "聯合物件可以與其他聯合物件一起進行相等性測試。細節如下:" -#: ../../library/stdtypes.rst:5349 +#: ../../library/stdtypes.rst:5405 msgid "Unions of unions are flattened::" msgstr "聯合的聯合會被扁平化: ::" -#: ../../library/stdtypes.rst:5351 +#: ../../library/stdtypes.rst:5407 msgid "(int | str) | float == int | str | float" msgstr "(int | str) | float == int | str | float" -#: ../../library/stdtypes.rst:5353 +#: ../../library/stdtypes.rst:5409 msgid "Redundant types are removed::" msgstr "冗餘型別會被刪除: ::" -#: ../../library/stdtypes.rst:5355 +#: ../../library/stdtypes.rst:5411 msgid "int | str | int == int | str" msgstr "int | str | int == int | str" -#: ../../library/stdtypes.rst:5357 +#: ../../library/stdtypes.rst:5413 msgid "When comparing unions, the order is ignored::" msgstr "比較聯合時,順序會被忽略: ::" -#: ../../library/stdtypes.rst:5359 +#: ../../library/stdtypes.rst:5415 msgid "int | str == str | int" msgstr "int | str == str | int" -#: ../../library/stdtypes.rst:5361 +#: ../../library/stdtypes.rst:5417 msgid "It is compatible with :data:`typing.Union`::" msgstr "它與 :data:`typing.Union` 相容: ::" -#: ../../library/stdtypes.rst:5363 +#: ../../library/stdtypes.rst:5419 msgid "int | str == typing.Union[int, str]" msgstr "int | str == typing.Union[int, str]" -#: ../../library/stdtypes.rst:5365 +#: ../../library/stdtypes.rst:5421 msgid "Optional types can be spelled as a union with ``None``::" msgstr "可選型別可以表示為與 ``None`` 的聯合: ::" -#: ../../library/stdtypes.rst:5367 +#: ../../library/stdtypes.rst:5423 msgid "str | None == typing.Optional[str]" msgstr "str | None == typing.Optional[str]" -#: ../../library/stdtypes.rst:5372 +#: ../../library/stdtypes.rst:5428 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" msgstr "聯合物件也支援 :func:`isinstance` 和 :func:`issubclass` 的呼叫: ::" -#: ../../library/stdtypes.rst:5375 +#: ../../library/stdtypes.rst:5431 msgid "" ">>> isinstance(\"\", int | str)\n" "True" @@ -7803,14 +7882,14 @@ msgstr "" ">>> isinstance(\"\", int | str)\n" "True" -#: ../../library/stdtypes.rst:5378 +#: ../../library/stdtypes.rst:5434 msgid "" "However, :ref:`parameterized generics ` in union objects " "cannot be checked::" msgstr "" "然而聯合物件中的\\ :ref:`參數化泛型 `\\ 則無法被檢查: ::" -#: ../../library/stdtypes.rst:5381 +#: ../../library/stdtypes.rst:5437 msgid "" ">>> isinstance(1, int | list[int]) # short-circuit evaluation\n" "True\n" @@ -7820,17 +7899,16 @@ msgid "" "TypeError: isinstance() argument 2 cannot be a parameterized generic" msgstr "" -#: ../../library/stdtypes.rst:5388 +#: ../../library/stdtypes.rst:5444 msgid "" -"The user-exposed type for the union object can be accessed " -"from :data:`types.UnionType` and used for :func:`isinstance` checks. An " -"object cannot be instantiated from the type::" +"The user-exposed type for the union object can be accessed from :data:`types." +"UnionType` and used for :func:`isinstance` checks. An object cannot be " +"instantiated from the type::" msgstr "" -"構成聯合物件的對使用者公開型別 (user-exposed type) 可以透" -"過 :data:`types.UnionType` 存取並用於 :func:`isinstance` 檢查。物件不能以型別" -"來實例化: ::" +"構成聯合物件的對使用者公開型別 (user-exposed type) 可以透過 :data:`types." +"UnionType` 存取並用於 :func:`isinstance` 檢查。物件不能以型別來實例化: ::" -#: ../../library/stdtypes.rst:5392 +#: ../../library/stdtypes.rst:5448 msgid "" ">>> import types\n" ">>> isinstance(int | str, types.UnionType)\n" @@ -7848,7 +7926,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: cannot create 'types.UnionType' instances" -#: ../../library/stdtypes.rst:5401 +#: ../../library/stdtypes.rst:5457 msgid "" "The :meth:`!__or__` method for type objects was added to support the syntax " "``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may " @@ -7857,7 +7935,7 @@ msgstr "" "新增了型別物件的 :meth:`!__or__` 方法來支援 ``X | Y`` 語法。如果元類別有實" "作 :meth:`!__or__`,則 Union 可以覆寫 (override) 它: ::" -#: ../../library/stdtypes.rst:5405 +#: ../../library/stdtypes.rst:5461 msgid "" ">>> class M(type):\n" "... def __or__(self, other):\n" @@ -7883,72 +7961,72 @@ msgstr "" ">>> int | C\n" "int | C" -#: ../../library/stdtypes.rst:5421 +#: ../../library/stdtypes.rst:5477 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." msgstr ":pep:`604` -- PEP 提出 ``X | Y`` 語法和聯合型別。" -#: ../../library/stdtypes.rst:5429 +#: ../../library/stdtypes.rst:5485 msgid "Other Built-in Types" msgstr "其他內建型別" -#: ../../library/stdtypes.rst:5431 +#: ../../library/stdtypes.rst:5487 msgid "" "The interpreter supports several other kinds of objects. Most of these " "support only one or two operations." msgstr "" -#: ../../library/stdtypes.rst:5438 +#: ../../library/stdtypes.rst:5494 msgid "Modules" msgstr "模組" -#: ../../library/stdtypes.rst:5440 +#: ../../library/stdtypes.rst:5496 msgid "" "The only special operation on a module is attribute access: ``m.name``, " "where *m* is a module and *name* accesses a name defined in *m*'s symbol " -"table. Module attributes can be assigned to. (Note that " -"the :keyword:`import` statement is not, strictly speaking, an operation on a " -"module object; ``import foo`` does not require a module object named *foo* " -"to exist, rather it requires an (external) *definition* for a module named " +"table. Module attributes can be assigned to. (Note that the :keyword:" +"`import` statement is not, strictly speaking, an operation on a module " +"object; ``import foo`` does not require a module object named *foo* to " +"exist, rather it requires an (external) *definition* for a module named " "*foo* somewhere.)" msgstr "" -#: ../../library/stdtypes.rst:5447 +#: ../../library/stdtypes.rst:5503 msgid "" "A special attribute of every module is :attr:`~object.__dict__`. This is the " "dictionary containing the module's symbol table. Modifying this dictionary " "will actually change the module's symbol table, but direct assignment to " -"the :attr:`~object.__dict__` attribute is not possible (you can write " -"``m.__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but you can't " -"write ``m.__dict__ = {}``). Modifying :attr:`~object.__dict__` directly is " -"not recommended." +"the :attr:`~object.__dict__` attribute is not possible (you can write ``m." +"__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but you can't write " +"``m.__dict__ = {}``). Modifying :attr:`~object.__dict__` directly is not " +"recommended." msgstr "" -#: ../../library/stdtypes.rst:5455 +#: ../../library/stdtypes.rst:5511 msgid "" -"Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ````." +"Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ````." msgstr "" -#: ../../library/stdtypes.rst:5463 +#: ../../library/stdtypes.rst:5519 msgid "Classes and Class Instances" msgstr "類別與類別實例" -#: ../../library/stdtypes.rst:5465 +#: ../../library/stdtypes.rst:5521 msgid "See :ref:`objects` and :ref:`class` for these." msgstr "請見 :ref:`objects` 和 :ref:`class`。" -#: ../../library/stdtypes.rst:5471 +#: ../../library/stdtypes.rst:5527 msgid "Functions" msgstr "函式" -#: ../../library/stdtypes.rst:5473 +#: ../../library/stdtypes.rst:5529 msgid "" "Function objects are created by function definitions. The only operation on " "a function object is to call it: ``func(argument-list)``." msgstr "" -#: ../../library/stdtypes.rst:5476 +#: ../../library/stdtypes.rst:5532 msgid "" "There are really two flavors of function objects: built-in functions and " "user-defined functions. Both support the same operation (to call the " @@ -7956,36 +8034,36 @@ msgid "" "types." msgstr "" -#: ../../library/stdtypes.rst:5480 +#: ../../library/stdtypes.rst:5536 msgid "See :ref:`function` for more information." msgstr "更多資訊請見 :ref:`function`。" -#: ../../library/stdtypes.rst:5486 +#: ../../library/stdtypes.rst:5542 msgid "Methods" msgstr "方法" -#: ../../library/stdtypes.rst:5490 +#: ../../library/stdtypes.rst:5546 msgid "" "Methods are functions that are called using the attribute notation. There " -"are two flavors: :ref:`built-in methods ` (such " -"as :meth:`append` on lists) and :ref:`class instance method `. Built-in methods are described with the types that support them." +"are two flavors: :ref:`built-in methods ` (such as :meth:" +"`append` on lists) and :ref:`class instance method `. " +"Built-in methods are described with the types that support them." msgstr "" -#: ../../library/stdtypes.rst:5495 +#: ../../library/stdtypes.rst:5551 msgid "" "If you access a method (a function defined in a class namespace) through an " -"instance, you get a special object: a :dfn:`bound method` (also " -"called :ref:`instance method `) object. When called, it " -"will add the ``self`` argument to the argument list. Bound methods have two " -"special read-only attributes: :attr:`m.__self__ ` is the " -"object on which the method operates, and :attr:`m.__func__ " -"` is the function implementing the method. Calling " -"``m(arg-1, arg-2, ..., arg-n)`` is completely equivalent to calling " -"``m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)``." +"instance, you get a special object: a :dfn:`bound method` (also called :ref:" +"`instance method `) object. When called, it will add the " +"``self`` argument to the argument list. Bound methods have two special read-" +"only attributes: :attr:`m.__self__ ` is the object on which " +"the method operates, and :attr:`m.__func__ ` is the " +"function implementing the method. Calling ``m(arg-1, arg-2, ..., arg-n)`` " +"is completely equivalent to calling ``m.__func__(m.__self__, arg-1, " +"arg-2, ..., arg-n)``." msgstr "" -#: ../../library/stdtypes.rst:5506 +#: ../../library/stdtypes.rst:5562 msgid "" "Like :ref:`function objects `, bound method objects " "support getting arbitrary attributes. However, since method attributes are " @@ -7996,7 +8074,7 @@ msgid "" "underlying function object:" msgstr "" -#: ../../library/stdtypes.rst:5514 +#: ../../library/stdtypes.rst:5570 msgid "" ">>> class C:\n" "... def method(self):\n" @@ -8024,25 +8102,25 @@ msgstr "" ">>> c.method.whoami\n" "'my name is method'" -#: ../../library/stdtypes.rst:5529 +#: ../../library/stdtypes.rst:5585 msgid "See :ref:`instance-methods` for more information." msgstr "更多資訊請見 :ref:`instance-methods`。" -#: ../../library/stdtypes.rst:5537 +#: ../../library/stdtypes.rst:5593 msgid "Code Objects" msgstr "程式碼物件" -#: ../../library/stdtypes.rst:5543 +#: ../../library/stdtypes.rst:5599 msgid "" "Code objects are used by the implementation to represent \"pseudo-compiled\" " "executable Python code such as a function body. They differ from function " "objects because they don't contain a reference to their global execution " "environment. Code objects are returned by the built-in :func:`compile` " -"function and can be extracted from function objects through " -"their :attr:`~function.__code__` attribute. See also the :mod:`code` module." +"function and can be extracted from function objects through their :attr:" +"`~function.__code__` attribute. See also the :mod:`code` module." msgstr "" -#: ../../library/stdtypes.rst:5550 +#: ../../library/stdtypes.rst:5606 msgid "" "Accessing :attr:`~function.__code__` raises an :ref:`auditing event " "` ``object.__getattr__`` with arguments ``obj`` and " @@ -8051,21 +8129,21 @@ msgstr "" "存取 :attr:`~function.__code__` 會引發一個附帶引數 ``obj`` 與 " "``\"__code__\"`` 的\\ :ref:`稽核事件 ` ``object.__getattr__``。" -#: ../../library/stdtypes.rst:5557 +#: ../../library/stdtypes.rst:5613 msgid "" "A code object can be executed or evaluated by passing it (instead of a " "source string) to the :func:`exec` or :func:`eval` built-in functions." msgstr "" -#: ../../library/stdtypes.rst:5560 +#: ../../library/stdtypes.rst:5616 msgid "See :ref:`types` for more information." msgstr "更多資訊請見 :ref:`types`。" -#: ../../library/stdtypes.rst:5566 +#: ../../library/stdtypes.rst:5622 msgid "Type Objects" msgstr "" -#: ../../library/stdtypes.rst:5572 +#: ../../library/stdtypes.rst:5628 msgid "" "Type objects represent the various object types. An object's type is " "accessed by the built-in function :func:`type`. There are no special " @@ -8073,119 +8151,119 @@ msgid "" "standard built-in types." msgstr "" -#: ../../library/stdtypes.rst:5577 +#: ../../library/stdtypes.rst:5633 msgid "Types are written like this: ````." msgstr "" -#: ../../library/stdtypes.rst:5583 +#: ../../library/stdtypes.rst:5639 msgid "The Null Object" msgstr "Null 物件" -#: ../../library/stdtypes.rst:5585 +#: ../../library/stdtypes.rst:5641 msgid "" "This object is returned by functions that don't explicitly return a value. " "It supports no special operations. There is exactly one null object, named " "``None`` (a built-in name). ``type(None)()`` produces the same singleton." msgstr "" -#: ../../library/stdtypes.rst:5589 +#: ../../library/stdtypes.rst:5645 msgid "It is written as ``None``." msgstr "它被寫為 ``None``。" -#: ../../library/stdtypes.rst:5596 +#: ../../library/stdtypes.rst:5652 msgid "The Ellipsis Object" msgstr "Ellipsis 物件" -#: ../../library/stdtypes.rst:5598 +#: ../../library/stdtypes.rst:5654 msgid "" "This object is commonly used by slicing (see :ref:`slicings`). It supports " -"no special operations. There is exactly one ellipsis object, " -"named :const:`Ellipsis` (a built-in name). ``type(Ellipsis)()`` produces " -"the :const:`Ellipsis` singleton." +"no special operations. There is exactly one ellipsis object, named :const:" +"`Ellipsis` (a built-in name). ``type(Ellipsis)()`` produces the :const:" +"`Ellipsis` singleton." msgstr "" -#: ../../library/stdtypes.rst:5603 +#: ../../library/stdtypes.rst:5659 msgid "It is written as ``Ellipsis`` or ``...``." msgstr "它被寫為 ``Ellipsis`` 或 ``...``。" -#: ../../library/stdtypes.rst:5609 +#: ../../library/stdtypes.rst:5665 msgid "The NotImplemented Object" msgstr "NotImplemented 物件" -#: ../../library/stdtypes.rst:5611 +#: ../../library/stdtypes.rst:5667 msgid "" "This object is returned from comparisons and binary operations when they are " "asked to operate on types they don't support. See :ref:`comparisons` for " -"more information. There is exactly one :data:`NotImplemented` " -"object. :code:`type(NotImplemented)()` produces the singleton instance." +"more information. There is exactly one :data:`NotImplemented` object. :code:" +"`type(NotImplemented)()` produces the singleton instance." msgstr "" -#: ../../library/stdtypes.rst:5616 +#: ../../library/stdtypes.rst:5672 msgid "It is written as :code:`NotImplemented`." msgstr "" -#: ../../library/stdtypes.rst:5622 +#: ../../library/stdtypes.rst:5678 msgid "Internal Objects" msgstr "內部物件" -#: ../../library/stdtypes.rst:5624 +#: ../../library/stdtypes.rst:5680 msgid "" "See :ref:`types` for this information. It describes :ref:`stack frame " "objects `, :ref:`traceback objects `, and " "slice objects." msgstr "" -#: ../../library/stdtypes.rst:5632 +#: ../../library/stdtypes.rst:5688 msgid "Special Attributes" msgstr "特殊屬性" -#: ../../library/stdtypes.rst:5634 +#: ../../library/stdtypes.rst:5690 msgid "" "The implementation adds a few special read-only attributes to several object " -"types, where they are relevant. Some of these are not reported by " -"the :func:`dir` built-in function." +"types, where they are relevant. Some of these are not reported by the :func:" +"`dir` built-in function." msgstr "" -#: ../../library/stdtypes.rst:5641 +#: ../../library/stdtypes.rst:5697 msgid "" "The name of the class, function, method, descriptor, or generator instance." msgstr "" -#: ../../library/stdtypes.rst:5647 +#: ../../library/stdtypes.rst:5703 msgid "" "The :term:`qualified name` of the class, function, method, descriptor, or " "generator instance." msgstr "" -#: ../../library/stdtypes.rst:5655 +#: ../../library/stdtypes.rst:5711 msgid "The name of the module in which a class or function was defined." msgstr "" -#: ../../library/stdtypes.rst:5660 +#: ../../library/stdtypes.rst:5716 msgid "" "The documentation string of a class or function, or ``None`` if undefined." msgstr "" -#: ../../library/stdtypes.rst:5665 +#: ../../library/stdtypes.rst:5721 msgid "" -"The :ref:`type parameters ` of generic classes, functions, " -"and :ref:`type aliases `. For classes and functions that are " -"not generic, this will be an empty tuple." +"The :ref:`type parameters ` of generic classes, functions, and :" +"ref:`type aliases `. For classes and functions that are not " +"generic, this will be an empty tuple." msgstr "" -#: ../../library/stdtypes.rst:5675 +#: ../../library/stdtypes.rst:5731 msgid "Integer string conversion length limitation" msgstr "" -#: ../../library/stdtypes.rst:5677 +#: ../../library/stdtypes.rst:5733 msgid "" -"CPython has a global limit for converting between :class:`int` " -"and :class:`str` to mitigate denial of service attacks. This limit *only* " -"applies to decimal or other non-power-of-two number bases. Hexadecimal, " -"octal, and binary conversions are unlimited. The limit can be configured." +"CPython has a global limit for converting between :class:`int` and :class:" +"`str` to mitigate denial of service attacks. This limit *only* applies to " +"decimal or other non-power-of-two number bases. Hexadecimal, octal, and " +"binary conversions are unlimited. The limit can be configured." msgstr "" -#: ../../library/stdtypes.rst:5682 +#: ../../library/stdtypes.rst:5738 msgid "" "The :class:`int` type in CPython is an arbitrary length number stored in " "binary form (commonly known as a \"bignum\"). There exists no algorithm that " @@ -8195,24 +8273,24 @@ msgid "" "value such as ``int('1' * 500_000)`` can take over a second on a fast CPU." msgstr "" -#: ../../library/stdtypes.rst:5689 +#: ../../library/stdtypes.rst:5745 msgid "" "Limiting conversion size offers a practical way to avoid :cve:`2020-10735`." msgstr "" -#: ../../library/stdtypes.rst:5691 +#: ../../library/stdtypes.rst:5747 msgid "" "The limit is applied to the number of digit characters in the input or " "output string when a non-linear conversion algorithm would be involved. " "Underscores and the sign are not counted towards the limit." msgstr "" -#: ../../library/stdtypes.rst:5695 +#: ../../library/stdtypes.rst:5751 msgid "" "When an operation would exceed the limit, a :exc:`ValueError` is raised:" msgstr "" -#: ../../library/stdtypes.rst:5697 +#: ../../library/stdtypes.rst:5753 msgid "" ">>> import sys\n" ">>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default.\n" @@ -8236,19 +8314,19 @@ msgid "" ">>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited." msgstr "" -#: ../../library/stdtypes.rst:5717 +#: ../../library/stdtypes.rst:5773 msgid "" -"The default limit is 4300 digits as provided " -"in :data:`sys.int_info.default_max_str_digits `. The lowest " -"limit that can be configured is 640 digits as provided " -"in :data:`sys.int_info.str_digits_check_threshold `." +"The default limit is 4300 digits as provided in :data:`sys.int_info." +"default_max_str_digits `. The lowest limit that can be " +"configured is 640 digits as provided in :data:`sys.int_info." +"str_digits_check_threshold `." msgstr "" -#: ../../library/stdtypes.rst:5722 +#: ../../library/stdtypes.rst:5778 msgid "Verification:" msgstr "" -#: ../../library/stdtypes.rst:5724 +#: ../../library/stdtypes.rst:5780 msgid "" ">>> import sys\n" ">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" @@ -8266,84 +8344,84 @@ msgstr "" "... '571186405732').to_bytes(53, 'big')\n" "..." -#: ../../library/stdtypes.rst:5737 +#: ../../library/stdtypes.rst:5793 msgid "Affected APIs" msgstr "受影響的 API" -#: ../../library/stdtypes.rst:5739 +#: ../../library/stdtypes.rst:5795 msgid "" -"The limitation only applies to potentially slow conversions " -"between :class:`int` and :class:`str` or :class:`bytes`:" +"The limitation only applies to potentially slow conversions between :class:" +"`int` and :class:`str` or :class:`bytes`:" msgstr "" -#: ../../library/stdtypes.rst:5742 +#: ../../library/stdtypes.rst:5798 msgid "``int(string)`` with default base 10." msgstr "``int(string)`` 以預設的 10 為底。" -#: ../../library/stdtypes.rst:5743 +#: ../../library/stdtypes.rst:5799 msgid "``int(string, base)`` for all bases that are not a power of 2." msgstr "" -#: ../../library/stdtypes.rst:5744 +#: ../../library/stdtypes.rst:5800 msgid "``str(integer)``." msgstr "``str(integer)``。" -#: ../../library/stdtypes.rst:5745 +#: ../../library/stdtypes.rst:5801 msgid "``repr(integer)``." msgstr "``repr(integer)``。" -#: ../../library/stdtypes.rst:5746 +#: ../../library/stdtypes.rst:5802 msgid "" "any other string conversion to base 10, for example ``f\"{integer}\"``, " "``\"{}\".format(integer)``, or ``b\"%d\" % integer``." msgstr "" -#: ../../library/stdtypes.rst:5749 +#: ../../library/stdtypes.rst:5805 msgid "The limitations do not apply to functions with a linear algorithm:" msgstr "" -#: ../../library/stdtypes.rst:5751 +#: ../../library/stdtypes.rst:5807 msgid "``int(string, base)`` with base 2, 4, 8, 16, or 32." msgstr "" -#: ../../library/stdtypes.rst:5752 +#: ../../library/stdtypes.rst:5808 msgid ":func:`int.from_bytes` and :func:`int.to_bytes`." msgstr ":func:`int.from_bytes` 和 :func:`int.to_bytes`。" -#: ../../library/stdtypes.rst:5753 +#: ../../library/stdtypes.rst:5809 msgid ":func:`hex`, :func:`oct`, :func:`bin`." msgstr ":func:`hex`、:func:`oct`、:func:`bin`。" -#: ../../library/stdtypes.rst:5754 +#: ../../library/stdtypes.rst:5810 msgid ":ref:`formatspec` for hex, octal, and binary numbers." msgstr "" -#: ../../library/stdtypes.rst:5755 +#: ../../library/stdtypes.rst:5811 msgid ":class:`str` to :class:`float`." msgstr "" -#: ../../library/stdtypes.rst:5756 +#: ../../library/stdtypes.rst:5812 msgid ":class:`str` to :class:`decimal.Decimal`." msgstr "" -#: ../../library/stdtypes.rst:5759 +#: ../../library/stdtypes.rst:5815 msgid "Configuring the limit" msgstr "設定限制" -#: ../../library/stdtypes.rst:5761 +#: ../../library/stdtypes.rst:5817 msgid "" "Before Python starts up you can use an environment variable or an " "interpreter command line flag to configure the limit:" msgstr "" -#: ../../library/stdtypes.rst:5764 +#: ../../library/stdtypes.rst:5820 msgid "" ":envvar:`PYTHONINTMAXSTRDIGITS`, e.g. ``PYTHONINTMAXSTRDIGITS=640 python3`` " "to set the limit to 640 or ``PYTHONINTMAXSTRDIGITS=0 python3`` to disable " "the limitation." msgstr "" -#: ../../library/stdtypes.rst:5767 +#: ../../library/stdtypes.rst:5823 msgid "" ":option:`-X int_max_str_digits <-X>`, e.g. ``python3 -X " "int_max_str_digits=640``" @@ -8351,48 +8429,47 @@ msgstr "" ":option:`-X int_max_str_digits <-X>`,例如 ``python3 -X " "int_max_str_digits=640``" -#: ../../library/stdtypes.rst:5769 +#: ../../library/stdtypes.rst:5825 msgid "" -":data:`sys.flags.int_max_str_digits` contains the value " -"of :envvar:`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`. " -"If both the env var and the ``-X`` option are set, the ``-X`` option takes " -"precedence. A value of *-1* indicates that both were unset, thus a value " -"of :data:`sys.int_info.default_max_str_digits` was used during " -"initialization." +":data:`sys.flags.int_max_str_digits` contains the value of :envvar:" +"`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`. If both the " +"env var and the ``-X`` option are set, the ``-X`` option takes precedence. A " +"value of *-1* indicates that both were unset, thus a value of :data:`sys." +"int_info.default_max_str_digits` was used during initialization." msgstr "" -#: ../../library/stdtypes.rst:5775 +#: ../../library/stdtypes.rst:5831 msgid "" -"From code, you can inspect the current limit and set a new one using " -"these :mod:`sys` APIs:" +"From code, you can inspect the current limit and set a new one using these :" +"mod:`sys` APIs:" msgstr "" -#: ../../library/stdtypes.rst:5778 +#: ../../library/stdtypes.rst:5834 msgid "" ":func:`sys.get_int_max_str_digits` and :func:`sys.set_int_max_str_digits` " "are a getter and setter for the interpreter-wide limit. Subinterpreters have " "their own limit." msgstr "" -#: ../../library/stdtypes.rst:5782 +#: ../../library/stdtypes.rst:5838 msgid "" -"Information about the default and minimum can be found " -"in :data:`sys.int_info`:" +"Information about the default and minimum can be found in :data:`sys." +"int_info`:" msgstr "" -#: ../../library/stdtypes.rst:5784 +#: ../../library/stdtypes.rst:5840 msgid "" ":data:`sys.int_info.default_max_str_digits ` is the compiled-" "in default limit." msgstr "" -#: ../../library/stdtypes.rst:5786 +#: ../../library/stdtypes.rst:5842 msgid "" ":data:`sys.int_info.str_digits_check_threshold ` is the lowest " "accepted value for the limit (other than 0 which disables it)." msgstr "" -#: ../../library/stdtypes.rst:5793 +#: ../../library/stdtypes.rst:5849 msgid "" "Setting a low limit *can* lead to problems. While rare, code exists that " "contains integer constants in decimal in their source that exceed the " @@ -8404,7 +8481,7 @@ msgid "" "constants is to convert them to ``0x`` hexadecimal form as it has no limit." msgstr "" -#: ../../library/stdtypes.rst:5802 +#: ../../library/stdtypes.rst:5858 msgid "" "Test your application thoroughly if you use a low limit. Ensure your tests " "run with the limit set early via the environment or flag so that it applies " @@ -8412,11 +8489,11 @@ msgid "" "to precompile ``.py`` sources to ``.pyc`` files." msgstr "" -#: ../../library/stdtypes.rst:5808 +#: ../../library/stdtypes.rst:5864 msgid "Recommended configuration" msgstr "建議的配置" -#: ../../library/stdtypes.rst:5810 +#: ../../library/stdtypes.rst:5866 msgid "" "The default :data:`sys.int_info.default_max_str_digits` is expected to be " "reasonable for most applications. If your application requires a different " @@ -8424,11 +8501,11 @@ msgid "" "as these APIs were added in security patch releases in versions before 3.12." msgstr "" -#: ../../library/stdtypes.rst:5815 +#: ../../library/stdtypes.rst:5871 msgid "Example::" msgstr "範例: ::" -#: ../../library/stdtypes.rst:5817 +#: ../../library/stdtypes.rst:5873 msgid "" ">>> import sys\n" ">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" @@ -8450,38 +8527,38 @@ msgstr "" "... elif current_limit < lower_bound:\n" "... sys.set_int_max_str_digits(lower_bound)" -#: ../../library/stdtypes.rst:5827 +#: ../../library/stdtypes.rst:5883 msgid "If you need to disable it entirely, set it to ``0``." msgstr "" -#: ../../library/stdtypes.rst:5831 +#: ../../library/stdtypes.rst:5887 msgid "Footnotes" msgstr "註腳" -#: ../../library/stdtypes.rst:5832 +#: ../../library/stdtypes.rst:5888 msgid "" "Additional information on these special methods may be found in the Python " "Reference Manual (:ref:`customization`)." msgstr "" -#: ../../library/stdtypes.rst:5835 +#: ../../library/stdtypes.rst:5891 msgid "" "As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, " "and similarly for tuples." msgstr "" -#: ../../library/stdtypes.rst:5838 +#: ../../library/stdtypes.rst:5894 msgid "They must have since the parser can't tell the type of the operands." msgstr "" -#: ../../library/stdtypes.rst:5840 +#: ../../library/stdtypes.rst:5896 msgid "" "Cased characters are those with general category property being one of " "\"Lu\" (Letter, uppercase), \"Ll\" (Letter, lowercase), or \"Lt\" (Letter, " "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:5843 +#: ../../library/stdtypes.rst:5899 msgid "" "To format only a tuple you should therefore provide a singleton tuple whose " "only element is the tuple to be formatted." @@ -8493,14 +8570,14 @@ msgstr "built-in(內建)" #: ../../library/stdtypes.rst:13 ../../library/stdtypes.rst:316 #: ../../library/stdtypes.rst:393 ../../library/stdtypes.rst:950 -#: ../../library/stdtypes.rst:1117 ../../library/stdtypes.rst:1139 -#: ../../library/stdtypes.rst:1154 ../../library/stdtypes.rst:4581 -#: ../../library/stdtypes.rst:5568 +#: ../../library/stdtypes.rst:1120 ../../library/stdtypes.rst:1142 +#: ../../library/stdtypes.rst:1157 ../../library/stdtypes.rst:4637 +#: ../../library/stdtypes.rst:5624 msgid "types" msgstr "type(型別)" -#: ../../library/stdtypes.rst:34 ../../library/stdtypes.rst:1154 -#: ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:34 ../../library/stdtypes.rst:1157 +#: ../../library/stdtypes.rst:4637 msgid "statement" msgstr "statement(陳述式)" @@ -8618,15 +8695,15 @@ msgid "is not" msgstr "is not" #: ../../library/stdtypes.rst:163 ../../library/stdtypes.rst:208 -#: ../../library/stdtypes.rst:934 ../../library/stdtypes.rst:1117 -#: ../../library/stdtypes.rst:1139 ../../library/stdtypes.rst:1260 -#: ../../library/stdtypes.rst:1339 ../../library/stdtypes.rst:1383 -#: ../../library/stdtypes.rst:1504 ../../library/stdtypes.rst:1540 -#: ../../library/stdtypes.rst:2672 ../../library/stdtypes.rst:2691 -#: ../../library/stdtypes.rst:2798 ../../library/stdtypes.rst:4379 -#: ../../library/stdtypes.rst:4581 ../../library/stdtypes.rst:5061 -#: ../../library/stdtypes.rst:5318 ../../library/stdtypes.rst:5488 -#: ../../library/stdtypes.rst:5532 +#: ../../library/stdtypes.rst:934 ../../library/stdtypes.rst:1120 +#: ../../library/stdtypes.rst:1142 ../../library/stdtypes.rst:1265 +#: ../../library/stdtypes.rst:1344 ../../library/stdtypes.rst:1388 +#: ../../library/stdtypes.rst:1509 ../../library/stdtypes.rst:1545 +#: ../../library/stdtypes.rst:2728 ../../library/stdtypes.rst:2747 +#: ../../library/stdtypes.rst:2854 ../../library/stdtypes.rst:4435 +#: ../../library/stdtypes.rst:4637 ../../library/stdtypes.rst:5117 +#: ../../library/stdtypes.rst:5374 ../../library/stdtypes.rst:5544 +#: ../../library/stdtypes.rst:5588 msgid "object" msgstr "object(物件)" @@ -8718,9 +8795,9 @@ msgid "arithmetic" msgstr "arithmetic(算術)" #: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:950 -#: ../../library/stdtypes.rst:1117 ../../library/stdtypes.rst:4581 -#: ../../library/stdtypes.rst:5539 ../../library/stdtypes.rst:5553 -#: ../../library/stdtypes.rst:5568 +#: ../../library/stdtypes.rst:1120 ../../library/stdtypes.rst:4637 +#: ../../library/stdtypes.rst:5595 ../../library/stdtypes.rst:5609 +#: ../../library/stdtypes.rst:5624 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -8736,8 +8813,8 @@ msgstr "float" msgid "complex" msgstr "complex(複數)" -#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2548 -#: ../../library/stdtypes.rst:3767 +#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2604 +#: ../../library/stdtypes.rst:3823 msgid "+ (plus)" msgstr "+ (加號)" @@ -8749,13 +8826,13 @@ msgstr "unary operator(一元運算子)" msgid "binary operator" msgstr "binary operator(二元運算子)" -#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2548 -#: ../../library/stdtypes.rst:3767 +#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2604 +#: ../../library/stdtypes.rst:3823 msgid "- (minus)" msgstr "- (減號)" -#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2505 -#: ../../library/stdtypes.rst:3724 +#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2561 +#: ../../library/stdtypes.rst:3780 msgid "* (asterisk)" msgstr "* (星號)" @@ -8767,8 +8844,8 @@ msgstr "/ (斜線)" msgid "//" msgstr "//" -#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2469 -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:246 ../../library/stdtypes.rst:2525 +#: ../../library/stdtypes.rst:3748 msgid "% (percent)" msgstr "% (百分號)" @@ -8777,8 +8854,8 @@ msgid "**" msgstr "**" #: ../../library/stdtypes.rst:316 ../../library/stdtypes.rst:393 -#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1154 -#: ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1157 +#: ../../library/stdtypes.rst:4637 msgid "operations on" msgstr "operations on(操作於)" @@ -8786,8 +8863,8 @@ msgstr "operations on(操作於)" msgid "conjugate() (complex number method)" msgstr "conjugate()(複數方法)" -#: ../../library/stdtypes.rst:335 ../../library/stdtypes.rst:1606 -#: ../../library/stdtypes.rst:2672 ../../library/stdtypes.rst:5568 +#: ../../library/stdtypes.rst:335 ../../library/stdtypes.rst:1611 +#: ../../library/stdtypes.rst:2728 ../../library/stdtypes.rst:5624 msgid "module" msgstr "模組" @@ -8855,7 +8932,7 @@ msgstr "values" msgid "iterator protocol" msgstr "iterator protocol(疊代器協定)" -#: ../../library/stdtypes.rst:847 ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:847 ../../library/stdtypes.rst:5032 msgid "protocol" msgstr "protocol(協定)" @@ -8864,8 +8941,8 @@ msgid "iterator" msgstr "iterator(疊代器)" #: ../../library/stdtypes.rst:847 ../../library/stdtypes.rst:934 -#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1117 -#: ../../library/stdtypes.rst:1139 ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1120 +#: ../../library/stdtypes.rst:1142 ../../library/stdtypes.rst:1157 msgid "sequence" msgstr "sequence(序列)" @@ -8881,7 +8958,7 @@ msgstr "container(容器)" msgid "iteration over" msgstr "iteration over(疊代於)" -#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:4637 msgid "len" msgstr "len" @@ -8905,11 +8982,11 @@ msgstr "operation(操作)" msgid "repetition" msgstr "repetition(重複)" -#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1157 msgid "subscript" msgstr "subscript(下標)" -#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:950 ../../library/stdtypes.rst:1157 msgid "slice" msgstr "slice(切片)" @@ -8937,356 +9014,356 @@ msgstr "mutable sequence(可變序列)" msgid "loop over" msgstr "loop over(迴圈)" -#: ../../library/stdtypes.rst:1117 +#: ../../library/stdtypes.rst:1120 msgid "immutable" msgstr "immutable(不可變)" -#: ../../library/stdtypes.rst:1117 ../../library/stdtypes.rst:1339 +#: ../../library/stdtypes.rst:1120 ../../library/stdtypes.rst:1344 msgid "tuple" msgstr "tuple(元組)" -#: ../../library/stdtypes.rst:1117 +#: ../../library/stdtypes.rst:1120 msgid "hash" msgstr "hash(雜湊)" -#: ../../library/stdtypes.rst:1139 +#: ../../library/stdtypes.rst:1142 msgid "mutable" msgstr "mutable(可變)" -#: ../../library/stdtypes.rst:1139 ../../library/stdtypes.rst:1154 -#: ../../library/stdtypes.rst:1260 +#: ../../library/stdtypes.rst:1142 ../../library/stdtypes.rst:1157 +#: ../../library/stdtypes.rst:1265 msgid "list" msgstr "list(串列)" -#: ../../library/stdtypes.rst:1139 ../../library/stdtypes.rst:2672 -#: ../../library/stdtypes.rst:2798 ../../library/stdtypes.rst:2870 -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:1142 ../../library/stdtypes.rst:2728 +#: ../../library/stdtypes.rst:2854 ../../library/stdtypes.rst:2926 +#: ../../library/stdtypes.rst:3748 msgid "bytearray" msgstr "bytearray(位元組陣列)" -#: ../../library/stdtypes.rst:1154 ../../library/stdtypes.rst:4581 -#: ../../library/stdtypes.rst:5318 ../../library/stdtypes.rst:5568 +#: ../../library/stdtypes.rst:1157 ../../library/stdtypes.rst:4637 +#: ../../library/stdtypes.rst:5374 ../../library/stdtypes.rst:5624 msgid "type" msgstr "type(型別)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "assignment" msgstr "assignment(賦值)" -#: ../../library/stdtypes.rst:1154 ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:1157 ../../library/stdtypes.rst:4637 msgid "del" msgstr "del" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "append() (sequence method)" msgstr "append()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "clear() (sequence method)" msgstr "clear()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "copy() (sequence method)" msgstr "copy()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "extend() (sequence method)" msgstr "extend()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "insert() (sequence method)" msgstr "insert()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "pop() (sequence method)" msgstr "pop()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "remove() (sequence method)" msgstr "remove()(序列方法)" -#: ../../library/stdtypes.rst:1154 +#: ../../library/stdtypes.rst:1157 msgid "reverse() (sequence method)" msgstr "reverse()(序列方法)" -#: ../../library/stdtypes.rst:1383 +#: ../../library/stdtypes.rst:1388 msgid "range" msgstr "range" -#: ../../library/stdtypes.rst:1504 ../../library/stdtypes.rst:1553 -#: ../../library/stdtypes.rst:1598 ../../library/stdtypes.rst:2323 -#: ../../library/stdtypes.rst:2469 +#: ../../library/stdtypes.rst:1509 ../../library/stdtypes.rst:1558 +#: ../../library/stdtypes.rst:1603 ../../library/stdtypes.rst:2379 +#: ../../library/stdtypes.rst:2525 msgid "string" msgstr "string(字串)" -#: ../../library/stdtypes.rst:1504 +#: ../../library/stdtypes.rst:1509 msgid "text sequence type" msgstr "text sequence type(文字序列型別)" -#: ../../library/stdtypes.rst:1504 ../../library/stdtypes.rst:1553 -#: ../../library/stdtypes.rst:1571 +#: ../../library/stdtypes.rst:1509 ../../library/stdtypes.rst:1558 +#: ../../library/stdtypes.rst:1576 msgid "str (built-in class)" msgstr "str(內建類別)" -#: ../../library/stdtypes.rst:1504 +#: ../../library/stdtypes.rst:1509 msgid "(see also string)" msgstr "(亦請見 string)" -#: ../../library/stdtypes.rst:1540 +#: ../../library/stdtypes.rst:1545 msgid "io.StringIO" msgstr "io.StringIO" -#: ../../library/stdtypes.rst:1571 ../../library/stdtypes.rst:2664 +#: ../../library/stdtypes.rst:1576 ../../library/stdtypes.rst:2720 msgid "buffer protocol" msgstr "buffer protocol(緩衝區協定)" -#: ../../library/stdtypes.rst:1571 ../../library/stdtypes.rst:2672 -#: ../../library/stdtypes.rst:2691 ../../library/stdtypes.rst:2870 -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:1576 ../../library/stdtypes.rst:2728 +#: ../../library/stdtypes.rst:2747 ../../library/stdtypes.rst:2926 +#: ../../library/stdtypes.rst:3748 msgid "bytes" msgstr "bytes(位元組)" -#: ../../library/stdtypes.rst:1598 ../../library/stdtypes.rst:2870 +#: ../../library/stdtypes.rst:1603 ../../library/stdtypes.rst:2926 msgid "methods" msgstr "methods(方法)" -#: ../../library/stdtypes.rst:1606 +#: ../../library/stdtypes.rst:1611 msgid "re" msgstr "re" -#: ../../library/stdtypes.rst:2137 ../../library/stdtypes.rst:3546 +#: ../../library/stdtypes.rst:2193 ../../library/stdtypes.rst:3602 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/stdtypes.rst:2137 +#: ../../library/stdtypes.rst:2193 msgid "str.splitlines method" msgstr "str.splitlines 方法" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "! formatted string literal" msgstr "! formatted string literals(! 格式化字串常數)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "formatted string literals" msgstr "formatted string literals(格式化字串常數)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "! f-string" msgstr "! f-string(! f 字串)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "f-strings" msgstr "f-string(f 字串)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "fstring" msgstr "fstring(f 字串)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "interpolated string literal" msgstr "interpolated string literal(插值字串常數)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "formatted literal" msgstr "formatted literal(格式化常數)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "interpolated literal" msgstr "interpolated literal(插值常數)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "{} (curly brackets)" msgstr "{} (花括號)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "in formatted string literal" msgstr "於格式化字串常數中" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "! (exclamation mark)" msgstr "! (驚嘆號)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid ": (colon)" msgstr ": (冒號)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "= (equals)" msgstr "= (等號)" -#: ../../library/stdtypes.rst:2323 +#: ../../library/stdtypes.rst:2379 msgid "for help in debugging using string literals" msgstr "" -#: ../../library/stdtypes.rst:2469 +#: ../../library/stdtypes.rst:2525 msgid "formatting, string (%)" msgstr "formatting(格式化)、字串 (%)" -#: ../../library/stdtypes.rst:2469 +#: ../../library/stdtypes.rst:2525 msgid "interpolation, string (%)" msgstr "interpolation(插值)、字串 (%)" -#: ../../library/stdtypes.rst:2469 +#: ../../library/stdtypes.rst:2525 msgid "formatting, printf" msgstr "formatting(格式化)、printf" -#: ../../library/stdtypes.rst:2469 +#: ../../library/stdtypes.rst:2525 msgid "interpolation, printf" msgstr "interpolation(插值)、printf" -#: ../../library/stdtypes.rst:2469 ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:2525 ../../library/stdtypes.rst:3748 msgid "printf-style formatting" msgstr "printf 風格格式化" -#: ../../library/stdtypes.rst:2469 ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:2525 ../../library/stdtypes.rst:3748 msgid "sprintf-style formatting" msgstr "sprintf 風格格式化" -#: ../../library/stdtypes.rst:2505 ../../library/stdtypes.rst:3724 +#: ../../library/stdtypes.rst:2561 ../../library/stdtypes.rst:3780 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../library/stdtypes.rst:2505 ../../library/stdtypes.rst:2548 -#: ../../library/stdtypes.rst:3724 ../../library/stdtypes.rst:3767 +#: ../../library/stdtypes.rst:2561 ../../library/stdtypes.rst:2604 +#: ../../library/stdtypes.rst:3780 ../../library/stdtypes.rst:3823 msgid "in printf-style formatting" msgstr "於 printf 風格格式化" -#: ../../library/stdtypes.rst:2505 ../../library/stdtypes.rst:3724 +#: ../../library/stdtypes.rst:2561 ../../library/stdtypes.rst:3780 msgid ". (dot)" msgstr ". (點)" -#: ../../library/stdtypes.rst:2548 ../../library/stdtypes.rst:3767 +#: ../../library/stdtypes.rst:2604 ../../library/stdtypes.rst:3823 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/stdtypes.rst:2548 ../../library/stdtypes.rst:3767 +#: ../../library/stdtypes.rst:2604 ../../library/stdtypes.rst:3823 msgid "space" msgstr "space(空白)" -#: ../../library/stdtypes.rst:2664 +#: ../../library/stdtypes.rst:2720 msgid "binary sequence types" msgstr "binary sequence types(二進位序列型別)" -#: ../../library/stdtypes.rst:2672 +#: ../../library/stdtypes.rst:2728 msgid "memoryview" msgstr "memoryview(記憶體視圖)" -#: ../../library/stdtypes.rst:2672 +#: ../../library/stdtypes.rst:2728 msgid "array" msgstr "array(陣列)" -#: ../../library/stdtypes.rst:3546 +#: ../../library/stdtypes.rst:3602 msgid "bytes.splitlines method" msgstr "bytes.splitlines 方法" -#: ../../library/stdtypes.rst:3546 +#: ../../library/stdtypes.rst:3602 msgid "bytearray.splitlines method" msgstr "bytearray.splitlines 方法" -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:3748 msgid "formatting" msgstr "formatting(格式化)" -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:3748 msgid "bytes (%)" msgstr "bytes (%)" -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:3748 msgid "bytearray (%)" msgstr "bytearray (%)" -#: ../../library/stdtypes.rst:3692 +#: ../../library/stdtypes.rst:3748 msgid "interpolation" msgstr "interpolation(插值)" -#: ../../library/stdtypes.rst:4379 +#: ../../library/stdtypes.rst:4435 msgid "set" msgstr "set(集合)" -#: ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:4637 msgid "mapping" msgstr "mapping(對映)" -#: ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:4637 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../library/stdtypes.rst:4691 +#: ../../library/stdtypes.rst:4747 msgid "__missing__()" msgstr "__missing__()" -#: ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:5032 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:5032 msgid "context management protocol" msgstr "context management protocol(情境管理協定)" -#: ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:5032 msgid "context management" msgstr "context management(情境管理)" -#: ../../library/stdtypes.rst:5049 +#: ../../library/stdtypes.rst:5105 msgid "annotation" msgstr "annotation(註記)" -#: ../../library/stdtypes.rst:5049 +#: ../../library/stdtypes.rst:5105 msgid "type annotation; type hint" msgstr "type annotation(型別註記);type hint(型別提示)" -#: ../../library/stdtypes.rst:5061 +#: ../../library/stdtypes.rst:5117 msgid "GenericAlias" msgstr "GenericAlias(泛型別名)" -#: ../../library/stdtypes.rst:5061 +#: ../../library/stdtypes.rst:5117 msgid "Generic" msgstr "Generic(泛型)" -#: ../../library/stdtypes.rst:5061 +#: ../../library/stdtypes.rst:5117 msgid "Alias" msgstr "Alias(別名)" -#: ../../library/stdtypes.rst:5318 +#: ../../library/stdtypes.rst:5374 msgid "Union" msgstr "Union(聯合)" -#: ../../library/stdtypes.rst:5318 +#: ../../library/stdtypes.rst:5374 msgid "union" msgstr "union(聯集)" -#: ../../library/stdtypes.rst:5488 +#: ../../library/stdtypes.rst:5544 msgid "method" msgstr "method(方法)" -#: ../../library/stdtypes.rst:5532 +#: ../../library/stdtypes.rst:5588 msgid "code" msgstr "code(程式碼)" -#: ../../library/stdtypes.rst:5532 +#: ../../library/stdtypes.rst:5588 msgid "code object" msgstr "code object(程式碼物件)" -#: ../../library/stdtypes.rst:5539 +#: ../../library/stdtypes.rst:5595 msgid "compile" msgstr "compile(編譯)" -#: ../../library/stdtypes.rst:5539 +#: ../../library/stdtypes.rst:5595 msgid "__code__ (function object attribute)" msgstr "__code__(函式物件屬性)" -#: ../../library/stdtypes.rst:5553 +#: ../../library/stdtypes.rst:5609 msgid "exec" msgstr "exec" -#: ../../library/stdtypes.rst:5553 +#: ../../library/stdtypes.rst:5609 msgid "eval" msgstr "eval" -#: ../../library/stdtypes.rst:5592 +#: ../../library/stdtypes.rst:5648 msgid "..." msgstr "..." -#: ../../library/stdtypes.rst:5592 +#: ../../library/stdtypes.rst:5648 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號)" diff --git a/library/tarfile.po b/library/tarfile.po index 285f869c65..e996b848ab 100644 --- a/library/tarfile.po +++ b/library/tarfile.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-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -343,12 +343,12 @@ msgstr "``'w|xz'``" msgid "Open an lzma compressed *stream* for writing." msgstr "" -#: ../../library/tarfile.rst:158 ../../library/tarfile.rst:425 +#: ../../library/tarfile.rst:158 ../../library/tarfile.rst:434 msgid "The ``'x'`` (exclusive creation) mode was added." msgstr "" -#: ../../library/tarfile.rst:161 ../../library/tarfile.rst:428 -#: ../../library/tarfile.rst:673 +#: ../../library/tarfile.rst:161 ../../library/tarfile.rst:437 +#: ../../library/tarfile.rst:682 msgid "The *name* parameter accepts a :term:`path-like object`." msgstr "" @@ -442,124 +442,132 @@ msgid "" "directory." msgstr "" -#: ../../library/tarfile.rst:253 +#: ../../library/tarfile.rst:254 +msgid "" +"Raised to refuse emulating a link (hard or symbolic) by extracting another " +"archive member, when that member would be rejected by the filter location. " +"The exception that was raised to reject the replacement member is available " +"as :attr:`!BaseException.__context__`." +msgstr "" + +#: ../../library/tarfile.rst:262 msgid "The following constants are available at the module level:" msgstr "" -#: ../../library/tarfile.rst:257 +#: ../../library/tarfile.rst:266 msgid "" "The default character encoding: ``'utf-8'`` on Windows, the value returned " "by :func:`sys.getfilesystemencoding` otherwise." msgstr "" -#: ../../library/tarfile.rst:263 +#: ../../library/tarfile.rst:272 msgid "A regular file :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:267 +#: ../../library/tarfile.rst:276 msgid "A link (inside tarfile) :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:271 +#: ../../library/tarfile.rst:280 msgid "A symbolic link :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:275 +#: ../../library/tarfile.rst:284 msgid "A character special device :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:279 +#: ../../library/tarfile.rst:288 msgid "A block special device :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:283 +#: ../../library/tarfile.rst:292 msgid "A directory :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:287 +#: ../../library/tarfile.rst:296 msgid "A FIFO special device :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:291 +#: ../../library/tarfile.rst:300 msgid "A contiguous file :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:295 +#: ../../library/tarfile.rst:304 msgid "A GNU tar longname :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:299 +#: ../../library/tarfile.rst:308 msgid "A GNU tar longlink :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:303 +#: ../../library/tarfile.rst:312 msgid "A GNU tar sparse file :attr:`~TarInfo.type`." msgstr "" -#: ../../library/tarfile.rst:306 +#: ../../library/tarfile.rst:315 msgid "" "Each of the following constants defines a tar archive format that the :mod:" "`tarfile` module is able to create. See section :ref:`tar-formats` for " "details." msgstr "" -#: ../../library/tarfile.rst:313 +#: ../../library/tarfile.rst:322 msgid "POSIX.1-1988 (ustar) format." msgstr "" -#: ../../library/tarfile.rst:318 +#: ../../library/tarfile.rst:327 msgid "GNU tar format." msgstr "" -#: ../../library/tarfile.rst:323 +#: ../../library/tarfile.rst:332 msgid "POSIX.1-2001 (pax) format." msgstr "" -#: ../../library/tarfile.rst:328 +#: ../../library/tarfile.rst:337 msgid "" "The default format for creating archives. This is currently :const:" "`PAX_FORMAT`." msgstr "" -#: ../../library/tarfile.rst:330 +#: ../../library/tarfile.rst:339 msgid "" "The default format for new archives was changed to :const:`PAX_FORMAT` from :" "const:`GNU_FORMAT`." msgstr "" -#: ../../library/tarfile.rst:337 +#: ../../library/tarfile.rst:346 msgid "Module :mod:`zipfile`" msgstr ":mod:`zipfile` 模組" -#: ../../library/tarfile.rst:338 +#: ../../library/tarfile.rst:347 msgid "Documentation of the :mod:`zipfile` standard module." msgstr "" -#: ../../library/tarfile.rst:340 +#: ../../library/tarfile.rst:349 msgid ":ref:`archiving-operations`" msgstr ":ref:`archiving-operations`" -#: ../../library/tarfile.rst:341 +#: ../../library/tarfile.rst:350 msgid "" "Documentation of the higher-level archiving facilities provided by the " "standard :mod:`shutil` module." msgstr "" -#: ../../library/tarfile.rst:344 +#: ../../library/tarfile.rst:353 msgid "" "`GNU tar manual, Basic Tar Format `_" msgstr "" -#: ../../library/tarfile.rst:345 +#: ../../library/tarfile.rst:354 msgid "Documentation for tar archive files, including GNU tar extensions." msgstr "" -#: ../../library/tarfile.rst:351 +#: ../../library/tarfile.rst:360 msgid "TarFile Objects" msgstr "TarFile 物件" -#: ../../library/tarfile.rst:353 +#: ../../library/tarfile.rst:362 msgid "" "The :class:`TarFile` object provides an interface to a tar archive. A tar " "archive is a sequence of blocks. An archive member (a stored file) is made " @@ -568,7 +576,7 @@ msgid "" "class:`TarInfo` object, see :ref:`tarinfo-objects` for details." msgstr "" -#: ../../library/tarfile.rst:359 +#: ../../library/tarfile.rst:368 msgid "" "A :class:`TarFile` object can be used as a context manager in a :keyword:" "`with` statement. It will automatically be closed when the block is " @@ -577,24 +585,24 @@ msgid "" "be closed. See the :ref:`tar-examples` section for a use case." msgstr "" -#: ../../library/tarfile.rst:365 +#: ../../library/tarfile.rst:374 msgid "Added support for the context management protocol." msgstr "" -#: ../../library/tarfile.rst:370 +#: ../../library/tarfile.rst:379 msgid "" "All following arguments are optional and can be accessed as instance " "attributes as well." msgstr "" -#: ../../library/tarfile.rst:373 +#: ../../library/tarfile.rst:382 msgid "" "*name* is the pathname of the archive. *name* may be a :term:`path-like " "object`. It can be omitted if *fileobj* is given. In this case, the file " "object's :attr:`!name` attribute is used if it exists." msgstr "" -#: ../../library/tarfile.rst:377 +#: ../../library/tarfile.rst:386 msgid "" "*mode* is either ``'r'`` to read from an existing archive, ``'a'`` to append " "data to an existing file, ``'w'`` to create a new file overwriting an " @@ -602,18 +610,18 @@ msgid "" "exist." msgstr "" -#: ../../library/tarfile.rst:381 +#: ../../library/tarfile.rst:390 msgid "" "If *fileobj* is given, it is used for reading or writing data. If it can be " "determined, *mode* is overridden by *fileobj*'s mode. *fileobj* will be used " "from position 0." msgstr "" -#: ../../library/tarfile.rst:387 +#: ../../library/tarfile.rst:396 msgid "*fileobj* is not closed, when :class:`TarFile` is closed." msgstr "" -#: ../../library/tarfile.rst:389 +#: ../../library/tarfile.rst:398 msgid "" "*format* controls the archive format for writing. It must be one of the " "constants :const:`USTAR_FORMAT`, :const:`GNU_FORMAT` or :const:`PAX_FORMAT` " @@ -621,20 +629,20 @@ msgid "" "detected, even if different formats are present in a single archive." msgstr "" -#: ../../library/tarfile.rst:394 +#: ../../library/tarfile.rst:403 msgid "" "The *tarinfo* argument can be used to replace the default :class:`TarInfo` " "class with a different one." msgstr "" -#: ../../library/tarfile.rst:397 +#: ../../library/tarfile.rst:406 msgid "" "If *dereference* is :const:`False`, add symbolic and hard links to the " "archive. If it is :const:`True`, add the content of the target files to the " "archive. This has no effect on systems that do not support symbolic links." msgstr "" -#: ../../library/tarfile.rst:401 +#: ../../library/tarfile.rst:410 msgid "" "If *ignore_zeros* is :const:`False`, treat an empty block as the end of the " "archive. If it is :const:`True`, skip empty (and invalid) blocks and try to " @@ -642,19 +650,19 @@ msgid "" "concatenated or damaged archives." msgstr "" -#: ../../library/tarfile.rst:405 +#: ../../library/tarfile.rst:414 msgid "" "*debug* can be set from ``0`` (no debug messages) up to ``3`` (all debug " "messages). The messages are written to ``sys.stderr``." msgstr "" -#: ../../library/tarfile.rst:408 +#: ../../library/tarfile.rst:417 msgid "" "*errorlevel* controls how extraction errors are handled, see :attr:`the " "corresponding attribute `." msgstr "" -#: ../../library/tarfile.rst:411 +#: ../../library/tarfile.rst:420 msgid "" "The *encoding* and *errors* arguments define the character encoding to be " "used for reading or writing the archive and how conversion errors are going " @@ -662,57 +670,57 @@ msgid "" "ref:`tar-unicode` for in-depth information." msgstr "" -#: ../../library/tarfile.rst:416 +#: ../../library/tarfile.rst:425 msgid "" "The *pax_headers* argument is an optional dictionary of strings which will " "be added as a pax global header if *format* is :const:`PAX_FORMAT`." msgstr "" -#: ../../library/tarfile.rst:419 +#: ../../library/tarfile.rst:428 msgid "" "If *stream* is set to :const:`True` then while reading the archive info " "about files in the archive are not cached, saving memory." msgstr "" -#: ../../library/tarfile.rst:422 ../../library/tarfile.rst:742 +#: ../../library/tarfile.rst:431 ../../library/tarfile.rst:751 msgid "Use ``'surrogateescape'`` as the default for the *errors* argument." msgstr "" -#: ../../library/tarfile.rst:431 +#: ../../library/tarfile.rst:440 msgid "Add the *stream* parameter." msgstr "新增 *stream* 參數。" -#: ../../library/tarfile.rst:436 +#: ../../library/tarfile.rst:445 msgid "" "Alternative constructor. The :func:`tarfile.open` function is actually a " "shortcut to this classmethod." msgstr "" -#: ../../library/tarfile.rst:442 +#: ../../library/tarfile.rst:451 msgid "" "Return a :class:`TarInfo` object for member *name*. If *name* can not be " "found in the archive, :exc:`KeyError` is raised." msgstr "" -#: ../../library/tarfile.rst:447 +#: ../../library/tarfile.rst:456 msgid "" "If a member occurs more than once in the archive, its last occurrence is " "assumed to be the most up-to-date version." msgstr "" -#: ../../library/tarfile.rst:453 +#: ../../library/tarfile.rst:462 msgid "" "Return the members of the archive as a list of :class:`TarInfo` objects. The " "list has the same order as the members in the archive." msgstr "" -#: ../../library/tarfile.rst:459 +#: ../../library/tarfile.rst:468 msgid "" "Return the members as a list of their names. It has the same order as the " "list returned by :meth:`getmembers`." msgstr "" -#: ../../library/tarfile.rst:465 +#: ../../library/tarfile.rst:474 msgid "" "Print a table of contents to ``sys.stdout``. If *verbose* is :const:`False`, " "only the names of the members are printed. If it is :const:`True`, output " @@ -720,18 +728,18 @@ msgid "" "given, it must be a subset of the list returned by :meth:`getmembers`." msgstr "" -#: ../../library/tarfile.rst:470 +#: ../../library/tarfile.rst:479 msgid "Added the *members* parameter." msgstr "新增 *members* 參數。" -#: ../../library/tarfile.rst:476 +#: ../../library/tarfile.rst:485 msgid "" "Return the next member of the archive as a :class:`TarInfo` object, when :" "class:`TarFile` is opened for reading. Return :const:`None` if there is no " "more available." msgstr "" -#: ../../library/tarfile.rst:483 +#: ../../library/tarfile.rst:492 msgid "" "Extract all members from the archive to the current working directory or " "directory *path*. If optional *members* is given, it must be a subset of the " @@ -743,14 +751,14 @@ msgid "" "fail." msgstr "" -#: ../../library/tarfile.rst:491 +#: ../../library/tarfile.rst:500 msgid "" "If *numeric_owner* is :const:`True`, the uid and gid numbers from the " "tarfile are used to set the owner/group for the extracted files. Otherwise, " "the named values from the tarfile are used." msgstr "" -#: ../../library/tarfile.rst:495 +#: ../../library/tarfile.rst:504 msgid "" "The *filter* argument specifies how ``members`` are modified or rejected " "before extraction. See :ref:`tarfile-extraction-filter` for details. It is " @@ -758,7 +766,7 @@ msgid "" "need to support." msgstr "" -#: ../../library/tarfile.rst:503 +#: ../../library/tarfile.rst:512 msgid "" "Never extract archives from untrusted sources without prior inspection. It " "is possible that files are created outside of *path*, e.g. members that have " @@ -766,26 +774,26 @@ msgid "" "\"``." msgstr "" -#: ../../library/tarfile.rst:508 ../../library/tarfile.rst:541 +#: ../../library/tarfile.rst:517 ../../library/tarfile.rst:550 msgid "" "Set ``filter='data'`` to prevent the most dangerous security issues, and " "read the :ref:`tarfile-extraction-filter` section for details." msgstr "" -#: ../../library/tarfile.rst:511 ../../library/tarfile.rst:547 +#: ../../library/tarfile.rst:520 ../../library/tarfile.rst:556 msgid "Added the *numeric_owner* parameter." msgstr "新增 *numeric_owner* 參數。" -#: ../../library/tarfile.rst:514 ../../library/tarfile.rst:550 +#: ../../library/tarfile.rst:523 ../../library/tarfile.rst:559 msgid "The *path* parameter accepts a :term:`path-like object`." msgstr "" -#: ../../library/tarfile.rst:517 ../../library/tarfile.rst:553 -#: ../../library/tarfile.rst:635 +#: ../../library/tarfile.rst:526 ../../library/tarfile.rst:562 +#: ../../library/tarfile.rst:644 msgid "Added the *filter* parameter." msgstr "新增 *filter* 參數。" -#: ../../library/tarfile.rst:523 +#: ../../library/tarfile.rst:532 msgid "" "Extract a member from the archive to the current working directory, using " "its full name. Its file information is extracted as accurately as possible. " @@ -794,27 +802,27 @@ msgid "" "File attributes (owner, mtime, mode) are set unless *set_attrs* is false." msgstr "" -#: ../../library/tarfile.rst:529 +#: ../../library/tarfile.rst:538 msgid "" "The *numeric_owner* and *filter* arguments are the same as for :meth:" "`extractall`." msgstr "" -#: ../../library/tarfile.rst:534 +#: ../../library/tarfile.rst:543 msgid "" "The :meth:`extract` method does not take care of several extraction issues. " "In most cases you should consider using the :meth:`extractall` method." msgstr "" -#: ../../library/tarfile.rst:539 +#: ../../library/tarfile.rst:548 msgid "See the warning for :meth:`extractall`." msgstr "參閱 :meth:`extractall` 的警告。" -#: ../../library/tarfile.rst:544 +#: ../../library/tarfile.rst:553 msgid "Added the *set_attrs* parameter." msgstr "增加 *set_attrs* 參數。" -#: ../../library/tarfile.rst:559 +#: ../../library/tarfile.rst:568 msgid "" "Extract a member from the archive as a file object. *member* may be a " "filename or a :class:`TarInfo` object. If *member* is a regular file or a " @@ -823,17 +831,17 @@ msgid "" "the archive, :exc:`KeyError` is raised." msgstr "" -#: ../../library/tarfile.rst:565 +#: ../../library/tarfile.rst:574 msgid "Return an :class:`io.BufferedReader` object." msgstr "" -#: ../../library/tarfile.rst:568 +#: ../../library/tarfile.rst:577 msgid "" "The returned :class:`io.BufferedReader` object has the :attr:`!mode` " "attribute which is always equal to ``'rb'``." msgstr "" -#: ../../library/tarfile.rst:575 +#: ../../library/tarfile.rst:584 msgid "" "If *errorlevel* is ``0``, errors are ignored when using :meth:`TarFile." "extract` and :meth:`TarFile.extractall`. Nevertheless, they appear as error " @@ -843,39 +851,39 @@ msgid "" "exc:`TarError` exceptions as well." msgstr "" -#: ../../library/tarfile.rst:583 +#: ../../library/tarfile.rst:592 msgid "" "Some exceptions, e.g. ones caused by wrong argument types or data " "corruption, are always raised." msgstr "" -#: ../../library/tarfile.rst:586 +#: ../../library/tarfile.rst:595 msgid "" "Custom :ref:`extraction filters ` should raise :" "exc:`FilterError` for *fatal* errors and :exc:`ExtractError` for *non-fatal* " "ones." msgstr "" -#: ../../library/tarfile.rst:590 +#: ../../library/tarfile.rst:599 msgid "" "Note that when an exception is raised, the archive may be partially " "extracted. It is the user’s responsibility to clean up." msgstr "" -#: ../../library/tarfile.rst:597 +#: ../../library/tarfile.rst:606 msgid "" "The :ref:`extraction filter ` used as a default " "for the *filter* argument of :meth:`~TarFile.extract` and :meth:`~TarFile." "extractall`." msgstr "" -#: ../../library/tarfile.rst:601 +#: ../../library/tarfile.rst:610 msgid "" "The attribute may be ``None`` or a callable. String names are not allowed " "for this attribute, unlike the *filter* argument to :meth:`~TarFile.extract`." msgstr "" -#: ../../library/tarfile.rst:605 +#: ../../library/tarfile.rst:614 msgid "" "If ``extraction_filter`` is ``None`` (the default), calling an extraction " "method without a *filter* argument will raise a ``DeprecationWarning``, and " @@ -883,13 +891,13 @@ msgid "" "dangerous behavior matches previous versions of Python." msgstr "" -#: ../../library/tarfile.rst:611 +#: ../../library/tarfile.rst:620 msgid "" "In Python 3.14+, leaving ``extraction_filter=None`` will cause extraction " "methods to use the :func:`data ` filter by default." msgstr "" -#: ../../library/tarfile.rst:614 +#: ../../library/tarfile.rst:623 msgid "" "The attribute may be set on instances or overridden in subclasses. It also " "is possible to set it on the ``TarFile`` class itself to set a global " @@ -899,7 +907,7 @@ msgid "" "wrapped in :func:`staticmethod` to prevent injection of a ``self`` argument." msgstr "" -#: ../../library/tarfile.rst:624 +#: ../../library/tarfile.rst:633 msgid "" "Add the file *name* to the archive. *name* may be any type of file " "(directory, fifo, symbolic link, etc.). If given, *arcname* specifies an " @@ -912,11 +920,11 @@ msgid "" "ref:`tar-examples` for an example." msgstr "" -#: ../../library/tarfile.rst:638 +#: ../../library/tarfile.rst:647 msgid "Recursion adds entries in sorted order." msgstr "" -#: ../../library/tarfile.rst:644 +#: ../../library/tarfile.rst:653 msgid "" "Add the :class:`TarInfo` object *tarinfo* to the archive. If *tarinfo* " "represents a non zero-size regular file, the *fileobj* argument should be a :" @@ -925,11 +933,11 @@ msgid "" "meth:`gettarinfo`." msgstr "" -#: ../../library/tarfile.rst:651 +#: ../../library/tarfile.rst:660 msgid "*fileobj* must be given for non-zero-sized regular files." msgstr "" -#: ../../library/tarfile.rst:656 +#: ../../library/tarfile.rst:665 msgid "" "Create a :class:`TarInfo` object from the result of :func:`os.stat` or " "equivalent on an existing file. The file is either named by *name*, or " @@ -940,7 +948,7 @@ msgid "" "The name should be a text string." msgstr "" -#: ../../library/tarfile.rst:665 +#: ../../library/tarfile.rst:674 msgid "" "You can modify some of the :class:`TarInfo`’s attributes before you add it " "using :meth:`addfile`. If the file object is not an ordinary file object " @@ -950,21 +958,21 @@ msgid "" "case *arcname* could be a dummy string." msgstr "" -#: ../../library/tarfile.rst:679 +#: ../../library/tarfile.rst:688 msgid "" "Close the :class:`TarFile`. In write mode, two finishing zero blocks are " "appended to the archive." msgstr "" -#: ../../library/tarfile.rst:686 +#: ../../library/tarfile.rst:695 msgid "A dictionary containing key-value pairs of pax global headers." msgstr "" -#: ../../library/tarfile.rst:693 +#: ../../library/tarfile.rst:702 msgid "TarInfo Objects" msgstr "TarInfo 物件" -#: ../../library/tarfile.rst:695 +#: ../../library/tarfile.rst:704 msgid "" "A :class:`TarInfo` object represents one member in a :class:`TarFile`. Aside " "from storing all required attributes of a file (like file type, size, time, " @@ -972,14 +980,14 @@ msgid "" "type. It does *not* contain the file's data itself." msgstr "" -#: ../../library/tarfile.rst:700 +#: ../../library/tarfile.rst:709 msgid "" ":class:`TarInfo` objects are returned by :class:`TarFile`'s methods :meth:" "`~TarFile.getmember`, :meth:`~TarFile.getmembers` and :meth:`~TarFile." "gettarinfo`." msgstr "" -#: ../../library/tarfile.rst:704 +#: ../../library/tarfile.rst:713 msgid "" "Modifying the objects returned by :meth:`~TarFile.getmember` or :meth:" "`~TarFile.getmembers` will affect all subsequent operations on the archive. " @@ -988,82 +996,82 @@ msgid "" "step." msgstr "" -#: ../../library/tarfile.rst:710 +#: ../../library/tarfile.rst:719 msgid "" "Several attributes can be set to ``None`` to indicate that a piece of " "metadata is unused or unknown. Different :class:`TarInfo` methods handle " "``None`` differently:" msgstr "" -#: ../../library/tarfile.rst:714 +#: ../../library/tarfile.rst:723 msgid "" "The :meth:`~TarFile.extract` or :meth:`~TarFile.extractall` methods will " "ignore the corresponding metadata, leaving it set to a default." msgstr "" -#: ../../library/tarfile.rst:716 +#: ../../library/tarfile.rst:725 msgid ":meth:`~TarFile.addfile` will fail." msgstr "" -#: ../../library/tarfile.rst:717 +#: ../../library/tarfile.rst:726 msgid ":meth:`~TarFile.list` will print a placeholder string." msgstr "" -#: ../../library/tarfile.rst:721 +#: ../../library/tarfile.rst:730 msgid "Create a :class:`TarInfo` object." msgstr "" -#: ../../library/tarfile.rst:726 +#: ../../library/tarfile.rst:735 msgid "Create and return a :class:`TarInfo` object from string buffer *buf*." msgstr "" -#: ../../library/tarfile.rst:728 +#: ../../library/tarfile.rst:737 msgid "Raises :exc:`HeaderError` if the buffer is invalid." msgstr "" -#: ../../library/tarfile.rst:733 +#: ../../library/tarfile.rst:742 msgid "" "Read the next member from the :class:`TarFile` object *tarfile* and return " "it as a :class:`TarInfo` object." msgstr "" -#: ../../library/tarfile.rst:739 +#: ../../library/tarfile.rst:748 msgid "" "Create a string buffer from a :class:`TarInfo` object. For information on " "the arguments see the constructor of the :class:`TarFile` class." msgstr "" -#: ../../library/tarfile.rst:746 +#: ../../library/tarfile.rst:755 msgid "A ``TarInfo`` object has the following public data attributes:" msgstr "" -#: ../../library/tarfile.rst:752 +#: ../../library/tarfile.rst:761 msgid "Name of the archive member." msgstr "" -#: ../../library/tarfile.rst:758 +#: ../../library/tarfile.rst:767 msgid "Size in bytes." msgstr "" -#: ../../library/tarfile.rst:764 +#: ../../library/tarfile.rst:773 msgid "" "Time of last modification in seconds since the :ref:`epoch `, as in :" "attr:`os.stat_result.st_mtime`." msgstr "" -#: ../../library/tarfile.rst:769 ../../library/tarfile.rst:780 -#: ../../library/tarfile.rst:812 ../../library/tarfile.rst:823 -#: ../../library/tarfile.rst:834 ../../library/tarfile.rst:845 +#: ../../library/tarfile.rst:778 ../../library/tarfile.rst:789 +#: ../../library/tarfile.rst:821 ../../library/tarfile.rst:832 +#: ../../library/tarfile.rst:843 ../../library/tarfile.rst:854 msgid "" "Can be set to ``None`` for :meth:`~TarFile.extract` and :meth:`~TarFile." "extractall`, causing extraction to skip applying this attribute." msgstr "" -#: ../../library/tarfile.rst:776 +#: ../../library/tarfile.rst:785 msgid "Permission bits, as for :func:`os.chmod`." msgstr "" -#: ../../library/tarfile.rst:786 +#: ../../library/tarfile.rst:795 msgid "" "File type. *type* is usually one of these constants: :const:`REGTYPE`, :" "const:`AREGTYPE`, :const:`LNKTYPE`, :const:`SYMTYPE`, :const:`DIRTYPE`, :" @@ -1072,128 +1080,128 @@ msgid "" "more conveniently, use the ``is*()`` methods below." msgstr "" -#: ../../library/tarfile.rst:796 +#: ../../library/tarfile.rst:805 msgid "" "Name of the target file name, which is only present in :class:`TarInfo` " "objects of type :const:`LNKTYPE` and :const:`SYMTYPE`." msgstr "" -#: ../../library/tarfile.rst:799 +#: ../../library/tarfile.rst:808 msgid "" "For symbolic links (``SYMTYPE``), the *linkname* is relative to the " "directory that contains the link. For hard links (``LNKTYPE``), the " "*linkname* is relative to the root of the archive." msgstr "" -#: ../../library/tarfile.rst:808 +#: ../../library/tarfile.rst:817 msgid "User ID of the user who originally stored this member." msgstr "" -#: ../../library/tarfile.rst:819 +#: ../../library/tarfile.rst:828 msgid "Group ID of the user who originally stored this member." msgstr "" -#: ../../library/tarfile.rst:830 +#: ../../library/tarfile.rst:839 msgid "User name." msgstr "" -#: ../../library/tarfile.rst:841 +#: ../../library/tarfile.rst:850 msgid "Group name." msgstr "" -#: ../../library/tarfile.rst:852 +#: ../../library/tarfile.rst:861 msgid "Header checksum." msgstr "" -#: ../../library/tarfile.rst:858 +#: ../../library/tarfile.rst:867 msgid "Device major number." msgstr "" -#: ../../library/tarfile.rst:864 +#: ../../library/tarfile.rst:873 msgid "Device minor number." msgstr "" -#: ../../library/tarfile.rst:870 +#: ../../library/tarfile.rst:879 msgid "The tar header starts here." msgstr "" -#: ../../library/tarfile.rst:876 +#: ../../library/tarfile.rst:885 msgid "The file's data starts here." msgstr "" -#: ../../library/tarfile.rst:881 +#: ../../library/tarfile.rst:890 msgid "Sparse member information." msgstr "" -#: ../../library/tarfile.rst:887 +#: ../../library/tarfile.rst:896 msgid "" "A dictionary containing key-value pairs of an associated pax extended header." msgstr "" -#: ../../library/tarfile.rst:895 +#: ../../library/tarfile.rst:904 msgid "" "Return a *new* copy of the :class:`!TarInfo` object with the given " "attributes changed. For example, to return a ``TarInfo`` with the group name " "set to ``'staff'``, use::" msgstr "" -#: ../../library/tarfile.rst:899 +#: ../../library/tarfile.rst:908 msgid "new_tarinfo = old_tarinfo.replace(gname='staff')" msgstr "new_tarinfo = old_tarinfo.replace(gname='staff')" -#: ../../library/tarfile.rst:901 +#: ../../library/tarfile.rst:910 msgid "" "By default, a deep copy is made. If *deep* is false, the copy is shallow, i." "e. ``pax_headers`` and any custom attributes are shared with the original " "``TarInfo`` object." msgstr "" -#: ../../library/tarfile.rst:905 +#: ../../library/tarfile.rst:914 msgid "A :class:`TarInfo` object also provides some convenient query methods:" msgstr "" -#: ../../library/tarfile.rst:910 +#: ../../library/tarfile.rst:919 msgid "Return :const:`True` if the :class:`TarInfo` object is a regular file." msgstr "" -#: ../../library/tarfile.rst:915 +#: ../../library/tarfile.rst:924 msgid "Same as :meth:`isfile`." msgstr "" -#: ../../library/tarfile.rst:920 +#: ../../library/tarfile.rst:929 msgid "Return :const:`True` if it is a directory." msgstr "" -#: ../../library/tarfile.rst:925 +#: ../../library/tarfile.rst:934 msgid "Return :const:`True` if it is a symbolic link." msgstr "" -#: ../../library/tarfile.rst:930 +#: ../../library/tarfile.rst:939 msgid "Return :const:`True` if it is a hard link." msgstr "" -#: ../../library/tarfile.rst:935 +#: ../../library/tarfile.rst:944 msgid "Return :const:`True` if it is a character device." msgstr "" -#: ../../library/tarfile.rst:940 +#: ../../library/tarfile.rst:949 msgid "Return :const:`True` if it is a block device." msgstr "" -#: ../../library/tarfile.rst:945 +#: ../../library/tarfile.rst:954 msgid "Return :const:`True` if it is a FIFO." msgstr "" -#: ../../library/tarfile.rst:950 +#: ../../library/tarfile.rst:959 msgid "" "Return :const:`True` if it is one of character device, block device or FIFO." msgstr "" -#: ../../library/tarfile.rst:956 +#: ../../library/tarfile.rst:965 msgid "Extraction filters" msgstr "" -#: ../../library/tarfile.rst:960 +#: ../../library/tarfile.rst:969 msgid "" "The *tar* format is designed to capture all details of a UNIX-like " "filesystem, which makes it very powerful. Unfortunately, the features make " @@ -1203,66 +1211,66 @@ msgid "" "components, or symlinks that affect later members)." msgstr "" -#: ../../library/tarfile.rst:968 +#: ../../library/tarfile.rst:977 msgid "" "In most cases, the full functionality is not needed. Therefore, *tarfile* " "supports extraction filters: a mechanism to limit functionality, and thus " "mitigate some of the security issues." msgstr "" -#: ../../library/tarfile.rst:974 +#: ../../library/tarfile.rst:983 msgid ":pep:`706`" msgstr ":pep:`706`" -#: ../../library/tarfile.rst:975 +#: ../../library/tarfile.rst:984 msgid "Contains further motivation and rationale behind the design." msgstr "" -#: ../../library/tarfile.rst:977 +#: ../../library/tarfile.rst:986 msgid "" "The *filter* argument to :meth:`TarFile.extract` or :meth:`~TarFile." "extractall` can be:" msgstr "" -#: ../../library/tarfile.rst:980 +#: ../../library/tarfile.rst:989 msgid "" "the string ``'fully_trusted'``: Honor all metadata as specified in the " "archive. Should be used if the user trusts the archive completely, or " "implements their own complex verification." msgstr "" -#: ../../library/tarfile.rst:985 +#: ../../library/tarfile.rst:994 msgid "" "the string ``'tar'``: Honor most *tar*-specific features (i.e. features of " "UNIX-like filesystems), but block features that are very likely to be " "surprising or malicious. See :func:`tar_filter` for details." msgstr "" -#: ../../library/tarfile.rst:989 +#: ../../library/tarfile.rst:998 msgid "" "the string ``'data'``: Ignore or block most features specific to UNIX-like " "filesystems. Intended for extracting cross-platform data archives. See :func:" "`data_filter` for details." msgstr "" -#: ../../library/tarfile.rst:993 +#: ../../library/tarfile.rst:1002 msgid "``None`` (default): Use :attr:`TarFile.extraction_filter`." msgstr "" -#: ../../library/tarfile.rst:995 +#: ../../library/tarfile.rst:1004 msgid "" "If that is also ``None`` (the default), raise a ``DeprecationWarning``, and " "fall back to the ``'fully_trusted'`` filter, whose dangerous behavior " "matches previous versions of Python." msgstr "" -#: ../../library/tarfile.rst:999 +#: ../../library/tarfile.rst:1008 msgid "" "In Python 3.14, the ``'data'`` filter will become the default instead. It's " "possible to switch earlier; see :attr:`TarFile.extraction_filter`." msgstr "" -#: ../../library/tarfile.rst:1002 +#: ../../library/tarfile.rst:1011 msgid "" "A callable which will be called for each extracted member with a :ref:" "`TarInfo ` describing the member and the destination path " @@ -1270,27 +1278,27 @@ msgid "" "members)::" msgstr "" -#: ../../library/tarfile.rst:1007 +#: ../../library/tarfile.rst:1016 msgid "filter(member: TarInfo, path: str, /) -> TarInfo | None" msgstr "filter(member: TarInfo, path: str, /) -> TarInfo | None" -#: ../../library/tarfile.rst:1009 +#: ../../library/tarfile.rst:1018 msgid "" "The callable is called just before each member is extracted, so it can take " "the current state of the disk into account. It can:" msgstr "" -#: ../../library/tarfile.rst:1013 +#: ../../library/tarfile.rst:1022 msgid "" "return a :class:`TarInfo` object which will be used instead of the metadata " "in the archive, or" msgstr "" -#: ../../library/tarfile.rst:1015 +#: ../../library/tarfile.rst:1024 msgid "return ``None``, in which case the member will be skipped, or" msgstr "" -#: ../../library/tarfile.rst:1016 +#: ../../library/tarfile.rst:1025 msgid "" "raise an exception to abort the operation or skip the member, depending on :" "attr:`~TarFile.errorlevel`. Note that when extraction is aborted, :meth:" @@ -1298,118 +1306,130 @@ msgid "" "attempt to clean up." msgstr "" -#: ../../library/tarfile.rst:1022 +#: ../../library/tarfile.rst:1031 msgid "Default named filters" msgstr "" -#: ../../library/tarfile.rst:1024 +#: ../../library/tarfile.rst:1033 msgid "" "The pre-defined, named filters are available as functions, so they can be " "reused in custom filters:" msgstr "" -#: ../../library/tarfile.rst:1029 +#: ../../library/tarfile.rst:1038 msgid "Return *member* unchanged." msgstr "" -#: ../../library/tarfile.rst:1031 +#: ../../library/tarfile.rst:1040 msgid "This implements the ``'fully_trusted'`` filter." msgstr "" -#: ../../library/tarfile.rst:1035 +#: ../../library/tarfile.rst:1044 msgid "Implements the ``'tar'`` filter." msgstr "" -#: ../../library/tarfile.rst:1037 +#: ../../library/tarfile.rst:1046 msgid "Strip leading slashes (``/`` and :data:`os.sep`) from filenames." msgstr "" -#: ../../library/tarfile.rst:1038 +#: ../../library/tarfile.rst:1047 msgid "" ":ref:`Refuse ` to extract files with absolute " "paths (in case the name is absolute even after stripping slashes, e.g. ``C:/" "foo`` on Windows). This raises :class:`~tarfile.AbsolutePathError`." msgstr "" -#: ../../library/tarfile.rst:1042 +#: ../../library/tarfile.rst:1051 msgid "" ":ref:`Refuse ` to extract files whose absolute " "path (after following symlinks) would end up outside the destination. This " "raises :class:`~tarfile.OutsideDestinationError`." msgstr "" -#: ../../library/tarfile.rst:1045 +#: ../../library/tarfile.rst:1054 msgid "" "Clear high mode bits (setuid, setgid, sticky) and group/other write bits (:" "const:`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`)." msgstr "" -#: ../../library/tarfile.rst:1048 ../../library/tarfile.rst:1081 +#: ../../library/tarfile.rst:1057 ../../library/tarfile.rst:1096 msgid "Return the modified ``TarInfo`` member." msgstr "" -#: ../../library/tarfile.rst:1052 +#: ../../library/tarfile.rst:1061 msgid "" "Implements the ``'data'`` filter. In addition to what ``tar_filter`` does:" msgstr "" -#: ../../library/tarfile.rst:1055 +#: ../../library/tarfile.rst:1064 +msgid "" +"Normalize link targets (:attr:`TarInfo.linkname`) using :func:`os.path." +"normpath`. Note that this removes internal ``..`` components, which may " +"change the meaning of the link if the path in :attr:`!TarInfo.linkname` " +"traverses symbolic links." +msgstr "" + +#: ../../library/tarfile.rst:1070 msgid "" ":ref:`Refuse ` to extract links (hard or soft) " "that link to absolute paths, or ones that link outside the destination." msgstr "" -#: ../../library/tarfile.rst:1058 +#: ../../library/tarfile.rst:1073 msgid "" "This raises :class:`~tarfile.AbsoluteLinkError` or :class:`~tarfile." "LinkOutsideDestinationError`." msgstr "" -#: ../../library/tarfile.rst:1061 +#: ../../library/tarfile.rst:1076 msgid "" "Note that such files are refused even on platforms that do not support " "symbolic links." msgstr "" -#: ../../library/tarfile.rst:1064 +#: ../../library/tarfile.rst:1079 msgid "" ":ref:`Refuse ` to extract device files (including " "pipes). This raises :class:`~tarfile.SpecialFileError`." msgstr "" -#: ../../library/tarfile.rst:1068 +#: ../../library/tarfile.rst:1083 msgid "For regular files, including hard links:" msgstr "" -#: ../../library/tarfile.rst:1070 +#: ../../library/tarfile.rst:1085 msgid "" "Set the owner read and write permissions (:const:`~stat.S_IRUSR` | :const:" "`~stat.S_IWUSR`)." msgstr "" -#: ../../library/tarfile.rst:1072 +#: ../../library/tarfile.rst:1087 msgid "" "Remove the group & other executable permission (:const:`~stat.S_IXGRP` | :" "const:`~stat.S_IXOTH`) if the owner doesn’t have it (:const:`~stat.S_IXUSR`)." msgstr "" -#: ../../library/tarfile.rst:1076 +#: ../../library/tarfile.rst:1091 msgid "" "For other files (directories), set ``mode`` to ``None``, so that extraction " "methods skip applying permission bits." msgstr "" -#: ../../library/tarfile.rst:1078 +#: ../../library/tarfile.rst:1093 msgid "" "Set user and group info (``uid``, ``gid``, ``uname``, ``gname``) to " "``None``, so that extraction methods skip setting it." msgstr "" -#: ../../library/tarfile.rst:1087 +#: ../../library/tarfile.rst:1100 +msgid "Link targets are now normalized." +msgstr "" + +#: ../../library/tarfile.rst:1106 msgid "Filter errors" msgstr "" -#: ../../library/tarfile.rst:1089 +#: ../../library/tarfile.rst:1108 msgid "" "When a filter refuses to extract a file, it will raise an appropriate " "exception, a subclass of :class:`~tarfile.FilterError`. This will abort the " @@ -1418,11 +1438,11 @@ msgid "" "continue." msgstr "" -#: ../../library/tarfile.rst:1097 +#: ../../library/tarfile.rst:1116 msgid "Hints for further verification" msgstr "" -#: ../../library/tarfile.rst:1099 +#: ../../library/tarfile.rst:1118 msgid "" "Even with ``filter='data'``, *tarfile* is not suited for extracting " "untrusted files without prior inspection. Among other issues, the pre-" @@ -1430,69 +1450,73 @@ msgid "" "additional checks." msgstr "" -#: ../../library/tarfile.rst:1104 +#: ../../library/tarfile.rst:1123 msgid "Here is an incomplete list of things to consider:" msgstr "" -#: ../../library/tarfile.rst:1106 +#: ../../library/tarfile.rst:1125 msgid "" "Extract to a :func:`new temporary directory ` to prevent e." "g. exploiting pre-existing links, and to make it easier to clean up after a " "failed extraction." msgstr "" -#: ../../library/tarfile.rst:1109 +#: ../../library/tarfile.rst:1128 +msgid "Disallow symbolic links if you do not need the functionality." +msgstr "" + +#: ../../library/tarfile.rst:1129 msgid "" "When working with untrusted data, use external (e.g. OS-level) limits on " "disk, memory and CPU usage." msgstr "" -#: ../../library/tarfile.rst:1111 +#: ../../library/tarfile.rst:1131 msgid "" "Check filenames against an allow-list of characters (to filter out control " "characters, confusables, foreign path separators, etc.)." msgstr "" -#: ../../library/tarfile.rst:1114 +#: ../../library/tarfile.rst:1134 msgid "" "Check that filenames have expected extensions (discouraging files that " "execute when you “click on them”, or extension-less files like Windows " "special device names)." msgstr "" -#: ../../library/tarfile.rst:1116 +#: ../../library/tarfile.rst:1136 msgid "" "Limit the number of extracted files, total size of extracted data, filename " "length (including symlink length), and size of individual files." msgstr "" -#: ../../library/tarfile.rst:1118 +#: ../../library/tarfile.rst:1138 msgid "Check for files that would be shadowed on case-insensitive filesystems." msgstr "" -#: ../../library/tarfile.rst:1120 +#: ../../library/tarfile.rst:1140 msgid "Also note that:" msgstr "" -#: ../../library/tarfile.rst:1122 +#: ../../library/tarfile.rst:1142 msgid "" "Tar files may contain multiple versions of the same file. Later ones are " "expected to overwrite any earlier ones. This feature is crucial to allow " "updating tape archives, but can be abused maliciously." msgstr "" -#: ../../library/tarfile.rst:1126 +#: ../../library/tarfile.rst:1146 msgid "" "*tarfile* does not protect against issues with “live” data, e.g. an attacker " "tinkering with the destination (or source) directory while extraction (or " "archiving) is in progress." msgstr "" -#: ../../library/tarfile.rst:1132 +#: ../../library/tarfile.rst:1152 msgid "Supporting older Python versions" msgstr "" -#: ../../library/tarfile.rst:1134 +#: ../../library/tarfile.rst:1154 msgid "" "Extraction filters were added to Python 3.12, but may be backported to older " "versions as security updates. To check whether the feature is available, use " @@ -1500,18 +1524,18 @@ msgid "" "version." msgstr "" -#: ../../library/tarfile.rst:1139 +#: ../../library/tarfile.rst:1159 msgid "" "The following examples show how to support Python versions with and without " "the feature. Note that setting ``extraction_filter`` will affect any " "subsequent operations." msgstr "" -#: ../../library/tarfile.rst:1143 +#: ../../library/tarfile.rst:1163 msgid "Fully trusted archive::" msgstr "" -#: ../../library/tarfile.rst:1145 +#: ../../library/tarfile.rst:1165 msgid "" "my_tarfile.extraction_filter = (lambda member, path: member)\n" "my_tarfile.extractall()" @@ -1519,13 +1543,13 @@ msgstr "" "my_tarfile.extraction_filter = (lambda member, path: member)\n" "my_tarfile.extractall()" -#: ../../library/tarfile.rst:1148 +#: ../../library/tarfile.rst:1168 msgid "" "Use the ``'data'`` filter if available, but revert to Python 3.11 behavior " "(``'fully_trusted'``) if this feature is not available::" msgstr "" -#: ../../library/tarfile.rst:1151 +#: ../../library/tarfile.rst:1171 msgid "" "my_tarfile.extraction_filter = getattr(tarfile, 'data_filter',\n" " (lambda member, path: member))\n" @@ -1535,19 +1559,19 @@ msgstr "" " (lambda member, path: member))\n" "my_tarfile.extractall()" -#: ../../library/tarfile.rst:1155 +#: ../../library/tarfile.rst:1175 msgid "Use the ``'data'`` filter; *fail* if it is not available::" msgstr "" -#: ../../library/tarfile.rst:1157 +#: ../../library/tarfile.rst:1177 msgid "my_tarfile.extractall(filter=tarfile.data_filter)" msgstr "my_tarfile.extractall(filter=tarfile.data_filter)" -#: ../../library/tarfile.rst:1159 +#: ../../library/tarfile.rst:1179 msgid "or::" msgstr "或: ::" -#: ../../library/tarfile.rst:1161 +#: ../../library/tarfile.rst:1181 msgid "" "my_tarfile.extraction_filter = tarfile.data_filter\n" "my_tarfile.extractall()" @@ -1555,11 +1579,11 @@ msgstr "" "my_tarfile.extraction_filter = tarfile.data_filter\n" "my_tarfile.extractall()" -#: ../../library/tarfile.rst:1164 +#: ../../library/tarfile.rst:1184 msgid "Use the ``'data'`` filter; *warn* if it is not available::" msgstr "" -#: ../../library/tarfile.rst:1166 +#: ../../library/tarfile.rst:1186 msgid "" "if hasattr(tarfile, 'data_filter'):\n" " my_tarfile.extractall(filter='data')\n" @@ -1569,18 +1593,18 @@ msgid "" " my_tarfile.extractall()" msgstr "" -#: ../../library/tarfile.rst:1175 +#: ../../library/tarfile.rst:1195 msgid "Stateful extraction filter example" msgstr "" -#: ../../library/tarfile.rst:1177 +#: ../../library/tarfile.rst:1197 msgid "" "While *tarfile*'s extraction methods take a simple *filter* callable, custom " "filters may be more complex objects with an internal state. It may be useful " "to write these as context managers, to be used like this::" msgstr "" -#: ../../library/tarfile.rst:1181 +#: ../../library/tarfile.rst:1201 msgid "" "with StatefulFilter() as filter_func:\n" " tar.extractall(path, filter=filter_func)" @@ -1588,11 +1612,11 @@ msgstr "" "with StatefulFilter() as filter_func:\n" " tar.extractall(path, filter=filter_func)" -#: ../../library/tarfile.rst:1184 +#: ../../library/tarfile.rst:1204 msgid "Such a filter can be written as, for example::" msgstr "" -#: ../../library/tarfile.rst:1186 +#: ../../library/tarfile.rst:1206 msgid "" "class StatefulFilter:\n" " def __init__(self):\n" @@ -1609,103 +1633,103 @@ msgid "" " print(f'{self.file_count} files extracted')" msgstr "" -#: ../../library/tarfile.rst:1206 +#: ../../library/tarfile.rst:1226 msgid "Command-Line Interface" msgstr "" -#: ../../library/tarfile.rst:1210 +#: ../../library/tarfile.rst:1230 msgid "" "The :mod:`tarfile` module provides a simple command-line interface to " "interact with tar archives." msgstr "" -#: ../../library/tarfile.rst:1213 +#: ../../library/tarfile.rst:1233 msgid "" "If you want to create a new tar archive, specify its name after the :option:" "`-c` option and then list the filename(s) that should be included:" msgstr "" -#: ../../library/tarfile.rst:1216 +#: ../../library/tarfile.rst:1236 msgid "$ python -m tarfile -c monty.tar spam.txt eggs.txt" msgstr "$ python -m tarfile -c monty.tar spam.txt eggs.txt" -#: ../../library/tarfile.rst:1220 +#: ../../library/tarfile.rst:1240 msgid "Passing a directory is also acceptable:" msgstr "" -#: ../../library/tarfile.rst:1222 +#: ../../library/tarfile.rst:1242 msgid "$ python -m tarfile -c monty.tar life-of-brian_1979/" msgstr "$ python -m tarfile -c monty.tar life-of-brian_1979/" -#: ../../library/tarfile.rst:1226 +#: ../../library/tarfile.rst:1246 msgid "" "If you want to extract a tar archive into the current directory, use the :" "option:`-e` option:" msgstr "" -#: ../../library/tarfile.rst:1229 +#: ../../library/tarfile.rst:1249 msgid "$ python -m tarfile -e monty.tar" msgstr "$ python -m tarfile -e monty.tar" -#: ../../library/tarfile.rst:1233 +#: ../../library/tarfile.rst:1253 msgid "" "You can also extract a tar archive into a different directory by passing the " "directory's name:" msgstr "" -#: ../../library/tarfile.rst:1236 +#: ../../library/tarfile.rst:1256 msgid "$ python -m tarfile -e monty.tar other-dir/" msgstr "$ python -m tarfile -e monty.tar other-dir/" -#: ../../library/tarfile.rst:1240 +#: ../../library/tarfile.rst:1260 msgid "For a list of the files in a tar archive, use the :option:`-l` option:" msgstr "" -#: ../../library/tarfile.rst:1242 +#: ../../library/tarfile.rst:1262 msgid "$ python -m tarfile -l monty.tar" msgstr "$ python -m tarfile -l monty.tar" -#: ../../library/tarfile.rst:1248 +#: ../../library/tarfile.rst:1268 msgid "Command-line options" msgstr "命令列選項" -#: ../../library/tarfile.rst:1253 +#: ../../library/tarfile.rst:1273 msgid "List files in a tarfile." msgstr "" -#: ../../library/tarfile.rst:1258 +#: ../../library/tarfile.rst:1278 msgid "Create tarfile from source files." msgstr "" -#: ../../library/tarfile.rst:1263 +#: ../../library/tarfile.rst:1283 msgid "" "Extract tarfile into the current directory if *output_dir* is not specified." msgstr "" -#: ../../library/tarfile.rst:1268 +#: ../../library/tarfile.rst:1288 msgid "Test whether the tarfile is valid or not." msgstr "" -#: ../../library/tarfile.rst:1272 +#: ../../library/tarfile.rst:1292 msgid "Verbose output." msgstr "" -#: ../../library/tarfile.rst:1276 +#: ../../library/tarfile.rst:1296 msgid "" "Specifies the *filter* for ``--extract``. See :ref:`tarfile-extraction-" "filter` for details. Only string names are accepted (that is, " "``fully_trusted``, ``tar``, and ``data``)." msgstr "" -#: ../../library/tarfile.rst:1284 +#: ../../library/tarfile.rst:1304 msgid "Examples" msgstr "範例" -#: ../../library/tarfile.rst:1286 +#: ../../library/tarfile.rst:1306 msgid "How to extract an entire tar archive to the current working directory::" msgstr "" -#: ../../library/tarfile.rst:1288 +#: ../../library/tarfile.rst:1308 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar.gz\")\n" @@ -1717,13 +1741,13 @@ msgstr "" "tar.extractall(filter='data')\n" "tar.close()" -#: ../../library/tarfile.rst:1293 +#: ../../library/tarfile.rst:1313 msgid "" "How to extract a subset of a tar archive with :meth:`TarFile.extractall` " "using a generator function instead of a list::" msgstr "" -#: ../../library/tarfile.rst:1296 +#: ../../library/tarfile.rst:1316 msgid "" "import os\n" "import tarfile\n" @@ -1749,11 +1773,11 @@ msgstr "" "tar.extractall(members=py_files(tar))\n" "tar.close()" -#: ../../library/tarfile.rst:1308 +#: ../../library/tarfile.rst:1328 msgid "How to create an uncompressed tar archive from a list of filenames::" msgstr "" -#: ../../library/tarfile.rst:1310 +#: ../../library/tarfile.rst:1330 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar\", \"w\")\n" @@ -1767,11 +1791,11 @@ msgstr "" " tar.add(name)\n" "tar.close()" -#: ../../library/tarfile.rst:1316 +#: ../../library/tarfile.rst:1336 msgid "The same example using the :keyword:`with` statement::" msgstr "" -#: ../../library/tarfile.rst:1318 +#: ../../library/tarfile.rst:1338 msgid "" "import tarfile\n" "with tarfile.open(\"sample.tar\", \"w\") as tar:\n" @@ -1783,13 +1807,13 @@ msgstr "" " for name in [\"foo\", \"bar\", \"quux\"]:\n" " tar.add(name)" -#: ../../library/tarfile.rst:1323 +#: ../../library/tarfile.rst:1343 msgid "" "How to read a gzip compressed tar archive and display some member " "information::" msgstr "" -#: ../../library/tarfile.rst:1325 +#: ../../library/tarfile.rst:1345 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar.gz\", \"r:gz\")\n" @@ -1805,13 +1829,13 @@ msgid "" "tar.close()" msgstr "" -#: ../../library/tarfile.rst:1337 +#: ../../library/tarfile.rst:1357 msgid "" "How to create an archive and reset the user information using the *filter* " "parameter in :meth:`TarFile.add`::" msgstr "" -#: ../../library/tarfile.rst:1340 +#: ../../library/tarfile.rst:1360 msgid "" "import tarfile\n" "def reset(tarinfo):\n" @@ -1831,17 +1855,17 @@ msgstr "" "tar.add(\"foo\", filter=reset)\n" "tar.close()" -#: ../../library/tarfile.rst:1353 +#: ../../library/tarfile.rst:1373 msgid "Supported tar formats" msgstr "" -#: ../../library/tarfile.rst:1355 +#: ../../library/tarfile.rst:1375 msgid "" "There are three tar formats that can be created with the :mod:`tarfile` " "module:" msgstr "" -#: ../../library/tarfile.rst:1357 +#: ../../library/tarfile.rst:1377 msgid "" "The POSIX.1-1988 ustar format (:const:`USTAR_FORMAT`). It supports filenames " "up to a length of at best 256 characters and linknames up to 100 characters. " @@ -1849,7 +1873,7 @@ msgid "" "supported format." msgstr "" -#: ../../library/tarfile.rst:1362 +#: ../../library/tarfile.rst:1382 msgid "" "The GNU tar format (:const:`GNU_FORMAT`). It supports long filenames and " "linknames, files bigger than 8 GiB and sparse files. It is the de facto " @@ -1857,7 +1881,7 @@ msgid "" "extensions for long names, sparse file support is read-only." msgstr "" -#: ../../library/tarfile.rst:1367 +#: ../../library/tarfile.rst:1387 msgid "" "The POSIX.1-2001 pax format (:const:`PAX_FORMAT`). It is the most flexible " "format with virtually no limits. It supports long filenames and linknames, " @@ -1868,7 +1892,7 @@ msgid "" "*ustar* format. It is the current default format for new archives." msgstr "" -#: ../../library/tarfile.rst:1375 +#: ../../library/tarfile.rst:1395 msgid "" "It extends the existing *ustar* format with extra headers for information " "that cannot be stored otherwise. There are two flavours of pax headers: " @@ -1877,13 +1901,13 @@ msgid "" "in a pax header is encoded in *UTF-8* for portability reasons." msgstr "" -#: ../../library/tarfile.rst:1381 +#: ../../library/tarfile.rst:1401 msgid "" "There are some more variants of the tar format which can be read, but not " "created:" msgstr "" -#: ../../library/tarfile.rst:1384 +#: ../../library/tarfile.rst:1404 msgid "" "The ancient V7 format. This is the first tar format from Unix Seventh " "Edition, storing only regular files and directories. Names must not be " @@ -1892,17 +1916,17 @@ msgid "" "ASCII characters." msgstr "" -#: ../../library/tarfile.rst:1389 +#: ../../library/tarfile.rst:1409 msgid "" "The SunOS tar extended format. This format is a variant of the POSIX.1-2001 " "pax format, but is not compatible." msgstr "" -#: ../../library/tarfile.rst:1395 +#: ../../library/tarfile.rst:1415 msgid "Unicode issues" msgstr "" -#: ../../library/tarfile.rst:1397 +#: ../../library/tarfile.rst:1417 msgid "" "The tar format was originally conceived to make backups on tape drives with " "the main focus on preserving file system information. Nowadays tar archives " @@ -1917,13 +1941,13 @@ msgid "" "It stores non-ASCII metadata using the universal character encoding *UTF-8*." msgstr "" -#: ../../library/tarfile.rst:1409 +#: ../../library/tarfile.rst:1429 msgid "" "The details of character conversion in :mod:`tarfile` are controlled by the " "*encoding* and *errors* keyword arguments of the :class:`TarFile` class." msgstr "" -#: ../../library/tarfile.rst:1412 +#: ../../library/tarfile.rst:1432 msgid "" "*encoding* defines the character encoding to use for the metadata in the " "archive. The default value is :func:`sys.getfilesystemencoding` or " @@ -1932,7 +1956,7 @@ msgid "" "not set appropriately, this conversion may fail." msgstr "" -#: ../../library/tarfile.rst:1418 +#: ../../library/tarfile.rst:1438 msgid "" "The *errors* argument defines how characters are treated that cannot be " "converted. Possible values are listed in section :ref:`error-handlers`. The " @@ -1940,7 +1964,7 @@ msgid "" "system calls, see :ref:`os-filenames`." msgstr "" -#: ../../library/tarfile.rst:1423 +#: ../../library/tarfile.rst:1443 msgid "" "For :const:`PAX_FORMAT` archives (the default), *encoding* is generally not " "needed because all the metadata is stored using *UTF-8*. *encoding* is only " diff --git a/library/threading.po b/library/threading.po index 17431fee17..56ffbbf335 100644 --- a/library/threading.po +++ b/library/threading.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-06 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -31,156 +31,236 @@ msgid "" "level :mod:`_thread` module." msgstr "" -#: ../../library/threading.rst:14 -msgid "This module used to be optional, it is now always available." +#: ../../library/threading.rst:194 ../../library/threading.rst:293 +#: ../../library/threading.rst:641 ../../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 "" +"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" +"availability`。" + +#: ../../library/threading.rst:17 +msgid "Introduction" msgstr "" #: ../../library/threading.rst:19 msgid "" +"The :mod:`!threading` module provides a way to run multiple `threads " +"`_ (smaller units of a " +"process) concurrently within a single process. It allows for the creation " +"and management of threads, making it possible to execute tasks in parallel, " +"sharing memory space. Threads are particularly useful when tasks are I/O " +"bound, such as file operations or making network requests, where much of the " +"time is spent waiting for external resources." +msgstr "" + +#: ../../library/threading.rst:27 +msgid "" +"A typical use case for :mod:`!threading` includes managing a pool of worker " +"threads that can process multiple tasks concurrently. Here's a basic " +"example of creating and starting threads using :class:`~threading.Thread`::" +msgstr "" + +#: ../../library/threading.rst:31 +msgid "" +"import threading\n" +"import time\n" +"\n" +"def crawl(link, delay=3):\n" +" print(f\"crawl started for {link}\")\n" +" time.sleep(delay) # Blocking I/O (simulating a network request)\n" +" print(f\"crawl ended for {link}\")\n" +"\n" +"links = [\n" +" \"https://python.org\",\n" +" \"https://docs.python.org\",\n" +" \"https://peps.python.org\",\n" +"]\n" +"\n" +"# Start threads for each link\n" +"threads = []\n" +"for link in links:\n" +" # Using `args` to pass positional arguments and `kwargs` for keyword " +"arguments\n" +" t = threading.Thread(target=crawl, args=(link,), kwargs={\"delay\": 2})\n" +" threads.append(t)\n" +"\n" +"# Start each thread\n" +"for t in threads:\n" +" t.start()\n" +"\n" +"# Wait for all threads to finish\n" +"for t in threads:\n" +" t.join()" +msgstr "" + +#: ../../library/threading.rst:60 +msgid "This module used to be optional, it is now always available." +msgstr "" + +#: ../../library/threading.rst:65 +msgid "" ":class:`concurrent.futures.ThreadPoolExecutor` offers a higher level " "interface to push tasks to a background thread without blocking execution of " "the calling thread, while still being able to retrieve their results when " "needed." msgstr "" -#: ../../library/threading.rst:23 +#: ../../library/threading.rst:69 msgid "" ":mod:`queue` provides a thread-safe interface for exchanging data between " "running threads." msgstr "" -#: ../../library/threading.rst:26 +#: ../../library/threading.rst:72 msgid "" ":mod:`asyncio` offers an alternative approach to achieving task level " "concurrency without requiring the use of multiple operating system threads." msgstr "" -#: ../../library/threading.rst:31 +#: ../../library/threading.rst:77 msgid "" "In the Python 2.x series, this module contained ``camelCase`` names for some " "methods and functions. These are deprecated as of Python 3.10, but they are " "still supported for compatibility with Python 2.5 and lower." msgstr "" -#: ../../library/threading.rst:38 +#: ../../library/threading.rst:84 msgid "" "In CPython, due to the :term:`Global Interpreter Lock `, only one thread can execute Python code at once (even though certain " "performance-oriented libraries might overcome this limitation). If you want " "your application to make better use of the computational resources of multi-" -"core machines, you are advised to use :mod:`multiprocessing` " -"or :class:`concurrent.futures.ProcessPoolExecutor`. However, threading is " -"still an appropriate model if you want to run multiple I/O-bound tasks " -"simultaneously." +"core machines, you are advised to use :mod:`multiprocessing` or :class:" +"`concurrent.futures.ProcessPoolExecutor`. However, threading is still an " +"appropriate model if you want to run multiple I/O-bound tasks simultaneously." msgstr "" -#: ../../library/threading.rst:130 ../../library/threading.rst:229 -#: ../../library/threading.rst:577 ../../includes/wasm-notavail.rst:3 -msgid "Availability" +#: ../../library/threading.rst:95 +msgid "GIL and performance considerations" msgstr "" -#: ../../includes/wasm-notavail.rst:5 +#: ../../library/threading.rst:97 msgid "" -"This module does not work or is not available on WebAssembly. See :ref:`wasm-" -"availability` for more information." +"Unlike the :mod:`multiprocessing` module, which uses separate processes to " +"bypass the :term:`global interpreter lock` (GIL), the threading module " +"operates within a single process, meaning that all threads share the same " +"memory space. However, the GIL limits the performance gains of threading " +"when it comes to CPU-bound tasks, as only one thread can execute Python " +"bytecode at a time. Despite this, threads remain a useful tool for achieving " +"concurrency in many scenarios." +msgstr "" + +#: ../../library/threading.rst:105 +msgid "" +"As of Python 3.13, experimental :term:`free-threaded ` " +"builds can disable the GIL, enabling true parallel execution of threads, but " +"this feature is not available by default (see :pep:`703`)." msgstr "" -"此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" -"availability`。" -#: ../../library/threading.rst:50 +#: ../../library/threading.rst:112 +msgid "Reference" +msgstr "" + +#: ../../library/threading.rst:114 msgid "This module defines the following functions:" msgstr "此模組定義了以下函式:" -#: ../../library/threading.rst:55 +#: ../../library/threading.rst:119 msgid "" "Return the number of :class:`Thread` objects currently alive. The returned " "count is equal to the length of the list returned by :func:`.enumerate`." msgstr "" -#: ../../library/threading.rst:58 +#: ../../library/threading.rst:122 msgid "The function ``activeCount`` is a deprecated alias for this function." msgstr "" -#: ../../library/threading.rst:63 +#: ../../library/threading.rst:127 msgid "" "Return the current :class:`Thread` object, corresponding to the caller's " "thread of control. If the caller's thread of control was not created " -"through the :mod:`threading` module, a dummy thread object with limited " +"through the :mod:`!threading` module, a dummy thread object with limited " "functionality is returned." msgstr "" -#: ../../library/threading.rst:68 +#: ../../library/threading.rst:132 msgid "The function ``currentThread`` is a deprecated alias for this function." msgstr "``currentThread`` 函式是此函式的已棄用別名。" -#: ../../library/threading.rst:73 +#: ../../library/threading.rst:137 msgid "Handle uncaught exception raised by :func:`Thread.run`." msgstr "處理由 :func:`Thread.run` 引發且未被捕捉到的例外。" -#: ../../library/threading.rst:75 +#: ../../library/threading.rst:139 msgid "The *args* argument has the following attributes:" msgstr "*args* 引數有下列屬性:" -#: ../../library/threading.rst:77 +#: ../../library/threading.rst:141 msgid "*exc_type*: Exception type." msgstr "*exc_type*:例外型別。" -#: ../../library/threading.rst:78 +#: ../../library/threading.rst:142 msgid "*exc_value*: Exception value, can be ``None``." msgstr "" -#: ../../library/threading.rst:79 +#: ../../library/threading.rst:143 msgid "*exc_traceback*: Exception traceback, can be ``None``." msgstr "" -#: ../../library/threading.rst:80 +#: ../../library/threading.rst:144 msgid "*thread*: Thread which raised the exception, can be ``None``." msgstr "*thread*:引發例外的執行緒,可以是 ``None``。" -#: ../../library/threading.rst:82 +#: ../../library/threading.rst:146 msgid "" "If *exc_type* is :exc:`SystemExit`, the exception is silently ignored. " "Otherwise, the exception is printed out on :data:`sys.stderr`." msgstr "" -#: ../../library/threading.rst:85 +#: ../../library/threading.rst:149 msgid "" "If this function raises an exception, :func:`sys.excepthook` is called to " "handle it." msgstr "如果這個函式引發例外,則會呼叫 :func:`sys.excepthook` 來處理它。" -#: ../../library/threading.rst:88 +#: ../../library/threading.rst:152 msgid "" ":func:`threading.excepthook` can be overridden to control how uncaught " "exceptions raised by :func:`Thread.run` are handled." msgstr "" -#: ../../library/threading.rst:91 +#: ../../library/threading.rst:155 msgid "" "Storing *exc_value* using a custom hook can create a reference cycle. It " "should be cleared explicitly to break the reference cycle when the exception " "is no longer needed." msgstr "" -#: ../../library/threading.rst:95 +#: ../../library/threading.rst:159 msgid "" "Storing *thread* using a custom hook can resurrect it if it is set to an " "object which is being finalized. Avoid storing *thread* after the custom " "hook completes to avoid resurrecting objects." msgstr "" -#: ../../library/threading.rst:100 +#: ../../library/threading.rst:164 msgid ":func:`sys.excepthook` handles uncaught exceptions." msgstr ":func:`sys.excepthook` 處理未被捕捉到的例外。" -#: ../../library/threading.rst:106 +#: ../../library/threading.rst:170 msgid "" "Holds the original value of :func:`threading.excepthook`. It is saved so " "that the original value can be restored in case they happen to get replaced " "with broken or alternative objects." msgstr "" -#: ../../library/threading.rst:114 +#: ../../library/threading.rst:178 msgid "" "Return the 'thread identifier' of the current thread. This is a nonzero " "integer. Its value has no direct meaning; it is intended as a magic cookie " @@ -189,7 +269,7 @@ msgid "" "created." msgstr "" -#: ../../library/threading.rst:125 +#: ../../library/threading.rst:189 msgid "" "Return the native integral Thread ID of the current thread assigned by the " "kernel. This is a non-negative integer. Its value may be used to uniquely " @@ -197,80 +277,80 @@ msgid "" "after which the value may be recycled by the OS)." msgstr "" -#: ../../library/threading.rst:134 +#: ../../library/threading.rst:198 msgid "Added support for GNU/kFreeBSD." msgstr "新增對 GNU/kFreeBSD 的支援。" -#: ../../library/threading.rst:140 +#: ../../library/threading.rst:204 msgid "" "Return a list of all :class:`Thread` objects currently active. The list " -"includes daemonic threads and dummy thread objects created " -"by :func:`current_thread`. It excludes terminated threads and threads that " -"have not yet been started. However, the main thread is always part of the " -"result, even when terminated." +"includes daemonic threads and dummy thread objects created by :func:" +"`current_thread`. It excludes terminated threads and threads that have not " +"yet been started. However, the main thread is always part of the result, " +"even when terminated." msgstr "" -#: ../../library/threading.rst:149 +#: ../../library/threading.rst:213 msgid "" "Return the main :class:`Thread` object. In normal conditions, the main " "thread is the thread from which the Python interpreter was started." msgstr "" -#: ../../library/threading.rst:160 +#: ../../library/threading.rst:224 msgid "" -"Set a trace function for all threads started from the :mod:`threading` " +"Set a trace function for all threads started from the :mod:`!threading` " "module. The *func* will be passed to :func:`sys.settrace` for each thread, " "before its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:166 +#: ../../library/threading.rst:230 msgid "" -"Set a trace function for all threads started from the :mod:`threading` " +"Set a trace function for all threads started from the :mod:`!threading` " "module and all Python threads that are currently executing." msgstr "" -#: ../../library/threading.rst:169 +#: ../../library/threading.rst:233 msgid "" "The *func* will be passed to :func:`sys.settrace` for each thread, before " "its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:180 +#: ../../library/threading.rst:244 msgid "Get the trace function as set by :func:`settrace`." msgstr "" -#: ../../library/threading.rst:189 +#: ../../library/threading.rst:253 msgid "" -"Set a profile function for all threads started from the :mod:`threading` " +"Set a profile function for all threads started from the :mod:`!threading` " "module. The *func* will be passed to :func:`sys.setprofile` for each " "thread, before its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:195 +#: ../../library/threading.rst:259 msgid "" -"Set a profile function for all threads started from the :mod:`threading` " +"Set a profile function for all threads started from the :mod:`!threading` " "module and all Python threads that are currently executing." msgstr "" -#: ../../library/threading.rst:198 +#: ../../library/threading.rst:262 msgid "" "The *func* will be passed to :func:`sys.setprofile` for each thread, before " "its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:207 +#: ../../library/threading.rst:271 msgid "Get the profiler function as set by :func:`setprofile`." msgstr "" -#: ../../library/threading.rst:214 +#: ../../library/threading.rst:278 msgid "" "Return the thread stack size used when creating new threads. The optional " "*size* argument specifies the stack size to be used for subsequently created " "threads, and must be 0 (use platform or configured default) or a positive " "integer value of at least 32,768 (32 KiB). If *size* is not specified, 0 is " -"used. If changing the thread stack size is unsupported, " -"a :exc:`RuntimeError` is raised. If the specified stack size is invalid, " -"a :exc:`ValueError` is raised and the stack size is unmodified. 32 KiB is " +"used. If changing the thread stack size is unsupported, a :exc:" +"`RuntimeError` is raised. If the specified stack size is invalid, a :exc:" +"`ValueError` is raised and the stack size is unmodified. 32 KiB is " "currently the minimum supported stack size value to guarantee sufficient " "stack space for the interpreter itself. Note that some platforms may have " "particular restrictions on values for the stack size, such as requiring a " @@ -281,29 +361,29 @@ msgid "" "information)." msgstr "" -#: ../../library/threading.rst:231 +#: ../../library/threading.rst:295 msgid "Unix platforms with POSIX threads support." msgstr "" -#: ../../library/threading.rst:234 +#: ../../library/threading.rst:298 msgid "This module also defines the following constant:" msgstr "" -#: ../../library/threading.rst:238 +#: ../../library/threading.rst:302 msgid "" "The maximum value allowed for the *timeout* parameter of blocking functions " "(:meth:`Lock.acquire`, :meth:`RLock.acquire`, :meth:`Condition.wait`, etc.). " -"Specifying a timeout greater than this value will raise " -"an :exc:`OverflowError`." +"Specifying a timeout greater than this value will raise an :exc:" +"`OverflowError`." msgstr "" -#: ../../library/threading.rst:246 +#: ../../library/threading.rst:310 msgid "" "This module defines a number of classes, which are detailed in the sections " "below." msgstr "" -#: ../../library/threading.rst:249 +#: ../../library/threading.rst:313 msgid "" "The design of this module is loosely based on Java's threading model. " "However, where Java makes locks and condition variables basic behavior of " @@ -314,22 +394,22 @@ msgid "" "Thread class, when implemented, are mapped to module-level functions." msgstr "" -#: ../../library/threading.rst:257 +#: ../../library/threading.rst:321 msgid "All of the methods described below are executed atomically." msgstr "" -#: ../../library/threading.rst:261 -msgid "Thread-Local Data" +#: ../../library/threading.rst:325 +msgid "Thread-local data" msgstr "" -#: ../../library/threading.rst:263 +#: ../../library/threading.rst:327 msgid "" "Thread-local data is data whose values are thread specific. If you have data " "that you want to be local to a thread, create a :class:`local` object and " "use its attributes::" msgstr "" -#: ../../library/threading.rst:267 +#: ../../library/threading.rst:331 msgid "" ">>> mydata = local()\n" ">>> mydata.number = 42\n" @@ -341,11 +421,11 @@ msgstr "" ">>> mydata.number\n" "42" -#: ../../library/threading.rst:272 +#: ../../library/threading.rst:336 msgid "You can also access the :class:`local`-object's dictionary::" msgstr "" -#: ../../library/threading.rst:274 +#: ../../library/threading.rst:338 msgid "" ">>> mydata.__dict__\n" "{'number': 42}\n" @@ -361,11 +441,11 @@ msgstr "" ">>> mydata.widgets\n" "[]" -#: ../../library/threading.rst:281 +#: ../../library/threading.rst:345 msgid "If we access the data in a different thread::" msgstr "" -#: ../../library/threading.rst:283 +#: ../../library/threading.rst:347 msgid "" ">>> log = []\n" ">>> def f():\n" @@ -395,13 +475,13 @@ msgstr "" ">>> log\n" "[[], 11]" -#: ../../library/threading.rst:297 +#: ../../library/threading.rst:361 msgid "" "we get different data. Furthermore, changes made in the other thread don't " "affect data seen in this thread::" msgstr "" -#: ../../library/threading.rst:300 +#: ../../library/threading.rst:364 msgid "" ">>> mydata.number\n" "42" @@ -409,22 +489,22 @@ msgstr "" ">>> mydata.number\n" "42" -#: ../../library/threading.rst:303 +#: ../../library/threading.rst:367 msgid "" -"Of course, values you get from a :class:`local` object, including " -"their :attr:`~object.__dict__` attribute, are for whatever thread was " -"current at the time the attribute was read. For that reason, you generally " -"don't want to save these values across threads, as they apply only to the " -"thread they came from." +"Of course, values you get from a :class:`local` object, including their :" +"attr:`~object.__dict__` attribute, are for whatever thread was current at " +"the time the attribute was read. For that reason, you generally don't want " +"to save these values across threads, as they apply only to the thread they " +"came from." msgstr "" -#: ../../library/threading.rst:309 +#: ../../library/threading.rst:373 msgid "" -"You can create custom :class:`local` objects by subclassing " -"the :class:`local` class::" +"You can create custom :class:`local` objects by subclassing the :class:" +"`local` class::" msgstr "" -#: ../../library/threading.rst:312 +#: ../../library/threading.rst:376 msgid "" ">>> class MyLocal(local):\n" "... number = 2\n" @@ -440,7 +520,7 @@ msgstr "" "... def squared(self):\n" "... return self.number ** 2" -#: ../../library/threading.rst:319 +#: ../../library/threading.rst:383 msgid "" "This can be useful to support default values, methods and initialization. " "Note that if you define an :py:meth:`~object.__init__` method, it will be " @@ -448,19 +528,19 @@ msgid "" "This is necessary to initialize each thread's dictionary." msgstr "" -#: ../../library/threading.rst:325 +#: ../../library/threading.rst:389 msgid "Now if we create a :class:`local` object::" msgstr "現在如果我們建立一個 :class:`local` 物件: ::" -#: ../../library/threading.rst:327 +#: ../../library/threading.rst:391 msgid ">>> mydata = MyLocal(color='red')" msgstr ">>> mydata = MyLocal(color='red')" -#: ../../library/threading.rst:329 +#: ../../library/threading.rst:393 msgid "we have a default number::" msgstr "會有一個預設的數字: ::" -#: ../../library/threading.rst:331 +#: ../../library/threading.rst:395 msgid "" ">>> mydata.number\n" "2" @@ -468,11 +548,11 @@ msgstr "" ">>> mydata.number\n" "2" -#: ../../library/threading.rst:334 +#: ../../library/threading.rst:398 msgid "an initial color::" msgstr "和一個初始顏色: ::" -#: ../../library/threading.rst:336 +#: ../../library/threading.rst:400 msgid "" ">>> mydata.color\n" "'red'\n" @@ -482,11 +562,11 @@ msgstr "" "'red'\n" ">>> del mydata.color" -#: ../../library/threading.rst:340 +#: ../../library/threading.rst:404 msgid "And a method that operates on the data::" msgstr "和一個操作資料的方法: ::" -#: ../../library/threading.rst:342 +#: ../../library/threading.rst:406 msgid "" ">>> mydata.squared()\n" "4" @@ -494,11 +574,11 @@ msgstr "" ">>> mydata.squared()\n" "4" -#: ../../library/threading.rst:345 +#: ../../library/threading.rst:409 msgid "As before, we can access the data in a separate thread::" msgstr "" -#: ../../library/threading.rst:347 +#: ../../library/threading.rst:411 msgid "" ">>> log = []\n" ">>> thread = threading.Thread(target=f)\n" @@ -514,11 +594,11 @@ msgstr "" ">>> log\n" "[[('color', 'red')], 11]" -#: ../../library/threading.rst:354 +#: ../../library/threading.rst:418 msgid "without affecting this thread's data::" msgstr "" -#: ../../library/threading.rst:356 +#: ../../library/threading.rst:420 msgid "" ">>> mydata.number\n" "2\n" @@ -534,13 +614,13 @@ msgstr "" "...\n" "AttributeError: 'MyLocal' object has no attribute 'color'" -#: ../../library/threading.rst:363 +#: ../../library/threading.rst:427 msgid "" "Note that subclasses can define :term:`__slots__`, but they are not thread " "local. They are shared across threads::" msgstr "" -#: ../../library/threading.rst:366 +#: ../../library/threading.rst:430 msgid "" ">>> class MyLocal(local):\n" "... __slots__ = 'number'\n" @@ -556,11 +636,11 @@ msgstr "" ">>> mydata.number = 42\n" ">>> mydata.color = 'red'" -#: ../../library/threading.rst:373 +#: ../../library/threading.rst:437 msgid "So, the separate thread::" msgstr "" -#: ../../library/threading.rst:375 +#: ../../library/threading.rst:439 msgid "" ">>> thread = threading.Thread(target=f)\n" ">>> thread.start()\n" @@ -570,11 +650,11 @@ msgstr "" ">>> thread.start()\n" ">>> thread.join()" -#: ../../library/threading.rst:379 +#: ../../library/threading.rst:443 msgid "affects what we see::" msgstr "" -#: ../../library/threading.rst:381 +#: ../../library/threading.rst:445 msgid "" ">>> mydata.number\n" "11" @@ -582,15 +662,15 @@ msgstr "" ">>> mydata.number\n" "11" -#: ../../library/threading.rst:387 +#: ../../library/threading.rst:451 msgid "A class that represents thread-local data." msgstr "" -#: ../../library/threading.rst:393 -msgid "Thread Objects" +#: ../../library/threading.rst:457 +msgid "Thread objects" msgstr "Thread 物件" -#: ../../library/threading.rst:395 +#: ../../library/threading.rst:459 msgid "" "The :class:`Thread` class represents an activity that is run in a separate " "thread of control. There are two ways to specify the activity: by passing a " @@ -600,42 +680,42 @@ msgid "" "``__init__()`` and :meth:`~Thread.run` methods of this class." msgstr "" -#: ../../library/threading.rst:402 +#: ../../library/threading.rst:466 msgid "" "Once a thread object is created, its activity must be started by calling the " "thread's :meth:`~Thread.start` method. This invokes the :meth:`~Thread.run` " "method in a separate thread of control." msgstr "" -#: ../../library/threading.rst:406 +#: ../../library/threading.rst:470 msgid "" "Once the thread's activity is started, the thread is considered 'alive'. It " "stops being alive when its :meth:`~Thread.run` method terminates -- either " -"normally, or by raising an unhandled exception. " -"The :meth:`~Thread.is_alive` method tests whether the thread is alive." +"normally, or by raising an unhandled exception. The :meth:`~Thread." +"is_alive` method tests whether the thread is alive." msgstr "" -#: ../../library/threading.rst:411 +#: ../../library/threading.rst:475 msgid "" "Other threads can call a thread's :meth:`~Thread.join` method. This blocks " "the calling thread until the thread whose :meth:`~Thread.join` method is " "called is terminated." msgstr "" -#: ../../library/threading.rst:415 +#: ../../library/threading.rst:479 msgid "" "A thread has a name. The name can be passed to the constructor, and read or " "changed through the :attr:`~Thread.name` attribute." msgstr "" -#: ../../library/threading.rst:418 +#: ../../library/threading.rst:482 msgid "" -"If the :meth:`~Thread.run` method raises an " -"exception, :func:`threading.excepthook` is called to handle it. By " -"default, :func:`threading.excepthook` ignores silently :exc:`SystemExit`." +"If the :meth:`~Thread.run` method raises an exception, :func:`threading." +"excepthook` is called to handle it. By default, :func:`threading.excepthook` " +"ignores silently :exc:`SystemExit`." msgstr "" -#: ../../library/threading.rst:422 +#: ../../library/threading.rst:486 msgid "" "A thread can be flagged as a \"daemon thread\". The significance of this " "flag is that the entire Python program exits when only daemon threads are " @@ -644,7 +724,7 @@ msgid "" "constructor argument." msgstr "" -#: ../../library/threading.rst:429 +#: ../../library/threading.rst:493 msgid "" "Daemon threads are abruptly stopped at shutdown. Their resources (such as " "open files, database transactions, etc.) may not be released properly. If " @@ -652,13 +732,13 @@ msgid "" "suitable signalling mechanism such as an :class:`Event`." msgstr "" -#: ../../library/threading.rst:434 +#: ../../library/threading.rst:498 msgid "" "There is a \"main thread\" object; this corresponds to the initial thread of " "control in the Python program. It is not a daemon thread." msgstr "" -#: ../../library/threading.rst:437 +#: ../../library/threading.rst:501 msgid "" "There is the possibility that \"dummy thread objects\" are created. These " "are thread objects corresponding to \"alien threads\", which are threads of " @@ -669,25 +749,25 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:448 +#: ../../library/threading.rst:512 msgid "" "This constructor should always be called with keyword arguments. Arguments " "are:" msgstr "" -#: ../../library/threading.rst:451 +#: ../../library/threading.rst:515 msgid "" "*group* should be ``None``; reserved for future extension when a :class:`!" "ThreadGroup` class is implemented." msgstr "" -#: ../../library/threading.rst:454 +#: ../../library/threading.rst:518 msgid "" "*target* is the callable object to be invoked by the :meth:`run` method. " "Defaults to ``None``, meaning nothing is called." msgstr "" -#: ../../library/threading.rst:457 +#: ../../library/threading.rst:521 msgid "" "*name* is the thread name. By default, a unique name is constructed of the " "form \"Thread-*N*\" where *N* is a small decimal number, or \"Thread-*N* " @@ -695,62 +775,62 @@ msgid "" "is specified." msgstr "" -#: ../../library/threading.rst:462 +#: ../../library/threading.rst:526 msgid "" "*args* is a list or tuple of arguments for the target invocation. Defaults " "to ``()``." msgstr "" -#: ../../library/threading.rst:464 +#: ../../library/threading.rst:528 msgid "" "*kwargs* is a dictionary of keyword arguments for the target invocation. " "Defaults to ``{}``." msgstr "" -#: ../../library/threading.rst:467 +#: ../../library/threading.rst:531 msgid "" "If not ``None``, *daemon* explicitly sets whether the thread is daemonic. If " "``None`` (the default), the daemonic property is inherited from the current " "thread." msgstr "" -#: ../../library/threading.rst:471 +#: ../../library/threading.rst:535 msgid "" "If the subclass overrides the constructor, it must make sure to invoke the " "base class constructor (``Thread.__init__()``) before doing anything else to " "the thread." msgstr "" -#: ../../library/threading.rst:475 +#: ../../library/threading.rst:539 msgid "Added the *daemon* parameter." msgstr "新增 *daemon* 參數。" -#: ../../library/threading.rst:478 +#: ../../library/threading.rst:542 msgid "Use the *target* name if *name* argument is omitted." msgstr "" -#: ../../library/threading.rst:483 +#: ../../library/threading.rst:547 msgid "Start the thread's activity." msgstr "" -#: ../../library/threading.rst:485 +#: ../../library/threading.rst:549 msgid "" "It must be called at most once per thread object. It arranges for the " "object's :meth:`~Thread.run` method to be invoked in a separate thread of " "control." msgstr "" -#: ../../library/threading.rst:489 +#: ../../library/threading.rst:553 msgid "" "This method will raise a :exc:`RuntimeError` if called more than once on the " "same thread object." msgstr "" -#: ../../library/threading.rst:494 +#: ../../library/threading.rst:558 msgid "Method representing the thread's activity." msgstr "" -#: ../../library/threading.rst:496 +#: ../../library/threading.rst:560 msgid "" "You may override this method in a subclass. The standard :meth:`run` method " "invokes the callable object passed to the object's constructor as the " @@ -758,17 +838,17 @@ msgid "" "the *args* and *kwargs* arguments, respectively." msgstr "" -#: ../../library/threading.rst:501 +#: ../../library/threading.rst:565 msgid "" -"Using list or tuple as the *args* argument which passed to " -"the :class:`Thread` could achieve the same effect." +"Using list or tuple as the *args* argument which passed to the :class:" +"`Thread` could achieve the same effect." msgstr "" -#: ../../library/threading.rst:504 +#: ../../library/threading.rst:568 msgid "Example::" msgstr "舉例來說: ::" -#: ../../library/threading.rst:506 +#: ../../library/threading.rst:570 msgid "" ">>> from threading import Thread\n" ">>> t = Thread(target=print, args=[1])\n" @@ -786,7 +866,7 @@ msgstr "" ">>> t.run()\n" "1" -#: ../../library/threading.rst:518 +#: ../../library/threading.rst:582 msgid "" "Wait until the thread terminates. This blocks the calling thread until the " "thread whose :meth:`~Thread.join` method is called terminates -- either " @@ -794,27 +874,27 @@ msgid "" "occurs." msgstr "" -#: ../../library/threading.rst:523 +#: ../../library/threading.rst:587 msgid "" "When the *timeout* argument is present and not ``None``, it should be a " "floating-point number specifying a timeout for the operation in seconds (or " "fractions thereof). As :meth:`~Thread.join` always returns ``None``, you " "must call :meth:`~Thread.is_alive` after :meth:`~Thread.join` to decide " -"whether a timeout happened -- if the thread is still alive, " -"the :meth:`~Thread.join` call timed out." +"whether a timeout happened -- if the thread is still alive, the :meth:" +"`~Thread.join` call timed out." msgstr "" -#: ../../library/threading.rst:530 +#: ../../library/threading.rst:594 msgid "" "When the *timeout* argument is not present or ``None``, the operation will " "block until the thread terminates." msgstr "" -#: ../../library/threading.rst:533 +#: ../../library/threading.rst:597 msgid "A thread can be joined many times." msgstr "" -#: ../../library/threading.rst:535 +#: ../../library/threading.rst:599 msgid "" ":meth:`~Thread.join` raises a :exc:`RuntimeError` if an attempt is made to " "join the current thread as that would cause a deadlock. It is also an error " @@ -822,20 +902,20 @@ msgid "" "do so raise the same exception." msgstr "" -#: ../../library/threading.rst:542 +#: ../../library/threading.rst:606 msgid "" "A string used for identification purposes only. It has no semantics. " "Multiple threads may be given the same name. The initial name is set by the " "constructor." msgstr "" -#: ../../library/threading.rst:549 +#: ../../library/threading.rst:613 msgid "" "Deprecated getter/setter API for :attr:`~Thread.name`; use it directly as a " "property instead." msgstr "" -#: ../../library/threading.rst:556 +#: ../../library/threading.rst:620 msgid "" "The 'thread identifier' of this thread or ``None`` if the thread has not " "been started. This is a nonzero integer. See the :func:`get_ident` " @@ -844,7 +924,7 @@ msgid "" "thread has exited." msgstr "" -#: ../../library/threading.rst:564 +#: ../../library/threading.rst:628 msgid "" "The Thread ID (``TID``) of this thread, as assigned by the OS (kernel). This " "is a non-negative integer, or ``None`` if the thread has not been started. " @@ -853,102 +933,102 @@ msgid "" "after which the value may be recycled by the OS)." msgstr "" -#: ../../library/threading.rst:573 +#: ../../library/threading.rst:637 msgid "" "Similar to Process IDs, Thread IDs are only valid (guaranteed unique system-" "wide) from the time the thread is created until the thread has been " "terminated." msgstr "" -#: ../../library/threading.rst:583 +#: ../../library/threading.rst:647 msgid "Return whether the thread is alive." msgstr "" -#: ../../library/threading.rst:585 +#: ../../library/threading.rst:649 msgid "" "This method returns ``True`` just before the :meth:`~Thread.run` method " "starts until just after the :meth:`~Thread.run` method terminates. The " "module function :func:`.enumerate` returns a list of all alive threads." msgstr "" -#: ../../library/threading.rst:591 +#: ../../library/threading.rst:655 msgid "" "A boolean value indicating whether this thread is a daemon thread (``True``) " "or not (``False``). This must be set before :meth:`~Thread.start` is " "called, otherwise :exc:`RuntimeError` is raised. Its initial value is " "inherited from the creating thread; the main thread is not a daemon thread " -"and therefore all threads created in the main thread default " -"to :attr:`~Thread.daemon` = ``False``." +"and therefore all threads created in the main thread default to :attr:" +"`~Thread.daemon` = ``False``." msgstr "" -#: ../../library/threading.rst:598 +#: ../../library/threading.rst:662 msgid "" "The entire Python program exits when no alive non-daemon threads are left." msgstr "" -#: ../../library/threading.rst:603 +#: ../../library/threading.rst:667 msgid "" "Deprecated getter/setter API for :attr:`~Thread.daemon`; use it directly as " "a property instead." msgstr "" -#: ../../library/threading.rst:612 -msgid "Lock Objects" +#: ../../library/threading.rst:676 +msgid "Lock objects" msgstr "Lock 物件" -#: ../../library/threading.rst:614 +#: ../../library/threading.rst:678 msgid "" "A primitive lock is a synchronization primitive that is not owned by a " "particular thread when locked. In Python, it is currently the lowest level " -"synchronization primitive available, implemented directly by " -"the :mod:`_thread` extension module." +"synchronization primitive available, implemented directly by the :mod:" +"`_thread` extension module." msgstr "" "原始鎖 (primitive lock) 是一種同步原語 (synchronization primitive),在鎖定時" -"不屬於特定執行緒。在 Python 中,它是目前可用的最低階同步原語,直接" -"由 :mod:`_thread` 擴充模組實作。" +"不屬於特定執行緒。在 Python 中,它是目前可用的最低階同步原語,直接由 :mod:" +"`_thread` 擴充模組實作。" -#: ../../library/threading.rst:619 +#: ../../library/threading.rst:683 msgid "" "A primitive lock is in one of two states, \"locked\" or \"unlocked\". It is " -"created in the unlocked state. It has two basic " -"methods, :meth:`~Lock.acquire` and :meth:`~Lock.release`. When the state is " -"unlocked, :meth:`~Lock.acquire` changes the state to locked and returns " -"immediately. When the state is locked, :meth:`~Lock.acquire` blocks until a " -"call to :meth:`~Lock.release` in another thread changes it to unlocked, then " -"the :meth:`~Lock.acquire` call resets it to locked and returns. " -"The :meth:`~Lock.release` method should only be called in the locked state; " -"it changes the state to unlocked and returns immediately. If an attempt is " -"made to release an unlocked lock, a :exc:`RuntimeError` will be raised." +"created in the unlocked state. It has two basic methods, :meth:`~Lock." +"acquire` and :meth:`~Lock.release`. When the state is unlocked, :meth:" +"`~Lock.acquire` changes the state to locked and returns immediately. When " +"the state is locked, :meth:`~Lock.acquire` blocks until a call to :meth:" +"`~Lock.release` in another thread changes it to unlocked, then the :meth:" +"`~Lock.acquire` call resets it to locked and returns. The :meth:`~Lock." +"release` method should only be called in the locked state; it changes the " +"state to unlocked and returns immediately. If an attempt is made to release " +"an unlocked lock, a :exc:`RuntimeError` will be raised." msgstr "" "原始鎖會處於兩種狀態之一:「鎖定 (locked)」或「未鎖定 (unclocked)」,建立時會" -"處於未鎖定狀態。它有兩個基本方法 :meth:`~Lock.acquire` " -"和 :meth:`~Lock.release`。當狀態為未鎖定時,:meth:`~Lock.acquire` 會將狀態變" -"更為鎖定並立即回傳。當狀態被鎖定時,:meth:`~Lock.acquire` 會阻塞 (block),直" -"到另一個執行緒中對 :meth:`~Lock.release` 的呼叫將其更改為未鎖定狀態,然" -"後 :meth:`~Lock.acquire` 呼叫會將其重置為鎖定並回傳。:meth:`~Lock.release` 方" -"法只能在鎖定狀態下呼叫;它將狀態更改為未鎖定並立即回傳。如果嘗試釋放未鎖定的" -"鎖,則會引發 :exc:`RuntimeError`。" - -#: ../../library/threading.rst:630 +"處於未鎖定狀態。它有兩個基本方法 :meth:`~Lock.acquire` 和 :meth:`~Lock." +"release`。當狀態為未鎖定時,:meth:`~Lock.acquire` 會將狀態變更為鎖定並立即回" +"傳。當狀態被鎖定時,:meth:`~Lock.acquire` 會阻塞 (block),直到另一個執行緒中" +"對 :meth:`~Lock.release` 的呼叫將其更改為未鎖定狀態,然後 :meth:`~Lock." +"acquire` 呼叫會將其重置為鎖定並回傳。:meth:`~Lock.release` 方法只能在鎖定狀態" +"下呼叫;它將狀態更改為未鎖定並立即回傳。如果嘗試釋放未鎖定的鎖,則會引發 :" +"exc:`RuntimeError`。" + +#: ../../library/threading.rst:694 msgid "Locks also support the :ref:`context management protocol `." msgstr "鎖也支援\\ :ref:`情境管理協定 `。" -#: ../../library/threading.rst:632 +#: ../../library/threading.rst:696 msgid "" "When more than one thread is blocked in :meth:`~Lock.acquire` waiting for " -"the state to turn to unlocked, only one thread proceeds when " -"a :meth:`~Lock.release` call resets the state to unlocked; which one of the " -"waiting threads proceeds is not defined, and may vary across implementations." +"the state to turn to unlocked, only one thread proceeds when a :meth:`~Lock." +"release` call resets the state to unlocked; which one of the waiting threads " +"proceeds is not defined, and may vary across implementations." msgstr "" -"當多個執行緒阻塞在 :meth:`~Lock.acquire` 中等待狀態轉變為未鎖定,此時若呼" -"叫 :meth:`~Lock.release` 將狀態重置為未鎖定,則只會有一個執行緒繼續進行;哪一" -"個等待執行緒會繼續進行是未定義的,並且可能因實作而異。" +"當多個執行緒阻塞在 :meth:`~Lock.acquire` 中等待狀態轉變為未鎖定,此時若呼叫 :" +"meth:`~Lock.release` 將狀態重置為未鎖定,則只會有一個執行緒繼續進行;哪一個等" +"待執行緒會繼續進行是未定義的,並且可能因實作而異。" -#: ../../library/threading.rst:637 +#: ../../library/threading.rst:701 msgid "All methods are executed atomically." msgstr "所有方法均以最小不可分割的操作方式 (atomically) 執行。" -#: ../../library/threading.rst:642 +#: ../../library/threading.rst:706 msgid "" "The class implementing primitive lock objects. Once a thread has acquired a " "lock, subsequent attempts to acquire it block, until it is released; any " @@ -957,7 +1037,7 @@ msgstr "" "實作原始鎖物件的類別。一旦執行緒獲得了鎖,後續再嘗試獲得它就會被阻塞,直到鎖" "被釋放;任何執行緒都可以去釋放它。" -#: ../../library/threading.rst:646 +#: ../../library/threading.rst:710 msgid "" "``Lock`` is now a class. In earlier Pythons, ``Lock`` was a factory function " "which returned an instance of the underlying private lock type." @@ -965,11 +1045,11 @@ msgstr "" "``Lock`` 現在是一個類別。在早期的 Python 中,``Lock`` 是一個會回傳底層私有鎖" "型別實例的工廠函式。" -#: ../../library/threading.rst:654 ../../library/threading.rst:745 +#: ../../library/threading.rst:718 ../../library/threading.rst:809 msgid "Acquire a lock, blocking or non-blocking." msgstr "阻塞或非阻塞地取得鎖。" -#: ../../library/threading.rst:656 +#: ../../library/threading.rst:720 msgid "" "When invoked with the *blocking* argument set to ``True`` (the default), " "block until the lock is unlocked, then set it to locked and return ``True``." @@ -977,7 +1057,7 @@ msgstr "" "當以 *blocking* 引數設為 ``True``\\ (預設值)來叫用,將會阻塞直到鎖被解鎖," "然後將其設為鎖定並回傳 ``True``。" -#: ../../library/threading.rst:659 +#: ../../library/threading.rst:723 msgid "" "When invoked with the *blocking* argument set to ``False``, do not block. If " "a call with *blocking* set to ``True`` would block, return ``False`` " @@ -987,7 +1067,7 @@ msgstr "" "``True`` 的呼叫會阻塞,則立即回傳 ``False``;否則將鎖設為鎖定並回傳 " "``True``。" -#: ../../library/threading.rst:663 +#: ../../library/threading.rst:727 msgid "" "When invoked with the floating-point *timeout* argument set to a positive " "value, block for at most the number of seconds specified by *timeout* and as " @@ -999,7 +1079,7 @@ msgstr "" "塞 *timeout* 指定的秒數。``-1`` 的 *timeout* 引數代表指定為不會停止的等待。" "當 *blocking* 為 ``False`` 時禁止指定 *timeout*。" -#: ../../library/threading.rst:669 +#: ../../library/threading.rst:733 msgid "" "The return value is ``True`` if the lock is acquired successfully, ``False`` " "if not (for example if the *timeout* expired)." @@ -1007,24 +1087,24 @@ msgstr "" "如果成功取得鎖,則回傳值為 ``True``,否則回傳值為 ``False``\\ (例如像是 " "*timeout* 已逾期)。" -#: ../../library/threading.rst:672 ../../library/threading.rst:783 -#: ../../library/threading.rst:1030 +#: ../../library/threading.rst:736 ../../library/threading.rst:847 +#: ../../library/threading.rst:1094 msgid "The *timeout* parameter is new." msgstr "新的 *timeout* 參數。" -#: ../../library/threading.rst:675 +#: ../../library/threading.rst:739 msgid "" "Lock acquisition can now be interrupted by signals on POSIX if the " "underlying threading implementation supports it." msgstr "如果底層執行緒實作支援的話,鎖的取得現在可以被 POSIX 上的訊號中斷。" -#: ../../library/threading.rst:682 +#: ../../library/threading.rst:746 msgid "" "Release a lock. This can be called from any thread, not only the thread " "which has acquired the lock." msgstr "釋放鎖。這可以從任何執行緒呼叫,而不是只有獲得鎖的執行緒。" -#: ../../library/threading.rst:685 +#: ../../library/threading.rst:749 msgid "" "When the lock is locked, reset it to unlocked, and return. If any other " "threads are blocked waiting for the lock to become unlocked, allow exactly " @@ -1033,23 +1113,23 @@ msgstr "" "當鎖被鎖定時,將其重置為未鎖定然後回傳。如果任何其他執行緒在等待鎖被解鎖時被" "阻塞,只允許其中一個執行緒繼續進行。" -#: ../../library/threading.rst:689 +#: ../../library/threading.rst:753 msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised." msgstr "當在未鎖定的鎖上叫用時,會引發 :exc:`RuntimeError`" -#: ../../library/threading.rst:691 ../../library/threading.rst:799 +#: ../../library/threading.rst:755 ../../library/threading.rst:863 msgid "There is no return value." msgstr "沒有回傳值。" -#: ../../library/threading.rst:695 +#: ../../library/threading.rst:759 msgid "Return ``True`` if the lock is acquired." msgstr "如果有取得了鎖,則回傳 ``True``。" -#: ../../library/threading.rst:702 -msgid "RLock Objects" +#: ../../library/threading.rst:766 +msgid "RLock objects" msgstr "RLock 物件" -#: ../../library/threading.rst:704 +#: ../../library/threading.rst:768 msgid "" "A reentrant lock is a synchronization primitive that may be acquired " "multiple times by the same thread. Internally, it uses the concepts of " @@ -1062,26 +1142,26 @@ msgstr "" "「遞迴等級 (recursion level)」的概念。在鎖定狀態下,某個執行緒會擁有鎖;在未" "鎖定狀態下則沒有執行緒擁有它。" -#: ../../library/threading.rst:710 +#: ../../library/threading.rst:774 msgid "" -"Threads call a lock's :meth:`~RLock.acquire` method to lock it, and " -"its :meth:`~Lock.release` method to unlock it." +"Threads call a lock's :meth:`~RLock.acquire` method to lock it, and its :" +"meth:`~Lock.release` method to unlock it." msgstr "" -"執行緒呼叫鎖的 :meth:`~RLock.acquire` 方法來鎖定它,並呼叫它" -"的 :meth:`~Lock.release` 方法來解鎖它。" +"執行緒呼叫鎖的 :meth:`~RLock.acquire` 方法來鎖定它,並呼叫它的 :meth:`~Lock." +"release` 方法來解鎖它。" -#: ../../library/threading.rst:715 +#: ../../library/threading.rst:779 msgid "" "Reentrant locks support the :ref:`context management protocol `, " -"so it is recommended to use :keyword:`with` instead of manually " -"calling :meth:`~RLock.acquire` and :meth:`~RLock.release` to handle " -"acquiring and releasing the lock for a block of code." +"so it is recommended to use :keyword:`with` instead of manually calling :" +"meth:`~RLock.acquire` and :meth:`~RLock.release` to handle acquiring and " +"releasing the lock for a block of code." msgstr "" "可重入鎖支援\\ :ref:`情境管理協定`,因此建議使用 :keyword:`with` " "而不是手動呼叫 :meth:`~RLock.acquire` 和 :meth:`~RLock.release` 來對程式碼區" "塊處理鎖的獲得和釋放。" -#: ../../library/threading.rst:720 +#: ../../library/threading.rst:784 msgid "" "RLock's :meth:`~RLock.acquire`/:meth:`~RLock.release` call pairs may be " "nested, unlike Lock's :meth:`~Lock.acquire`/:meth:`~Lock.release`. Only the " @@ -1094,7 +1174,7 @@ msgstr "" "個 :meth:`~RLock.release`\\ (最外面一對的 :meth:`~Lock.release`)會將鎖重置" "為未鎖定狀態,並允許在 :meth:`~RLock.acquire` 中阻塞的另一個執行緒繼續進行。" -#: ../../library/threading.rst:726 +#: ../../library/threading.rst:790 msgid "" ":meth:`~RLock.acquire`/:meth:`~RLock.release` must be used in pairs: each " "acquire must have a release in the thread that has acquired the lock. " @@ -1105,7 +1185,7 @@ msgstr "" "已獲得鎖的執行緒中有一個釋放。如果鎖釋放的次數不能和取得的次數一樣的話,可能" "會導致死鎖 (deadlock)。" -#: ../../library/threading.rst:733 +#: ../../library/threading.rst:797 msgid "" "This class implements reentrant lock objects. A reentrant lock must be " "released by the thread that acquired it. Once a thread has acquired a " @@ -1116,7 +1196,7 @@ msgstr "" "得了可重入鎖,同一個執行緒可以再次獲得它而不會阻塞;執行緒每次獲得它也都必須" "釋放它一次。" -#: ../../library/threading.rst:738 +#: ../../library/threading.rst:802 msgid "" "Note that ``RLock`` is actually a factory function which returns an instance " "of the most efficient version of the concrete RLock class that is supported " @@ -1125,11 +1205,11 @@ msgstr "" "請注意,``RLock`` 實際上是一個工廠函式,它會回傳平台有支援的特定 RLock 類別的" "最高效率版本的實例。" -#: ../../library/threading.rst:749 +#: ../../library/threading.rst:813 msgid ":ref:`Using RLock as a context manager `" msgstr ":ref:`將 RLock 用作為情境管理器 `" -#: ../../library/threading.rst:750 +#: ../../library/threading.rst:814 msgid "" "Recommended over manual :meth:`!acquire` and :meth:`release` calls whenever " "practical." @@ -1137,16 +1217,16 @@ msgstr "" "若是使用場景合理,和手動呼叫 :meth:`!acquire` 和 :meth:`release` 相比,會是更" "為推薦的使用方式。" -#: ../../library/threading.rst:754 +#: ../../library/threading.rst:818 msgid "" "When invoked with the *blocking* argument set to ``True`` (the default):" msgstr "當以 *blocking* 引數設為 ``True``\\ (預設值)來呼叫:" -#: ../../library/threading.rst:756 ../../library/threading.rst:768 +#: ../../library/threading.rst:820 ../../library/threading.rst:832 msgid "If no thread owns the lock, acquire the lock and return immediately." msgstr "如果沒有執行緒擁有鎖,則獲得鎖並立即回傳。" -#: ../../library/threading.rst:758 +#: ../../library/threading.rst:822 msgid "" "If another thread owns the lock, block until we are able to acquire lock, or " "*timeout*, if set to a positive float value." @@ -1154,32 +1234,32 @@ msgstr "" "如果另一個執行緒擁有鎖,則阻塞直到能夠取得鎖,或者達到 *timeout*\\ (如果設定" "為正浮點值)。" -#: ../../library/threading.rst:761 +#: ../../library/threading.rst:825 msgid "" "If the same thread owns the lock, acquire the lock again, and return " "immediately. This is the difference between :class:`Lock` and :class:`!" "RLock`; :class:`Lock` handles this case the same as the previous, blocking " "until the lock can be acquired." msgstr "" -"如果同一個執行緒擁有鎖,則再次取得鎖,並立即回傳。這就是 :class:`Lock` " -"和 :class:`!RLock` 之間的差別;:class:`Lock` 處理方式與上一種情況相同,會阻塞" -"直到能夠取得鎖。" +"如果同一個執行緒擁有鎖,則再次取得鎖,並立即回傳。這就是 :class:`Lock` 和 :" +"class:`!RLock` 之間的差別;:class:`Lock` 處理方式與上一種情況相同,會阻塞直到" +"能夠取得鎖。" -#: ../../library/threading.rst:766 +#: ../../library/threading.rst:830 msgid "When invoked with the *blocking* argument set to ``False``:" msgstr "當以 *blocking* 引數設為 ``False`` 來呼叫:" -#: ../../library/threading.rst:770 +#: ../../library/threading.rst:834 msgid "If another thread owns the lock, return immediately." msgstr "如果另一個執行緒擁有該鎖,則立即回傳。" -#: ../../library/threading.rst:772 +#: ../../library/threading.rst:836 msgid "" "If the same thread owns the lock, acquire the lock again and return " "immediately." msgstr "如果同一個執行緒擁有鎖,則再次取得鎖並立即回傳。" -#: ../../library/threading.rst:775 +#: ../../library/threading.rst:839 msgid "" "In all cases, if the thread was able to acquire the lock, return ``True``. " "If the thread was unable to acquire the lock (i.e. if not blocking or the " @@ -1188,7 +1268,7 @@ msgstr "" "在所有情況下,如果執行緒能夠取得鎖則回傳 ``True``。如果執行緒無法取得鎖(即沒" "有阻塞或已達超時限制)則回傳 ``False``。" -#: ../../library/threading.rst:779 +#: ../../library/threading.rst:843 msgid "" "If called multiple times, failing to call :meth:`~RLock.release` as many " "times may lead to deadlock. Consider using :class:`!RLock` as a context " @@ -1197,7 +1277,7 @@ msgstr "" "如果多次呼叫,又未能呼叫相同次數的 :meth:`~RLock.release`,則可能會導致死鎖。" "考慮將 :class:`!RLock` 作為情境管理器使用,而不是直接呼叫 acquire/release。" -#: ../../library/threading.rst:789 +#: ../../library/threading.rst:853 msgid "" "Release a lock, decrementing the recursion level. If after the decrement it " "is zero, reset the lock to unlocked (not owned by any thread), and if any " @@ -1209,20 +1289,20 @@ msgstr "" "並且如果任何其他執行緒被阻塞以等待鎖變成未鎖定狀態,則僅允許其中一個執行緒繼" "續進行。如果遞減後遞迴等級仍然非零,則鎖會保持鎖定並由呼叫它的執行緒所擁有。" -#: ../../library/threading.rst:795 +#: ../../library/threading.rst:859 msgid "" -"Only call this method when the calling thread owns the lock. " -"A :exc:`RuntimeError` is raised if this method is called when the lock is " -"not acquired." +"Only call this method when the calling thread owns the lock. A :exc:" +"`RuntimeError` is raised if this method is called when the lock is not " +"acquired." msgstr "" -"僅當呼叫的執行緒擁有鎖時才能呼叫此方法。如果在未取得鎖時呼叫此方法則會引" -"發 :exc:`RuntimeError`。" +"僅當呼叫的執行緒擁有鎖時才能呼叫此方法。如果在未取得鎖時呼叫此方法則會引發 :" +"exc:`RuntimeError`。" -#: ../../library/threading.rst:805 -msgid "Condition Objects" +#: ../../library/threading.rst:869 +msgid "Condition objects" msgstr "" -#: ../../library/threading.rst:807 +#: ../../library/threading.rst:871 msgid "" "A condition variable is always associated with some kind of lock; this can " "be passed in or one will be created by default. Passing one in is useful " @@ -1230,33 +1310,32 @@ msgid "" "of the condition object: you don't have to track it separately." msgstr "" -#: ../../library/threading.rst:812 +#: ../../library/threading.rst:876 msgid "" "A condition variable obeys the :ref:`context management protocol `: using the ``with`` statement acquires the associated lock for the " -"duration of the enclosed block. The :meth:`~Condition.acquire` " -"and :meth:`~Condition.release` methods also call the corresponding methods " -"of the associated lock." +"duration of the enclosed block. The :meth:`~Condition.acquire` and :meth:" +"`~Condition.release` methods also call the corresponding methods of the " +"associated lock." msgstr "" -#: ../../library/threading.rst:818 +#: ../../library/threading.rst:882 msgid "" -"Other methods must be called with the associated lock held. " -"The :meth:`~Condition.wait` method releases the lock, and then blocks until " -"another thread awakens it by calling :meth:`~Condition.notify` " -"or :meth:`~Condition.notify_all`. Once awakened, :meth:`~Condition.wait` re-" -"acquires the lock and returns. It is also possible to specify a timeout." +"Other methods must be called with the associated lock held. The :meth:" +"`~Condition.wait` method releases the lock, and then blocks until another " +"thread awakens it by calling :meth:`~Condition.notify` or :meth:`~Condition." +"notify_all`. Once awakened, :meth:`~Condition.wait` re-acquires the lock " +"and returns. It is also possible to specify a timeout." msgstr "" -#: ../../library/threading.rst:824 +#: ../../library/threading.rst:888 msgid "" "The :meth:`~Condition.notify` method wakes up one of the threads waiting for " -"the condition variable, if any are waiting. " -"The :meth:`~Condition.notify_all` method wakes up all threads waiting for " -"the condition variable." +"the condition variable, if any are waiting. The :meth:`~Condition." +"notify_all` method wakes up all threads waiting for the condition variable." msgstr "" -#: ../../library/threading.rst:828 +#: ../../library/threading.rst:892 msgid "" "Note: the :meth:`~Condition.notify` and :meth:`~Condition.notify_all` " "methods don't release the lock; this means that the thread or threads " @@ -1265,19 +1344,19 @@ msgid "" "or :meth:`~Condition.notify_all` finally relinquishes ownership of the lock." msgstr "" -#: ../../library/threading.rst:834 +#: ../../library/threading.rst:898 msgid "" "The typical programming style using condition variables uses the lock to " "synchronize access to some shared state; threads that are interested in a " "particular change of state call :meth:`~Condition.wait` repeatedly until " -"they see the desired state, while threads that modify the state " -"call :meth:`~Condition.notify` or :meth:`~Condition.notify_all` when they " -"change the state in such a way that it could possibly be a desired state for " -"one of the waiters. For example, the following code is a generic producer-" -"consumer situation with unlimited buffer capacity::" +"they see the desired state, while threads that modify the state call :meth:" +"`~Condition.notify` or :meth:`~Condition.notify_all` when they change the " +"state in such a way that it could possibly be a desired state for one of the " +"waiters. For example, the following code is a generic producer-consumer " +"situation with unlimited buffer capacity::" msgstr "" -#: ../../library/threading.rst:843 +#: ../../library/threading.rst:907 msgid "" "# Consume one item\n" "with cv:\n" @@ -1291,17 +1370,17 @@ msgid "" " cv.notify()" msgstr "" -#: ../../library/threading.rst:854 +#: ../../library/threading.rst:918 msgid "" "The ``while`` loop checking for the application's condition is necessary " "because :meth:`~Condition.wait` can return after an arbitrary long time, and " "the condition which prompted the :meth:`~Condition.notify` call may no " -"longer hold true. This is inherent to multi-threaded programming. " -"The :meth:`~Condition.wait_for` method can be used to automate the condition " +"longer hold true. This is inherent to multi-threaded programming. The :" +"meth:`~Condition.wait_for` method can be used to automate the condition " "checking, and eases the computation of timeouts::" msgstr "" -#: ../../library/threading.rst:861 +#: ../../library/threading.rst:925 msgid "" "# Consume an item\n" "with cv:\n" @@ -1309,54 +1388,54 @@ msgid "" " get_an_available_item()" msgstr "" -#: ../../library/threading.rst:866 +#: ../../library/threading.rst:930 msgid "" -"To choose between :meth:`~Condition.notify` " -"and :meth:`~Condition.notify_all`, consider whether one state change can be " -"interesting for only one or several waiting threads. E.g. in a typical " -"producer-consumer situation, adding one item to the buffer only needs to " -"wake up one consumer thread." +"To choose between :meth:`~Condition.notify` and :meth:`~Condition." +"notify_all`, consider whether one state change can be interesting for only " +"one or several waiting threads. E.g. in a typical producer-consumer " +"situation, adding one item to the buffer only needs to wake up one consumer " +"thread." msgstr "" -#: ../../library/threading.rst:874 +#: ../../library/threading.rst:938 msgid "" "This class implements condition variable objects. A condition variable " "allows one or more threads to wait until they are notified by another thread." msgstr "" -#: ../../library/threading.rst:877 +#: ../../library/threading.rst:941 msgid "" "If the *lock* argument is given and not ``None``, it must be a :class:`Lock` " "or :class:`RLock` object, and it is used as the underlying lock. Otherwise, " "a new :class:`RLock` object is created and used as the underlying lock." msgstr "" -#: ../../library/threading.rst:881 ../../library/threading.rst:1005 -#: ../../library/threading.rst:1051 ../../library/threading.rst:1103 -#: ../../library/threading.rst:1171 +#: ../../library/threading.rst:945 ../../library/threading.rst:1069 +#: ../../library/threading.rst:1115 ../../library/threading.rst:1167 +#: ../../library/threading.rst:1235 msgid "changed from a factory function to a class." msgstr "" -#: ../../library/threading.rst:886 +#: ../../library/threading.rst:950 msgid "" "Acquire the underlying lock. This method calls the corresponding method on " "the underlying lock; the return value is whatever that method returns." msgstr "" -#: ../../library/threading.rst:891 +#: ../../library/threading.rst:955 msgid "" "Release the underlying lock. This method calls the corresponding method on " "the underlying lock; there is no return value." msgstr "" -#: ../../library/threading.rst:896 +#: ../../library/threading.rst:960 msgid "" "Wait until notified or until a timeout occurs. If the calling thread has not " "acquired the lock when this method is called, a :exc:`RuntimeError` is " "raised." msgstr "" -#: ../../library/threading.rst:900 +#: ../../library/threading.rst:964 msgid "" "This method releases the underlying lock, and then blocks until it is " "awakened by a :meth:`notify` or :meth:`notify_all` call for the same " @@ -1364,41 +1443,41 @@ msgid "" "Once awakened or timed out, it re-acquires the lock and returns." msgstr "" -#: ../../library/threading.rst:905 +#: ../../library/threading.rst:969 msgid "" "When the *timeout* argument is present and not ``None``, it should be a " "floating-point number specifying a timeout for the operation in seconds (or " "fractions thereof)." msgstr "" -#: ../../library/threading.rst:909 +#: ../../library/threading.rst:973 msgid "" -"When the underlying lock is an :class:`RLock`, it is not released using " -"its :meth:`release` method, since this may not actually unlock the lock when " -"it was acquired multiple times recursively. Instead, an internal interface " -"of the :class:`RLock` class is used, which really unlocks it even when it " -"has been recursively acquired several times. Another internal interface is " -"then used to restore the recursion level when the lock is reacquired." +"When the underlying lock is an :class:`RLock`, it is not released using its :" +"meth:`release` method, since this may not actually unlock the lock when it " +"was acquired multiple times recursively. Instead, an internal interface of " +"the :class:`RLock` class is used, which really unlocks it even when it has " +"been recursively acquired several times. Another internal interface is then " +"used to restore the recursion level when the lock is reacquired." msgstr "" -#: ../../library/threading.rst:917 +#: ../../library/threading.rst:981 msgid "" "The return value is ``True`` unless a given *timeout* expired, in which case " "it is ``False``." msgstr "" -#: ../../library/threading.rst:920 ../../library/threading.rst:1136 +#: ../../library/threading.rst:984 ../../library/threading.rst:1200 msgid "Previously, the method always returned ``None``." msgstr "" -#: ../../library/threading.rst:925 +#: ../../library/threading.rst:989 msgid "" "Wait until a condition evaluates to true. *predicate* should be a callable " "which result will be interpreted as a boolean value. A *timeout* may be " "provided giving the maximum time to wait." msgstr "" -#: ../../library/threading.rst:929 +#: ../../library/threading.rst:993 msgid "" "This utility method may call :meth:`wait` repeatedly until the predicate is " "satisfied, or until a timeout occurs. The return value is the last return " @@ -1406,13 +1485,13 @@ msgid "" "out." msgstr "" -#: ../../library/threading.rst:934 +#: ../../library/threading.rst:998 msgid "" "Ignoring the timeout feature, calling this method is roughly equivalent to " "writing::" msgstr "" -#: ../../library/threading.rst:937 +#: ../../library/threading.rst:1001 msgid "" "while not predicate():\n" " cv.wait()" @@ -1420,27 +1499,27 @@ msgstr "" "while not predicate():\n" " cv.wait()" -#: ../../library/threading.rst:940 +#: ../../library/threading.rst:1004 msgid "" "Therefore, the same rules apply as with :meth:`wait`: The lock must be held " "when called and is re-acquired on return. The predicate is evaluated with " "the lock held." msgstr "" -#: ../../library/threading.rst:948 +#: ../../library/threading.rst:1012 msgid "" "By default, wake up one thread waiting on this condition, if any. If the " -"calling thread has not acquired the lock when this method is called, " -"a :exc:`RuntimeError` is raised." +"calling thread has not acquired the lock when this method is called, a :exc:" +"`RuntimeError` is raised." msgstr "" -#: ../../library/threading.rst:952 +#: ../../library/threading.rst:1016 msgid "" "This method wakes up at most *n* of the threads waiting for the condition " "variable; it is a no-op if no threads are waiting." msgstr "" -#: ../../library/threading.rst:955 +#: ../../library/threading.rst:1019 msgid "" "The current implementation wakes up exactly *n* threads, if at least *n* " "threads are waiting. However, it's not safe to rely on this behavior. A " @@ -1448,52 +1527,52 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:960 +#: ../../library/threading.rst:1024 msgid "" "Note: an awakened thread does not actually return from its :meth:`wait` call " "until it can reacquire the lock. Since :meth:`notify` does not release the " "lock, its caller should." msgstr "" -#: ../../library/threading.rst:966 +#: ../../library/threading.rst:1030 msgid "" -"Wake up all threads waiting on this condition. This method acts " -"like :meth:`notify`, but wakes up all waiting threads instead of one. If the " -"calling thread has not acquired the lock when this method is called, " -"a :exc:`RuntimeError` is raised." +"Wake up all threads waiting on this condition. This method acts like :meth:" +"`notify`, but wakes up all waiting threads instead of one. If the calling " +"thread has not acquired the lock when this method is called, a :exc:" +"`RuntimeError` is raised." msgstr "" -#: ../../library/threading.rst:971 +#: ../../library/threading.rst:1035 msgid "The method ``notifyAll`` is a deprecated alias for this method." msgstr "" -#: ../../library/threading.rst:977 -msgid "Semaphore Objects" -msgstr "" +#: ../../library/threading.rst:1041 +msgid "Semaphore objects" +msgstr "Semaphore 物件" -#: ../../library/threading.rst:979 +#: ../../library/threading.rst:1043 msgid "" "This is one of the oldest synchronization primitives in the history of " "computer science, invented by the early Dutch computer scientist Edsger W. " -"Dijkstra (he used the names ``P()`` and ``V()`` instead " -"of :meth:`~Semaphore.acquire` and :meth:`~Semaphore.release`)." +"Dijkstra (he used the names ``P()`` and ``V()`` instead of :meth:`~Semaphore." +"acquire` and :meth:`~Semaphore.release`)." msgstr "" -#: ../../library/threading.rst:984 +#: ../../library/threading.rst:1048 msgid "" -"A semaphore manages an internal counter which is decremented by " -"each :meth:`~Semaphore.acquire` call and incremented by " -"each :meth:`~Semaphore.release` call. The counter can never go below zero; " -"when :meth:`~Semaphore.acquire` finds that it is zero, it blocks, waiting " -"until some other thread calls :meth:`~Semaphore.release`." +"A semaphore manages an internal counter which is decremented by each :meth:" +"`~Semaphore.acquire` call and incremented by each :meth:`~Semaphore.release` " +"call. The counter can never go below zero; when :meth:`~Semaphore.acquire` " +"finds that it is zero, it blocks, waiting until some other thread calls :" +"meth:`~Semaphore.release`." msgstr "" -#: ../../library/threading.rst:990 +#: ../../library/threading.rst:1054 msgid "" "Semaphores also support the :ref:`context management protocol `." msgstr "" -#: ../../library/threading.rst:995 +#: ../../library/threading.rst:1059 msgid "" "This class implements semaphore objects. A semaphore manages an atomic " "counter representing the number of :meth:`release` calls minus the number " @@ -1502,75 +1581,75 @@ msgid "" "If not given, *value* defaults to 1." msgstr "" -#: ../../library/threading.rst:1001 +#: ../../library/threading.rst:1065 msgid "" "The optional argument gives the initial *value* for the internal counter; it " "defaults to ``1``. If the *value* given is less than 0, :exc:`ValueError` is " "raised." msgstr "" -#: ../../library/threading.rst:1010 +#: ../../library/threading.rst:1074 msgid "Acquire a semaphore." msgstr "" -#: ../../library/threading.rst:1012 +#: ../../library/threading.rst:1076 msgid "When invoked without arguments:" msgstr "" -#: ../../library/threading.rst:1014 +#: ../../library/threading.rst:1078 msgid "" "If the internal counter is larger than zero on entry, decrement it by one " "and return ``True`` immediately." msgstr "" -#: ../../library/threading.rst:1016 +#: ../../library/threading.rst:1080 msgid "" -"If the internal counter is zero on entry, block until awoken by a call " -"to :meth:`~Semaphore.release`. Once awoken (and the counter is greater than " -"0), decrement the counter by 1 and return ``True``. Exactly one thread will " -"be awoken by each call to :meth:`~Semaphore.release`. The order in which " +"If the internal counter is zero on entry, block until awoken by a call to :" +"meth:`~Semaphore.release`. Once awoken (and the counter is greater than 0), " +"decrement the counter by 1 and return ``True``. Exactly one thread will be " +"awoken by each call to :meth:`~Semaphore.release`. The order in which " "threads are awoken should not be relied on." msgstr "" -#: ../../library/threading.rst:1022 +#: ../../library/threading.rst:1086 msgid "" "When invoked with *blocking* set to ``False``, do not block. If a call " "without an argument would block, return ``False`` immediately; otherwise, do " "the same thing as when called without arguments, and return ``True``." msgstr "" -#: ../../library/threading.rst:1026 +#: ../../library/threading.rst:1090 msgid "" "When invoked with a *timeout* other than ``None``, it will block for at most " "*timeout* seconds. If acquire does not complete successfully in that " "interval, return ``False``. Return ``True`` otherwise." msgstr "" -#: ../../library/threading.rst:1035 +#: ../../library/threading.rst:1099 msgid "" "Release a semaphore, incrementing the internal counter by *n*. When it was " "zero on entry and other threads are waiting for it to become larger than " "zero again, wake up *n* of those threads." msgstr "" -#: ../../library/threading.rst:1039 +#: ../../library/threading.rst:1103 msgid "Added the *n* parameter to release multiple waiting threads at once." msgstr "" -#: ../../library/threading.rst:1045 +#: ../../library/threading.rst:1109 msgid "" "Class implementing bounded semaphore objects. A bounded semaphore checks to " -"make sure its current value doesn't exceed its initial value. If it " -"does, :exc:`ValueError` is raised. In most situations semaphores are used to " -"guard resources with limited capacity. If the semaphore is released too " -"many times it's a sign of a bug. If not given, *value* defaults to 1." +"make sure its current value doesn't exceed its initial value. If it does, :" +"exc:`ValueError` is raised. In most situations semaphores are used to guard " +"resources with limited capacity. If the semaphore is released too many " +"times it's a sign of a bug. If not given, *value* defaults to 1." msgstr "" -#: ../../library/threading.rst:1058 -msgid ":class:`Semaphore` Example" +#: ../../library/threading.rst:1122 +msgid ":class:`Semaphore` example" msgstr ":class:`Semaphore` 範例" -#: ../../library/threading.rst:1060 +#: ../../library/threading.rst:1124 msgid "" "Semaphores are often used to guard resources with limited capacity, for " "example, a database server. In any situation where the size of the resource " @@ -1578,7 +1657,7 @@ msgid "" "threads, your main thread would initialize the semaphore::" msgstr "" -#: ../../library/threading.rst:1065 +#: ../../library/threading.rst:1129 msgid "" "maxconnections = 5\n" "# ...\n" @@ -1588,13 +1667,13 @@ msgstr "" "# ...\n" "pool_sema = BoundedSemaphore(value=maxconnections)" -#: ../../library/threading.rst:1069 +#: ../../library/threading.rst:1133 msgid "" "Once spawned, worker threads call the semaphore's acquire and release " "methods when they need to connect to the server::" msgstr "" -#: ../../library/threading.rst:1072 +#: ../../library/threading.rst:1136 msgid "" "with pool_sema:\n" " conn = connectdb()\n" @@ -1610,62 +1689,61 @@ msgstr "" " finally:\n" " conn.close()" -#: ../../library/threading.rst:1079 +#: ../../library/threading.rst:1143 msgid "" "The use of a bounded semaphore reduces the chance that a programming error " "which causes the semaphore to be released more than it's acquired will go " "undetected." msgstr "" -#: ../../library/threading.rst:1086 -msgid "Event Objects" +#: ../../library/threading.rst:1150 +msgid "Event objects" msgstr "" -#: ../../library/threading.rst:1088 +#: ../../library/threading.rst:1152 msgid "" "This is one of the simplest mechanisms for communication between threads: " "one thread signals an event and other threads wait for it." msgstr "" -#: ../../library/threading.rst:1091 +#: ../../library/threading.rst:1155 msgid "" -"An event object manages an internal flag that can be set to true with " -"the :meth:`~Event.set` method and reset to false with " -"the :meth:`~Event.clear` method. The :meth:`~Event.wait` method blocks " -"until the flag is true." +"An event object manages an internal flag that can be set to true with the :" +"meth:`~Event.set` method and reset to false with the :meth:`~Event.clear` " +"method. The :meth:`~Event.wait` method blocks until the flag is true." msgstr "" -#: ../../library/threading.rst:1098 +#: ../../library/threading.rst:1162 msgid "" "Class implementing event objects. An event manages a flag that can be set " -"to true with the :meth:`~Event.set` method and reset to false with " -"the :meth:`clear` method. The :meth:`wait` method blocks until the flag is " -"true. The flag is initially false." +"to true with the :meth:`~Event.set` method and reset to false with the :meth:" +"`clear` method. The :meth:`wait` method blocks until the flag is true. The " +"flag is initially false." msgstr "" -#: ../../library/threading.rst:1108 +#: ../../library/threading.rst:1172 msgid "Return ``True`` if and only if the internal flag is true." msgstr "" -#: ../../library/threading.rst:1110 +#: ../../library/threading.rst:1174 msgid "The method ``isSet`` is a deprecated alias for this method." msgstr "" -#: ../../library/threading.rst:1114 +#: ../../library/threading.rst:1178 msgid "" "Set the internal flag to true. All threads waiting for it to become true are " "awakened. Threads that call :meth:`wait` once the flag is true will not " "block at all." msgstr "" -#: ../../library/threading.rst:1120 +#: ../../library/threading.rst:1184 msgid "" "Reset the internal flag to false. Subsequently, threads calling :meth:`wait` " "will block until :meth:`.set` is called to set the internal flag to true " "again." msgstr "" -#: ../../library/threading.rst:1126 +#: ../../library/threading.rst:1190 msgid "" "Block as long as the internal flag is false and the timeout, if given, has " "not expired. The return value represents the reason that this blocking " @@ -1674,26 +1752,26 @@ msgid "" "become true within the given wait time." msgstr "" -#: ../../library/threading.rst:1132 +#: ../../library/threading.rst:1196 msgid "" "When the timeout argument is present and not ``None``, it should be a " "floating-point number specifying a timeout for the operation in seconds, or " "fractions thereof." msgstr "" -#: ../../library/threading.rst:1143 -msgid "Timer Objects" -msgstr "" +#: ../../library/threading.rst:1207 +msgid "Timer objects" +msgstr "Timer 物件" -#: ../../library/threading.rst:1145 +#: ../../library/threading.rst:1209 msgid "" "This class represents an action that should be run only after a certain " -"amount of time has passed --- a timer. :class:`Timer` is a subclass " -"of :class:`Thread` and as such also functions as an example of creating " -"custom threads." +"amount of time has passed --- a timer. :class:`Timer` is a subclass of :" +"class:`Thread` and as such also functions as an example of creating custom " +"threads." msgstr "" -#: ../../library/threading.rst:1149 +#: ../../library/threading.rst:1213 msgid "" "Timers are started, as with threads, by calling their :meth:`Timer.start " "` method. The timer can be stopped (before its action has " @@ -1702,11 +1780,11 @@ msgid "" "interval specified by the user." msgstr "" -#: ../../library/threading.rst:1155 +#: ../../library/threading.rst:1219 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/threading.rst:1157 +#: ../../library/threading.rst:1221 msgid "" "def hello():\n" " print(\"hello, world\")\n" @@ -1720,7 +1798,7 @@ msgstr "" "t = Timer(30.0, hello)\n" "t.start() # 30 秒後會印出 \"hello, world\"" -#: ../../library/threading.rst:1166 +#: ../../library/threading.rst:1230 msgid "" "Create a timer that will run *function* with arguments *args* and keyword " "arguments *kwargs*, after *interval* seconds have passed. If *args* is " @@ -1728,17 +1806,17 @@ msgid "" "``None`` (the default) then an empty dict will be used." msgstr "" -#: ../../library/threading.rst:1176 +#: ../../library/threading.rst:1240 msgid "" "Stop the timer, and cancel the execution of the timer's action. This will " "only work if the timer is still in its waiting stage." msgstr "" -#: ../../library/threading.rst:1181 -msgid "Barrier Objects" -msgstr "" +#: ../../library/threading.rst:1245 +msgid "Barrier objects" +msgstr "Barrier 物件" -#: ../../library/threading.rst:1185 +#: ../../library/threading.rst:1249 msgid "" "This class provides a simple synchronization primitive for use by a fixed " "number of threads that need to wait for each other. Each of the threads " @@ -1747,18 +1825,18 @@ msgid "" "calls. At this point, the threads are released simultaneously." msgstr "" -#: ../../library/threading.rst:1191 +#: ../../library/threading.rst:1255 msgid "" "The barrier can be reused any number of times for the same number of threads." msgstr "" -#: ../../library/threading.rst:1193 +#: ../../library/threading.rst:1257 msgid "" "As an example, here is a simple way to synchronize a client and server " "thread::" msgstr "" -#: ../../library/threading.rst:1195 +#: ../../library/threading.rst:1259 msgid "" "b = Barrier(2, timeout=5)\n" "\n" @@ -1790,7 +1868,7 @@ msgstr "" " connection = make_connection()\n" " process_client_connection(connection)" -#: ../../library/threading.rst:1213 +#: ../../library/threading.rst:1277 msgid "" "Create a barrier object for *parties* number of threads. An *action*, when " "provided, is a callable to be called by one of the threads when they are " @@ -1798,7 +1876,7 @@ msgid "" "the :meth:`wait` method." msgstr "" -#: ../../library/threading.rst:1220 +#: ../../library/threading.rst:1284 msgid "" "Pass the barrier. When all the threads party to the barrier have called " "this function, they are all released simultaneously. If a *timeout* is " @@ -1806,14 +1884,14 @@ msgid "" "constructor." msgstr "" -#: ../../library/threading.rst:1225 +#: ../../library/threading.rst:1289 msgid "" "The return value is an integer in the range 0 to *parties* -- 1, different " "for each thread. This can be used to select a thread to do some special " "housekeeping, e.g.::" msgstr "" -#: ../../library/threading.rst:1229 +#: ../../library/threading.rst:1293 msgid "" "i = barrier.wait()\n" "if i == 0:\n" @@ -1825,37 +1903,37 @@ msgstr "" " # 只會有一個執行緒會印出這個\n" " print(\"passed the barrier\")" -#: ../../library/threading.rst:1234 +#: ../../library/threading.rst:1298 msgid "" "If an *action* was provided to the constructor, one of the threads will have " "called it prior to being released. Should this call raise an error, the " "barrier is put into the broken state." msgstr "" -#: ../../library/threading.rst:1238 +#: ../../library/threading.rst:1302 msgid "If the call times out, the barrier is put into the broken state." msgstr "" -#: ../../library/threading.rst:1240 +#: ../../library/threading.rst:1304 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " "is broken or reset while a thread is waiting." msgstr "" -#: ../../library/threading.rst:1245 +#: ../../library/threading.rst:1309 msgid "" "Return the barrier to the default, empty state. Any threads waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" -#: ../../library/threading.rst:1248 +#: ../../library/threading.rst:1312 msgid "" "Note that using this function may require some external synchronization if " "there are other threads whose state is unknown. If a barrier is broken it " "may be better to just leave it and create a new one." msgstr "" -#: ../../library/threading.rst:1254 +#: ../../library/threading.rst:1318 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 " @@ -1863,36 +1941,36 @@ msgid "" "application." msgstr "" -#: ../../library/threading.rst:1259 +#: ../../library/threading.rst:1323 msgid "" "It may be preferable to simply create the barrier with a sensible *timeout* " "value to automatically guard against one of the threads going awry." msgstr "" -#: ../../library/threading.rst:1265 +#: ../../library/threading.rst:1329 msgid "The number of threads required to pass the barrier." msgstr "" -#: ../../library/threading.rst:1269 +#: ../../library/threading.rst:1333 msgid "The number of threads currently waiting in the barrier." msgstr "" -#: ../../library/threading.rst:1273 +#: ../../library/threading.rst:1337 msgid "A boolean that is ``True`` if the barrier is in the broken state." msgstr "" -#: ../../library/threading.rst:1278 +#: ../../library/threading.rst:1342 msgid "" -"This exception, a subclass of :exc:`RuntimeError`, is raised when " -"the :class:`Barrier` object is reset or broken." +"This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:" +"`Barrier` object is reset or broken." msgstr "" -#: ../../library/threading.rst:1285 +#: ../../library/threading.rst:1349 msgid "" "Using locks, conditions, and semaphores in the :keyword:`!with` statement" msgstr "" -#: ../../library/threading.rst:1287 +#: ../../library/threading.rst:1351 msgid "" "All of the objects provided by this module that have ``acquire`` and " "``release`` methods can be used as context managers for a :keyword:`with` " @@ -1901,7 +1979,7 @@ msgid "" "following snippet::" msgstr "" -#: ../../library/threading.rst:1293 +#: ../../library/threading.rst:1357 msgid "" "with some_lock:\n" " # do something..." @@ -1909,11 +1987,11 @@ msgstr "" "with some_lock:\n" " # 做某些事情..." -#: ../../library/threading.rst:1296 +#: ../../library/threading.rst:1360 msgid "is equivalent to::" msgstr "" -#: ../../library/threading.rst:1298 +#: ../../library/threading.rst:1362 msgid "" "some_lock.acquire()\n" "try:\n" @@ -1927,22 +2005,22 @@ msgstr "" "finally:\n" " some_lock.release()" -#: ../../library/threading.rst:1304 +#: ../../library/threading.rst:1368 msgid "" -"Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, :class:`Semaphore`, " -"and :class:`BoundedSemaphore` objects may be used as :keyword:`with` " -"statement context managers." +"Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, :class:" +"`Semaphore`, and :class:`BoundedSemaphore` objects may be used as :keyword:" +"`with` statement context managers." msgstr "" -#: ../../library/threading.rst:158 ../../library/threading.rst:176 +#: ../../library/threading.rst:222 ../../library/threading.rst:240 msgid "trace function" msgstr "" -#: ../../library/threading.rst:176 +#: ../../library/threading.rst:240 msgid "debugger" msgstr "debugger(除錯器)" -#: ../../library/threading.rst:187 ../../library/threading.rst:205 +#: ../../library/threading.rst:251 ../../library/threading.rst:269 msgid "profile function" msgstr "" diff --git a/library/token.po b/library/token.po index 28c57739a7..372ad403c3 100644 --- a/library/token.po +++ b/library/token.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-25 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:13+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -74,7 +74,7 @@ msgstr "" #: ../../library/token.rst:53 msgid "" "Token value that indicates an :ref:`identifier `. Note that " -"keywords are also initially tokenized an ``NAME`` tokens." +"keywords are also initially tokenized as ``NAME`` tokens." msgstr "" #: ../../library/token.rst:58 diff --git a/library/unittest.mock.po b/library/unittest.mock.po index dcdcb78d7a..6fe3d592f0 100644 --- a/library/unittest.mock.po +++ b/library/unittest.mock.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-22 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2024-02-19 21:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -50,15 +50,15 @@ msgstr "" #: ../../library/unittest.mock.rst:26 msgid "" "Additionally, mock provides a :func:`patch` decorator that handles patching " -"module and class level attributes within the scope of a test, along " -"with :const:`sentinel` for creating unique objects. See the `quick guide`_ " -"for some examples of how to use :class:`Mock`, :class:`MagicMock` " -"and :func:`patch`." +"module and class level attributes within the scope of a test, along with :" +"const:`sentinel` for creating unique objects. See the `quick guide`_ for " +"some examples of how to use :class:`Mock`, :class:`MagicMock` and :func:" +"`patch`." msgstr "" "此外,mock 還提供了一個 :func:`patch` 裝飾器,用於 patching 測試範圍內對 " -"module(模組)以及 class(類別)級別的屬性,以及用於建立唯一物件" -"的 :const:`sentinel`。有關如何使用 :class:`Mock`\\、:class:`MagicMock` " -"和 :func:`patch` 的一些範例,請參閱\\ `快速導引 `_。" +"module(模組)以及 class(類別)級別的屬性,以及用於建立唯一物件的 :const:" +"`sentinel`。有關如何使用 :class:`Mock`\\、:class:`MagicMock` 和 :func:" +"`patch` 的一些範例,請參閱\\ `快速導引 `_。" #: ../../library/unittest.mock.rst:32 msgid "" @@ -222,11 +222,11 @@ msgid "" "replacing, and any functions and methods (including constructors) have the " "same call signature as the real object." msgstr "" -"為了確保測試中的 mock 物件與它們要替換的物件具有相同的 api,你可以使用" -"\\ :ref:`自動規格 `。自動規格(auto-speccing)可以通過 patch " -"的 *autospec* 引數或 :func:`create_autospec` 函式來完成。自動規格建立的 mock " -"物件與它們要替換的物件具有相同的屬性和方法,並且任何函式和方法(包括建構函" -"式)都具有與真實物件相同的呼叫簽名(call signature)。" +"為了確保測試中的 mock 物件與它們要替換的物件具有相同的 api,你可以使用\\ :" +"ref:`自動規格 `。自動規格(auto-speccing)可以通過 patch 的 " +"*autospec* 引數或 :func:`create_autospec` 函式來完成。自動規格建立的 mock 物" +"件與它們要替換的物件具有相同的屬性和方法,並且任何函式和方法(包括建構函式)" +"都具有與真實物件相同的呼叫簽名(call signature)。" #: ../../library/unittest.mock.rst:177 msgid "" @@ -264,12 +264,12 @@ msgstr "" msgid "" ":class:`MagicMock` is a subclass of :class:`Mock` with all the magic methods " "pre-created and ready to use. There are also non-callable variants, useful " -"when you are mocking out objects that aren't " -"callable: :class:`NonCallableMock` and :class:`NonCallableMagicMock`" +"when you are mocking out objects that aren't callable: :class:" +"`NonCallableMock` and :class:`NonCallableMagicMock`" msgstr "" ":class:`MagicMock` 是 :class:`Mock` 的子類別,其中所有魔術方法均已預先建立並" -"可供使用。也有不可呼叫的變體,在你 mock 無法呼叫的物件時很有" -"用::class:`NonCallableMock` 和 :class:`NonCallableMagicMock`" +"可供使用。也有不可呼叫的變體,在你 mock 無法呼叫的物件時很有用::class:" +"`NonCallableMock` 和 :class:`NonCallableMagicMock`" #: ../../library/unittest.mock.rst:224 msgid "" @@ -279,8 +279,8 @@ msgid "" "class of :class:`Mock` using the *new_callable* argument to :func:`patch`." msgstr "" ":func:`patch` 裝飾器可以輕鬆地用 :class:`Mock` 物件臨時替換特定模組中的類別。" -"預設情況下,:func:`patch` 會為你建立一個 :class:`MagicMock`。你可以使" -"用 :func:`patch` 的 *new_callable* 引數指定 :class:`Mock` 的替代類別。" +"預設情況下,:func:`patch` 會為你建立一個 :class:`MagicMock`。你可以使用 :" +"func:`patch` 的 *new_callable* 引數指定 :class:`Mock` 的替代類別。" #: ../../library/unittest.mock.rst:232 msgid "" @@ -300,18 +300,18 @@ msgid "" msgstr "" "*spec*:這可以是字串的 list(串列),也可以是充當 mock 物件規格的現有物件(類" "別或實例)。如果傳入一個物件,則通過對該物件呼叫 dir 來形成字串的串列(不包括" -"不支援的魔術屬性和方法)。存取不在此串列中的任何屬性都會引" -"發 :exc:`AttributeError`。" +"不支援的魔術屬性和方法)。存取不在此串列中的任何屬性都會引發 :exc:" +"`AttributeError`。" #: ../../library/unittest.mock.rst:241 msgid "" -"If *spec* is an object (rather than a list of strings) " -"then :attr:`~object.__class__` returns the class of the spec object. This " -"allows mocks to pass :func:`isinstance` tests." +"If *spec* is an object (rather than a list of strings) then :attr:`~object." +"__class__` returns the class of the spec object. This allows mocks to pass :" +"func:`isinstance` tests." msgstr "" -"如果 *spec* 是一個物件(而不是一個字串的串列),那" -"麼 :attr:`~object.__class__` 會回傳 spec 物件的類別。這允許 mocks 通" -"過 :func:`isinstance` 測試。" +"如果 *spec* 是一個物件(而不是一個字串的串列),那麼 :attr:`~object." +"__class__` 會回傳 spec 物件的類別。這允許 mocks 通過 :func:`isinstance` 測" +"試。" #: ../../library/unittest.mock.rst:245 msgid "" @@ -320,13 +320,13 @@ msgid "" "will raise an :exc:`AttributeError`." msgstr "" "*spec_set*:*spec* 的一個更嚴格的變體。如果使用 *spec_set*,在 mock 上嘗試 " -"*set* 或取得不在傳遞給 *spec_set* 的物件上的屬性將會引" -"發 :exc:`AttributeError`。" +"*set* 或取得不在傳遞給 *spec_set* 的物件上的屬性將會引發 :exc:" +"`AttributeError`。" #: ../../library/unittest.mock.rst:249 msgid "" -"*side_effect*: A function to be called whenever the Mock is called. See " -"the :attr:`~Mock.side_effect` attribute. Useful for raising exceptions or " +"*side_effect*: A function to be called whenever the Mock is called. See the :" +"attr:`~Mock.side_effect` attribute. Useful for raising exceptions or " "dynamically changing return values. The function is called with the same " "arguments as the mock, and unless it returns :data:`DEFAULT`, the return " "value of this function is used as the return value." @@ -367,8 +367,8 @@ msgstr "" #: ../../library/unittest.mock.rst:267 msgid "" "*unsafe*: By default, accessing any attribute whose name starts with " -"*assert*, *assret*, *asert*, *aseert* or *assrt* will raise " -"an :exc:`AttributeError`. Passing ``unsafe=True`` will allow access to these " +"*assert*, *assret*, *asert*, *aseert* or *assrt* will raise an :exc:" +"`AttributeError`. Passing ``unsafe=True`` will allow access to these " "attributes." msgstr "" "*unsafe*:預設情況下,存取任何以 *assert*、*assret*、*asert*、*aseert* 或 " @@ -381,13 +381,13 @@ msgid "" "calling the Mock will pass the call through to the wrapped object (returning " "the real result). Attribute access on the mock will return a Mock object " "that wraps the corresponding attribute of the wrapped object (so attempting " -"to access an attribute that doesn't exist will raise " -"an :exc:`AttributeError`)." +"to access an attribute that doesn't exist will raise an :exc:" +"`AttributeError`)." msgstr "" "*wraps*:被 mock 物件包裝的項目。如果 *wraps* 不是 ``None``,那麼呼叫 Mock 將" "通過被包裝的物件(回傳真實結果)。存取 mock 的屬性將會回傳一個 Mock 物件,該" -"物件包裝了被包裝物件的對應屬性(因此嘗試存取不存在的屬性將引" -"發 :exc:`AttributeError`\\ )。" +"物件包裝了被包裝物件的對應屬性(因此嘗試存取不存在的屬性將引發 :exc:" +"`AttributeError`\\ )。" #: ../../library/unittest.mock.rst:281 msgid "" @@ -408,8 +408,8 @@ msgstr "" #: ../../library/unittest.mock.rst:288 msgid "" "Mocks can also be called with arbitrary keyword arguments. These will be " -"used to set attributes on the mock after it is created. See " -"the :meth:`configure_mock` method for details." +"used to set attributes on the mock after it is created. See the :meth:" +"`configure_mock` method for details." msgstr "" "Mocks 還可以使用任意的關鍵字引數進行呼叫。這些關鍵字引數將在建立 mock 之後用" "於設定 mock 的屬性。欲知更多,請參見 :meth:`configure_mock` 方法。" @@ -440,19 +440,19 @@ msgstr "斷言 mock 已經被使用指定的引數呼叫。" #: ../../library/unittest.mock.rst:351 msgid "" -"The assert passes if the mock has *ever* been called, " -"unlike :meth:`assert_called_with` and :meth:`assert_called_once_with` that " -"only pass if the call is the most recent one, and in the case " -"of :meth:`assert_called_once_with` it must also be the only call." +"The assert passes if the mock has *ever* been called, unlike :meth:" +"`assert_called_with` and :meth:`assert_called_once_with` that only pass if " +"the call is the most recent one, and in the case of :meth:" +"`assert_called_once_with` it must also be the only call." msgstr "" -"這個斷言在 mock 曾經被呼叫過時通過,不同於 :meth:`assert_called_with` " -"和 :meth:`assert_called_once_with`,他們針對的是最近的一次的呼叫,而且對" -"於 :meth:`assert_called_once_with`,最近一次的呼叫還必須也是唯一一次的呼叫。" +"這個斷言在 mock 曾經被呼叫過時通過,不同於 :meth:`assert_called_with` 和 :" +"meth:`assert_called_once_with`,他們針對的是最近的一次的呼叫,而且對於 :meth:" +"`assert_called_once_with`,最近一次的呼叫還必須也是唯一一次的呼叫。" #: ../../library/unittest.mock.rst:364 msgid "" -"assert the mock has been called with the specified calls. " -"The :attr:`mock_calls` list is checked for the calls." +"assert the mock has been called with the specified calls. The :attr:" +"`mock_calls` list is checked for the calls." msgstr "" "斷言 mock 已經使用指定的呼叫方式來呼叫。此斷言會檢查 :attr:`mock_calls` 串列" "中的呼叫。" @@ -553,9 +553,9 @@ msgstr "" #: ../../library/unittest.mock.rst:441 msgid "" -"Note that :meth:`reset_mock` *doesn't* clear " -"the :attr:`return_value`, :attr:`side_effect` or any child attributes you " -"have set using normal assignment by default." +"Note that :meth:`reset_mock` *doesn't* clear the :attr:`return_value`, :attr:" +"`side_effect` or any child attributes you have set using normal assignment " +"by default." msgstr "" #: ../../library/unittest.mock.rst:445 @@ -581,8 +581,8 @@ msgstr "如果 *spec_set* 為 true,那麼只能設定在規格中的屬性。" #: ../../library/unittest.mock.rst:461 msgid "" "Attach a mock as an attribute of this one, replacing its name and parent. " -"Calls to the attached mock will be recorded in the :attr:`method_calls` " -"and :attr:`mock_calls` attributes of this one." +"Calls to the attached mock will be recorded in the :attr:`method_calls` and :" +"attr:`mock_calls` attributes of this one." msgstr "" "將一個 mock 作為這個 Mock 的屬性附加,取代它的名稱和上代 (parent)。對附加的 " "mock 的呼叫將被記錄在這個 Mock 的 :attr:`method_calls` 和 :attr:`mock_calls` " @@ -679,17 +679,17 @@ msgid "" "returns :data:`DEFAULT` then the mock will return its normal value (from " "the :attr:`return_value`)." msgstr "" -"如果你傳遞一個函式,它將被呼叫,其引數與 mock 相同,且除非該函式回" -"傳 :data:`DEFAULT` 單例 (singleton),否則對 mock 的呼叫將回傳函式回傳的任何" -"值。如果函式回傳 :data:`DEFAULT`,那麼 mock 將回傳其正常的回傳值" -"(從 :attr:`return_value` 得到)。" +"如果你傳遞一個函式,它將被呼叫,其引數與 mock 相同,且除非該函式回傳 :data:" +"`DEFAULT` 單例 (singleton),否則對 mock 的呼叫將回傳函式回傳的任何值。如果函" +"式回傳 :data:`DEFAULT`,那麼 mock 將回傳其正常的回傳值(從 :attr:" +"`return_value` 得到)。" #: ../../library/unittest.mock.rst:583 msgid "" "If you pass in an iterable, it is used to retrieve an iterator which must " "yield a value on every call. This value can either be an exception instance " -"to be raised, or a value to be returned from the call to the mock " -"(:data:`DEFAULT` handling is identical to the function case)." +"to be raised, or a value to be returned from the call to the mock (:data:" +"`DEFAULT` handling is identical to the function case)." msgstr "" "如果你傳遞一個可疊代物件,它將被用於檢索一個疊代器,該疊代器必須在每次呼叫時" "產出 (yield) 一個值。這個值可以是要引發的例外實例,或者是對 mock 呼叫時要回傳" @@ -737,15 +737,14 @@ msgstr "" #: ../../library/unittest.mock.rst:672 msgid "" -":attr:`call_args`, along with members of the " -"lists :attr:`call_args_list`, :attr:`method_calls` and :attr:`mock_calls` " -"are :data:`call` objects. These are tuples, so they can be unpacked to get " -"at the individual arguments and make more complex assertions. " -"See :ref:`calls as tuples `." +":attr:`call_args`, along with members of the lists :attr:`call_args_list`, :" +"attr:`method_calls` and :attr:`mock_calls` are :data:`call` objects. These " +"are tuples, so they can be unpacked to get at the individual arguments and " +"make more complex assertions. See :ref:`calls as tuples `." msgstr "" -":attr:`call_args`,以及串列 :attr:`call_args_list`、:attr:`method_calls` " -"和 :attr:`mock_calls` 的成員都是 :data:`call` 物件。這些都是元組,因此可以解" -"包以取得各個引數並進行更複雜的斷言。參見 :ref:`calls as tuples `。" #: ../../library/unittest.mock.rst:678 @@ -757,8 +756,8 @@ msgid "" "This is a list of all the calls made to the mock object in sequence (so the " "length of the list is the number of times it has been called). Before any " "calls have been made it is an empty list. The :data:`call` object can be " -"used for conveniently constructing lists of calls to compare " -"with :attr:`call_args_list`." +"used for conveniently constructing lists of calls to compare with :attr:" +"`call_args_list`." msgstr "" "這是按順序列出所有呼叫 mock 物件的串列(因此串列的長度表示它被呼叫的次數)。" "在任何呼叫發生之前,它會是一個空的串列。 :data:`call` 物件可用於方便地建構呼" @@ -829,8 +828,8 @@ msgstr "" #: ../../library/unittest.mock.rst:772 msgid "" -":attr:`!__class__` is assignable to, this allows a mock to pass " -"an :func:`isinstance` check without forcing you to use a spec:" +":attr:`!__class__` is assignable to, this allows a mock to pass an :func:" +"`isinstance` check without forcing you to use a spec:" msgstr "" ":attr:`!__class__` 可以被指定,這允許 mock 通過 :func:`isinstance` 檢查,而不" "需要強制使用 spec:" @@ -849,13 +848,13 @@ msgid "" "Mock objects that use a class or an instance as a :attr:`!spec` or :attr:`!" "spec_set` are able to pass :func:`isinstance` tests:" msgstr "" -"使用類別或實例作為 :attr:`!spec` 或 :attr:`!spec_set` 的 mock 物件能夠通" -"過 :func:`isinstance` 測試:" +"使用類別或實例作為 :attr:`!spec` 或 :attr:`!spec_set` 的 mock 物件能夠通過 :" +"func:`isinstance` 測試:" #: ../../library/unittest.mock.rst:796 msgid "" -"The :class:`Mock` classes have support for mocking magic methods. " -"See :ref:`magic methods ` for the full details." +"The :class:`Mock` classes have support for mocking magic methods. See :ref:" +"`magic methods ` for the full details." msgstr "" ":class:`Mock` 類別支援 mock 魔術方法。細節請參考\\ :ref:`魔術方法 `。" @@ -867,9 +866,9 @@ msgid "" "are passed to the constructor of the mock being created. The keyword " "arguments are for configuring attributes of the mock:" msgstr "" -"Mock類別和 :func:`patch` 裝飾器於組態時接受任意的關鍵字引數。對" -"於 :func:`patch` 裝飾器,這些關鍵字會傳遞給正在建立 mock 的建構函式。這些關鍵" -"字引數用於配置 mock 的屬性:" +"Mock類別和 :func:`patch` 裝飾器於組態時接受任意的關鍵字引數。對於 :func:" +"`patch` 裝飾器,這些關鍵字會傳遞給正在建立 mock 的建構函式。這些關鍵字引數用" +"於配置 mock 的屬性:" #: ../../library/unittest.mock.rst:810 msgid "" @@ -911,15 +910,15 @@ msgstr "" #: ../../library/unittest.mock.rst:838 msgid "" -"This applies " -"to :meth:`~Mock.assert_called_with`, :meth:`~Mock.assert_called_once_with`, :meth:`~Mock.assert_has_calls` " -"and :meth:`~Mock.assert_any_call`. When :ref:`auto-speccing`, it will also " -"apply to method calls on the mock object." +"This applies to :meth:`~Mock.assert_called_with`, :meth:`~Mock." +"assert_called_once_with`, :meth:`~Mock.assert_has_calls` and :meth:`~Mock." +"assert_any_call`. When :ref:`auto-speccing`, it will also apply to method " +"calls on the mock object." msgstr "" -"這適用" -"於 :meth:`~Mock.assert_called_with`、:meth:`~Mock.assert_called_once_with`、:meth:`~Mock.assert_has_calls` " -"和 :meth:`~Mock.assert_any_call`。在使用 :ref:`auto-speccing` 時,它還適用於 " -"mock 物件的方法呼叫。" +"這適用於 :meth:`~Mock.assert_called_with`、:meth:`~Mock." +"assert_called_once_with`、:meth:`~Mock.assert_has_calls` 和 :meth:`~Mock." +"assert_any_call`。在使用 :ref:`auto-speccing` 時,它還適用於 mock 物件的方法" +"呼叫。" #: ../../library/unittest.mock.rst:843 msgid "Added signature introspection on specced and autospecced mock objects." @@ -929,14 +928,14 @@ msgstr "" #: ../../library/unittest.mock.rst:849 msgid "" -"A mock intended to be used as a :class:`property`, or " -"other :term:`descriptor`, on a class. :class:`PropertyMock` " -"provides :meth:`~object.__get__` and :meth:`~object.__set__` methods so you " -"can specify a return value when it is fetched." +"A mock intended to be used as a :class:`property`, or other :term:" +"`descriptor`, on a class. :class:`PropertyMock` provides :meth:`~object." +"__get__` and :meth:`~object.__set__` methods so you can specify a return " +"value when it is fetched." msgstr "" -"一個理應在類別上當成 :class:`property` 或其他 :term:`descriptor` 的 " -"mock。:class:`PropertyMock` 提供了 :meth:`~object.__get__` " -"和 :meth:`~object.__set__` 方法,因此你可以在它被提取時指定回傳值。" +"一個理應在類別上當成 :class:`property` 或其他 :term:`descriptor` 的 mock。:" +"class:`PropertyMock` 提供了 :meth:`~object.__get__` 和 :meth:`~object." +"__set__` 方法,因此你可以在它被提取時指定回傳值。" #: ../../library/unittest.mock.rst:854 msgid "" @@ -986,9 +985,9 @@ msgstr "" #: ../../library/unittest.mock.rst:875 msgid "" -"Because of the way mock attributes are stored you can't directly attach " -"a :class:`PropertyMock` to a mock object. Instead you can attach it to the " -"mock type object::" +"Because of the way mock attributes are stored you can't directly attach a :" +"class:`PropertyMock` to a mock object. Instead you can attach it to the mock " +"type object::" msgstr "" "由於 mock 屬性的儲存方式,你無法直接將 :class:`PropertyMock` 附加到 mock 物" "件。但是你可以將其附加到 mock 型別的物件: ::" @@ -1091,18 +1090,18 @@ msgstr "" #: ../../library/unittest.mock.rst:940 msgid "" -"Setting the *spec* of a :class:`Mock`, :class:`MagicMock`, " -"or :class:`AsyncMock` to a class with asynchronous and synchronous functions " -"will automatically detect the synchronous functions and set them " -"as :class:`MagicMock` (if the parent mock is :class:`AsyncMock` " -"or :class:`MagicMock`) or :class:`Mock` (if the parent mock " -"is :class:`Mock`). All asynchronous functions will be :class:`AsyncMock`." +"Setting the *spec* of a :class:`Mock`, :class:`MagicMock`, or :class:" +"`AsyncMock` to a class with asynchronous and synchronous functions will " +"automatically detect the synchronous functions and set them as :class:" +"`MagicMock` (if the parent mock is :class:`AsyncMock` or :class:`MagicMock`) " +"or :class:`Mock` (if the parent mock is :class:`Mock`). All asynchronous " +"functions will be :class:`AsyncMock`." msgstr "" "將 :class:`Mock`、:class:`MagicMock` 或 :class:`AsyncMock` 的 *spec* 設定為具" -"有同步和非同步函式的類別,會自動檢測同步函式並將其設定" -"為 :class:`MagicMock`\\ (如果上代 mock 為 :class:`AsyncMock` " -"或 :class:`MagicMock`\\ )或 :class:`Mock`\\ (如果上代 mock " -"為 :class:`Mock`\\ )。所有非同步函式將被設定為 :class:`AsyncMock`。" +"有同步和非同步函式的類別,會自動檢測同步函式並將其設定為 :class:" +"`MagicMock`\\ (如果上代 mock 為 :class:`AsyncMock` 或 :class:" +"`MagicMock`\\ )或 :class:`Mock`\\ (如果上代 mock 為 :class:`Mock`\\ )。所" +"有非同步函式將被設定為 :class:`AsyncMock`。" #: ../../library/unittest.mock.rst:968 msgid "" @@ -1132,8 +1131,8 @@ msgstr "斷言 mock 曾經被使用指定的引數等待過。" #: ../../library/unittest.mock.rst:1053 msgid "" -"Assert the mock has been awaited with the specified calls. " -"The :attr:`await_args_list` list is checked for the awaits." +"Assert the mock has been awaited with the specified calls. The :attr:" +"`await_args_list` list is checked for the awaits." msgstr "" "斷言 mock 已被使用指定的呼叫進行等待。:attr:`await_args_list` 串列將被檢查以" "確認等待的內容。" @@ -1151,8 +1150,8 @@ msgid "" "If *any_order* is true then the awaits can be in any order, but they must " "all appear in :attr:`await_args_list`." msgstr "" -"如果 *any_order* 為 true,則等待可以以任何順序出現,但它們必須全部出現" -"在 :attr:`await_args_list` 中。" +"如果 *any_order* 為 true,則等待可以以任何順序出現,但它們必須全部出現在 :" +"attr:`await_args_list` 中。" #: ../../library/unittest.mock.rst:1080 msgid "Assert that the mock was never awaited." @@ -1160,11 +1159,11 @@ msgstr "斷言 mock 從未被等待。" #: ../../library/unittest.mock.rst:1087 msgid "" -"See :func:`Mock.reset_mock`. Also sets :attr:`await_count` to " -"0, :attr:`await_args` to None, and clears the :attr:`await_args_list`." +"See :func:`Mock.reset_mock`. Also sets :attr:`await_count` to 0, :attr:" +"`await_args` to None, and clears the :attr:`await_args_list`." msgstr "" -"參見 :func:`Mock.reset_mock`。同時將 :attr:`await_count` 設定為 " -"0,:attr:`await_args` 設定為 None,並清除 :attr:`await_args_list`。" +"參見 :func:`Mock.reset_mock`。同時將 :attr:`await_count` 設定為 0,:attr:" +"`await_args` 設定為 None,並清除 :attr:`await_args_list`。" #: ../../library/unittest.mock.rst:1092 msgid "" @@ -1174,8 +1173,8 @@ msgstr "一個整數,用來記錄 mock 物件已被等待的次數。" #: ../../library/unittest.mock.rst:1107 msgid "" "This is either ``None`` (if the mock hasn’t been awaited), or the arguments " -"that the mock was last awaited with. Functions the same " -"as :attr:`Mock.call_args`." +"that the mock was last awaited with. Functions the same as :attr:`Mock." +"call_args`." msgstr "" "這可能是 ``None``\\ (如果 mock 尚未被等待),或者是上次等待 mock 時使用的引" "數。與 :attr:`Mock.call_args` 的功能相同。" @@ -1191,9 +1190,9 @@ msgstr "" #: ../../library/unittest.mock.rst:1145 msgid "" -"A version of :class:`MagicMock` for multithreading tests. " -"The :class:`ThreadingMock` object provides extra methods to wait for a call " -"to be invoked, rather than assert on it immediately." +"A version of :class:`MagicMock` for multithreading tests. The :class:" +"`ThreadingMock` object provides extra methods to wait for a call to be " +"invoked, rather than assert on it immediately." msgstr "" #: ../../library/unittest.mock.rst:1149 @@ -1205,8 +1204,8 @@ msgstr "" #: ../../library/unittest.mock.rst:1152 msgid "" -"You can configure the global default timeout by " -"setting :attr:`ThreadingMock.DEFAULT_TIMEOUT`." +"You can configure the global default timeout by setting :attr:`ThreadingMock." +"DEFAULT_TIMEOUT`." msgstr "" #: ../../library/unittest.mock.rst:1156 @@ -1226,14 +1225,14 @@ msgstr "等到直到 mock 被以特定引數呼叫。" #: ../../library/unittest.mock.rst:1172 msgid "" -"If a timeout was passed at the creation of the mock the function raises " -"an :exc:`AssertionError` if the call is not performed in time." +"If a timeout was passed at the creation of the mock the function raises an :" +"exc:`AssertionError` if the call is not performed in time." msgstr "" #: ../../library/unittest.mock.rst:1183 msgid "" -"Global default timeout in seconds to create instances " -"of :class:`ThreadingMock`." +"Global default timeout in seconds to create instances of :class:" +"`ThreadingMock`." msgstr "" #: ../../library/unittest.mock.rst:1189 @@ -1242,11 +1241,11 @@ msgstr "呼叫" #: ../../library/unittest.mock.rst:1191 msgid "" -"Mock objects are callable. The call will return the value set as " -"the :attr:`~Mock.return_value` attribute. The default return value is a new " -"Mock object; it is created the first time the return value is accessed " -"(either explicitly or by calling the Mock) - but it is stored and the same " -"one returned each time." +"Mock objects are callable. The call will return the value set as the :attr:" +"`~Mock.return_value` attribute. The default return value is a new Mock " +"object; it is created the first time the return value is accessed (either " +"explicitly or by calling the Mock) - but it is stored and the same one " +"returned each time." msgstr "" "Mock 物件可被呼叫。呼叫將回傳設定為 :attr:`~Mock.return_value` 屬性的值。預設" "的回傳值是一個新的 Mock 物件;它會在第一次存取回傳值時(無論是顯式存取還是透" @@ -1254,11 +1253,11 @@ msgstr "" #: ../../library/unittest.mock.rst:1197 msgid "" -"Calls made to the object will be recorded in the attributes " -"like :attr:`~Mock.call_args` and :attr:`~Mock.call_args_list`." +"Calls made to the object will be recorded in the attributes like :attr:" +"`~Mock.call_args` and :attr:`~Mock.call_args_list`." msgstr "" -"對物件的呼叫會被記錄在如 :attr:`~Mock.call_args` " -"和 :attr:`~Mock.call_args_list` 等屬性中。" +"對物件的呼叫會被記錄在如 :attr:`~Mock.call_args` 和 :attr:`~Mock." +"call_args_list` 等屬性中。" #: ../../library/unittest.mock.rst:1200 msgid "" @@ -1271,8 +1270,8 @@ msgstr "" #: ../../library/unittest.mock.rst:1204 msgid "" -"The simplest way to make a mock raise an exception when called is to " -"make :attr:`~Mock.side_effect` an exception class or instance:" +"The simplest way to make a mock raise an exception when called is to make :" +"attr:`~Mock.side_effect` an exception class or instance:" msgstr "" "呼叫 mock 時引發例外的最簡單方式是將 :attr:`~Mock.side_effect` 設定為例外類別" "或實例:" @@ -1296,8 +1295,8 @@ msgid "" "return :data:`DEFAULT`:" msgstr "" "如果你希望 mock 仍然回傳預設的回傳值(一個新的 mock),或者是任何已設定的回傳" -"值,有兩種方法可以實現。從 :attr:`~Mock.side_effect` 內部回" -"傳 :attr:`~Mock.return_value`,或回傳 :data:`DEFAULT`:" +"值,有兩種方法可以實現。從 :attr:`~Mock.side_effect` 內部回傳 :attr:`~Mock." +"return_value`,或回傳 :data:`DEFAULT`:" #: ../../library/unittest.mock.rst:1257 msgid "" @@ -1372,8 +1371,8 @@ msgid "" "You \"block\" attributes by deleting them. Once deleted, accessing an " "attribute will raise an :exc:`AttributeError`." msgstr "" -"你可以通過刪除屬性來「阻擋」它們。一旦刪除,再次存取該屬性將會引" -"發 :exc:`AttributeError`。" +"你可以通過刪除屬性來「阻擋」它們。一旦刪除,再次存取該屬性將會引發 :exc:" +"`AttributeError`。" #: ../../library/unittest.mock.rst:1331 msgid "Mock names and the name attribute" @@ -1383,8 +1382,8 @@ msgstr "Mock 名稱與名稱屬性" msgid "" "Since \"name\" is an argument to the :class:`Mock` constructor, if you want " "your mock object to have a \"name\" attribute you can't just pass it in at " -"creation time. There are two alternatives. One option is to " -"use :meth:`~Mock.configure_mock`::" +"creation time. There are two alternatives. One option is to use :meth:`~Mock." +"configure_mock`::" msgstr "" "由於 \"name\" 是傳遞給 :class:`Mock` 建構函式的引數,如果你想讓你的 mock 物件" "擁有 \"name\" 屬性,你不能在建立時直接傳遞它。有兩種替代方法。其中一個選擇是" @@ -1447,8 +1446,8 @@ msgstr "" #: ../../library/unittest.mock.rst:1381 msgid "" "Mocks created for you by :func:`patch` are automatically given names. To " -"attach mocks that have names to a parent you use " -"the :meth:`~Mock.attach_mock` method::" +"attach mocks that have names to a parent you use the :meth:`~Mock." +"attach_mock` method::" msgstr "" "由 :func:`patch` 為你建立的 mock 會自動被賦予名稱。若要將具有名稱的 mock 附加" "到上代,你可以使用 :meth:`~Mock.attach_mock` 方法: ::" @@ -1490,10 +1489,10 @@ msgid "" "a new Mock object when it expects a magic method. If you need magic method " "support see :ref:`magic methods `." msgstr "" -"唯一的例外是魔術方法和屬性(具有前後雙底線)。Mock 不會建立這些,而是會引" -"發 :exc:`AttributeError`。這是因為直譯器通常會隱式地要求這些方法,在期望得到" -"一個魔術方法卻獲得一個新的 Mock 物件時,會讓直譯器\\ *非常*\\ 困惑。如果你需" -"要魔術方法的支援,請參閱\\ :ref:`魔術方法 `。" +"唯一的例外是魔術方法和屬性(具有前後雙底線)。Mock 不會建立這些,而是會引發 :" +"exc:`AttributeError`。這是因為直譯器通常會隱式地要求這些方法,在期望得到一個" +"魔術方法卻獲得一個新的 Mock 物件時,會讓直譯器\\ *非常*\\ 困惑。如果你需要魔" +"術方法的支援,請參閱\\ :ref:`魔術方法 `。" #: ../../library/unittest.mock.rst:1408 msgid "The patchers" @@ -1540,11 +1539,10 @@ msgid "" "If :func:`patch` is used as a context manager the created mock is returned " "by the context manager." msgstr "" -"如果 *new* 被省略,則如果被 patch 的物件是非同步函式,目標會被替換" -"為 :class:`AsyncMock`,反之則替換為 :class:`MagicMock`。如果 :func:`patch` 做" -"為裝飾器使用且省略了 *new*,則所建立的 mock 會作為額外的引數傳遞給被裝飾的函" -"式。如果 :func:`patch` 作為情境管理器使用,則所建立的 mock 將由情境管理器回" -"傳。" +"如果 *new* 被省略,則如果被 patch 的物件是非同步函式,目標會被替換為 :class:" +"`AsyncMock`,反之則替換為 :class:`MagicMock`。如果 :func:`patch` 做為裝飾器使" +"用且省略了 *new*,則所建立的 mock 會作為額外的引數傳遞給被裝飾的函式。如果 :" +"func:`patch` 作為情境管理器使用,則所建立的 mock 將由情境管理器回傳。" #: ../../library/unittest.mock.rst:1438 msgid "" @@ -1555,14 +1553,14 @@ msgid "" "function is executed, not at decoration time." msgstr "" "*target* 應該是以 ``'package.module.ClassName'`` 形式出現的字串。*target* 會" -"被引入並用 *new* 物件替換指定的物件,因此 *target* 必須可從你呼" -"叫 :func:`patch` 的環境中引入。target 在執行被裝飾的函式時被引入,而不是在裝" -"飾器作用時 (decoration time)。" +"被引入並用 *new* 物件替換指定的物件,因此 *target* 必須可從你呼叫 :func:" +"`patch` 的環境中引入。target 在執行被裝飾的函式時被引入,而不是在裝飾器作用" +"時 (decoration time)。" #: ../../library/unittest.mock.rst:1444 msgid "" -"The *spec* and *spec_set* keyword arguments are passed to " -"the :class:`MagicMock` if patch is creating one for you." +"The *spec* and *spec_set* keyword arguments are passed to the :class:" +"`MagicMock` if patch is creating one for you." msgstr "" "*spec* 和 *spec_set* 關鍵字引數會傳遞給 :class:`MagicMock`,如果 patch 正在為" "你建立一個。" @@ -1578,9 +1576,8 @@ msgstr "" #: ../../library/unittest.mock.rst:1450 msgid "" "*new_callable* allows you to specify a different class, or callable object, " -"that will be called to create the *new* object. By " -"default :class:`AsyncMock` is used for async functions " -"and :class:`MagicMock` for the rest." +"that will be called to create the *new* object. By default :class:" +"`AsyncMock` is used for async functions and :class:`MagicMock` for the rest." msgstr "" "*new_callable* 允許你指定一個不同的類別或可呼叫的物件,用於被呼叫並建立 " "*new* 物件。預設情況下,對於非同步函式使用 :class:`AsyncMock`,而對於其他情況" @@ -1594,15 +1591,15 @@ msgid "" "attribute of the object being replaced. Methods and functions being mocked " "will have their arguments checked and will raise a :exc:`TypeError` if they " "are called with the wrong signature. For mocks replacing a class, their " -"return value (the 'instance') will have the same spec as the class. See " -"the :func:`create_autospec` function and :ref:`auto-speccing`." +"return value (the 'instance') will have the same spec as the class. See the :" +"func:`create_autospec` function and :ref:`auto-speccing`." msgstr "" "*spec* 的一種更強大的形式是 *autospec*。如果你設定 ``autospec=True``,則該 " "mock 將使用被替換物件的規格來建立。該 mock 的所有屬性也將具有被替換物件的對應" "屬性的規格。被 mock 的方法和函式將檢查其引數,如果呼叫時引數與規格不符(被使" "用錯誤的簽名 (signature) 呼叫),將引發 :exc:`TypeError`。對於替換類別的 " -"mock,它們的回傳值(即 'instance')將具有與類別相同的規格。請參" -"閱 :func:`create_autospec` 函式和 :ref:`auto-speccing`。" +"mock,它們的回傳值(即 'instance')將具有與類別相同的規格。請參閱 :func:" +"`create_autospec` 函式和 :ref:`auto-speccing`。" #: ../../library/unittest.mock.rst:1464 msgid "" @@ -1641,10 +1638,10 @@ msgid "" "Patch can be used as a :class:`~unittest.TestCase` class decorator. It works " "by decorating each test method in the class. This reduces the boilerplate " "code when your test methods share a common patchings set. :func:`patch` " -"finds tests by looking for method names that start with " -"``patch.TEST_PREFIX``. By default this is ``'test'``, which matches the " -"way :mod:`unittest` finds tests. You can specify an alternative prefix by " -"setting ``patch.TEST_PREFIX``." +"finds tests by looking for method names that start with ``patch." +"TEST_PREFIX``. By default this is ``'test'``, which matches the way :mod:" +"`unittest` finds tests. You can specify an alternative prefix by setting " +"``patch.TEST_PREFIX``." msgstr "" "patch 可以做為 :class:`~unittest.TestCase` 類別的裝飾器使用。它透過裝飾類別中" "的每個測試方法來運作。當你的測試方法共享一組常見的 patch 時,這會減少繁冗的代" @@ -1665,9 +1662,9 @@ msgstr "" #: ../../library/unittest.mock.rst:1493 msgid "" -":func:`patch` takes arbitrary keyword arguments. These will be passed " -"to :class:`AsyncMock` if the patched object is asynchronous, " -"to :class:`MagicMock` otherwise or to *new_callable* if specified." +":func:`patch` takes arbitrary keyword arguments. These will be passed to :" +"class:`AsyncMock` if the patched object is asynchronous, to :class:" +"`MagicMock` otherwise or to *new_callable* if specified." msgstr "" ":func:`patch` 接受任意的關鍵字引數。如果被 patch 的物件是非同步的,這些將會被" "傳遞給 :class:`AsyncMock`,如果是同步的則會傳遞給 :class:`MagicMock`,或如果" @@ -1707,18 +1704,18 @@ msgstr "" #: ../../library/unittest.mock.rst:1510 msgid "" "Patching a class replaces the class with a :class:`MagicMock` *instance*. If " -"the class is instantiated in the code under test then it will be " -"the :attr:`~Mock.return_value` of the mock that will be used." +"the class is instantiated in the code under test then it will be the :attr:" +"`~Mock.return_value` of the mock that will be used." msgstr "" "Patch 一個類別會以 :class:`MagicMock`\\ *實例*\\ 取代該類別。如果該類別在被" -"測試的程式碼中實例化,那麼它將是會被使用的 mock " -"的 :attr:`~Mock.return_value`。" +"測試的程式碼中實例化,那麼它將是會被使用的 mock 的 :attr:`~Mock." +"return_value`。" #: ../../library/unittest.mock.rst:1514 msgid "" -"If the class is instantiated multiple times you could " -"use :attr:`~Mock.side_effect` to return a new mock each time. Alternatively " -"you can set the *return_value* to be anything you want." +"If the class is instantiated multiple times you could use :attr:`~Mock." +"side_effect` to return a new mock each time. Alternatively you can set the " +"*return_value* to be anything you want." msgstr "" "如果該類別被實例化多次,你可以使用 :attr:`~Mock.side_effect` 來每次回傳一個新" "的 mock。 或者你可以將 *return_value* 設定成你想要的任何值。" @@ -1728,8 +1725,8 @@ msgid "" "To configure return values on methods of *instances* on the patched class " "you must do this on the :attr:`~Mock.return_value`. For example::" msgstr "" -"若要配置被 patch 的類別的\\ *實例*\\ 方法的回傳值,你必須" -"在 :attr:`~Mock.return_value` 上進行配置。例如: ::" +"若要配置被 patch 的類別的\\ *實例*\\ 方法的回傳值,你必須在 :attr:`~Mock." +"return_value` 上進行配置。例如: ::" #: ../../library/unittest.mock.rst:1521 msgid "" @@ -1870,16 +1867,16 @@ msgstr "" #: ../../library/unittest.mock.rst:1580 msgid "" -"As well as attributes on the created mock attributes, like " -"the :attr:`~Mock.return_value` and :attr:`~Mock.side_effect`, of child mocks " -"can also be configured. These aren't syntactically valid to pass in directly " -"as keyword arguments, but a dictionary with these as keys can still be " -"expanded into a :func:`patch` call using ``**``::" +"As well as attributes on the created mock attributes, like the :attr:`~Mock." +"return_value` and :attr:`~Mock.side_effect`, of child mocks can also be " +"configured. These aren't syntactically valid to pass in directly as keyword " +"arguments, but a dictionary with these as keys can still be expanded into a :" +"func:`patch` call using ``**``::" msgstr "" -"除了被建立的 mock 上的屬性外,還可以配置 child mock " -"的 :attr:`~Mock.return_value` 和 :attr:`~Mock.side_effect`。它們在語法上不能" -"直接作為關鍵字引數傳入,但是以它們作為鍵的字典仍然可以使用 ``**`` 擴充為一" -"個 :func:`patch` 呼叫: ::" +"除了被建立的 mock 上的屬性外,還可以配置 child mock 的 :attr:`~Mock." +"return_value` 和 :attr:`~Mock.side_effect`。它們在語法上不能直接作為關鍵字引" +"數傳入,但是以它們作為鍵的字典仍然可以使用 ``**`` 擴充為一個 :func:`patch` 呼" +"叫: ::" #: ../../library/unittest.mock.rst:1586 msgid "" @@ -1906,8 +1903,8 @@ msgstr "" #: ../../library/unittest.mock.rst:1596 msgid "" "By default, attempting to patch a function in a module (or a method or an " -"attribute in a class) that does not exist will fail " -"with :exc:`AttributeError`::" +"attribute in a class) that does not exist will fail with :exc:" +"`AttributeError`::" msgstr "" "預設情況下,嘗試 patch 模組中不存在的函式(或類別中的方法或屬性)將會失敗,並" "引發 :exc:`AttributeError`: ::" @@ -1979,19 +1976,19 @@ msgstr "" msgid "" ":func:`patch.object` can be used as a decorator, class decorator or a " "context manager. Arguments *new*, *spec*, *create*, *spec_set*, *autospec* " -"and *new_callable* have the same meaning as for :func:`patch`. " -"Like :func:`patch`, :func:`patch.object` takes arbitrary keyword arguments " -"for configuring the mock object it creates." +"and *new_callable* have the same meaning as for :func:`patch`. Like :func:" +"`patch`, :func:`patch.object` takes arbitrary keyword arguments for " +"configuring the mock object it creates." msgstr "" ":func:`patch.object` 可以做為裝飾器、類別裝飾器或情境管理器使用。引數 *new*、" -"*spec*、*create*、*spec_set*、*autospec* 和 *new_callable* 與" -"在 :func:`patch` 中的引數具有相同的意義。與 :func:`patch` 一" -"樣,:func:`patch.object` 接受任意關鍵字引數來配置它所建立的 mock 物件。" +"*spec*、*create*、*spec_set*、*autospec* 和 *new_callable* 與在 :func:" +"`patch` 中的引數具有相同的意義。與 :func:`patch` 一樣,:func:`patch.object` " +"接受任意關鍵字引數來配置它所建立的 mock 物件。" #: ../../library/unittest.mock.rst:1636 msgid "" -"When used as a class decorator :func:`patch.object` honours " -"``patch.TEST_PREFIX`` for choosing which methods to wrap." +"When used as a class decorator :func:`patch.object` honours ``patch." +"TEST_PREFIX`` for choosing which methods to wrap." msgstr "" "當作為類別裝飾器使用時,:func:`patch.object` 會遵循 ``patch.TEST_PREFIX`` 來" "選擇要包裝的方法。" @@ -2081,9 +2078,8 @@ msgstr ":func:`patch.dict` 可以做為情境管理器、裝飾器或類別裝 #: ../../library/unittest.mock.rst:1698 msgid "" -"When used as a class decorator :func:`patch.dict` honours " -"``patch.TEST_PREFIX`` (default to ``'test'``) for choosing which methods to " -"wrap:" +"When used as a class decorator :func:`patch.dict` honours ``patch." +"TEST_PREFIX`` (default to ``'test'``) for choosing which methods to wrap:" msgstr "" "當作為類別裝飾器使用時,:func:`patch.dict` 會遵循 ``patch.TEST_PREFIX``\\ " "(預設為 ``'test'``\\ )來選擇要包裝的方法:" @@ -2118,14 +2114,15 @@ msgid "" ":func:`patch.dict` can be used with dictionary like objects that aren't " "actually dictionaries. At the very minimum they must support item getting, " "setting, deleting and either iteration or membership test. This corresponds " -"to the magic " -"methods :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, :meth:`~object.__delitem__` " -"and either :meth:`~container.__iter__` or :meth:`~object.__contains__`." +"to the magic methods :meth:`~object.__getitem__`, :meth:`~object." +"__setitem__`, :meth:`~object.__delitem__` and either :meth:`~container." +"__iter__` or :meth:`~object.__contains__`." msgstr "" ":func:`patch.dict` 可以與實際上不是字典的類字典物件一起使用。最低限度它們必須" -"支援項目的取得、設定、刪除以及疊代或隸屬資格檢測。這對應到魔術方法中" -"的 :meth:`~object.__getitem__`、:meth:`~object.__setitem__`、:meth:`~object.__delitem__` " -"以及 :meth:`~container.__iter__` 或 :meth:`~object.__contains__`。" +"支援項目的取得、設定、刪除以及疊代或隸屬資格檢測。這對應到魔術方法中的 :meth:" +"`~object.__getitem__`、:meth:`~object.__setitem__`、:meth:`~object." +"__delitem__` 以及 :meth:`~container.__iter__` 或 :meth:`~object." +"__contains__`。" #: ../../library/unittest.mock.rst:1774 msgid "patch.multiple" @@ -2152,12 +2149,12 @@ msgstr "" msgid "" "Use :data:`DEFAULT` as the value if you want :func:`patch.multiple` to " "create mocks for you. In this case the created mocks are passed into a " -"decorated function by keyword, and a dictionary is returned " -"when :func:`patch.multiple` is used as a context manager." +"decorated function by keyword, and a dictionary is returned when :func:" +"`patch.multiple` is used as a context manager." msgstr "" "如果你想要 :func:`patch.multiple` 為你建立 mock,請使用 :data:`DEFAULT` 作為" -"值。在這種情況下,被建立的 mock 會透過關鍵字傳遞到被裝飾的函式中,並且" -"當 :func:`patch.multiple` 作為情境管理器時會回傳字典。" +"值。在這種情況下,被建立的 mock 會透過關鍵字傳遞到被裝飾的函式中,並且當 :" +"func:`patch.multiple` 作為情境管理器時會回傳字典。" #: ../../library/unittest.mock.rst:1790 msgid "" @@ -2167,14 +2164,14 @@ msgid "" "will be applied to *all* patches done by :func:`patch.multiple`." msgstr "" ":func:`patch.multiple` 可以做為裝飾器、類別裝飾器或情境管理器使用。引數 " -"*spec*、*spec_set*、*create*、*autospec* 和 *new_callable* 與" -"在 :func:`patch` 中的引數具有相同的意義。這些引數將應用於" -"由 :func:`patch.multiple` 完成的\\ *所有* patch。" +"*spec*、*spec_set*、*create*、*autospec* 和 *new_callable* 與在 :func:" +"`patch` 中的引數具有相同的意義。這些引數將應用於由 :func:`patch.multiple` 完" +"成的\\ *所有* patch。" #: ../../library/unittest.mock.rst:1795 msgid "" -"When used as a class decorator :func:`patch.multiple` honours " -"``patch.TEST_PREFIX`` for choosing which methods to wrap." +"When used as a class decorator :func:`patch.multiple` honours ``patch." +"TEST_PREFIX`` for choosing which methods to wrap." msgstr "" "當作為類別裝飾器使用時,:func:`patch.multiple` 遵循 ``patch.TEST_PREFIX`` 來" "選擇要包裝的方法。" @@ -2186,9 +2183,9 @@ msgid "" "decorator then the created mocks are passed into the decorated function by " "keyword. ::" msgstr "" -"如果你想要 :func:`patch.multiple` 為你建立 mock,那麼你可以使" -"用 :data:`DEFAULT` 作為值。如果你使用 :func:`patch.multiple` 作為裝飾器,那麼" -"被建立的 mock 將透過關鍵字傳遞到被裝飾的函式中。: ::" +"如果你想要 :func:`patch.multiple` 為你建立 mock,那麼你可以使用 :data:" +"`DEFAULT` 作為值。如果你使用 :func:`patch.multiple` 作為裝飾器,那麼被建立的 " +"mock 將透過關鍵字傳遞到被裝飾的函式中。: ::" #: ../../library/unittest.mock.rst:1802 msgid "" @@ -2289,9 +2286,9 @@ msgid "" "then call :meth:`!start` to put the patch in place and :meth:`!stop` to undo " "it." msgstr "" -"要使用它們,請像平常一樣呼叫 :func:`patch`、:func:`patch.object` " -"或 :func:`patch.dict` ,並保留對回傳的 ``patcher`` 物件的參照。之後你就可以呼" -"叫 :meth:`!start` 將 patch 準備就緒,並呼叫 :meth:`!stop` 來取消 patch。" +"要使用它們,請像平常一樣呼叫 :func:`patch`、:func:`patch.object` 或 :func:" +"`patch.dict` ,並保留對回傳的 ``patcher`` 物件的參照。之後你就可以呼叫 :meth:" +"`!start` 將 patch 準備就緒,並呼叫 :meth:`!stop` 來取消 patch。" #: ../../library/unittest.mock.rst:1848 msgid "" @@ -2371,8 +2368,8 @@ msgstr "" msgid "" "If you use this technique you must ensure that the patching is \"undone\" by " "calling ``stop``. This can be fiddlier than you might think, because if an " -"exception is raised in the ``setUp`` then ``tearDown`` is not " -"called. :meth:`unittest.TestCase.addCleanup` makes this easier::" +"exception is raised in the ``setUp`` then ``tearDown`` is not called. :meth:" +"`unittest.TestCase.addCleanup` makes this easier::" msgstr "" "如果你使用這個技巧,你必須確保透過呼叫 ``stop`` 來 \"取消\" patch。這可能會比" "你想像的還要複雜一點,因為如果有例外在 ``setUp`` 中被引發,則 ``tearDown`` 就" @@ -2408,8 +2405,8 @@ msgstr "作為額外的好處,你不再需要保留對 ``patcher`` 物件的 #: ../../library/unittest.mock.rst:1902 msgid "" -"It is also possible to stop all patches which have been started by " -"using :func:`patch.stopall`." +"It is also possible to stop all patches which have been started by using :" +"func:`patch.stopall`." msgstr "也可以使用 :func:`patch.stopall` 來停止所有已啟動的 patch。" #: ../../library/unittest.mock.rst:1907 @@ -2457,14 +2454,14 @@ msgid "" "the :class:`unittest.TestLoader` finds test methods by default." msgstr "" "所有 patcher 都可以作為類別裝飾器使用。以這種方式使用時,它們包裝了類別上的每" -"個測試方法。Patcher 將 ``'test'`` 開頭的方法認定為測試方法。這" -"與 :class:`unittest.TestLoader` 預設尋找測試方法的方式相同。" +"個測試方法。Patcher 將 ``'test'`` 開頭的方法認定為測試方法。這與 :class:" +"`unittest.TestLoader` 預設尋找測試方法的方式相同。" #: ../../library/unittest.mock.rst:1936 msgid "" "It is possible that you want to use a different prefix for your tests. You " -"can inform the patchers of the different prefix by setting " -"``patch.TEST_PREFIX``::" +"can inform the patchers of the different prefix by setting ``patch." +"TEST_PREFIX``::" msgstr "" "你可能會想為你的測試使用不同的前綴。你可以透過設定 ``patch.TEST_PREFIX`` 來告" "知 patcher 使用不同的前綴: ::" @@ -2579,10 +2576,10 @@ msgstr "" msgid "" "Now we want to test ``some_function`` but we want to mock out ``SomeClass`` " "using :func:`patch`. The problem is that when we import module b, which we " -"will have to do when it imports ``SomeClass`` from module a. If we " -"use :func:`patch` to mock out ``a.SomeClass`` then it will have no effect on " -"our test; module b already has a reference to the *real* ``SomeClass`` and " -"it looks like our patching had no effect." +"will have to do when it imports ``SomeClass`` from module a. If we use :func:" +"`patch` to mock out ``a.SomeClass`` then it will have no effect on our test; " +"module b already has a reference to the *real* ``SomeClass`` and it looks " +"like our patching had no effect." msgstr "" "現在我們想要測試 ``some_function``,但我們想使用 :func:`patch` mock " "``SomeClass``。問題是,當我們 import 模組 b 時(我們必須這樣做),它會從模組 " @@ -2608,10 +2605,10 @@ msgstr "@patch('b.SomeClass')" #: ../../library/unittest.mock.rst:2021 msgid "" "However, consider the alternative scenario where instead of ``from a import " -"SomeClass`` module b does ``import a`` and ``some_function`` uses " -"``a.SomeClass``. Both of these import forms are common. In this case the " -"class we want to patch is being looked up in the module and so we have to " -"patch ``a.SomeClass`` instead::" +"SomeClass`` module b does ``import a`` and ``some_function`` uses ``a." +"SomeClass``. Both of these import forms are common. In this case the class " +"we want to patch is being looked up in the module and so we have to patch " +"``a.SomeClass`` instead::" msgstr "" "然而,考慮另一種情況,其中模組 b 並不是使用 ``from a import SomeClass``,而" "是 ``import a``,然後 ``some_function`` 使用 ``a.SomeClass``。這兩種 import " @@ -2631,14 +2628,14 @@ msgid "" "Both patch_ and patch.object_ correctly patch and restore descriptors: class " "methods, static methods and properties. You should patch these on the " "*class* rather than an instance. They also work with *some* objects that " -"proxy attribute access, like the `django settings object `_." msgstr "" "patch_ 和 patch.object_ 都正確地 patch 和還原描述器:類別方法、靜態方法以及屬" "性。你應該在 *類別* 而不是實例上 patch 它們。它們還可以使用代理屬性存取的\\ *" -"一些*\\ 物件,例如 `django 設定物件 `_。" #: ../../library/unittest.mock.rst:2040 @@ -2651,9 +2648,9 @@ msgstr "Mock 魔術方法" #: ../../library/unittest.mock.rst:2047 msgid "" -":class:`Mock` supports mocking the Python protocol methods, also known " -"as :term:`\"magic methods\" `. This allows mock objects to " -"replace containers or other objects that implement Python protocols." +":class:`Mock` supports mocking the Python protocol methods, also known as :" +"term:`\"magic methods\" `. This allows mock objects to replace " +"containers or other objects that implement Python protocols." msgstr "" ":class:`Mock` 支援 mock Python 協定方法,其也被稱作 :term:`\"魔術方法\" " "`。這允許 mock 物件替換容器或實作 Python 協定的其他物件。" @@ -2680,8 +2677,8 @@ msgstr "" #: ../../library/unittest.mock.rst:2079 msgid "" -"One use case for this is for mocking objects used as context managers in " -"a :keyword:`with` statement:" +"One use case for this is for mocking objects used as context managers in a :" +"keyword:`with` statement:" msgstr "一個用法是在 :keyword:`with` 陳述式中 mock 作為情境管理器使用的物件:" #: ../../library/unittest.mock.rst:2091 @@ -2689,14 +2686,14 @@ msgid "" "Calls to magic methods do not appear in :attr:`~Mock.method_calls`, but they " "are recorded in :attr:`~Mock.mock_calls`." msgstr "" -"對魔術方法的呼叫並不會出現在 :attr:`~Mock.method_calls` 中,它們會被記錄" -"在 :attr:`~Mock.mock_calls` 內。" +"對魔術方法的呼叫並不會出現在 :attr:`~Mock.method_calls` 中,它們會被記錄在 :" +"attr:`~Mock.mock_calls` 內。" #: ../../library/unittest.mock.rst:2096 msgid "" "If you use the *spec* keyword argument to create a mock then attempting to " -"set a magic method that isn't in the spec will raise " -"an :exc:`AttributeError`." +"set a magic method that isn't in the spec will raise an :exc:" +"`AttributeError`." msgstr "" "如果你使用\\ *spec*\\ 關鍵字引數來建立一個 mock,則嘗試設定規格中未包含的魔術" "方法將引發一個 :exc:`AttributeError`。" @@ -2821,11 +2818,11 @@ msgstr "Magic Mock" #: ../../library/unittest.mock.rst:2141 msgid "" -"There are two ``MagicMock`` variants: :class:`MagicMock` " -"and :class:`NonCallableMagicMock`." +"There are two ``MagicMock`` variants: :class:`MagicMock` and :class:" +"`NonCallableMagicMock`." msgstr "" -"``MagicMock`` 有兩個變體::class:`MagicMock` " -"和 :class:`NonCallableMagicMock`。" +"``MagicMock`` 有兩個變體::class:`MagicMock` 和 :class:" +"`NonCallableMagicMock`。" #: ../../library/unittest.mock.rst:2146 msgid "" @@ -2960,13 +2957,13 @@ msgstr "舉例來說:" #: ../../library/unittest.mock.rst:2212 msgid "" "The two equality methods, :meth:`!__eq__` and :meth:`!__ne__`, are special. " -"They do the default equality comparison on identity, using " -"the :attr:`~Mock.side_effect` attribute, unless you change their return " -"value to return something else::" +"They do the default equality comparison on identity, using the :attr:`~Mock." +"side_effect` attribute, unless you change their return value to return " +"something else::" msgstr "" -":meth:`!__eq__` 和 :meth:`!__ne__` 這兩個相等的方法是特別的。它們使" -"用 :attr:`~Mock.side_effect` 屬性對識別性 (identity) 進行預設的相等比較,除非" -"你變更它們的回傳值以回傳其他內容: ::" +":meth:`!__eq__` 和 :meth:`!__ne__` 這兩個相等的方法是特別的。它們使用 :attr:" +"`~Mock.side_effect` 屬性對識別性 (identity) 進行預設的相等比較,除非你變更它" +"們的回傳值以回傳其他內容: ::" #: ../../library/unittest.mock.rst:2217 msgid "" @@ -3090,8 +3087,8 @@ msgstr "" #: ../../library/unittest.mock.rst:2284 msgid "" -"The ``sentinel`` attributes now preserve their identity when they " -"are :mod:`copied ` or :mod:`pickled `." +"The ``sentinel`` attributes now preserve their identity when they are :mod:" +"`copied ` or :mod:`pickled `." msgstr "" "``哨兵``\\ 屬性現在當被\\ :mod:`複製 `\\ 或\\ :mod:`序列化 `\\ " "時會保留其識別性。" @@ -3109,8 +3106,8 @@ msgstr "" #: ../../library/unittest.mock.rst:2293 msgid "" -"In this example we monkey patch ``method`` to return " -"``sentinel.some_object``:" +"In this example we monkey patch ``method`` to return ``sentinel." +"some_object``:" msgstr "" "在這個例子中,我們 monkey patch ``method`` 以回傳 ``sentinel.some_object``:" @@ -3120,13 +3117,13 @@ msgstr "DEFAULT" #: ../../library/unittest.mock.rst:2310 msgid "" -"The :data:`DEFAULT` object is a pre-created sentinel (actually " -"``sentinel.DEFAULT``). It can be used by :attr:`~Mock.side_effect` functions " -"to indicate that the normal return value should be used." +"The :data:`DEFAULT` object is a pre-created sentinel (actually ``sentinel." +"DEFAULT``). It can be used by :attr:`~Mock.side_effect` functions to " +"indicate that the normal return value should be used." msgstr "" -":data:`DEFAULT` 物件是一個預先建立的哨兵(實際上是 " -"``sentinel.DEFAULT``\\ )。它可以被 :attr:`~Mock.side_effect` 函式使用來表示" -"正常的回傳值應該被使用。" +":data:`DEFAULT` 物件是一個預先建立的哨兵(實際上是 ``sentinel." +"DEFAULT``\\ )。它可以被 :attr:`~Mock.side_effect` 函式使用來表示正常的回傳值" +"應該被使用。" #: ../../library/unittest.mock.rst:2316 msgid "call" @@ -3135,13 +3132,14 @@ msgstr "call" #: ../../library/unittest.mock.rst:2320 msgid "" ":func:`call` is a helper object for making simpler assertions, for comparing " -"with :attr:`~Mock.call_args`, :attr:`~Mock.call_args_list`, :attr:`~Mock.mock_calls` " -"and :attr:`~Mock.method_calls`. :func:`call` can also be used " +"with :attr:`~Mock.call_args`, :attr:`~Mock.call_args_list`, :attr:`~Mock." +"mock_calls` and :attr:`~Mock.method_calls`. :func:`call` can also be used " "with :meth:`~Mock.assert_has_calls`." msgstr "" -"與 :attr:`~Mock.call_args`、:attr:`~Mock.call_args_list`、:attr:`~Mock.mock_calls` " -"和 :attr:`~Mock.method_calls` 相比,:func:`call` 是一個用於進行更簡單的斷言的" -"輔助物件。:func:`call` 也可以與 :meth:`~Mock.assert_has_calls` 一起使用。" +"與 :attr:`~Mock.call_args`、:attr:`~Mock.call_args_list`、:attr:`~Mock." +"mock_calls` 和 :attr:`~Mock.method_calls` 相比,:func:`call` 是一個用於進行更" +"簡單的斷言的輔助物件。:func:`call` 也可以與 :meth:`~Mock.assert_has_calls` 一" +"起使用。" #: ../../library/unittest.mock.rst:2333 msgid "" @@ -3173,24 +3171,22 @@ msgid "" "A ``call`` object is either a tuple of (positional args, keyword args) or " "(name, positional args, keyword args) depending on how it was constructed. " "When you construct them yourself this isn't particularly interesting, but " -"the ``call`` objects that are in " -"the :attr:`Mock.call_args`, :attr:`Mock.call_args_list` " -"and :attr:`Mock.mock_calls` attributes can be introspected to get at the " -"individual arguments they contain." +"the ``call`` objects that are in the :attr:`Mock.call_args`, :attr:`Mock." +"call_args_list` and :attr:`Mock.mock_calls` attributes can be introspected " +"to get at the individual arguments they contain." msgstr "" "取決於它的建構方式,一個 ``call`` 物件會是(位置引數, 關鍵字引數)的元組,或" "是 (名稱, 位置引數, 關鍵字引數) 的元組。當你自己建構它們時,這並不是那麼有" -"趣,但是 :attr:`Mock.call_args`、:attr:`Mock.call_args_list` " -"和 :attr:`Mock.mock_calls` 屬性中的 ``call`` 物件可以被內省以取得它們包含的各" -"個引數。" +"趣,但是 :attr:`Mock.call_args`、:attr:`Mock.call_args_list` 和 :attr:`Mock." +"mock_calls` 屬性中的 ``call`` 物件可以被內省以取得它們包含的各個引數。" #: ../../library/unittest.mock.rst:2366 msgid "" -"The ``call`` objects in :attr:`Mock.call_args` " -"and :attr:`Mock.call_args_list` are two-tuples of (positional args, keyword " -"args) whereas the ``call`` objects in :attr:`Mock.mock_calls`, along with " -"ones you construct yourself, are three-tuples of (name, positional args, " -"keyword args)." +"The ``call`` objects in :attr:`Mock.call_args` and :attr:`Mock." +"call_args_list` are two-tuples of (positional args, keyword args) whereas " +"the ``call`` objects in :attr:`Mock.mock_calls`, along with ones you " +"construct yourself, are three-tuples of (name, positional args, keyword " +"args)." msgstr "" ":attr:`Mock.call_args` 和 :attr:`Mock.call_args_list` 中的 ``call`` 物件是" "(位置引數, 關鍵字引數)的二元組,而 :attr:`Mock.mock_calls` 中的 ``call`` 物" @@ -3229,8 +3225,8 @@ msgid "" "If *spec_set* is ``True`` then attempting to set attributes that don't exist " "on the spec object will raise an :exc:`AttributeError`." msgstr "" -"如果 *spec_set* 為 ``True``,則嘗試設定規格物件上不存在的屬性將引" -"發 :exc:`AttributeError`。" +"如果 *spec_set* 為 ``True``,則嘗試設定規格物件上不存在的屬性將引發 :exc:" +"`AttributeError`。" #: ../../library/unittest.mock.rst:2418 msgid "" @@ -3253,8 +3249,8 @@ msgstr "" #: ../../library/unittest.mock.rst:2426 msgid "" -"See :ref:`auto-speccing` for examples of how to use auto-speccing " -"with :func:`create_autospec` and the *autospec* argument to :func:`patch`." +"See :ref:`auto-speccing` for examples of how to use auto-speccing with :func:" +"`create_autospec` and the *autospec* argument to :func:`patch`." msgstr "" "請參閱 :ref:`auto-speccing` 以得知如何以 :func:`create_autospec` 使用自動規格" "以及如何在 :func:`patch` 中使用 *autospec* 引數的範例。" @@ -3264,8 +3260,8 @@ msgid "" ":func:`create_autospec` now returns an :class:`AsyncMock` if the target is " "an async function." msgstr "" -"如果目標是一個非同步函式,:func:`create_autospec` 現在會回傳一" -"個 :class:`AsyncMock`。" +"如果目標是一個非同步函式,:func:`create_autospec` 現在會回傳一個 :class:" +"`AsyncMock`。" #: ../../library/unittest.mock.rst:2437 msgid "ANY" @@ -3284,18 +3280,17 @@ msgstr "" #: ../../library/unittest.mock.rst:2446 msgid "" "To ignore certain arguments you can pass in objects that compare equal to " -"*everything*. Calls to :meth:`~Mock.assert_called_with` " -"and :meth:`~Mock.assert_called_once_with` will then succeed no matter what " -"was passed in." +"*everything*. Calls to :meth:`~Mock.assert_called_with` and :meth:`~Mock." +"assert_called_once_with` will then succeed no matter what was passed in." msgstr "" "要忽略某些引數,你可以傳入對\\ *所有物件*\\ 來說都相等的物件。那麼無論傳入什" -"麼內容,對 :meth:`~Mock.assert_used_with` " -"和 :meth:`~Mock.assert_used_once_with` 的呼叫都會成功。" +"麼內容,對 :meth:`~Mock.assert_used_with` 和 :meth:`~Mock." +"assert_used_once_with` 的呼叫都會成功。" #: ../../library/unittest.mock.rst:2455 msgid "" -":data:`ANY` can also be used in comparisons with call lists " -"like :attr:`~Mock.mock_calls`:" +":data:`ANY` can also be used in comparisons with call lists like :attr:" +"`~Mock.mock_calls`:" msgstr "" ":data:`ANY` 也可以用來與呼叫串列進行比較,例如 :attr:`~Mock.mock_calls`:" @@ -3328,8 +3323,8 @@ msgid "" ":data:`FILTER_DIR` is a module level variable that controls the way mock " "objects respond to :func:`dir`. The default is ``True``, which uses the " "filtering described below, to only show useful members. If you dislike this " -"filtering, or need to switch it off for diagnostic purposes, then set " -"``mock.FILTER_DIR = False``." +"filtering, or need to switch it off for diagnostic purposes, then set ``mock." +"FILTER_DIR = False``." msgstr "" ":data:`FILTER_DIR` 是一個模組級別的變數,用於控制 mock 物件回應 :func:`dir` " "的方式。其預設值為 ``True``,它使用以下描述的過濾方式來只顯示有用的成員。如果" @@ -3431,8 +3426,8 @@ msgid "" "of :const:`FILTER_DIR`." msgstr "" "或者,你可以只使用 ``vars(my_mock)``\\ (實例成員)和 " -"``dir(type(my_mock))``\\ (型別成員)來略過過濾,而不考" -"慮 :const:`FILTER_DIR`。" +"``dir(type(my_mock))``\\ (型別成員)來略過過濾,而不考慮 :const:" +"`FILTER_DIR`。" #: ../../library/unittest.mock.rst:2540 msgid "mock_open" @@ -3457,25 +3452,23 @@ msgstr "" #: ../../library/unittest.mock.rst:2551 msgid "" -"*read_data* is a string for " -"the :meth:`~io.RawIOBase.read`, :meth:`~io.IOBase.readline`, " -"and :meth:`~io.IOBase.readlines` methods of the file handle to return. " -"Calls to those methods will take data from *read_data* until it is " -"depleted. The mock of these methods is pretty simplistic: every time the " -"*mock* is called, the *read_data* is rewound to the start. If you need more " -"control over the data that you are feeding to the tested code you will need " -"to customize this mock for yourself. When that is insufficient, one of the " -"in-memory filesystem packages on `PyPI `_ can offer a " -"realistic filesystem for testing." -msgstr "" -"*read_data* 是檔案處理方" -"法 :meth:`~io.RawIOBase.read`、:meth:`~io.IOBase.readline` " -"和 :meth:`~io.IOBase.readlines` 的回傳字串。對這些方法的呼叫將從 *read_data* " -"取得資料,直到資料耗盡。對這些方法的 mock 非常單純:每次呼叫 *mock* 時," -"*read_data* 都會倒回到起點。如果你需要對提供給測試程式碼的資料進行更多控制," -"你會需要自行客製化這個 mock。如果這樣還不夠,`PyPI `_ 上的" -"其中一個記憶體內檔案系統 (in-memory filesystem) 套件可以提供用於測試的真實檔" -"案系統。" +"*read_data* is a string for the :meth:`~io.RawIOBase.read`, :meth:`~io." +"IOBase.readline`, and :meth:`~io.IOBase.readlines` methods of the file " +"handle to return. Calls to those methods will take data from *read_data* " +"until it is depleted. The mock of these methods is pretty simplistic: every " +"time the *mock* is called, the *read_data* is rewound to the start. If you " +"need more control over the data that you are feeding to the tested code you " +"will need to customize this mock for yourself. When that is insufficient, " +"one of the in-memory filesystem packages on `PyPI `_ can " +"offer a realistic filesystem for testing." +msgstr "" +"*read_data* 是檔案處理方法 :meth:`~io.RawIOBase.read`、:meth:`~io.IOBase." +"readline` 和 :meth:`~io.IOBase.readlines` 的回傳字串。對這些方法的呼叫將從 " +"*read_data* 取得資料,直到資料耗盡。對這些方法的 mock 非常單純:每次呼叫 " +"*mock* 時,*read_data* 都會倒回到起點。如果你需要對提供給測試程式碼的資料進行" +"更多控制,你會需要自行客製化這個 mock。如果這樣還不夠,`PyPI `_ 上的其中一個記憶體內檔案系統 (in-memory filesystem) 套件可以提供用於測" +"試的真實檔案系統。" #: ../../library/unittest.mock.rst:2561 msgid "" @@ -3483,9 +3476,9 @@ msgid "" "The mock of :meth:`~io.RawIOBase.read` changed to consume *read_data* rather " "than returning it on each call." msgstr "" -"新增對 :meth:`~io.IOBase.readline` 和 :meth:`~io.IOBase.readlines` 的支" -"援。:meth:`~io.RawIOBase.read` 的 mock 更改為消耗 *read_data* 而不是在每次呼" -"叫時回傳它。" +"新增對 :meth:`~io.IOBase.readline` 和 :meth:`~io.IOBase.readlines` 的支援。:" +"meth:`~io.RawIOBase.read` 的 mock 更改為消耗 *read_data* 而不是在每次呼叫時回" +"傳它。" #: ../../library/unittest.mock.rst:2566 msgid "*read_data* is now reset on each call to the *mock*." @@ -3518,8 +3511,8 @@ msgstr "" #: ../../library/unittest.mock.rst:2579 msgid "" "The issue is that even if you mock out the call to :func:`open` it is the " -"*returned object* that is used as a context manager (and " -"has :meth:`~object.__enter__` and :meth:`~object.__exit__` called)." +"*returned object* that is used as a context manager (and has :meth:`~object." +"__enter__` and :meth:`~object.__exit__` called)." msgstr "" "問題是,即使你 mock 了對 :func:`open` 的呼叫,它也是作為情境管理器使用的\\ *" "回傳物件*\\ (且其 :meth:`~object.__enter__` 和 :meth:`~ object.__exit__` 已" @@ -3593,8 +3586,8 @@ msgid "" "limits the api of mocks to the api of an original object (the spec), but it " "is recursive (implemented lazily) so that attributes of mocks only have the " "same api as the attributes of the spec. In addition mocked functions / " -"methods have the same call signature as the original so they raise " -"a :exc:`TypeError` if they are called incorrectly." +"methods have the same call signature as the original so they raise a :exc:" +"`TypeError` if they are called incorrectly." msgstr "" "自動規格以 mock 現有的 :attr:`!spec` 功能作為基礎。它將 mock 的 api 限制為原" "始物件(規格)的 api,但它是遞迴的(惰性 (lazily) 實現),因此 mock 的屬性僅" @@ -3655,18 +3648,18 @@ msgstr "該規格僅適用於 mock 本身,因此在 mock 上的任何方法仍 #: ../../library/unittest.mock.rst:2654 msgid "" -">>> mock.has_data()\n" +">>> mock.header_items()\n" "\n" -">>> mock.has_data.assret_called_with() # Intentional typo!" +">>> mock.header_items.assret_called_with() # Intentional typo!" msgstr "" -">>> mock.has_data()\n" +">>> mock.header_items()\n" "\n" -">>> mock.has_data.assret_called_with() # 故意的錯字!" +">>> mock.header_items.assret_called_with() # 故意的錯字!" #: ../../library/unittest.mock.rst:2660 msgid "" -"Auto-speccing solves this problem. You can either pass ``autospec=True`` " -"to :func:`patch` / :func:`patch.object` or use the :func:`create_autospec` " +"Auto-speccing solves this problem. You can either pass ``autospec=True`` to :" +"func:`patch` / :func:`patch.object` or use the :func:`create_autospec` " "function to create a mock with a spec. If you use the ``autospec=True`` " "argument to :func:`patch` then the object that is being replaced will be " "used as the spec object. Because the speccing is done \"lazily\" (the spec " @@ -3674,12 +3667,12 @@ msgid "" "complex or deeply nested objects (like modules that import modules that " "import modules) without a big performance hit." msgstr "" -"自動規格解決了這個問題。你可以將 ``autospec=True`` 傳遞" -"給 :func:`patch` / :func:`patch.object` 或使用 :func:`create_autospec` 函式建" -"立帶有規格的 mock。如果你對 :func:`patch` 使用 ``autospec=True`` 引數,則被取" -"代的物件將作為規格物件使用。因為規格是「惰性」完成的(規格是在 mock 被存取時" -"作為屬性被建立的),所以你可以將它與非常複雜或深度巢狀使用的物件(例如連續引" -"用的模組)一起使用,而不會過於影響性能。" +"自動規格解決了這個問題。你可以將 ``autospec=True`` 傳遞給 :func:`patch` / :" +"func:`patch.object` 或使用 :func:`create_autospec` 函式建立帶有規格的 mock。" +"如果你對 :func:`patch` 使用 ``autospec=True`` 引數,則被取代的物件將作為規格" +"物件使用。因為規格是「惰性」完成的(規格是在 mock 被存取時作為屬性被建立" +"的),所以你可以將它與非常複雜或深度巢狀使用的物件(例如連續引用的模組)一起" +"使用,而不會過於影響性能。" #: ../../library/unittest.mock.rst:2669 msgid "Here's an example of it in use::" @@ -3705,9 +3698,9 @@ msgstr "" #: ../../library/unittest.mock.rst:2679 msgid "" -"You can see that :class:`!request.Request` has a spec. :class:`!" -"request.Request` takes two arguments in the constructor (one of which is " -"*self*). Here's what happens if we try to call it incorrectly::" +"You can see that :class:`!request.Request` has a spec. :class:`!request." +"Request` takes two arguments in the constructor (one of which is *self*). " +"Here's what happens if we try to call it incorrectly::" msgstr "" "你可以看到 :class:`!request.Request` 有一個規格。:class:`!request.Request` 在" "建構函式中接受兩個引數(其中之一是 *self*\\ )。如果我們錯誤地呼叫它,會發生" @@ -3781,11 +3774,11 @@ msgstr "" #: ../../library/unittest.mock.rst:2711 msgid "" -"As well as using *autospec* through :func:`patch` there is " -"a :func:`create_autospec` for creating autospecced mocks directly:" +"As well as using *autospec* through :func:`patch` there is a :func:" +"`create_autospec` for creating autospecced mocks directly:" msgstr "" -"除了透過 :func:`patch` 使用 *autospec* 之外,還有一" -"個 :func:`create_autospec` 用於直接建立有自動規格的 mock:" +"除了透過 :func:`patch` 使用 *autospec* 之外,還有一個 :func:" +"`create_autospec` 用於直接建立有自動規格的 mock:" #: ../../library/unittest.mock.rst:2719 msgid "" @@ -4027,11 +4020,11 @@ msgstr "*wraps*" #: ../../library/unittest.mock.rst:2857 msgid "" -"If all three are set, mock will return the value " -"from :attr:`~Mock.side_effect`, ignoring :attr:`~Mock.return_value` and the " -"wrapped object altogether. If any two are set, the one with the higher " -"precedence will return the value. Regardless of the order of which was set " -"first, the order of precedence remains unchanged." +"If all three are set, mock will return the value from :attr:`~Mock." +"side_effect`, ignoring :attr:`~Mock.return_value` and the wrapped object " +"altogether. If any two are set, the one with the higher precedence will " +"return the value. Regardless of the order of which was set first, the order " +"of precedence remains unchanged." msgstr "" "如果這三個都有設定,mock 將會回傳來自 :attr:`~Mock.side_effect` 的值,並忽" "略 :attr:`~Mock.return_value` 和被包裝物件。如果設定了任兩項,則優先順序較高" @@ -4041,8 +4034,8 @@ msgstr "" msgid "" "As ``None`` is the default value of :attr:`~Mock.side_effect`, if you " "reassign its value back to ``None``, the order of precedence will be checked " -"between :attr:`~Mock.return_value` and the wrapped object, " -"ignoring :attr:`~Mock.side_effect`." +"between :attr:`~Mock.return_value` and the wrapped object, ignoring :attr:" +"`~Mock.side_effect`." msgstr "" "由於 ``None`` 是 :attr:`~Mock.side_effect` 的預設值,如果將其值重新賦值回為 " "``None``,則會檢查 :attr:`~Mock.return_value` 和被包裝物件之間的優先順序,忽" @@ -4059,11 +4052,11 @@ msgstr "" #: ../../library/unittest.mock.rst:2893 msgid "" -"When :class:`Mock` wraps an object, the default value " -"of :attr:`~Mock.return_value` will be :data:`DEFAULT`." +"When :class:`Mock` wraps an object, the default value of :attr:`~Mock." +"return_value` will be :data:`DEFAULT`." msgstr "" -"當 :class:`Mock` 包裝一個物件時,:attr:`~Mock.return_value` 的預設值將" -"為 :data:`DEFAULT`。" +"當 :class:`Mock` 包裝一個物件時,:attr:`~Mock.return_value` 的預設值將為 :" +"data:`DEFAULT`。" #: ../../library/unittest.mock.rst:2902 msgid "" @@ -4106,18 +4099,18 @@ msgstr "" #~ msgid "" #~ "This can be useful where you want to make a series of assertions that " -#~ "reuse the same object. Note that :meth:`reset_mock` *doesn't* clear " -#~ "the :attr:`return_value`, :attr:`side_effect` or any child attributes you " -#~ "have set using normal assignment by default. In case you want to " -#~ "reset :attr:`return_value` or :attr:`side_effect`, then pass the " -#~ "corresponding parameter as ``True``. Child mocks and the return value " -#~ "mock (if any) are reset as well." +#~ "reuse the same object. Note that :meth:`reset_mock` *doesn't* clear the :" +#~ "attr:`return_value`, :attr:`side_effect` or any child attributes you have " +#~ "set using normal assignment by default. In case you want to reset :attr:" +#~ "`return_value` or :attr:`side_effect`, then pass the corresponding " +#~ "parameter as ``True``. Child mocks and the return value mock (if any) are " +#~ "reset as well." #~ msgstr "" #~ "這在你想要進行一系列重複使用同一物件的斷言時非常有用。請注意,預設情況" -#~ "下,:meth:`reset_mock` *不會*\\ 清" -#~ "除 :attr:`return_value`、:attr:`side_effect` 或使用普通賦值設定的任何子屬" -#~ "性。如果你想要重置 :attr:`return_value` 或 :attr:`side_effect`,則將相應的" -#~ "參數設置為 ``True``。Child mock 和回傳值 mock(如果有的話)也會被重置。" +#~ "下,:meth:`reset_mock` *不會*\\ 清除 :attr:`return_value`、:attr:" +#~ "`side_effect` 或使用普通賦值設定的任何子屬性。如果你想要重置 :attr:" +#~ "`return_value` 或 :attr:`side_effect`,則將相應的參數設置為 ``True``。" +#~ "Child mock 和回傳值 mock(如果有的話)也會被重置。" #~ msgid "*return_value*, and *side_effect* are keyword-only arguments." #~ msgstr "*return_value* 和 *side_effect* 是僅限關鍵字引數。" diff --git a/library/unittest.po b/library/unittest.po index 80fe6553c4..6940a80894 100644 --- a/library/unittest.po +++ b/library/unittest.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-23 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-10-16 06:03+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -228,12 +228,12 @@ msgstr "" #: ../../library/unittest.rst:113 msgid "" -"A testcase is created by subclassing :class:`unittest.TestCase`. The three " +"A test case is created by subclassing :class:`unittest.TestCase`. The three " "individual tests are defined with methods whose names start with the letters " "``test``. This naming convention informs the test runner about which " "methods represent tests." msgstr "" -"測試用例 (testcase) 可以透過繼承 :class:`unittest.TestCase` 類別來建立。這裡" +"測試用例 (test case) 可以透過繼承 :class:`unittest.TestCase` 類別來建立。這裡" "定義了三個獨立的物件方法,名稱皆以 ``test`` 開頭。這樣的命名方式能告知 test " "runner 哪些物件方法為定義的測試。" diff --git a/library/urllib.request.po b/library/urllib.request.po index 0e3384e9e9..45e42e0699 100644 --- a/library/urllib.request.po +++ b/library/urllib.request.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-24 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-04-21 17:59+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,8 +42,8 @@ msgid "" "The `Requests package `_ is " "recommended for a higher-level HTTP client interface." msgstr "" -"有關於更高階的 HTTP 用戶端介面,推薦使用 `Requests 套件 `_。" +"有關於更高階的 HTTP 用戶端介面,推薦使用 `Requests 套件 `_。" #: ../../library/urllib.request.rst:26 msgid "" @@ -74,8 +74,8 @@ msgid "" "Open *url*, which can be either a string containing a valid, properly " "encoded URL, or a :class:`Request` object." msgstr "" -"打開 *url*,其值可以是一個包含有效且適當編碼 URL 的字串或是一" -"個 :class:`Request` 物件。" +"打開 *url*,其值可以是一個包含有效且適當編碼 URL 的字串或是一個 :class:" +"`Request` 物件。" #: ../../library/urllib.request.rst:42 msgid "" @@ -108,8 +108,8 @@ msgstr "" #: ../../library/urllib.request.rst:54 msgid "" "If *context* is specified, it must be a :class:`ssl.SSLContext` instance " -"describing the various SSL options. " -"See :class:`~http.client.HTTPSConnection` for more details." +"describing the various SSL options. See :class:`~http.client." +"HTTPSConnection` for more details." msgstr "" "若 *context* 有被指定時,它必須是一個 :class:`ssl.SSLContext` 的實例並描述著" "各種 SSL 選項。更多細節請見 :class:`~http.client.HTTPSConnection`。" @@ -117,37 +117,37 @@ msgstr "" #: ../../library/urllib.request.rst:58 msgid "" "This function always returns an object which can work as a :term:`context " -"manager` and has the properties *url*, *headers*, and *status*. " -"See :class:`urllib.response.addinfourl` for more detail on these properties." +"manager` and has the properties *url*, *headers*, and *status*. See :class:" +"`urllib.response.addinfourl` for more detail on these properties." msgstr "" "這個函式總是回傳一個可作為 :term:`context manager` 使用的物件,並有著特性 " -"(property) *url*、*headers* 與 *status*。欲知更多這些特性細節請參" -"見 :class:`urllib.response.addinfourl`。" +"(property) *url*、*headers* 與 *status*。欲知更多這些特性細節請參見 :class:" +"`urllib.response.addinfourl`。" #: ../../library/urllib.request.rst:62 msgid "" -"For HTTP and HTTPS URLs, this function returns " -"a :class:`http.client.HTTPResponse` object slightly modified. In addition to " -"the three new methods above, the msg attribute contains the same information " -"as the :attr:`~http.client.HTTPResponse.reason` attribute --- the reason " -"phrase returned by server --- instead of the response headers as it is " -"specified in the documentation for :class:`~http.client.HTTPResponse`." +"For HTTP and HTTPS URLs, this function returns a :class:`http.client." +"HTTPResponse` object slightly modified. In addition to the three new methods " +"above, the msg attribute contains the same information as the :attr:`~http." +"client.HTTPResponse.reason` attribute --- the reason phrase returned by " +"server --- instead of the response headers as it is specified in the " +"documentation for :class:`~http.client.HTTPResponse`." msgstr "" -"對於 HTTP 與 HTTPS 的 URLs,這個函式回傳一個稍有不同" -"的 :class:`http.client.HTTPResponse` 物件。除了上述提到的三個方法外,另有 " -"msg 屬性並有著與 :attr:`~http.client.HTTPResponse.reason` 相同的資訊 --- 由伺" -"服器回傳的原因敘述 (reason phrase),而不是" -"在 :class:`~http.client.HTTPResponse` 文件中提到的回應 headers。" +"對於 HTTP 與 HTTPS 的 URLs,這個函式回傳一個稍有不同的 :class:`http.client." +"HTTPResponse` 物件。除了上述提到的三個方法外,另有 msg 屬性並有著與 :attr:" +"`~http.client.HTTPResponse.reason` 相同的資訊 --- 由伺服器回傳的原因敘述 " +"(reason phrase),而不是在 :class:`~http.client.HTTPResponse` 文件中提到的回" +"應 headers。" #: ../../library/urllib.request.rst:70 msgid "" -"For FTP, file, and data URLs and requests explicitly handled by " -"legacy :class:`URLopener` and :class:`FancyURLopener` classes, this function " -"returns a :class:`urllib.response.addinfourl` object." +"For FTP, file, and data URLs and requests explicitly handled by legacy :" +"class:`URLopener` and :class:`FancyURLopener` classes, this function returns " +"a :class:`urllib.response.addinfourl` object." msgstr "" -"對於 FTP、檔案、資料的 URLs、以及那些由傳統 classes :class:`URLopener` " -"與 :class:`FancyURLopener` 所處理的請求,這個函式會回傳一" -"個 :class:`urllib.response.addinfourl` 物件。" +"對於 FTP、檔案、資料的 URLs、以及那些由傳統 classes :class:`URLopener` 與 :" +"class:`FancyURLopener` 所處理的請求,這個函式會回傳一個 :class:`urllib." +"response.addinfourl` 物件。" #: ../../library/urllib.request.rst:74 msgid "Raises :exc:`~urllib.error.URLError` on protocol errors." @@ -156,8 +156,8 @@ msgstr "當遇到協定上的錯誤時會引發 :exc:`~urllib.error.URLError`。 #: ../../library/urllib.request.rst:76 msgid "" "Note that ``None`` may be returned if no handler handles the request (though " -"the default installed global :class:`OpenerDirector` " -"uses :class:`UnknownHandler` to ensure this never happens)." +"the default installed global :class:`OpenerDirector` uses :class:" +"`UnknownHandler` to ensure this never happens)." msgstr "" "請注意若沒有 handler 處理請求時,``None`` 值將會被回傳。(即使有預設的全域類" "別 :class:`OpenerDirector` 使用 :class:`UnknownHandler` 來確保這種情況不會發" @@ -166,9 +166,9 @@ msgstr "" #: ../../library/urllib.request.rst:80 msgid "" "In addition, if proxy settings are detected (for example, when a ``*_proxy`` " -"environment variable like :envvar:`!http_proxy` is " -"set), :class:`ProxyHandler` is default installed and makes sure the requests " -"are handled through the proxy." +"environment variable like :envvar:`!http_proxy` is set), :class:" +"`ProxyHandler` is default installed and makes sure the requests are handled " +"through the proxy." msgstr "" "另外,若有偵測到代理服務的設定(例如當 ``*_proxy`` 環境變數像是::envvar:!" "http_proxy` 有被設置時),:class:`ProxyHandler` 會被預設使用以確保請求有透過" @@ -179,19 +179,19 @@ msgid "" "The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been " "discontinued; :func:`urllib.request.urlopen` corresponds to the old " "``urllib2.urlopen``. Proxy handling, which was done by passing a dictionary " -"parameter to ``urllib.urlopen``, can be obtained by " -"using :class:`ProxyHandler` objects." +"parameter to ``urllib.urlopen``, can be obtained by using :class:" +"`ProxyHandler` objects." msgstr "" -"Python 2.6 或更早版本的遺留函式 ``urllib.urlopen`` 已經不再被維護;新函" -"式 :func:`urllib.request.urlopen` 對應到舊函式 ``urllib2.urlopen``。有關代理" -"服務的處理,以往是透過傳遞 dictionary(字典)參數給 ``urllib.urlopen`` 來取得" -"的,現在則可以透過 :class:`ProxyHandler` 物件來取得。" +"Python 2.6 或更早版本的遺留函式 ``urllib.urlopen`` 已經不再被維護;新函式 :" +"func:`urllib.request.urlopen` 對應到舊函式 ``urllib2.urlopen``。有關代理服務" +"的處理,以往是透過傳遞 dictionary(字典)參數給 ``urllib.urlopen`` 來取得的," +"現在則可以透過 :class:`ProxyHandler` 物件來取得。" #: ../../library/urllib.request.rst:91 ../../library/urllib.request.rst:93 msgid "" -"The default opener raises an :ref:`auditing event ` " -"``urllib.Request`` with arguments ``fullurl``, ``data``, ``headers``, " -"``method`` taken from the request object." +"The default opener raises an :ref:`auditing event ` ``urllib." +"Request`` with arguments ``fullurl``, ``data``, ``headers``, ``method`` " +"taken from the request object." msgstr "" "預設的 opener 會觸發一個 :ref:`auditing event ` ``urllib.Request`` " "與其從請求物件中所獲得的引數 ``fullurl``、``data``、``headers``、``method``。" @@ -202,8 +202,8 @@ msgstr "新增 *cafile* 與 *capath*。" #: ../../library/urllib.request.rst:100 msgid "" -"HTTPS virtual hosts are now supported if possible (that is, " -"if :const:`ssl.HAS_SNI` is true)." +"HTTPS virtual hosts are now supported if possible (that is, if :const:`ssl." +"HAS_SNI` is true)." msgstr "" "HTTPS 虛擬主機 (virtual hosts) 現已支援,只要 :const:`ssl.HAS_SNI` 的值為 " "true。" @@ -222,13 +222,13 @@ msgstr "*context* 被新增。" #: ../../library/urllib.request.rst:111 msgid "" -"HTTPS connection now send an ALPN extension with protocol indicator ``http/" -"1.1`` when no *context* is given. Custom *context* should set ALPN protocols " -"with :meth:`~ssl.SSLContext.set_alpn_protocols`." +"HTTPS connection now send an ALPN extension with protocol indicator " +"``http/1.1`` when no *context* is given. Custom *context* should set ALPN " +"protocols with :meth:`~ssl.SSLContext.set_alpn_protocols`." msgstr "" -"當 *context* 沒有被指定時,HTTPS 連線現在會傳送一個帶有協定指示器 ``http/" -"1.1`` 的 ALPN 擴充 (extension)。自訂的 *context* 應該利" -"用 :meth:`~ssl.SSLContext.set_alpn_protocols` 來自行設定 ALPN 協定。" +"當 *context* 沒有被指定時,HTTPS 連線現在會傳送一個帶有協定指示器 " +"``http/1.1`` 的 ALPN 擴充 (extension)。自訂的 *context* 應該利用 :meth:`~ssl." +"SSLContext.set_alpn_protocols` 來自行設定 ALPN 協定。" #: ../../library/urllib.request.rst:116 msgid "" @@ -240,16 +240,15 @@ msgstr "" msgid "" "Install an :class:`OpenerDirector` instance as the default global opener. " "Installing an opener is only necessary if you want urlopen to use that " -"opener; otherwise, simply call :meth:`OpenerDirector.open` instead " -"of :func:`~urllib.request.urlopen`. The code does not check for a " -"real :class:`OpenerDirector`, and any class with the appropriate interface " -"will work." +"opener; otherwise, simply call :meth:`OpenerDirector.open` instead of :func:" +"`~urllib.request.urlopen`. The code does not check for a real :class:" +"`OpenerDirector`, and any class with the appropriate interface will work." msgstr "" "安裝一個 :class:`OpenerDirector` 實例作為預設的全域 opener。僅在當你想要讓 " -"urlopen 使用該 opener 時安裝一個 opener,否則的話應直接呼" -"叫 :meth:`OpenerDirector.open` 而非 :func:`~urllib.request.urlopen`。程式碼不" -"會檢查 class 是否真的為 :class:`OpenerDirector`,而是任何具有正確介面的 " -"class 都能適用。" +"urlopen 使用該 opener 時安裝一個 opener,否則的話應直接呼叫 :meth:" +"`OpenerDirector.open` 而非 :func:`~urllib.request.urlopen`。程式碼不會檢查 " +"class 是否真的為 :class:`OpenerDirector`,而是任何具有正確介面的 class 都能適" +"用。" #: ../../library/urllib.request.rst:133 msgid "" @@ -259,15 +258,19 @@ msgid "" "call the constructor without any parameters). Instances of the following " "classes will be in front of the *handler*\\s, unless the *handler*\\s " "contain them, instances of them or subclasses of them: :class:`ProxyHandler` " -"(if proxy settings are " -"detected), :class:`UnknownHandler`, :class:`HTTPHandler`, :class:`HTTPDefaultErrorHandler`, :class:`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`, :class:`HTTPErrorProcessor`." +"(if proxy settings are detected), :class:`UnknownHandler`, :class:" +"`HTTPHandler`, :class:`HTTPDefaultErrorHandler`, :class:" +"`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`, :class:" +"`HTTPErrorProcessor`." msgstr "" "回傳一個 :class:`OpenerDirector` 實例,以給定的順序把 handlers 串接起來。" "*handler*\\s 可以是 :class:`BaseHandler` 的實例,亦或是 :class:`BaseHandler` " "的 subclasses(這個情況下必須有不帶參數的建構函式能夠被呼叫)。以下 classes " "的實例順位會在 *handler*\\s 之前,除非 *handler*\\s 已經包含它們,是它們的實" "例,或是它們的 subclasses::class:`ProxyHandler`\\ (如果代理服務設定被偵測" -"到)、:class:`UnknownHandler`、:class:`HTTPHandler`、:class:`HTTPDefaultErrorHandler`、:class:`HTTPRedirectHandler`、:class:`FTPHandler`、:class:`FileHandler`、:class:`HTTPErrorProcessor`。" +"到)、:class:`UnknownHandler`、:class:`HTTPHandler`、:class:" +"`HTTPDefaultErrorHandler`、:class:`HTTPRedirectHandler`、:class:" +"`FTPHandler`、:class:`FileHandler`、:class:`HTTPErrorProcessor`。" #: ../../library/urllib.request.rst:143 msgid "" @@ -287,10 +290,10 @@ msgstr "" #: ../../library/urllib.request.rst:152 msgid "" -"Convert the given local path to a ``file:`` URL. This function " -"uses :func:`~urllib.parse.quote` function to encode the path. For historical " -"reasons, the return value omits the ``file:`` scheme prefix. This example " -"shows the function being used on Windows::" +"Convert the given local path to a ``file:`` URL. This function uses :func:" +"`~urllib.parse.quote` function to encode the path. For historical reasons, " +"the return value omits the ``file:`` scheme prefix. This example shows the " +"function being used on Windows::" msgstr "" #: ../../library/urllib.request.rst:157 @@ -307,10 +310,10 @@ msgstr "" #: ../../library/urllib.request.rst:165 msgid "" -"Convert the given ``file:`` URL to a local path. This function " -"uses :func:`~urllib.parse.unquote` to decode the URL. For historical " -"reasons, the given value *must* omit the ``file:`` scheme prefix. This " -"example shows the function being used on Windows::" +"Convert the given ``file:`` URL to a local path. This function uses :func:" +"`~urllib.parse.unquote` to decode the URL. For historical reasons, the given " +"value *must* omit the ``file:`` scheme prefix. This example shows the " +"function being used on Windows::" msgstr "" #: ../../library/urllib.request.rst:170 @@ -392,11 +395,11 @@ msgstr "" #: ../../library/urllib.request.rst:214 msgid "" -"For an HTTP POST request method, *data* should be a buffer in the " -"standard :mimetype:`application/x-www-form-urlencoded` format. " -"The :func:`urllib.parse.urlencode` function takes a mapping or sequence of 2-" -"tuples and returns an ASCII string in this format. It should be encoded to " -"bytes before being used as the *data* parameter." +"For an HTTP POST request method, *data* should be a buffer in the standard :" +"mimetype:`application/x-www-form-urlencoded` format. The :func:`urllib." +"parse.urlencode` function takes a mapping or sequence of 2-tuples and " +"returns an ASCII string in this format. It should be encoded to bytes before " +"being used as the *data* parameter." msgstr "" "對於一個 HTTP POST 請求方法,*data* 應為一個標準 :mimetype:`application/x-" "www-form-urlencoded` 格式的 buffer。:func:`urllib.parse.urlencode` 方法接受一" @@ -405,10 +408,10 @@ msgstr "" #: ../../library/urllib.request.rst:220 msgid "" -"*headers* should be a dictionary, and will be treated as " -"if :meth:`add_header` was called with each key and value as arguments. This " -"is often used to \"spoof\" the ``User-Agent`` header value, which is used by " -"a browser to identify itself -- some HTTP servers only allow requests coming " +"*headers* should be a dictionary, and will be treated as if :meth:" +"`add_header` was called with each key and value as arguments. This is often " +"used to \"spoof\" the ``User-Agent`` header value, which is used by a " +"browser to identify itself -- some HTTP servers only allow requests coming " "from common browsers as opposed to scripts. For example, Mozilla Firefox may " "identify itself as ``\"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 " "Firefox/2.0.0.11\"``, while :mod:`urllib`'s default user agent string is " @@ -419,9 +422,10 @@ msgstr "" "叫 :meth:`add_header`。經常用於「偽裝」 ``User-Agent`` header 的值,這個 " "header 是用來讓一個瀏覽器向伺服器表明自己的身分 --- 有些 HTTP 伺服器僅允許來" "自普通瀏覽器的請求,而不接受來自程式腳本的請求。例如,Mozilla Firefox 會將 " -"header 的值設為 ``\"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/" -"2.0.0.11\"``,而 :mod:`urllib` 的值則是 ``\"Python-urllib/2.6\"``\\ (在 " -"Python 2.6 上)。所有 header 的鍵都會以 camel case(駝峰式大小寫)來傳送。" +"header 的值設為 ``\"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 " +"Firefox/2.0.0.11\"``,而 :mod:`urllib` 的值則是 ``\"Python-urllib/2.6\"``\\ " +"(在 Python 2.6 上)。所有 header 的鍵都會以 camel case(駝峰式大小寫)來傳" +"送。" #: ../../library/urllib.request.rst:231 msgid "" @@ -444,16 +448,16 @@ msgstr "" #: ../../library/urllib.request.rst:239 msgid "" "*origin_req_host* should be the request-host of the origin transaction, as " -"defined by :rfc:`2965`. It defaults to " -"``http.cookiejar.request_host(self)``. This is the host name or IP address " -"of the original request that was initiated by the user. For example, if the " -"request is for an image in an HTML document, this should be the request-host " -"of the request for the page containing the image." +"defined by :rfc:`2965`. It defaults to ``http.cookiejar." +"request_host(self)``. This is the host name or IP address of the original " +"request that was initiated by the user. For example, if the request is for " +"an image in an HTML document, this should be the request-host of the request " +"for the page containing the image." msgstr "" -"*origin_req_host* 應為原始傳輸互動的請求主機 (request-host),如同" -"在 :rfc:`2965` 中的定義。預設值為 ``http.cookiejar.request_host(self)``。這是" -"使用者發起的原始請求的主機名稱或是 IP 位址。例如當請求是要求一個 HTML 文件中" -"的一個影像,則這個屬性應為請求包含影像頁面的請求主機。" +"*origin_req_host* 應為原始傳輸互動的請求主機 (request-host),如同在 :rfc:" +"`2965` 中的定義。預設值為 ``http.cookiejar.request_host(self)``。這是使用者發" +"起的原始請求的主機名稱或是 IP 位址。例如當請求是要求一個 HTML 文件中的一個影" +"像,則這個屬性應為請求包含影像頁面的請求主機。" #: ../../library/urllib.request.rst:247 msgid "" @@ -471,11 +475,11 @@ msgstr "" #: ../../library/urllib.request.rst:254 msgid "" "*method* should be a string that indicates the HTTP request method that will " -"be used (e.g. ``'HEAD'``). If provided, its value is stored in " -"the :attr:`~Request.method` attribute and is used by :meth:`get_method`. The " -"default is ``'GET'`` if *data* is ``None`` or ``'POST'`` otherwise. " -"Subclasses may indicate a different default method by setting " -"the :attr:`~Request.method` attribute in the class itself." +"be used (e.g. ``'HEAD'``). If provided, its value is stored in the :attr:" +"`~Request.method` attribute and is used by :meth:`get_method`. The default " +"is ``'GET'`` if *data* is ``None`` or ``'POST'`` otherwise. Subclasses may " +"indicate a different default method by setting the :attr:`~Request.method` " +"attribute in the class itself." msgstr "" "*method* 應為一個標示 HTTP 請求方法的字串(例如:``'HEAD'``)。如果有提供值," "則會被存在 :attr:`~Request.method` 屬性中且被 :meth:`get_method` 所使用。當 " @@ -594,9 +598,9 @@ msgstr "" msgid "" "This is a mixin class that helps with HTTP authentication, both to the " "remote host and to a proxy. *password_mgr*, if given, should be something " -"that is compatible with :class:`HTTPPasswordMgr`; refer to " -"section :ref:`http-password-mgr` for information on the interface that must " -"be supported. If *passwd_mgr* also provides ``is_authenticated`` and " +"that is compatible with :class:`HTTPPasswordMgr`; refer to section :ref:" +"`http-password-mgr` for information on the interface that must be " +"supported. If *passwd_mgr* also provides ``is_authenticated`` and " "``update_authenticated`` methods (see :ref:`http-password-mgr-with-prior-" "auth`), then the handler will use the ``is_authenticated`` result for a " "given URI to determine whether or not to send authentication credentials " @@ -634,9 +638,8 @@ msgstr "" msgid "" "This is a mixin class that helps with HTTP authentication, both to the " "remote host and to a proxy. *password_mgr*, if given, should be something " -"that is compatible with :class:`HTTPPasswordMgr`; refer to " -"section :ref:`http-password-mgr` for information on the interface that must " -"be supported." +"that is compatible with :class:`HTTPPasswordMgr`; refer to section :ref:" +"`http-password-mgr` for information on the interface that must be supported." msgstr "" #: ../../library/urllib.request.rst:404 @@ -712,9 +715,9 @@ msgstr "" #: ../../library/urllib.request.rst:487 msgid "" -"Request.full_url is a property with setter, getter and a deleter. " -"Getting :attr:`~Request.full_url` returns the original request URL with the " -"fragment, if it was present." +"Request.full_url is a property with setter, getter and a deleter. Getting :" +"attr:`~Request.full_url` returns the original request URL with the fragment, " +"if it was present." msgstr "" #: ../../library/urllib.request.rst:493 @@ -749,8 +752,8 @@ msgstr "" #: ../../library/urllib.request.rst:519 msgid "" -"boolean, indicates whether the request is unverifiable as defined " -"by :rfc:`2965`." +"boolean, indicates whether the request is unverifiable as defined by :rfc:" +"`2965`." msgstr "" #: ../../library/urllib.request.rst:524 @@ -772,10 +775,10 @@ msgstr "" #: ../../library/urllib.request.rst:541 msgid "" -"Return a string indicating the HTTP request method. " -"If :attr:`Request.method` is not ``None``, return its value, otherwise " -"return ``'GET'`` if :attr:`Request.data` is ``None``, or ``'POST'`` if it's " -"not. This is only meaningful for HTTP requests." +"Return a string indicating the HTTP request method. If :attr:`Request." +"method` is not ``None``, return its value, otherwise return ``'GET'`` if :" +"attr:`Request.data` is ``None``, or ``'POST'`` if it's not. This is only " +"meaningful for HTTP requests." msgstr "" #: ../../library/urllib.request.rst:546 @@ -856,10 +859,10 @@ msgid "" "*handler* should be an instance of :class:`BaseHandler`. The following " "methods are searched, and added to the possible chains (note that HTTP " "errors are a special case). Note that, in the following, *protocol* should " -"be replaced with the actual protocol to handle, for " -"example :meth:`http_response` would be the HTTP protocol response handler. " -"Also *type* should be replaced with the actual HTTP code, for " -"example :meth:`http_error_404` would handle HTTP 404 errors." +"be replaced with the actual protocol to handle, for example :meth:" +"`http_response` would be the HTTP protocol response handler. Also *type* " +"should be replaced with the actual HTTP code, for example :meth:" +"`http_error_404` would handle HTTP 404 errors." msgstr "" #: ../../library/urllib.request.rst:631 @@ -953,27 +956,25 @@ msgstr "" #: ../../library/urllib.request.rst:689 msgid "" "Handlers with a method named like :meth:`!_open` are called to " -"handle the request. This stage ends when a handler either returns a non-" -"\\ :const:`None` value (ie. a response), or raises an exception " -"(usually :exc:`~urllib.error.URLError`). Exceptions are allowed to " -"propagate." +"handle the request. This stage ends when a handler either returns a non-\\ :" +"const:`None` value (ie. a response), or raises an exception (usually :exc:" +"`~urllib.error.URLError`). Exceptions are allowed to propagate." msgstr "" #: ../../library/urllib.request.rst:694 msgid "" -"In fact, the above algorithm is first tried for methods " -"named :meth:`~BaseHandler.default_open`. If all such methods " -"return :const:`None`, the algorithm is repeated for methods named " -"like :meth:`!_open`. If all such methods return :const:`None`, " -"the algorithm is repeated for methods " +"In fact, the above algorithm is first tried for methods named :meth:" +"`~BaseHandler.default_open`. If all such methods return :const:`None`, the " +"algorithm is repeated for methods named like :meth:`!_open`. If " +"all such methods return :const:`None`, the algorithm is repeated for methods " "named :meth:`~BaseHandler.unknown_open`." msgstr "" #: ../../library/urllib.request.rst:700 msgid "" "Note that the implementation of these methods may involve calls of the " -"parent :class:`OpenerDirector` instance's :meth:`~OpenerDirector.open` " -"and :meth:`~OpenerDirector.error` methods." +"parent :class:`OpenerDirector` instance's :meth:`~OpenerDirector.open` and :" +"meth:`~OpenerDirector.error` methods." msgstr "" #: ../../library/urllib.request.rst:704 @@ -1010,8 +1011,8 @@ msgstr "" #: ../../library/urllib.request.rst:732 msgid "" "The convention has been adopted that subclasses defining :meth:`!" -"_request` or :meth:`!_response` methods are " -"named :class:`!\\*Processor`; all others are named :class:`!\\*Handler`." +"_request` or :meth:`!_response` methods are named :class:" +"`!\\*Processor`; all others are named :class:`!\\*Handler`." msgstr "" #: ../../library/urllib.request.rst:739 @@ -1028,13 +1029,12 @@ msgstr "" #: ../../library/urllib.request.rst:748 msgid "" -"This method, if implemented, will be called by the " -"parent :class:`OpenerDirector`. It should return a file-like object as " -"described in the return value of the :meth:`~OpenerDirector.open` method " -"of :class:`OpenerDirector`, or ``None``. It should " -"raise :exc:`~urllib.error.URLError`, unless a truly exceptional thing " -"happens (for example, :exc:`MemoryError` should not be mapped " -"to :exc:`~urllib.error.URLError`)." +"This method, if implemented, will be called by the parent :class:" +"`OpenerDirector`. It should return a file-like object as described in the " +"return value of the :meth:`~OpenerDirector.open` method of :class:" +"`OpenerDirector`, or ``None``. It should raise :exc:`~urllib.error." +"URLError`, unless a truly exceptional thing happens (for example, :exc:" +"`MemoryError` should not be mapped to :exc:`~urllib.error.URLError`)." msgstr "" #: ../../library/urllib.request.rst:755 @@ -1049,9 +1049,9 @@ msgstr "" #: ../../library/urllib.request.rst:765 msgid "" -"This method, if defined, will be called by the " -"parent :class:`OpenerDirector`. Return values should be the same as " -"for :meth:`~BaseHandler.default_open`." +"This method, if defined, will be called by the parent :class:" +"`OpenerDirector`. Return values should be the same as for :meth:" +"`~BaseHandler.default_open`." msgstr "" #: ../../library/urllib.request.rst:771 @@ -1063,18 +1063,18 @@ msgstr "" #: ../../library/urllib.request.rst:775 msgid "" -"This method, if implemented, will be called by " -"the :attr:`parent` :class:`OpenerDirector`. Return values should be the " -"same as for :meth:`default_open`." +"This method, if implemented, will be called by the :attr:`parent` :class:" +"`OpenerDirector`. Return values should be the same as for :meth:" +"`default_open`." msgstr "" #: ../../library/urllib.request.rst:782 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "override it if they intend to provide a catch-all for otherwise unhandled " -"HTTP errors. It will be called automatically by " -"the :class:`OpenerDirector` getting the error, and should not normally be " -"called in other circumstances." +"HTTP errors. It will be called automatically by the :class:" +"`OpenerDirector` getting the error, and should not normally be called in " +"other circumstances." msgstr "" #: ../../library/urllib.request.rst:787 @@ -1087,8 +1087,8 @@ msgstr "" #: ../../library/urllib.request.rst:792 msgid "" -"Return values and exceptions raised should be the same as those " -"of :func:`urlopen`." +"Return values and exceptions raised should be the same as those of :func:" +"`urlopen`." msgstr "" #: ../../library/urllib.request.rst:799 @@ -1104,8 +1104,8 @@ msgstr "" #: ../../library/urllib.request.rst:805 msgid "" -"Arguments, return values and exceptions raised should be the same as " -"for :meth:`~BaseHandler.http_error_default`." +"Arguments, return values and exceptions raised should be the same as for :" +"meth:`~BaseHandler.http_error_default`." msgstr "" #: ../../library/urllib.request.rst:813 @@ -1116,9 +1116,9 @@ msgstr "" #: ../../library/urllib.request.rst:816 msgid "" -"This method, if defined, will be called by the " -"parent :class:`OpenerDirector`. *req* will be a :class:`Request` object. The " -"return value should be a :class:`Request` object." +"This method, if defined, will be called by the parent :class:" +"`OpenerDirector`. *req* will be a :class:`Request` object. The return value " +"should be a :class:`Request` object." msgstr "" #: ../../library/urllib.request.rst:825 @@ -1129,11 +1129,11 @@ msgstr "" #: ../../library/urllib.request.rst:828 msgid "" -"This method, if defined, will be called by the " -"parent :class:`OpenerDirector`. *req* will be a :class:`Request` object. " -"*response* will be an object implementing the same interface as the return " -"value of :func:`urlopen`. The return value should implement the same " -"interface as the return value of :func:`urlopen`." +"This method, if defined, will be called by the parent :class:" +"`OpenerDirector`. *req* will be a :class:`Request` object. *response* will " +"be an object implementing the same interface as the return value of :func:" +"`urlopen`. The return value should implement the same interface as the " +"return value of :func:`urlopen`." msgstr "" #: ../../library/urllib.request.rst:838 @@ -1160,19 +1160,18 @@ msgid "" "called by the default implementations of the :meth:`!http_error_30\\*` " "methods when a redirection is received from the server. If a redirection " "should take place, return a new :class:`Request` to allow :meth:`!" -"http_error_30\\*` to perform the redirect to *newurl*. Otherwise, " -"raise :exc:`~urllib.error.HTTPError` if no other handler should try to " -"handle this URL, or return ``None`` if you can't but another handler might." +"http_error_30\\*` to perform the redirect to *newurl*. Otherwise, raise :" +"exc:`~urllib.error.HTTPError` if no other handler should try to handle this " +"URL, or return ``None`` if you can't but another handler might." msgstr "" #: ../../library/urllib.request.rst:863 msgid "" -"The default implementation of this method does not strictly " -"follow :rfc:`2616`, which says that 301 and 302 responses to ``POST`` " -"requests must not be automatically redirected without confirmation by the " -"user. In reality, browsers do allow automatic redirection of these " -"responses, changing the POST to a ``GET``, and the default implementation " -"reproduces this behavior." +"The default implementation of this method does not strictly follow :rfc:" +"`2616`, which says that 301 and 302 responses to ``POST`` requests must not " +"be automatically redirected without confirmation by the user. In reality, " +"browsers do allow automatic redirection of these responses, changing the " +"POST to a ``GET``, and the default implementation reproduces this behavior." msgstr "" #: ../../library/urllib.request.rst:872 @@ -1237,8 +1236,8 @@ msgstr "HTTPPasswordMgr 物件" #: ../../library/urllib.request.rst:935 msgid "" -"These methods are available on :class:`HTTPPasswordMgr` " -"and :class:`HTTPPasswordMgrWithDefaultRealm` objects." +"These methods are available on :class:`HTTPPasswordMgr` and :class:" +"`HTTPPasswordMgrWithDefaultRealm` objects." msgstr "" #: ../../library/urllib.request.rst:941 @@ -1274,10 +1273,10 @@ msgstr "" #: ../../library/urllib.request.rst:968 msgid "" -"*realm*, *uri*, *user*, *passwd* are as " -"for :meth:`HTTPPasswordMgr.add_password`. *is_authenticated* sets the " -"initial value of the ``is_authenticated`` flag for the given URI or list of " -"URIs. If *is_authenticated* is specified as ``True``, *realm* is ignored." +"*realm*, *uri*, *user*, *passwd* are as for :meth:`HTTPPasswordMgr." +"add_password`. *is_authenticated* sets the initial value of the " +"``is_authenticated`` flag for the given URI or list of URIs. If " +"*is_authenticated* is specified as ``True``, *realm* is ignored." msgstr "" #: ../../library/urllib.request.rst:976 @@ -1303,8 +1302,8 @@ msgid "" "Handle an authentication request by getting a user/password pair, and re-" "trying the request. *authreq* should be the name of the header where the " "information about the realm is included in the request, *host* specifies the " -"URL and path to authenticate for, *req* should be the " -"(failed) :class:`Request` object, and *headers* should be the error headers." +"URL and path to authenticate for, *req* should be the (failed) :class:" +"`Request` object, and *headers* should be the error headers." msgstr "" #: ../../library/urllib.request.rst:1006 @@ -1354,8 +1353,8 @@ msgstr "HTTPHandler 物件" #: ../../library/urllib.request.rst:1078 msgid "" -"Send an HTTP request, which can be either GET or POST, depending on " -"``req.has_data()``." +"Send an HTTP request, which can be either GET or POST, depending on ``req." +"data``." msgstr "" #: ../../library/urllib.request.rst:1085 @@ -1364,8 +1363,8 @@ msgstr "HTTPSHandler 物件" #: ../../library/urllib.request.rst:1090 msgid "" -"Send an HTTPS request, which can be either GET or POST, depending on " -"``req.has_data()``." +"Send an HTTPS request, which can be either GET or POST, depending on ``req." +"data``." msgstr "" #: ../../library/urllib.request.rst:1097 @@ -1446,8 +1445,8 @@ msgstr "" msgid "" "For non-200 error codes, this simply passes the job on to the :meth:`!" "http_error_\\` handler methods, via :meth:`OpenerDirector.error`. " -"Eventually, :class:`HTTPDefaultErrorHandler` will raise " -"an :exc:`~urllib.error.HTTPError` if no other handler handles the error." +"Eventually, :class:`HTTPDefaultErrorHandler` will raise an :exc:`~urllib." +"error.HTTPError` if no other handler handles the error." msgstr "" #: ../../library/urllib.request.rst:1186 @@ -1534,8 +1533,8 @@ msgstr "" #: ../../library/urllib.request.rst:1230 msgid "" -"It is also possible to achieve the same result without using " -"the :term:`context manager` approach::" +"It is also possible to achieve the same result without using the :term:" +"`context manager` approach::" msgstr "" #: ../../library/urllib.request.rst:1233 @@ -1644,11 +1643,11 @@ msgstr "" #: ../../library/urllib.request.rst:1288 msgid "" -":func:`build_opener` provides many handlers by default, including " -"a :class:`ProxyHandler`. By default, :class:`ProxyHandler` uses the " -"environment variables named ``_proxy``, where ```` is the " -"URL scheme involved. For example, the :envvar:`!http_proxy` environment " -"variable is read to obtain the HTTP proxy's URL." +":func:`build_opener` provides many handlers by default, including a :class:" +"`ProxyHandler`. By default, :class:`ProxyHandler` uses the environment " +"variables named ``_proxy``, where ```` is the URL scheme " +"involved. For example, the :envvar:`!http_proxy` environment variable is " +"read to obtain the HTTP proxy's URL." msgstr "" #: ../../library/urllib.request.rst:1294 @@ -1660,8 +1659,8 @@ msgstr "" #: ../../library/urllib.request.rst:1298 msgid "" -"proxy_handler = urllib.request.ProxyHandler({'http': 'http://" -"www.example.com:3128/'})\n" +"proxy_handler = urllib.request.ProxyHandler({'http': 'http://www.example." +"com:3128/'})\n" "proxy_auth_handler = urllib.request.ProxyBasicAuthHandler()\n" "proxy_auth_handler.add_password('realm', 'host', 'username', 'password')\n" "\n" @@ -1670,8 +1669,8 @@ msgid "" "with opener.open('http://www.example.com/login.html') as f:\n" " print(f.read().decode('utf-8'))" msgstr "" -"proxy_handler = urllib.request.ProxyHandler({'http': 'http://" -"www.example.com:3128/'})\n" +"proxy_handler = urllib.request.ProxyHandler({'http': 'http://www.example." +"com:3128/'})\n" "proxy_auth_handler = urllib.request.ProxyBasicAuthHandler()\n" "proxy_auth_handler.add_password('realm', 'host', 'username', 'password')\n" "\n" @@ -1728,10 +1727,9 @@ msgstr "" #: ../../library/urllib.request.rst:1329 msgid "" -"Also, remember that a few standard headers (:mailheader:`Content-" -"Length`, :mailheader:`Content-Type` and :mailheader:`Host`) are added when " -"the :class:`Request` is passed to :func:`urlopen` " -"(or :meth:`OpenerDirector.open`)." +"Also, remember that a few standard headers (:mailheader:`Content-Length`, :" +"mailheader:`Content-Type` and :mailheader:`Host`) are added when the :class:" +"`Request` is passed to :func:`urlopen` (or :meth:`OpenerDirector.open`)." msgstr "" #: ../../library/urllib.request.rst:1336 @@ -1843,9 +1841,9 @@ msgid "" "Copy a network object denoted by a URL to a local file. If the URL points to " "a local file, the object will not be copied unless filename is supplied. " "Return a tuple ``(filename, headers)`` where *filename* is the local file " -"name under which the object can be found, and *headers* is whatever " -"the :meth:`!info` method of the object returned by :func:`urlopen` returned " -"(for a remote object). Exceptions are the same as for :func:`urlopen`." +"name under which the object can be found, and *headers* is whatever the :" +"meth:`!info` method of the object returned by :func:`urlopen` returned (for " +"a remote object). Exceptions are the same as for :func:`urlopen`." msgstr "" #: ../../library/urllib.request.rst:1393 @@ -1867,14 +1865,14 @@ msgstr "" #: ../../library/urllib.request.rst:1404 msgid "" ">>> import urllib.request\n" -">>> local_filename, headers = urllib.request.urlretrieve('http://" -"python.org/')\n" +">>> local_filename, headers = urllib.request.urlretrieve('http://python." +"org/')\n" ">>> html = open(local_filename)\n" ">>> html.close()" msgstr "" ">>> import urllib.request\n" -">>> local_filename, headers = urllib.request.urlretrieve('http://" -"python.org/')\n" +">>> local_filename, headers = urllib.request.urlretrieve('http://python." +"org/')\n" ">>> html = open(local_filename)\n" ">>> html.close()" @@ -1882,9 +1880,9 @@ msgstr "" msgid "" "If the *url* uses the :file:`http:` scheme identifier, the optional *data* " "argument may be given to specify a ``POST`` request (normally the request " -"type is ``GET``). The *data* argument must be a bytes object in " -"standard :mimetype:`application/x-www-form-urlencoded` format; see " -"the :func:`urllib.parse.urlencode` function." +"type is ``GET``). The *data* argument must be a bytes object in standard :" +"mimetype:`application/x-www-form-urlencoded` format; see the :func:`urllib." +"parse.urlencode` function." msgstr "" #: ../../library/urllib.request.rst:1415 @@ -1924,8 +1922,8 @@ msgstr "" #: ../../library/urllib.request.rst:1440 msgid "" "Base class for opening and reading URLs. Unless you need to support opening " -"objects using schemes other than :file:`http:`, :file:`ftp:`, " -"or :file:`file:`, you probably want to use :class:`FancyURLopener`." +"objects using schemes other than :file:`http:`, :file:`ftp:`, or :file:`file:" +"`, you probably want to use :class:`FancyURLopener`." msgstr "" #: ../../library/urllib.request.rst:1444 @@ -1965,8 +1963,8 @@ msgid "" "Open *fullurl* using the appropriate protocol. This method sets up cache " "and proxy information, then calls the appropriate open method with its input " "arguments. If the scheme is not recognized, :meth:`open_unknown` is called. " -"The *data* argument has the same meaning as the *data* argument " -"of :func:`urlopen`." +"The *data* argument has the same meaning as the *data* argument of :func:" +"`urlopen`." msgstr "" #: ../../library/urllib.request.rst:1471 @@ -1980,35 +1978,35 @@ msgstr "" #: ../../library/urllib.request.rst:1480 msgid "" "Retrieves the contents of *url* and places it in *filename*. The return " -"value is a tuple consisting of a local filename and either " -"an :class:`email.message.Message` object containing the response headers " -"(for remote URLs) or ``None`` (for local URLs). The caller must then open " -"and read the contents of *filename*. If *filename* is not given and the URL " -"refers to a local file, the input filename is returned. If the URL is non-" -"local and *filename* is not given, the filename is the output " -"of :func:`tempfile.mktemp` with a suffix that matches the suffix of the last " -"path component of the input URL. If *reporthook* is given, it must be a " -"function accepting three numeric parameters: A chunk number, the maximum " -"size chunks are read in and the total size of the download (-1 if unknown). " -"It will be called once at the start and after each chunk of data is read " -"from the network. *reporthook* is ignored for local URLs." +"value is a tuple consisting of a local filename and either an :class:`email." +"message.Message` object containing the response headers (for remote URLs) or " +"``None`` (for local URLs). The caller must then open and read the contents " +"of *filename*. If *filename* is not given and the URL refers to a local " +"file, the input filename is returned. If the URL is non-local and " +"*filename* is not given, the filename is the output of :func:`tempfile." +"mktemp` with a suffix that matches the suffix of the last path component of " +"the input URL. If *reporthook* is given, it must be a function accepting " +"three numeric parameters: A chunk number, the maximum size chunks are read " +"in and the total size of the download (-1 if unknown). It will be called " +"once at the start and after each chunk of data is read from the network. " +"*reporthook* is ignored for local URLs." msgstr "" #: ../../library/urllib.request.rst:1493 msgid "" "If the *url* uses the :file:`http:` scheme identifier, the optional *data* " "argument may be given to specify a ``POST`` request (normally the request " -"type is ``GET``). The *data* argument must in " -"standard :mimetype:`application/x-www-form-urlencoded` format; see " -"the :func:`urllib.parse.urlencode` function." +"type is ``GET``). The *data* argument must in standard :mimetype:" +"`application/x-www-form-urlencoded` format; see the :func:`urllib.parse." +"urlencode` function." msgstr "" #: ../../library/urllib.request.rst:1502 msgid "" -"Variable that specifies the user agent of the opener object. To " -"get :mod:`urllib` to tell servers that it is a particular user agent, set " -"this in a subclass as a class variable or in the constructor before calling " -"the base constructor." +"Variable that specifies the user agent of the opener object. To get :mod:" +"`urllib` to tell servers that it is a particular user agent, set this in a " +"subclass as a class variable or in the constructor before calling the base " +"constructor." msgstr "" #: ../../library/urllib.request.rst:1512 @@ -2024,9 +2022,9 @@ msgstr "" #: ../../library/urllib.request.rst:1519 msgid "" -"For all other response codes, the " -"method :meth:`~BaseHandler.http_error_default` is called which you can " -"override in subclasses to handle the error appropriately." +"For all other response codes, the method :meth:`~BaseHandler." +"http_error_default` is called which you can override in subclasses to handle " +"the error appropriately." msgstr "" #: ../../library/urllib.request.rst:1524 @@ -2040,8 +2038,8 @@ msgstr "" #: ../../library/urllib.request.rst:1529 msgid "" -"The parameters to the constructor are the same as those " -"for :class:`URLopener`." +"The parameters to the constructor are the same as those for :class:" +"`URLopener`." msgstr "" #: ../../library/urllib.request.rst:1533 @@ -2118,9 +2116,9 @@ msgid "" "The data returned by :func:`urlopen` or :func:`urlretrieve` is the raw data " "returned by the server. This may be binary data (such as an image), plain " "text or (for example) HTML. The HTTP protocol provides type information in " -"the reply header, which can be inspected by looking at " -"the :mailheader:`Content-Type` header. If the returned data is HTML, you " -"can use the module :mod:`html.parser` to parse it." +"the reply header, which can be inspected by looking at the :mailheader:" +"`Content-Type` header. If the returned data is HTML, you can use the " +"module :mod:`html.parser` to parse it." msgstr "" #: ../../library/urllib.request.rst:1591 @@ -2149,9 +2147,9 @@ msgstr "" msgid "" "The :mod:`urllib.response` module defines functions and classes which define " "a minimal file-like interface, including ``read()`` and ``readline()``. " -"Functions defined by this module are used internally by " -"the :mod:`urllib.request` module. The typical response object is " -"a :class:`urllib.response.addinfourl` instance:" +"Functions defined by this module are used internally by the :mod:`urllib." +"request` module. The typical response object is a :class:`urllib.response." +"addinfourl` instance:" msgstr "" #: ../../library/urllib.request.rst:1622 @@ -2162,8 +2160,8 @@ msgstr "" #: ../../library/urllib.request.rst:1626 msgid "" -"Returns the headers of the response in the form of " -"an :class:`~email.message.EmailMessage` instance." +"Returns the headers of the response in the form of an :class:`~email.message." +"EmailMessage` instance." msgstr "" #: ../../library/urllib.request.rst:1632 @@ -2204,8 +2202,8 @@ msgstr "HTML" #~ "... print(f.read(300))\n" #~ "...\n" #~ "b'\\n\\n\\n\\n\\n\\n\\n\\n\\n\n" #~ "\\n\\n\\n\\n\\n\\n\\n\\n\\n\n" #~ "\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -94,8 +94,8 @@ msgid "" ">>> from zoneinfo import ZoneInfo\n" ">>> from datetime import datetime, timedelta\n" "\n" -">>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo(\"America/Los_Angeles" -"\"))\n" +">>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo(\"America/" +"Los_Angeles\"))\n" ">>> print(dt)\n" "2020-10-31 12:00:00-07:00\n" "\n" @@ -105,8 +105,8 @@ msgstr "" ">>> from zoneinfo import ZoneInfo\n" ">>> from datetime import datetime, timedelta\n" "\n" -">>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo(\"America/Los_Angeles" -"\"))\n" +">>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo(\"America/" +"Los_Angeles\"))\n" ">>> print(dt)\n" "2020-10-31 12:00:00-07:00\n" "\n" @@ -600,8 +600,8 @@ msgid "" msgstr "" "``ZoneInfo.no_cache(key)``:當從繞過快取的建構函式建構時,``ZoneInfo`` 物件也" "會按鍵序列化,但在去序列化時,去序列化過程會使用繞過快取的建構函式。如果 " -"``europe_berlin_pkl_nc`` 是一個包含從 ``ZoneInfo.no_cache(\"Europe/Berlin" -"\")`` 建構並封裝的字串,會預期以下行為:" +"``europe_berlin_pkl_nc`` 是一個包含從 ``ZoneInfo.no_cache(\"Europe/" +"Berlin\")`` 建構並封裝的字串,會預期以下行為:" #: ../../library/zoneinfo.rst:321 msgid "" @@ -617,13 +617,14 @@ msgstr "" #: ../../library/zoneinfo.rst:328 msgid "" -"``ZoneInfo.from_file(fobj, /, key=None)``: When constructed from a file, the " -"``ZoneInfo`` object raises an exception on pickling. If an end user wants to " -"pickle a ``ZoneInfo`` constructed from a file, it is recommended that they " -"use a wrapper type or a custom serialization function: either serializing by " -"key or storing the contents of the file object and serializing that." +"``ZoneInfo.from_file(file_obj, /, key=None)``: When constructed from a file, " +"the ``ZoneInfo`` object raises an exception on pickling. If an end user " +"wants to pickle a ``ZoneInfo`` constructed from a file, it is recommended " +"that they use a wrapper type or a custom serialization function: either " +"serializing by key or storing the contents of the file object and " +"serializing that." msgstr "" -"``ZoneInfo.from_file(fobj, /, key=None)``:當從檔案建構時,``ZoneInfo`` 物件" +"``ZoneInfo.from_file(file_obj, /, key=None)``:當從檔案建構時,``ZoneInfo`` 物件" "在封裝時會引發例外。如果終端使用者想要封裝一個從檔案建構的 ``ZoneInfo``,建議" "他們使用包裝器型別或自訂序列化函式:可以按鍵序列化,或儲存檔案物件的內容並將" "其序列化。" @@ -680,9 +681,9 @@ msgid "" "Locale Data Repository) to get more user-friendly strings. See also the " "cautionary note on :attr:`ZoneInfo.key`." msgstr "" -"這些值並非設計來暴露給終端使用者;對於面向使用者的元素,應用程式應使用像 " -"CLDR(Unicode 通用地區資料儲存庫)這樣的工具來取得更友善的使用者字串。另請參" -"閱關於 :attr:`ZoneInfo.key` 的警示說明。" +"這些值並非設計來暴露給終端使用者;對於面向使用者的元素,應用程式應使用像 CLDR" +"(Unicode 通用地區資料儲存庫)這樣的工具來取得更友善的使用者字串。另請參閱關" +"於 :attr:`ZoneInfo.key` 的警示說明。" #: ../../library/zoneinfo.rst:369 msgid "" diff --git a/reference/expressions.po b/reference/expressions.po index 5a0217870b..627c19e115 100644 --- a/reference/expressions.po +++ b/reference/expressions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-23 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 16:17+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -90,16 +90,16 @@ msgstr "" #: ../../reference/expressions.rst:70 msgid "" -"An identifier occurring as an atom is a name. See " -"section :ref:`identifiers` for lexical definition and section :ref:`naming` " -"for documentation of naming and binding." +"An identifier occurring as an atom is a name. See section :ref:" +"`identifiers` for lexical definition and section :ref:`naming` for " +"documentation of naming and binding." msgstr "" #: ../../reference/expressions.rst:76 msgid "" "When the name is bound to an object, evaluation of the atom yields that " -"object. When a name is not bound, an attempt to evaluate it raises " -"a :exc:`NameError` exception." +"object. When a name is not bound, an attempt to evaluate it raises a :exc:" +"`NameError` exception." msgstr "" #: ../../reference/expressions.rst:87 @@ -245,8 +245,8 @@ msgstr "" #: ../../reference/expressions.rst:203 msgid "" -"they are computed via a set of looping and filtering instructions, called " -"a :dfn:`comprehension`." +"they are computed via a set of looping and filtering instructions, called a :" +"dfn:`comprehension`." msgstr "" #: ../../reference/expressions.rst:211 @@ -255,9 +255,9 @@ msgstr "" #: ../../reference/expressions.rst:219 msgid "" -"The comprehension consists of a single expression followed by at least " -"one :keyword:`!for` clause and zero or more :keyword:`!for` or :keyword:`!" -"if` clauses. In this case, the elements of the new container are those that " +"The comprehension consists of a single expression followed by at least one :" +"keyword:`!for` clause and zero or more :keyword:`!for` or :keyword:`!if` " +"clauses. In this case, the elements of the new container are those that " "would be produced by considering each of the :keyword:`!for` or :keyword:`!" "if` clauses a block, nesting from left to right, and evaluating the " "expression to produce an element each time the innermost block is reached." @@ -292,8 +292,8 @@ msgstr "" msgid "" "Since Python 3.6, in an :keyword:`async def` function, an :keyword:`!async " "for` clause may be used to iterate over a :term:`asynchronous iterator`. A " -"comprehension in an :keyword:`!async def` function may consist of either " -"a :keyword:`!for` or :keyword:`!async for` clause following the leading " +"comprehension in an :keyword:`!async def` function may consist of either a :" +"keyword:`!for` or :keyword:`!async for` clause following the leading " "expression, may contain additional :keyword:`!for` or :keyword:`!async for` " "clauses, and may also use :keyword:`await` expressions." msgstr "" @@ -312,7 +312,7 @@ msgstr "" msgid "Asynchronous comprehensions were introduced." msgstr "" -#: ../../reference/expressions.rst:261 ../../reference/expressions.rst:439 +#: ../../reference/expressions.rst:261 ../../reference/expressions.rst:440 msgid "``yield`` and ``yield from`` prohibited in the implicitly nested scope." msgstr "" @@ -414,11 +414,11 @@ msgstr "" #: ../../reference/expressions.rst:375 msgid "" -"Restrictions on the types of the key values are listed earlier in " -"section :ref:`types`. (To summarize, the key type should " -"be :term:`hashable`, which excludes all mutable objects.) Clashes between " -"duplicate keys are not detected; the last value (textually rightmost in the " -"display) stored for a given key value prevails." +"Restrictions on the types of the key values are listed earlier in section :" +"ref:`types`. (To summarize, the key type should be :term:`hashable`, which " +"excludes all mutable objects.) Clashes between duplicate keys are not " +"detected; the last value (textually rightmost in the display) stored for a " +"given key value prevails." msgstr "" #: ../../reference/expressions.rst:381 @@ -446,11 +446,12 @@ msgstr "" #: ../../reference/expressions.rst:407 msgid "" -"Variables used in the generator expression are evaluated lazily when " -"the :meth:`~generator.__next__` method is called for the generator object " -"(in the same fashion as normal generators). However, the iterable " -"expression in the leftmost :keyword:`!for` clause is immediately evaluated, " -"so that an error produced by it will be emitted at the point where the " +"Variables used in the generator expression are evaluated lazily when the :" +"meth:`~generator.__next__` method is called for the generator object (in the " +"same fashion as normal generators). However, the iterable expression in the " +"leftmost :keyword:`!for` clause is immediately evaluated, and the :term:" +"`iterator` is immediately created for that iterable, so that an error " +"produced while creating the iterator will be emitted at the point where the " "generator expression is defined, rather than at the point where the first " "value is retrieved. Subsequent :keyword:`!for` clauses and any filter " "condition in the leftmost :keyword:`!for` clause cannot be evaluated in the " @@ -458,54 +459,54 @@ msgid "" "iterable. For example: ``(x*y for x in range(10) for y in range(x, x+10))``." msgstr "" -#: ../../reference/expressions.rst:418 +#: ../../reference/expressions.rst:419 msgid "" "The parentheses can be omitted on calls with only one argument. See " "section :ref:`calls` for details." msgstr "" -#: ../../reference/expressions.rst:421 +#: ../../reference/expressions.rst:422 msgid "" "To avoid interfering with the expected operation of the generator expression " "itself, ``yield`` and ``yield from`` expressions are prohibited in the " "implicitly defined generator." msgstr "" -#: ../../reference/expressions.rst:425 +#: ../../reference/expressions.rst:426 msgid "" -"If a generator expression contains either :keyword:`!async for` clauses " -"or :keyword:`await` expressions it is called an :dfn:`asynchronous generator " +"If a generator expression contains either :keyword:`!async for` clauses or :" +"keyword:`await` expressions it is called an :dfn:`asynchronous generator " "expression`. An asynchronous generator expression returns a new " -"asynchronous generator object, which is an asynchronous iterator " -"(see :ref:`async-iterators`)." +"asynchronous generator object, which is an asynchronous iterator (see :ref:" +"`async-iterators`)." msgstr "" -#: ../../reference/expressions.rst:431 +#: ../../reference/expressions.rst:432 msgid "Asynchronous generator expressions were introduced." msgstr "" -#: ../../reference/expressions.rst:434 +#: ../../reference/expressions.rst:435 msgid "" "Prior to Python 3.7, asynchronous generator expressions could only appear " "in :keyword:`async def` coroutines. Starting with 3.7, any function can use " "asynchronous generator expressions." msgstr "" -#: ../../reference/expressions.rst:446 +#: ../../reference/expressions.rst:447 msgid "Yield expressions" msgstr "" -#: ../../reference/expressions.rst:459 +#: ../../reference/expressions.rst:460 msgid "" "The yield expression is used when defining a :term:`generator` function or " "an :term:`asynchronous generator` function and thus can only be used in the " "body of a function definition. Using a yield expression in a function's " -"body causes that function to be a generator function, and using it in " -"an :keyword:`async def` function's body causes that coroutine function to be " -"an asynchronous generator function. For example::" +"body causes that function to be a generator function, and using it in an :" +"keyword:`async def` function's body causes that coroutine function to be an " +"asynchronous generator function. For example::" msgstr "" -#: ../../reference/expressions.rst:466 +#: ../../reference/expressions.rst:467 msgid "" "def gen(): # defines a generator function\n" " yield 123\n" @@ -514,48 +515,48 @@ msgid "" " yield 123" msgstr "" -#: ../../reference/expressions.rst:472 +#: ../../reference/expressions.rst:473 msgid "" "Due to their side effects on the containing scope, ``yield`` expressions are " "not permitted as part of the implicitly defined scopes used to implement " "comprehensions and generator expressions." msgstr "" -#: ../../reference/expressions.rst:476 +#: ../../reference/expressions.rst:477 msgid "" "Yield expressions prohibited in the implicitly nested scopes used to " "implement comprehensions and generator expressions." msgstr "" -#: ../../reference/expressions.rst:480 +#: ../../reference/expressions.rst:481 msgid "" "Generator functions are described below, while asynchronous generator " "functions are described separately in section :ref:`asynchronous-generator-" "functions`." msgstr "" -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:485 msgid "" "When a generator function is called, it returns an iterator known as a " "generator. That generator then controls the execution of the generator " "function. The execution starts when one of the generator's methods is " "called. At that time, the execution proceeds to the first yield expression, " -"where it is suspended again, returning the value of :token:`~python-" -"grammar:yield_list` to the generator's caller, or ``None`` " -"if :token:`~python-grammar:yield_list` is omitted. By suspended, we mean " -"that all local state is retained, including the current bindings of local " -"variables, the instruction pointer, the internal evaluation stack, and the " -"state of any exception handling. When the execution is resumed by calling " -"one of the generator's methods, the function can proceed exactly as if the " -"yield expression were just another external call. The value of the yield " +"where it is suspended again, returning the value of :token:`~python-grammar:" +"yield_list` to the generator's caller, or ``None`` if :token:`~python-" +"grammar:yield_list` is omitted. By suspended, we mean that all local state " +"is retained, including the current bindings of local variables, the " +"instruction pointer, the internal evaluation stack, and the state of any " +"exception handling. When the execution is resumed by calling one of the " +"generator's methods, the function can proceed exactly as if the yield " +"expression were just another external call. The value of the yield " "expression after resuming depends on the method which resumed the " -"execution. If :meth:`~generator.__next__` is used (typically via either " -"a :keyword:`for` or the :func:`next` builtin) then the result " -"is :const:`None`. Otherwise, if :meth:`~generator.send` is used, then the " -"result will be the value passed in to that method." +"execution. If :meth:`~generator.__next__` is used (typically via either a :" +"keyword:`for` or the :func:`next` builtin) then the result is :const:" +"`None`. Otherwise, if :meth:`~generator.send` is used, then the result will " +"be the value passed in to that method." msgstr "" -#: ../../reference/expressions.rst:504 +#: ../../reference/expressions.rst:505 msgid "" "All of this makes generator functions quite similar to coroutines; they " "yield multiple times, they have more than one entry point and their " @@ -564,122 +565,121 @@ msgid "" "the control is always transferred to the generator's caller." msgstr "" -#: ../../reference/expressions.rst:510 +#: ../../reference/expressions.rst:511 msgid "" "Yield expressions are allowed anywhere in a :keyword:`try` construct. If " "the generator is not resumed before it is finalized (by reaching a zero " -"reference count or by being garbage collected), the generator-" -"iterator's :meth:`~generator.close` method will be called, allowing any " -"pending :keyword:`finally` clauses to execute." +"reference count or by being garbage collected), the generator-iterator's :" +"meth:`~generator.close` method will be called, allowing any pending :keyword:" +"`finally` clauses to execute." msgstr "" -#: ../../reference/expressions.rst:519 +#: ../../reference/expressions.rst:520 msgid "" "When ``yield from `` is used, the supplied expression must be an " "iterable. The values produced by iterating that iterable are passed directly " -"to the caller of the current generator's methods. Any values passed in " -"with :meth:`~generator.send` and any exceptions passed in " -"with :meth:`~generator.throw` are passed to the underlying iterator if it " -"has the appropriate methods. If this is not the case, " -"then :meth:`~generator.send` will raise :exc:`AttributeError` " -"or :exc:`TypeError`, while :meth:`~generator.throw` will just raise the " -"passed in exception immediately." +"to the caller of the current generator's methods. Any values passed in with :" +"meth:`~generator.send` and any exceptions passed in with :meth:`~generator." +"throw` are passed to the underlying iterator if it has the appropriate " +"methods. If this is not the case, then :meth:`~generator.send` will raise :" +"exc:`AttributeError` or :exc:`TypeError`, while :meth:`~generator.throw` " +"will just raise the passed in exception immediately." msgstr "" -#: ../../reference/expressions.rst:528 +#: ../../reference/expressions.rst:529 msgid "" "When the underlying iterator is complete, the :attr:`~StopIteration.value` " "attribute of the raised :exc:`StopIteration` instance becomes the value of " -"the yield expression. It can be either set explicitly when " -"raising :exc:`StopIteration`, or automatically when the subiterator is a " -"generator (by returning a value from the subgenerator)." +"the yield expression. It can be either set explicitly when raising :exc:" +"`StopIteration`, or automatically when the subiterator is a generator (by " +"returning a value from the subgenerator)." msgstr "" -#: ../../reference/expressions.rst:534 +#: ../../reference/expressions.rst:535 msgid "Added ``yield from `` to delegate control flow to a subiterator." msgstr "" -#: ../../reference/expressions.rst:537 +#: ../../reference/expressions.rst:538 msgid "" "The parentheses may be omitted when the yield expression is the sole " "expression on the right hand side of an assignment statement." msgstr "" -#: ../../reference/expressions.rst:542 +#: ../../reference/expressions.rst:543 msgid ":pep:`255` - Simple Generators" msgstr "" -#: ../../reference/expressions.rst:543 +#: ../../reference/expressions.rst:544 msgid "" "The proposal for adding generators and the :keyword:`yield` statement to " "Python." msgstr "" -#: ../../reference/expressions.rst:545 +#: ../../reference/expressions.rst:546 msgid ":pep:`342` - Coroutines via Enhanced Generators" msgstr "" -#: ../../reference/expressions.rst:546 +#: ../../reference/expressions.rst:547 msgid "" "The proposal to enhance the API and syntax of generators, making them usable " "as simple coroutines." msgstr "" -#: ../../reference/expressions.rst:549 +#: ../../reference/expressions.rst:550 msgid ":pep:`380` - Syntax for Delegating to a Subgenerator" msgstr "" -#: ../../reference/expressions.rst:550 +#: ../../reference/expressions.rst:551 msgid "" "The proposal to introduce the :token:`~python-grammar:yield_from` syntax, " "making delegation to subgenerators easy." msgstr "" -#: ../../reference/expressions.rst:553 +#: ../../reference/expressions.rst:554 msgid ":pep:`525` - Asynchronous Generators" msgstr "" -#: ../../reference/expressions.rst:554 +#: ../../reference/expressions.rst:555 msgid "" "The proposal that expanded on :pep:`492` by adding generator capabilities to " "coroutine functions." msgstr "" -#: ../../reference/expressions.rst:561 +#: ../../reference/expressions.rst:562 msgid "Generator-iterator methods" msgstr "" -#: ../../reference/expressions.rst:563 +#: ../../reference/expressions.rst:564 msgid "" "This subsection describes the methods of a generator iterator. They can be " "used to control the execution of a generator function." msgstr "" -#: ../../reference/expressions.rst:566 +#: ../../reference/expressions.rst:567 msgid "" "Note that calling any of the generator methods below when the generator is " "already executing raises a :exc:`ValueError` exception." msgstr "" -#: ../../reference/expressions.rst:574 +#: ../../reference/expressions.rst:575 msgid "" "Starts the execution of a generator function or resumes it at the last " -"executed yield expression. When a generator function is resumed with " -"a :meth:`~generator.__next__` method, the current yield expression always " +"executed yield expression. When a generator function is resumed with a :" +"meth:`~generator.__next__` method, the current yield expression always " "evaluates to :const:`None`. The execution then continues to the next yield " -"expression, where the generator is suspended again, and the value of " -"the :token:`~python-grammar:yield_list` is returned to :meth:`__next__`'s " -"caller. If the generator exits without yielding another value, " -"a :exc:`StopIteration` exception is raised." +"expression, where the generator is suspended again, and the value of the :" +"token:`~python-grammar:yield_list` is returned to :meth:`__next__`'s " +"caller. If the generator exits without yielding another value, a :exc:" +"`StopIteration` exception is raised." msgstr "" -#: ../../reference/expressions.rst:583 +#: ../../reference/expressions.rst:584 msgid "" "This method is normally called implicitly, e.g. by a :keyword:`for` loop, or " "by the built-in :func:`next` function." msgstr "" -#: ../../reference/expressions.rst:589 +#: ../../reference/expressions.rst:590 msgid "" "Resumes the execution and \"sends\" a value into the generator function. " "The *value* argument becomes the result of the current yield expression. " @@ -690,7 +690,7 @@ msgid "" "expression that could receive the value." msgstr "" -#: ../../reference/expressions.rst:601 +#: ../../reference/expressions.rst:602 msgid "" "Raises an exception at the point where the generator was paused, and returns " "the next value yielded by the generator function. If the generator exits " @@ -699,13 +699,13 @@ msgid "" "a different exception, then that exception propagates to the caller." msgstr "" -#: ../../reference/expressions.rst:607 +#: ../../reference/expressions.rst:608 msgid "" "In typical use, this is called with a single exception instance similar to " "the way the :keyword:`raise` keyword is used." msgstr "" -#: ../../reference/expressions.rst:610 +#: ../../reference/expressions.rst:611 msgid "" "For backwards compatibility, however, the second signature is supported, " "following a convention from older versions of Python. The *type* argument " @@ -716,42 +716,44 @@ msgid "" "*value* may be cleared." msgstr "" -#: ../../reference/expressions.rst:621 ../../reference/expressions.rst:805 +#: ../../reference/expressions.rst:622 ../../reference/expressions.rst:808 msgid "" "The second signature \\(type\\[, value\\[, traceback\\]\\]\\) is deprecated " "and may be removed in a future version of Python." msgstr "" -#: ../../reference/expressions.rst:629 +#: ../../reference/expressions.rst:630 msgid "" -"Raises a :exc:`GeneratorExit` at the point where the generator function was " -"paused. If the generator function catches the exception and returns a " -"value, this value is returned from :meth:`close`. If the generator function " -"is already closed, or raises :exc:`GeneratorExit` (by not catching the " -"exception), :meth:`close` returns :const:`None`. If the generator yields a " -"value, a :exc:`RuntimeError` is raised. If the generator raises any other " -"exception, it is propagated to the caller. If the generator has already " -"exited due to an exception or normal exit, :meth:`close` " -"returns :const:`None` and has no other effect." +"Raises a :exc:`GeneratorExit` exception at the point where the generator " +"function was paused (equivalent to calling ``throw(GeneratorExit)``). The " +"exception is raised by the yield expression where the generator was paused. " +"If the generator function catches the exception and returns a value, this " +"value is returned from :meth:`close`. If the generator function is already " +"closed, or raises :exc:`GeneratorExit` (by not catching the exception), :" +"meth:`close` returns :const:`None`. If the generator yields a value, a :exc:" +"`RuntimeError` is raised. If the generator raises any other exception, it " +"is propagated to the caller. If the generator has already exited due to an " +"exception or normal exit, :meth:`close` returns :const:`None` and has no " +"other effect." msgstr "" -#: ../../reference/expressions.rst:641 +#: ../../reference/expressions.rst:644 msgid "" -"If a generator returns a value upon being closed, the value is returned " -"by :meth:`close`." +"If a generator returns a value upon being closed, the value is returned by :" +"meth:`close`." msgstr "" -#: ../../reference/expressions.rst:647 +#: ../../reference/expressions.rst:650 msgid "Examples" msgstr "模組" -#: ../../reference/expressions.rst:649 +#: ../../reference/expressions.rst:652 msgid "" "Here is a simple example that demonstrates the behavior of generators and " "generator functions::" msgstr "" -#: ../../reference/expressions.rst:652 +#: ../../reference/expressions.rst:655 msgid "" ">>> def echo(value=None):\n" "... print(\"Execution starts when 'next()' is called for the first time." @@ -779,53 +781,52 @@ msgid "" "Don't forget to clean up when 'close()' is called." msgstr "" -#: ../../reference/expressions.rst:676 +#: ../../reference/expressions.rst:679 msgid "" "For examples using ``yield from``, see :ref:`pep-380` in \"What's New in " "Python.\"" msgstr "" -#: ../../reference/expressions.rst:682 +#: ../../reference/expressions.rst:685 msgid "Asynchronous generator functions" msgstr "非同步產生器函式" -#: ../../reference/expressions.rst:684 +#: ../../reference/expressions.rst:687 msgid "" -"The presence of a yield expression in a function or method defined " -"using :keyword:`async def` further defines the function as " -"an :term:`asynchronous generator` function." +"The presence of a yield expression in a function or method defined using :" +"keyword:`async def` further defines the function as an :term:`asynchronous " +"generator` function." msgstr "" -#: ../../reference/expressions.rst:688 +#: ../../reference/expressions.rst:691 msgid "" "When an asynchronous generator function is called, it returns an " "asynchronous iterator known as an asynchronous generator object. That object " "then controls the execution of the generator function. An asynchronous " "generator object is typically used in an :keyword:`async for` statement in a " -"coroutine function analogously to how a generator object would be used in " -"a :keyword:`for` statement." -msgstr "" - -#: ../../reference/expressions.rst:695 -msgid "" -"Calling one of the asynchronous generator's methods returns " -"an :term:`awaitable` object, and the execution starts when this object is " -"awaited on. At that time, the execution proceeds to the first yield " -"expression, where it is suspended again, returning the value " -"of :token:`~python-grammar:yield_list` to the awaiting coroutine. As with a " -"generator, suspension means that all local state is retained, including the " -"current bindings of local variables, the instruction pointer, the internal " -"evaluation stack, and the state of any exception handling. When the " -"execution is resumed by awaiting on the next object returned by the " -"asynchronous generator's methods, the function can proceed exactly as if the " -"yield expression were just another external call. The value of the yield " -"expression after resuming depends on the method which resumed the " -"execution. If :meth:`~agen.__anext__` is used then the result " -"is :const:`None`. Otherwise, if :meth:`~agen.asend` is used, then the result " -"will be the value passed in to that method." +"coroutine function analogously to how a generator object would be used in a :" +"keyword:`for` statement." msgstr "" -#: ../../reference/expressions.rst:710 +#: ../../reference/expressions.rst:698 +msgid "" +"Calling one of the asynchronous generator's methods returns an :term:" +"`awaitable` object, and the execution starts when this object is awaited on. " +"At that time, the execution proceeds to the first yield expression, where it " +"is suspended again, returning the value of :token:`~python-grammar:" +"yield_list` to the awaiting coroutine. As with a generator, suspension means " +"that all local state is retained, including the current bindings of local " +"variables, the instruction pointer, the internal evaluation stack, and the " +"state of any exception handling. When the execution is resumed by awaiting " +"on the next object returned by the asynchronous generator's methods, the " +"function can proceed exactly as if the yield expression were just another " +"external call. The value of the yield expression after resuming depends on " +"the method which resumed the execution. If :meth:`~agen.__anext__` is used " +"then the result is :const:`None`. Otherwise, if :meth:`~agen.asend` is used, " +"then the result will be the value passed in to that method." +msgstr "" + +#: ../../reference/expressions.rst:713 msgid "" "If an asynchronous generator happens to exit early by :keyword:`break`, the " "caller task being cancelled, or other exceptions, the generator's async " @@ -837,7 +838,7 @@ msgid "" "generator and ultimately detach it from the event loop." msgstr "" -#: ../../reference/expressions.rst:720 +#: ../../reference/expressions.rst:723 msgid "" "In an asynchronous generator function, yield expressions are allowed " "anywhere in a :keyword:`try` construct. However, if an asynchronous " @@ -851,36 +852,36 @@ msgid "" "finally` clauses to execute." msgstr "" -#: ../../reference/expressions.rst:731 +#: ../../reference/expressions.rst:734 msgid "" "To take care of finalization upon event loop termination, an event loop " "should define a *finalizer* function which takes an asynchronous generator-" "iterator and presumably calls :meth:`~agen.aclose` and executes the " -"coroutine. This *finalizer* may be registered by " -"calling :func:`sys.set_asyncgen_hooks`. When first iterated over, an " -"asynchronous generator-iterator will store the registered *finalizer* to be " -"called upon finalization. For a reference example of a *finalizer* method " -"see the implementation of ``asyncio.Loop.shutdown_asyncgens`` " -"in :source:`Lib/asyncio/base_events.py`." +"coroutine. This *finalizer* may be registered by calling :func:`sys." +"set_asyncgen_hooks`. When first iterated over, an asynchronous generator-" +"iterator will store the registered *finalizer* to be called upon " +"finalization. For a reference example of a *finalizer* method see the " +"implementation of ``asyncio.Loop.shutdown_asyncgens`` in :source:`Lib/" +"asyncio/base_events.py`." msgstr "" -#: ../../reference/expressions.rst:740 +#: ../../reference/expressions.rst:743 msgid "" "The expression ``yield from `` is a syntax error when used in an " "asynchronous generator function." msgstr "" -#: ../../reference/expressions.rst:747 +#: ../../reference/expressions.rst:750 msgid "Asynchronous generator-iterator methods" msgstr "" -#: ../../reference/expressions.rst:749 +#: ../../reference/expressions.rst:752 msgid "" "This subsection describes the methods of an asynchronous generator iterator, " "which are used to control the execution of a generator function." msgstr "" -#: ../../reference/expressions.rst:758 +#: ../../reference/expressions.rst:761 msgid "" "Returns an awaitable which when run starts to execute the asynchronous " "generator or resumes it at the last executed yield expression. When an " @@ -890,44 +891,44 @@ msgid "" "expression. The value of the :token:`~python-grammar:yield_list` of the " "yield expression is the value of the :exc:`StopIteration` exception raised " "by the completing coroutine. If the asynchronous generator exits without " -"yielding another value, the awaitable instead raises " -"a :exc:`StopAsyncIteration` exception, signalling that the asynchronous " -"iteration has completed." +"yielding another value, the awaitable instead raises a :exc:" +"`StopAsyncIteration` exception, signalling that the asynchronous iteration " +"has completed." msgstr "" -#: ../../reference/expressions.rst:770 +#: ../../reference/expressions.rst:773 msgid "" "This method is normally called implicitly by a :keyword:`async for` loop." msgstr "" -#: ../../reference/expressions.rst:776 +#: ../../reference/expressions.rst:779 msgid "" "Returns an awaitable which when run resumes the execution of the " "asynchronous generator. As with the :meth:`~generator.send` method for a " "generator, this \"sends\" a value into the asynchronous generator function, " "and the *value* argument becomes the result of the current yield expression. " "The awaitable returned by the :meth:`asend` method will return the next " -"value yielded by the generator as the value of the " -"raised :exc:`StopIteration`, or raises :exc:`StopAsyncIteration` if the " -"asynchronous generator exits without yielding another value. " -"When :meth:`asend` is called to start the asynchronous generator, it must be " -"called with :const:`None` as the argument, because there is no yield " -"expression that could receive the value." +"value yielded by the generator as the value of the raised :exc:" +"`StopIteration`, or raises :exc:`StopAsyncIteration` if the asynchronous " +"generator exits without yielding another value. When :meth:`asend` is " +"called to start the asynchronous generator, it must be called with :const:" +"`None` as the argument, because there is no yield expression that could " +"receive the value." msgstr "" -#: ../../reference/expressions.rst:793 +#: ../../reference/expressions.rst:796 msgid "" "Returns an awaitable that raises an exception of type ``type`` at the point " "where the asynchronous generator was paused, and returns the next value " -"yielded by the generator function as the value of the " -"raised :exc:`StopIteration` exception. If the asynchronous generator exits " -"without yielding another value, a :exc:`StopAsyncIteration` exception is " -"raised by the awaitable. If the generator function does not catch the passed-" -"in exception, or raises a different exception, then when the awaitable is " -"run that exception propagates to the caller of the awaitable." +"yielded by the generator function as the value of the raised :exc:" +"`StopIteration` exception. If the asynchronous generator exits without " +"yielding another value, a :exc:`StopAsyncIteration` exception is raised by " +"the awaitable. If the generator function does not catch the passed-in " +"exception, or raises a different exception, then when the awaitable is run " +"that exception propagates to the caller of the awaitable." msgstr "" -#: ../../reference/expressions.rst:814 +#: ../../reference/expressions.rst:817 msgid "" "Returns an awaitable that when run will throw a :exc:`GeneratorExit` into " "the asynchronous generator function at the point where it was paused. If the " @@ -943,25 +944,25 @@ msgid "" "will return an awaitable that does nothing." msgstr "" -#: ../../reference/expressions.rst:830 +#: ../../reference/expressions.rst:833 msgid "Primaries" msgstr "" -#: ../../reference/expressions.rst:834 +#: ../../reference/expressions.rst:837 msgid "" "Primaries represent the most tightly bound operations of the language. Their " "syntax is:" msgstr "" -#: ../../reference/expressions.rst:844 +#: ../../reference/expressions.rst:847 msgid "Attribute references" msgstr "" -#: ../../reference/expressions.rst:850 +#: ../../reference/expressions.rst:853 msgid "An attribute reference is a primary followed by a period and a name:" msgstr "" -#: ../../reference/expressions.rst:860 +#: ../../reference/expressions.rst:863 msgid "" "The primary must evaluate to an object of a type that supports attribute " "references, which most objects do. This object is then asked to produce the " @@ -970,69 +971,67 @@ msgid "" "reference may yield different objects." msgstr "" -#: ../../reference/expressions.rst:866 +#: ../../reference/expressions.rst:869 msgid "" -"This production can be customized by overriding " -"the :meth:`~object.__getattribute__` method or " -"the :meth:`~object.__getattr__` method. The :meth:`!__getattribute__` " -"method is called first and either returns a value or " -"raises :exc:`AttributeError` if the attribute is not available." +"This production can be customized by overriding the :meth:`~object." +"__getattribute__` method or the :meth:`~object.__getattr__` method. The :" +"meth:`!__getattribute__` method is called first and either returns a value " +"or raises :exc:`AttributeError` if the attribute is not available." msgstr "" -#: ../../reference/expressions.rst:872 +#: ../../reference/expressions.rst:875 msgid "" "If an :exc:`AttributeError` is raised and the object has a :meth:`!" "__getattr__` method, that method is called as a fallback." msgstr "" -#: ../../reference/expressions.rst:878 +#: ../../reference/expressions.rst:881 msgid "Subscriptions" msgstr "" -#: ../../reference/expressions.rst:893 +#: ../../reference/expressions.rst:896 msgid "" "The subscription of an instance of a :ref:`container class ` " -"will generally select an element from the container. The subscription of " -"a :term:`generic class ` will generally return " -"a :ref:`GenericAlias ` object." +"will generally select an element from the container. The subscription of a :" +"term:`generic class ` will generally return a :ref:" +"`GenericAlias ` object." msgstr "" -#: ../../reference/expressions.rst:901 +#: ../../reference/expressions.rst:904 msgid "" "When an object is subscripted, the interpreter will evaluate the primary and " "the expression list." msgstr "" -#: ../../reference/expressions.rst:904 +#: ../../reference/expressions.rst:907 msgid "" "The primary must evaluate to an object that supports subscription. An object " -"may support subscription through defining one or both " -"of :meth:`~object.__getitem__` and :meth:`~object.__class_getitem__`. When " -"the primary is subscripted, the evaluated result of the expression list will " -"be passed to one of these methods. For more details on when " -"``__class_getitem__`` is called instead of ``__getitem__``, " -"see :ref:`classgetitem-versus-getitem`." +"may support subscription through defining one or both of :meth:`~object." +"__getitem__` and :meth:`~object.__class_getitem__`. When the primary is " +"subscripted, the evaluated result of the expression list will be passed to " +"one of these methods. For more details on when ``__class_getitem__`` is " +"called instead of ``__getitem__``, see :ref:`classgetitem-versus-getitem`." msgstr "" -#: ../../reference/expressions.rst:911 +#: ../../reference/expressions.rst:914 msgid "" "If the expression list contains at least one comma, or if any of the " -"expressions are starred, the expression list will evaluate to " -"a :class:`tuple` containing the items of the expression list. Otherwise, the " +"expressions are starred, the expression list will evaluate to a :class:" +"`tuple` containing the items of the expression list. Otherwise, the " "expression list will evaluate to the value of the list's sole member." msgstr "" -#: ../../reference/expressions.rst:916 +#: ../../reference/expressions.rst:919 msgid "Expressions in an expression list may be starred. See :pep:`646`." msgstr "" -#: ../../reference/expressions.rst:919 +#: ../../reference/expressions.rst:922 msgid "" "For built-in objects, there are two types of objects that support " "subscription via :meth:`~object.__getitem__`:" msgstr "" -#: ../../reference/expressions.rst:922 +#: ../../reference/expressions.rst:925 msgid "" "Mappings. If the primary is a :term:`mapping`, the expression list must " "evaluate to an object whose value is one of the keys of the mapping, and the " @@ -1040,47 +1039,47 @@ msgid "" "An example of a builtin mapping class is the :class:`dict` class." msgstr "" -#: ../../reference/expressions.rst:926 +#: ../../reference/expressions.rst:929 msgid "" "Sequences. If the primary is a :term:`sequence`, the expression list must " "evaluate to an :class:`int` or a :class:`slice` (as discussed in the " -"following section). Examples of builtin sequence classes include " -"the :class:`str`, :class:`list` and :class:`tuple` classes." +"following section). Examples of builtin sequence classes include the :class:" +"`str`, :class:`list` and :class:`tuple` classes." msgstr "" -#: ../../reference/expressions.rst:931 +#: ../../reference/expressions.rst:934 msgid "" -"The formal syntax makes no special provision for negative indices " -"in :term:`sequences `. However, built-in sequences all provide " -"a :meth:`~object.__getitem__` method that interprets negative indices by " -"adding the length of the sequence to the index so that, for example, " -"``x[-1]`` selects the last item of ``x``. The resulting value must be a " -"nonnegative integer less than the number of items in the sequence, and the " -"subscription selects the item whose index is that value (counting from " -"zero). Since the support for negative indices and slicing occurs in the " -"object's :meth:`~object.__getitem__` method, subclasses overriding this " -"method will need to explicitly add that support." +"The formal syntax makes no special provision for negative indices in :term:" +"`sequences `. However, built-in sequences all provide a :meth:" +"`~object.__getitem__` method that interprets negative indices by adding the " +"length of the sequence to the index so that, for example, ``x[-1]`` selects " +"the last item of ``x``. The resulting value must be a nonnegative integer " +"less than the number of items in the sequence, and the subscription selects " +"the item whose index is that value (counting from zero). Since the support " +"for negative indices and slicing occurs in the object's :meth:`~object." +"__getitem__` method, subclasses overriding this method will need to " +"explicitly add that support." msgstr "" -#: ../../reference/expressions.rst:945 +#: ../../reference/expressions.rst:948 msgid "" "A :class:`string ` is a special kind of sequence whose items are " "*characters*. A character is not a separate data type but a string of " "exactly one character." msgstr "" -#: ../../reference/expressions.rst:953 +#: ../../reference/expressions.rst:956 msgid "Slicings" msgstr "" -#: ../../reference/expressions.rst:967 +#: ../../reference/expressions.rst:970 msgid "" "A slicing selects a range of items in a sequence object (e.g., a string, " "tuple or list). Slicings may be used as expressions or as targets in " "assignment or :keyword:`del` statements. The syntax for a slicing:" msgstr "" -#: ../../reference/expressions.rst:980 +#: ../../reference/expressions.rst:983 msgid "" "There is ambiguity in the formal syntax here: anything that looks like an " "expression list also looks like a slice list, so any subscription can be " @@ -1090,7 +1089,7 @@ msgid "" "the case if the slice list contains no proper slice)." msgstr "" -#: ../../reference/expressions.rst:992 +#: ../../reference/expressions.rst:995 msgid "" "The semantics for a slicing are as follows. The primary is indexed (using " "the same :meth:`~object.__getitem__` method as normal subscription) with a " @@ -1099,29 +1098,29 @@ msgid "" "the slice items; otherwise, the conversion of the lone slice item is the " "key. The conversion of a slice item that is an expression is that " "expression. The conversion of a proper slice is a slice object (see " -"section :ref:`types`) whose :attr:`~slice.start`, :attr:`~slice.stop` " -"and :attr:`~slice.step` attributes are the values of the expressions given " -"as lower bound, upper bound and stride, respectively, substituting ``None`` " -"for missing expressions." +"section :ref:`types`) whose :attr:`~slice.start`, :attr:`~slice.stop` and :" +"attr:`~slice.step` attributes are the values of the expressions given as " +"lower bound, upper bound and stride, respectively, substituting ``None`` for " +"missing expressions." msgstr "" -#: ../../reference/expressions.rst:1016 +#: ../../reference/expressions.rst:1019 msgid "Calls" msgstr "" -#: ../../reference/expressions.rst:1018 +#: ../../reference/expressions.rst:1021 msgid "" "A call calls a callable object (e.g., a :term:`function`) with a possibly " "empty series of :term:`arguments `:" msgstr "" -#: ../../reference/expressions.rst:1035 +#: ../../reference/expressions.rst:1038 msgid "" "An optional trailing comma may be present after the positional and keyword " "arguments but does not affect the semantics." msgstr "" -#: ../../reference/expressions.rst:1041 +#: ../../reference/expressions.rst:1044 msgid "" "The primary must evaluate to a callable object (user-defined functions, " "built-in functions, methods of built-in objects, class objects, methods of " @@ -1131,7 +1130,7 @@ msgid "" "formal :term:`parameter` lists." msgstr "" -#: ../../reference/expressions.rst:1049 +#: ../../reference/expressions.rst:1052 msgid "" "If keyword arguments are present, they are first converted to positional " "arguments, as follows. First, a list of unfilled slots is created for the " @@ -1152,16 +1151,16 @@ msgid "" "filled slots is used as the argument list for the call." msgstr "" -#: ../../reference/expressions.rst:1069 +#: ../../reference/expressions.rst:1072 msgid "" "An implementation may provide built-in functions whose positional parameters " "do not have names, even if they are 'named' for the purpose of " "documentation, and which therefore cannot be supplied by keyword. In " -"CPython, this is the case for functions implemented in C that " -"use :c:func:`PyArg_ParseTuple` to parse their arguments." +"CPython, this is the case for functions implemented in C that use :c:func:" +"`PyArg_ParseTuple` to parse their arguments." msgstr "" -#: ../../reference/expressions.rst:1075 +#: ../../reference/expressions.rst:1078 msgid "" "If there are more positional arguments than there are formal parameter " "slots, a :exc:`TypeError` exception is raised, unless a formal parameter " @@ -1170,17 +1169,17 @@ msgid "" "empty tuple if there were no excess positional arguments)." msgstr "" -#: ../../reference/expressions.rst:1081 +#: ../../reference/expressions.rst:1084 msgid "" -"If any keyword argument does not correspond to a formal parameter name, " -"a :exc:`TypeError` exception is raised, unless a formal parameter using the " +"If any keyword argument does not correspond to a formal parameter name, a :" +"exc:`TypeError` exception is raised, unless a formal parameter using the " "syntax ``**identifier`` is present; in this case, that formal parameter " "receives a dictionary containing the excess keyword arguments (using the " "keywords as keys and the argument values as corresponding values), or a " "(new) empty dictionary if there were no excess keyword arguments." msgstr "" -#: ../../reference/expressions.rst:1092 +#: ../../reference/expressions.rst:1095 msgid "" "If the syntax ``*expression`` appears in the function call, ``expression`` " "must evaluate to an :term:`iterable`. Elements from these iterables are " @@ -1190,14 +1189,14 @@ msgid "" "*y1*, ..., *yM*, *x3*, *x4*." msgstr "" -#: ../../reference/expressions.rst:1099 +#: ../../reference/expressions.rst:1102 msgid "" "A consequence of this is that although the ``*expression`` syntax may appear " "*after* explicit keyword arguments, it is processed *before* the keyword " "arguments (and any ``**expression`` arguments -- see below). So::" msgstr "" -#: ../../reference/expressions.rst:1103 +#: ../../reference/expressions.rst:1106 msgid "" ">>> def f(a, b):\n" "... print(a, b)\n" @@ -1223,13 +1222,13 @@ msgstr "" ">>> f(1, *(2,))\n" "1 2" -#: ../../reference/expressions.rst:1115 +#: ../../reference/expressions.rst:1118 msgid "" "It is unusual for both keyword arguments and the ``*expression`` syntax to " "be used in the same call, so in practice this confusion does not often arise." msgstr "" -#: ../../reference/expressions.rst:1121 +#: ../../reference/expressions.rst:1124 msgid "" "If the syntax ``**expression`` appears in the function call, ``expression`` " "must evaluate to a :term:`mapping`, the contents of which are treated as " @@ -1238,7 +1237,7 @@ msgid "" "a :exc:`TypeError` exception is raised." msgstr "" -#: ../../reference/expressions.rst:1127 +#: ../../reference/expressions.rst:1130 msgid "" "When ``**expression`` is used, each key in this mapping must be a string. " "Each value from the mapping is assigned to the first formal parameter " @@ -1250,35 +1249,35 @@ msgid "" "is raised." msgstr "" -#: ../../reference/expressions.rst:1137 +#: ../../reference/expressions.rst:1140 msgid "" "Formal parameters using the syntax ``*identifier`` or ``**identifier`` " "cannot be used as positional argument slots or as keyword argument names." msgstr "" -#: ../../reference/expressions.rst:1140 +#: ../../reference/expressions.rst:1143 msgid "" "Function calls accept any number of ``*`` and ``**`` unpackings, positional " "arguments may follow iterable unpackings (``*``), and keyword arguments may " "follow dictionary unpackings (``**``). Originally proposed by :pep:`448`." msgstr "" -#: ../../reference/expressions.rst:1146 +#: ../../reference/expressions.rst:1149 msgid "" "A call always returns some value, possibly ``None``, unless it raises an " "exception. How this value is computed depends on the type of the callable " "object." msgstr "" -#: ../../reference/expressions.rst:1150 +#: ../../reference/expressions.rst:1153 msgid "If it is---" msgstr "" -#: ../../reference/expressions.rst:1152 +#: ../../reference/expressions.rst:1155 msgid "a user-defined function:" msgstr "" -#: ../../reference/expressions.rst:1159 +#: ../../reference/expressions.rst:1162 msgid "" "The code block for the function is executed, passing it the argument list. " "The first thing the code block will do is bind the formal parameters to the " @@ -1289,73 +1288,73 @@ msgid "" "``None``." msgstr "" -#: ../../reference/expressions.rst:1166 +#: ../../reference/expressions.rst:1169 msgid "a built-in function or method:" msgstr "" -#: ../../reference/expressions.rst:1177 +#: ../../reference/expressions.rst:1180 msgid "" "The result is up to the interpreter; see :ref:`built-in-funcs` for the " "descriptions of built-in functions and methods." msgstr "" -#: ../../reference/expressions.rst:1180 +#: ../../reference/expressions.rst:1183 msgid "a class object:" msgstr "" -#: ../../reference/expressions.rst:1185 +#: ../../reference/expressions.rst:1188 msgid "A new instance of that class is returned." msgstr "" -#: ../../reference/expressions.rst:1187 +#: ../../reference/expressions.rst:1190 msgid "a class instance method:" msgstr "" -#: ../../reference/expressions.rst:1193 +#: ../../reference/expressions.rst:1196 msgid "" "The corresponding user-defined function is called, with an argument list " "that is one longer than the argument list of the call: the instance becomes " "the first argument." msgstr "" -#: ../../reference/expressions.rst:1197 +#: ../../reference/expressions.rst:1200 msgid "a class instance:" msgstr "" -#: ../../reference/expressions.rst:1202 +#: ../../reference/expressions.rst:1205 msgid "" "The class must define a :meth:`~object.__call__` method; the effect is then " "the same as if that method was called." msgstr "" -#: ../../reference/expressions.rst:1210 ../../reference/expressions.rst:2011 +#: ../../reference/expressions.rst:1213 ../../reference/expressions.rst:2014 msgid "Await expression" msgstr "" -#: ../../reference/expressions.rst:1212 +#: ../../reference/expressions.rst:1215 msgid "" "Suspend the execution of :term:`coroutine` on an :term:`awaitable` object. " "Can only be used inside a :term:`coroutine function`." msgstr "" -#: ../../reference/expressions.rst:1224 +#: ../../reference/expressions.rst:1227 msgid "The power operator" msgstr "" -#: ../../reference/expressions.rst:1230 +#: ../../reference/expressions.rst:1233 msgid "" "The power operator binds more tightly than unary operators on its left; it " "binds less tightly than unary operators on its right. The syntax is:" msgstr "" -#: ../../reference/expressions.rst:1236 +#: ../../reference/expressions.rst:1239 msgid "" "Thus, in an unparenthesized sequence of power and unary operators, the " "operators are evaluated from right to left (this does not constrain the " "evaluation order for the operands): ``-1**2`` results in ``-1``." msgstr "" -#: ../../reference/expressions.rst:1240 +#: ../../reference/expressions.rst:1243 msgid "" "The power operator has the same semantics as the built-in :func:`pow` " "function, when called with two arguments: it yields its left argument raised " @@ -1363,7 +1362,7 @@ msgid "" "converted to a common type, and the result is of that type." msgstr "" -#: ../../reference/expressions.rst:1245 +#: ../../reference/expressions.rst:1248 msgid "" "For int operands, the result has the same type as the operands unless the " "second argument is negative; in that case, all arguments are converted to " @@ -1371,60 +1370,59 @@ msgid "" "``100``, but ``10**-2`` returns ``0.01``." msgstr "" -#: ../../reference/expressions.rst:1250 +#: ../../reference/expressions.rst:1253 msgid "" "Raising ``0.0`` to a negative power results in a :exc:`ZeroDivisionError`. " -"Raising a negative number to a fractional power results in " -"a :class:`complex` number. (In earlier versions it raised " -"a :exc:`ValueError`.)" +"Raising a negative number to a fractional power results in a :class:" +"`complex` number. (In earlier versions it raised a :exc:`ValueError`.)" msgstr "" -#: ../../reference/expressions.rst:1254 +#: ../../reference/expressions.rst:1257 msgid "" "This operation can be customized using the special :meth:`~object.__pow__` " "and :meth:`~object.__rpow__` methods." msgstr "" -#: ../../reference/expressions.rst:1260 +#: ../../reference/expressions.rst:1263 msgid "Unary arithmetic and bitwise operations" msgstr "" -#: ../../reference/expressions.rst:1266 +#: ../../reference/expressions.rst:1269 msgid "All unary arithmetic and bitwise operations have the same priority:" msgstr "" -#: ../../reference/expressions.rst:1277 +#: ../../reference/expressions.rst:1280 msgid "" "The unary ``-`` (minus) operator yields the negation of its numeric " "argument; the operation can be overridden with the :meth:`~object.__neg__` " "special method." msgstr "" -#: ../../reference/expressions.rst:1285 +#: ../../reference/expressions.rst:1288 msgid "" "The unary ``+`` (plus) operator yields its numeric argument unchanged; the " "operation can be overridden with the :meth:`~object.__pos__` special method." msgstr "" -#: ../../reference/expressions.rst:1292 +#: ../../reference/expressions.rst:1295 msgid "" "The unary ``~`` (invert) operator yields the bitwise inversion of its " "integer argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. " -"It only applies to integral numbers or to custom objects that override " -"the :meth:`~object.__invert__` special method." +"It only applies to integral numbers or to custom objects that override the :" +"meth:`~object.__invert__` special method." msgstr "" -#: ../../reference/expressions.rst:1301 +#: ../../reference/expressions.rst:1304 msgid "" -"In all three cases, if the argument does not have the proper type, " -"a :exc:`TypeError` exception is raised." +"In all three cases, if the argument does not have the proper type, a :exc:" +"`TypeError` exception is raised." msgstr "" -#: ../../reference/expressions.rst:1308 +#: ../../reference/expressions.rst:1311 msgid "Binary arithmetic operations" msgstr "" -#: ../../reference/expressions.rst:1312 +#: ../../reference/expressions.rst:1315 msgid "" "The binary arithmetic operations have the conventional priority levels. " "Note that some of these operations also apply to certain non-numeric types. " @@ -1432,7 +1430,7 @@ msgid "" "multiplicative operators and one for additive operators:" msgstr "" -#: ../../reference/expressions.rst:1327 +#: ../../reference/expressions.rst:1330 msgid "" "The ``*`` (multiplication) operator yields the product of its arguments. " "The arguments must either both be numbers, or one argument must be an " @@ -1442,25 +1440,25 @@ msgid "" "an empty sequence." msgstr "" -#: ../../reference/expressions.rst:1333 +#: ../../reference/expressions.rst:1336 msgid "" "This operation can be customized using the special :meth:`~object.__mul__` " "and :meth:`~object.__rmul__` methods." msgstr "" -#: ../../reference/expressions.rst:1340 +#: ../../reference/expressions.rst:1343 msgid "" "The ``@`` (at) operator is intended to be used for matrix multiplication. " "No builtin Python types implement this operator." msgstr "" -#: ../../reference/expressions.rst:1343 +#: ../../reference/expressions.rst:1346 msgid "" -"This operation can be customized using the " -"special :meth:`~object.__matmul__` and :meth:`~object.__rmatmul__` methods." +"This operation can be customized using the special :meth:`~object." +"__matmul__` and :meth:`~object.__rmatmul__` methods." msgstr "" -#: ../../reference/expressions.rst:1354 +#: ../../reference/expressions.rst:1357 msgid "" "The ``/`` (division) and ``//`` (floor division) operators yield the " "quotient of their arguments. The numeric arguments are first converted to a " @@ -1470,16 +1468,15 @@ msgid "" "the :exc:`ZeroDivisionError` exception." msgstr "" -#: ../../reference/expressions.rst:1361 +#: ../../reference/expressions.rst:1364 msgid "" -"The division operation can be customized using the " -"special :meth:`~object.__truediv__` and :meth:`~object.__rtruediv__` " -"methods. The floor division operation can be customized using the " -"special :meth:`~object.__floordiv__` and :meth:`~object.__rfloordiv__` " -"methods." +"The division operation can be customized using the special :meth:`~object." +"__truediv__` and :meth:`~object.__rtruediv__` methods. The floor division " +"operation can be customized using the special :meth:`~object.__floordiv__` " +"and :meth:`~object.__rfloordiv__` methods." msgstr "" -#: ../../reference/expressions.rst:1370 +#: ../../reference/expressions.rst:1373 msgid "" "The ``%`` (modulo) operator yields the remainder from the division of the " "first argument by the second. The numeric arguments are first converted to " @@ -1491,7 +1488,7 @@ msgid "" "absolute value of the second operand [#]_." msgstr "" -#: ../../reference/expressions.rst:1379 +#: ../../reference/expressions.rst:1382 msgid "" "The floor division and modulo operators are connected by the following " "identity: ``x == (x//y)*y + (x%y)``. Floor division and modulo are also " @@ -1499,7 +1496,7 @@ msgid "" "y, x%y)``. [#]_." msgstr "" -#: ../../reference/expressions.rst:1384 +#: ../../reference/expressions.rst:1387 msgid "" "In addition to performing the modulo operation on numbers, the ``%`` " "operator is also overloaded by string objects to perform old-style string " @@ -1508,20 +1505,20 @@ msgid "" "formatting`." msgstr "" -#: ../../reference/expressions.rst:1389 +#: ../../reference/expressions.rst:1392 msgid "" -"The *modulo* operation can be customized using the " -"special :meth:`~object.__mod__` and :meth:`~object.__rmod__` methods." +"The *modulo* operation can be customized using the special :meth:`~object." +"__mod__` and :meth:`~object.__rmod__` methods." msgstr "" -#: ../../reference/expressions.rst:1392 +#: ../../reference/expressions.rst:1395 msgid "" "The floor division operator, the modulo operator, and the :func:`divmod` " "function are not defined for complex numbers. Instead, convert to a " "floating-point number using the :func:`abs` function if appropriate." msgstr "" -#: ../../reference/expressions.rst:1401 +#: ../../reference/expressions.rst:1404 msgid "" "The ``+`` (addition) operator yields the sum of its arguments. The " "arguments must either both be numbers or both be sequences of the same " @@ -1529,89 +1526,87 @@ msgid "" "then added together. In the latter case, the sequences are concatenated." msgstr "" -#: ../../reference/expressions.rst:1406 +#: ../../reference/expressions.rst:1409 msgid "" "This operation can be customized using the special :meth:`~object.__add__` " "and :meth:`~object.__radd__` methods." msgstr "" -#: ../../reference/expressions.rst:1414 +#: ../../reference/expressions.rst:1417 msgid "" "The ``-`` (subtraction) operator yields the difference of its arguments. " "The numeric arguments are first converted to a common type." msgstr "" -#: ../../reference/expressions.rst:1417 +#: ../../reference/expressions.rst:1420 msgid "" "This operation can be customized using the special :meth:`~object.__sub__` " "and :meth:`~object.__rsub__` methods." msgstr "" -#: ../../reference/expressions.rst:1424 +#: ../../reference/expressions.rst:1427 msgid "Shifting operations" msgstr "" -#: ../../reference/expressions.rst:1431 +#: ../../reference/expressions.rst:1434 msgid "" "The shifting operations have lower priority than the arithmetic operations:" msgstr "" -#: ../../reference/expressions.rst:1436 +#: ../../reference/expressions.rst:1439 msgid "" "These operators accept integers as arguments. They shift the first argument " "to the left or right by the number of bits given by the second argument." msgstr "" -#: ../../reference/expressions.rst:1439 +#: ../../reference/expressions.rst:1442 msgid "" -"The left shift operation can be customized using the " -"special :meth:`~object.__lshift__` and :meth:`~object.__rlshift__` methods. " -"The right shift operation can be customized using the " -"special :meth:`~object.__rshift__` and :meth:`~object.__rrshift__` methods." +"The left shift operation can be customized using the special :meth:`~object." +"__lshift__` and :meth:`~object.__rlshift__` methods. The right shift " +"operation can be customized using the special :meth:`~object.__rshift__` " +"and :meth:`~object.__rrshift__` methods." msgstr "" -#: ../../reference/expressions.rst:1446 +#: ../../reference/expressions.rst:1449 msgid "" "A right shift by *n* bits is defined as floor division by ``pow(2,n)``. A " "left shift by *n* bits is defined as multiplication with ``pow(2,n)``." msgstr "" -#: ../../reference/expressions.rst:1453 +#: ../../reference/expressions.rst:1456 msgid "Binary bitwise operations" msgstr "" -#: ../../reference/expressions.rst:1457 +#: ../../reference/expressions.rst:1460 msgid "Each of the three bitwise operations has a different priority level:" msgstr "" -#: ../../reference/expressions.rst:1468 +#: ../../reference/expressions.rst:1471 msgid "" "The ``&`` operator yields the bitwise AND of its arguments, which must be " -"integers or one of them must be a custom object " -"overriding :meth:`~object.__and__` or :meth:`~object.__rand__` special " -"methods." +"integers or one of them must be a custom object overriding :meth:`~object." +"__and__` or :meth:`~object.__rand__` special methods." msgstr "" -#: ../../reference/expressions.rst:1477 +#: ../../reference/expressions.rst:1480 msgid "" "The ``^`` operator yields the bitwise XOR (exclusive OR) of its arguments, " -"which must be integers or one of them must be a custom object " -"overriding :meth:`~object.__xor__` or :meth:`~object.__rxor__` special " -"methods." +"which must be integers or one of them must be a custom object overriding :" +"meth:`~object.__xor__` or :meth:`~object.__rxor__` special methods." msgstr "" -#: ../../reference/expressions.rst:1486 +#: ../../reference/expressions.rst:1489 msgid "" "The ``|`` operator yields the bitwise (inclusive) OR of its arguments, which " -"must be integers or one of them must be a custom object " -"overriding :meth:`~object.__or__` or :meth:`~object.__ror__` special methods." +"must be integers or one of them must be a custom object overriding :meth:" +"`~object.__or__` or :meth:`~object.__ror__` special methods." msgstr "" -#: ../../reference/expressions.rst:1494 +#: ../../reference/expressions.rst:1497 msgid "Comparisons" msgstr "" -#: ../../reference/expressions.rst:1506 +#: ../../reference/expressions.rst:1509 msgid "" "Unlike C, all comparison operations in Python have the same priority, which " "is lower than that of any arithmetic, shifting or bitwise operation. Also " @@ -1619,14 +1614,14 @@ msgid "" "conventional in mathematics:" msgstr "" -#: ../../reference/expressions.rst:1516 +#: ../../reference/expressions.rst:1519 msgid "" "Comparisons yield boolean values: ``True`` or ``False``. Custom :dfn:`rich " "comparison methods` may return non-boolean values. In this case Python will " "call :func:`bool` on such value in boolean contexts." msgstr "" -#: ../../reference/expressions.rst:1522 +#: ../../reference/expressions.rst:1525 msgid "" "Comparisons can be chained arbitrarily, e.g., ``x < y <= z`` is equivalent " "to ``x < y and y <= z``, except that ``y`` is evaluated only once (but in " @@ -1634,7 +1629,7 @@ msgid "" "false)." msgstr "" -#: ../../reference/expressions.rst:1526 +#: ../../reference/expressions.rst:1529 msgid "" "Formally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*, " "*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y opN " @@ -1642,24 +1637,24 @@ msgid "" "each expression is evaluated at most once." msgstr "" -#: ../../reference/expressions.rst:1531 +#: ../../reference/expressions.rst:1534 msgid "" "Note that ``a op1 b op2 c`` doesn't imply any kind of comparison between *a* " "and *c*, so that, e.g., ``x < y > z`` is perfectly legal (though perhaps not " "pretty)." msgstr "" -#: ../../reference/expressions.rst:1538 +#: ../../reference/expressions.rst:1541 msgid "Value comparisons" msgstr "" -#: ../../reference/expressions.rst:1540 +#: ../../reference/expressions.rst:1543 msgid "" "The operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare the " "values of two objects. The objects do not need to have the same type." msgstr "" -#: ../../reference/expressions.rst:1543 +#: ../../reference/expressions.rst:1546 msgid "" "Chapter :ref:`objects` states that objects have a value (in addition to type " "and identity). The value of an object is a rather abstract notion in " @@ -1671,7 +1666,7 @@ msgid "" "indirectly, by means of their comparison implementation." msgstr "" -#: ../../reference/expressions.rst:1552 +#: ../../reference/expressions.rst:1555 msgid "" "Because all types are (direct or indirect) subtypes of :class:`object`, they " "inherit the default comparison behavior from :class:`object`. Types can " @@ -1679,7 +1674,7 @@ msgid "" "methods` like :meth:`~object.__lt__`, described in :ref:`customization`." msgstr "" -#: ../../reference/expressions.rst:1558 +#: ../../reference/expressions.rst:1561 msgid "" "The default behavior for equality comparison (``==`` and ``!=``) is based on " "the identity of the objects. Hence, equality comparison of instances with " @@ -1689,14 +1684,14 @@ msgid "" "``x is y`` implies ``x == y``)." msgstr "" -#: ../../reference/expressions.rst:1565 +#: ../../reference/expressions.rst:1568 msgid "" "A default order comparison (``<``, ``>``, ``<=``, and ``>=``) is not " "provided; an attempt raises :exc:`TypeError`. A motivation for this default " "behavior is the lack of a similar invariant as for equality." msgstr "" -#: ../../reference/expressions.rst:1569 +#: ../../reference/expressions.rst:1572 msgid "" "The behavior of the default equality comparison, that instances with " "different identities are always unequal, may be in contrast to what types " @@ -1705,13 +1700,13 @@ msgid "" "in fact, a number of built-in types have done that." msgstr "" -#: ../../reference/expressions.rst:1575 +#: ../../reference/expressions.rst:1578 msgid "" "The following list describes the comparison behavior of the most important " "built-in types." msgstr "" -#: ../../reference/expressions.rst:1578 +#: ../../reference/expressions.rst:1581 msgid "" "Numbers of built-in numeric types (:ref:`typesnumeric`) and of the standard " "library types :class:`fractions.Fraction` and :class:`decimal.Decimal` can " @@ -1721,7 +1716,7 @@ msgid "" "of precision." msgstr "" -#: ../../reference/expressions.rst:1585 +#: ../../reference/expressions.rst:1588 msgid "" "The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are " "special. Any ordered comparison of a number to a not-a-number value is " @@ -1731,32 +1726,32 @@ msgid "" "is compliant with IEEE 754." msgstr "" -#: ../../reference/expressions.rst:1592 +#: ../../reference/expressions.rst:1595 msgid "" "``None`` and :data:`NotImplemented` are singletons. :PEP:`8` advises that " "comparisons for singletons should always be done with ``is`` or ``is not``, " "never the equality operators." msgstr "" -#: ../../reference/expressions.rst:1596 +#: ../../reference/expressions.rst:1599 msgid "" "Binary sequences (instances of :class:`bytes` or :class:`bytearray`) can be " "compared within and across their types. They compare lexicographically " "using the numeric values of their elements." msgstr "" -#: ../../reference/expressions.rst:1600 +#: ../../reference/expressions.rst:1603 msgid "" "Strings (instances of :class:`str`) compare lexicographically using the " -"numerical Unicode code points (the result of the built-in " -"function :func:`ord`) of their characters. [#]_" +"numerical Unicode code points (the result of the built-in function :func:" +"`ord`) of their characters. [#]_" msgstr "" -#: ../../reference/expressions.rst:1604 +#: ../../reference/expressions.rst:1607 msgid "Strings and binary sequences cannot be directly compared." msgstr "" -#: ../../reference/expressions.rst:1606 +#: ../../reference/expressions.rst:1609 msgid "" "Sequences (instances of :class:`tuple`, :class:`list`, or :class:`range`) " "can be compared only within each of their types, with the restriction that " @@ -1765,7 +1760,7 @@ msgid "" "raises :exc:`TypeError`." msgstr "" -#: ../../reference/expressions.rst:1612 +#: ../../reference/expressions.rst:1615 msgid "" "Sequences compare lexicographically using comparison of corresponding " "elements. The built-in containers typically assume identical objects are " @@ -1773,19 +1768,19 @@ msgid "" "objects to improve performance and to maintain their internal invariants." msgstr "" -#: ../../reference/expressions.rst:1617 +#: ../../reference/expressions.rst:1620 msgid "" "Lexicographical comparison between built-in collections works as follows:" msgstr "" -#: ../../reference/expressions.rst:1619 +#: ../../reference/expressions.rst:1622 msgid "" "For two collections to compare equal, they must be of the same type, have " "the same length, and each pair of corresponding elements must compare equal " "(for example, ``[1,2] == (1,2)`` is false because the type is not the same)." msgstr "" -#: ../../reference/expressions.rst:1624 +#: ../../reference/expressions.rst:1627 msgid "" "Collections that support order comparison are ordered the same as their " "first unequal elements (for example, ``[1,2,x] <= [1,2,y]`` has the same " @@ -1794,151 +1789,150 @@ msgid "" "true)." msgstr "" -#: ../../reference/expressions.rst:1630 +#: ../../reference/expressions.rst:1633 msgid "" "Mappings (instances of :class:`dict`) compare equal if and only if they have " "equal ``(key, value)`` pairs. Equality comparison of the keys and values " "enforces reflexivity." msgstr "" -#: ../../reference/expressions.rst:1634 +#: ../../reference/expressions.rst:1637 msgid "" "Order comparisons (``<``, ``>``, ``<=``, and ``>=``) raise :exc:`TypeError`." msgstr "" -#: ../../reference/expressions.rst:1636 +#: ../../reference/expressions.rst:1639 msgid "" "Sets (instances of :class:`set` or :class:`frozenset`) can be compared " "within and across their types." msgstr "" -#: ../../reference/expressions.rst:1639 +#: ../../reference/expressions.rst:1642 msgid "" "They define order comparison operators to mean subset and superset tests. " "Those relations do not define total orderings (for example, the two sets " "``{1,2}`` and ``{2,3}`` are not equal, nor subsets of one another, nor " "supersets of one another). Accordingly, sets are not appropriate arguments " -"for functions which depend on total ordering (for " -"example, :func:`min`, :func:`max`, and :func:`sorted` produce undefined " -"results given a list of sets as inputs)." +"for functions which depend on total ordering (for example, :func:`min`, :" +"func:`max`, and :func:`sorted` produce undefined results given a list of " +"sets as inputs)." msgstr "" -#: ../../reference/expressions.rst:1647 +#: ../../reference/expressions.rst:1650 msgid "Comparison of sets enforces reflexivity of its elements." msgstr "" -#: ../../reference/expressions.rst:1649 +#: ../../reference/expressions.rst:1652 msgid "" "Most other built-in types have no comparison methods implemented, so they " "inherit the default comparison behavior." msgstr "" -#: ../../reference/expressions.rst:1652 +#: ../../reference/expressions.rst:1655 msgid "" "User-defined classes that customize their comparison behavior should follow " "some consistency rules, if possible:" msgstr "" -#: ../../reference/expressions.rst:1655 +#: ../../reference/expressions.rst:1658 msgid "" "Equality comparison should be reflexive. In other words, identical objects " "should compare equal:" msgstr "" -#: ../../reference/expressions.rst:1658 +#: ../../reference/expressions.rst:1661 msgid "``x is y`` implies ``x == y``" msgstr "" -#: ../../reference/expressions.rst:1660 +#: ../../reference/expressions.rst:1663 msgid "" "Comparison should be symmetric. In other words, the following expressions " "should have the same result:" msgstr "" -#: ../../reference/expressions.rst:1663 +#: ../../reference/expressions.rst:1666 msgid "``x == y`` and ``y == x``" msgstr "``x == y`` 和 ``y == x``" -#: ../../reference/expressions.rst:1665 +#: ../../reference/expressions.rst:1668 msgid "``x != y`` and ``y != x``" msgstr "``x != y`` 和 ``y != x``" -#: ../../reference/expressions.rst:1667 +#: ../../reference/expressions.rst:1670 msgid "``x < y`` and ``y > x``" msgstr "``x < y`` 和 ``y > x``" -#: ../../reference/expressions.rst:1669 +#: ../../reference/expressions.rst:1672 msgid "``x <= y`` and ``y >= x``" msgstr "``x <= y`` 和 ``y >= x``" -#: ../../reference/expressions.rst:1671 +#: ../../reference/expressions.rst:1674 msgid "" "Comparison should be transitive. The following (non-exhaustive) examples " "illustrate that:" msgstr "" -#: ../../reference/expressions.rst:1674 +#: ../../reference/expressions.rst:1677 msgid "``x > y and y > z`` implies ``x > z``" msgstr "``x > y and y > z`` 暗示了 ``x > z``" -#: ../../reference/expressions.rst:1676 +#: ../../reference/expressions.rst:1679 msgid "``x < y and y <= z`` implies ``x < z``" msgstr "``x < y and y <= z`` 暗示了 ``x < z``" -#: ../../reference/expressions.rst:1678 +#: ../../reference/expressions.rst:1681 msgid "" "Inverse comparison should result in the boolean negation. In other words, " "the following expressions should have the same result:" msgstr "" -#: ../../reference/expressions.rst:1681 +#: ../../reference/expressions.rst:1684 msgid "``x == y`` and ``not x != y``" msgstr "``x == y`` 和 ``not x != y``" -#: ../../reference/expressions.rst:1683 +#: ../../reference/expressions.rst:1686 msgid "``x < y`` and ``not x >= y`` (for total ordering)" msgstr "" -#: ../../reference/expressions.rst:1685 +#: ../../reference/expressions.rst:1688 msgid "``x > y`` and ``not x <= y`` (for total ordering)" msgstr "" -#: ../../reference/expressions.rst:1687 +#: ../../reference/expressions.rst:1690 msgid "" "The last two expressions apply to totally ordered collections (e.g. to " -"sequences, but not to sets or mappings). See also " -"the :func:`~functools.total_ordering` decorator." +"sequences, but not to sets or mappings). See also the :func:`~functools." +"total_ordering` decorator." msgstr "" -#: ../../reference/expressions.rst:1691 +#: ../../reference/expressions.rst:1694 msgid "" "The :func:`hash` result should be consistent with equality. Objects that are " "equal should either have the same hash value, or be marked as unhashable." msgstr "" -#: ../../reference/expressions.rst:1695 +#: ../../reference/expressions.rst:1698 msgid "" "Python does not enforce these consistency rules. In fact, the not-a-number " "values are an example for not following these rules." msgstr "" -#: ../../reference/expressions.rst:1704 +#: ../../reference/expressions.rst:1707 msgid "Membership test operations" msgstr "" -#: ../../reference/expressions.rst:1706 +#: ../../reference/expressions.rst:1709 msgid "" "The operators :keyword:`in` and :keyword:`not in` test for membership. ``x " "in s`` evaluates to ``True`` if *x* is a member of *s*, and ``False`` " "otherwise. ``x not in s`` returns the negation of ``x in s``. All built-in " -"sequences and set types support this as well as dictionary, for " -"which :keyword:`!in` tests whether the dictionary has a given key. For " -"container types such as list, tuple, set, frozenset, dict, or " -"collections.deque, the expression ``x in y`` is equivalent to ``any(x is e " -"or x == e for e in y)``." +"sequences and set types support this as well as dictionary, for which :" +"keyword:`!in` tests whether the dictionary has a given key. For container " +"types such as list, tuple, set, frozenset, dict, or collections.deque, the " +"expression ``x in y`` is equivalent to ``any(x is e or x == e for e in y)``." msgstr "" -#: ../../reference/expressions.rst:1714 +#: ../../reference/expressions.rst:1717 msgid "" "For the string and bytes types, ``x in y`` is ``True`` if and only if *x* is " "a substring of *y*. An equivalent test is ``y.find(x) != -1``. Empty " @@ -1946,14 +1940,14 @@ msgid "" "``\"\" in \"abc\"`` will return ``True``." msgstr "" -#: ../../reference/expressions.rst:1719 +#: ../../reference/expressions.rst:1722 msgid "" "For user-defined classes which define the :meth:`~object.__contains__` " "method, ``x in y`` returns ``True`` if ``y.__contains__(x)`` returns a true " "value, and ``False`` otherwise." msgstr "" -#: ../../reference/expressions.rst:1723 +#: ../../reference/expressions.rst:1726 msgid "" "For user-defined classes which do not define :meth:`~object.__contains__` " "but do define :meth:`~object.__iter__`, ``x in y`` is ``True`` if some value " @@ -1962,27 +1956,26 @@ msgid "" "it is as if :keyword:`in` raised that exception." msgstr "" -#: ../../reference/expressions.rst:1729 +#: ../../reference/expressions.rst:1732 msgid "" -"Lastly, the old-style iteration protocol is tried: if a class " -"defines :meth:`~object.__getitem__`, ``x in y`` is ``True`` if and only if " -"there is a non-negative integer index *i* such that ``x is y[i] or x == " -"y[i]``, and no lower integer index raises the :exc:`IndexError` exception. " -"(If any other exception is raised, it is as if :keyword:`in` raised that " -"exception)." +"Lastly, the old-style iteration protocol is tried: if a class defines :meth:" +"`~object.__getitem__`, ``x in y`` is ``True`` if and only if there is a non-" +"negative integer index *i* such that ``x is y[i] or x == y[i]``, and no " +"lower integer index raises the :exc:`IndexError` exception. (If any other " +"exception is raised, it is as if :keyword:`in` raised that exception)." msgstr "" -#: ../../reference/expressions.rst:1741 +#: ../../reference/expressions.rst:1744 msgid "" "The operator :keyword:`not in` is defined to have the inverse truth value " "of :keyword:`in`." msgstr "" -#: ../../reference/expressions.rst:1754 +#: ../../reference/expressions.rst:1757 msgid "Identity comparisons" msgstr "" -#: ../../reference/expressions.rst:1756 +#: ../../reference/expressions.rst:1759 msgid "" "The operators :keyword:`is` and :keyword:`is not` test for an object's " "identity: ``x is y`` is true if and only if *x* and *y* are the same " @@ -1990,40 +1983,40 @@ msgid "" "``x is not y`` yields the inverse truth value. [#]_" msgstr "" -#: ../../reference/expressions.rst:1768 +#: ../../reference/expressions.rst:1771 msgid "Boolean operations" msgstr "" -#: ../../reference/expressions.rst:1779 +#: ../../reference/expressions.rst:1782 msgid "" "In the context of Boolean operations, and also when expressions are used by " "control flow statements, the following values are interpreted as false: " "``False``, ``None``, numeric zero of all types, and empty strings and " "containers (including strings, tuples, lists, dictionaries, sets and " "frozensets). All other values are interpreted as true. User-defined " -"objects can customize their truth value by providing " -"a :meth:`~object.__bool__` method." +"objects can customize their truth value by providing a :meth:`~object." +"__bool__` method." msgstr "" -#: ../../reference/expressions.rst:1788 +#: ../../reference/expressions.rst:1791 msgid "" "The operator :keyword:`not` yields ``True`` if its argument is false, " "``False`` otherwise." msgstr "" -#: ../../reference/expressions.rst:1793 +#: ../../reference/expressions.rst:1796 msgid "" "The expression ``x and y`` first evaluates *x*; if *x* is false, its value " "is returned; otherwise, *y* is evaluated and the resulting value is returned." msgstr "" -#: ../../reference/expressions.rst:1798 +#: ../../reference/expressions.rst:1801 msgid "" "The expression ``x or y`` first evaluates *x*; if *x* is true, its value is " "returned; otherwise, *y* is evaluated and the resulting value is returned." msgstr "" -#: ../../reference/expressions.rst:1801 +#: ../../reference/expressions.rst:1804 msgid "" "Note that neither :keyword:`and` nor :keyword:`or` restrict the value and " "type they return to ``False`` and ``True``, but rather return the last " @@ -2034,23 +2027,23 @@ msgid "" "argument (for example, ``not 'foo'`` produces ``False`` rather than ``''``.)" msgstr "" -#: ../../reference/expressions.rst:1820 +#: ../../reference/expressions.rst:1823 msgid "Assignment expressions" msgstr "" -#: ../../reference/expressions.rst:1825 +#: ../../reference/expressions.rst:1828 msgid "" "An assignment expression (sometimes also called a \"named expression\" or " -"\"walrus\") assigns an :token:`~python-grammar:expression` to " -"an :token:`~python-grammar:identifier`, while also returning the value of " -"the :token:`~python-grammar:expression`." +"\"walrus\") assigns an :token:`~python-grammar:expression` to an :token:" +"`~python-grammar:identifier`, while also returning the value of the :token:" +"`~python-grammar:expression`." msgstr "" -#: ../../reference/expressions.rst:1830 +#: ../../reference/expressions.rst:1833 msgid "One common use case is when handling matched regular expressions:" msgstr "" -#: ../../reference/expressions.rst:1832 +#: ../../reference/expressions.rst:1835 msgid "" "if matching := pattern.search(data):\n" " do_something(matching)" @@ -2058,11 +2051,11 @@ msgstr "" "if matching := pattern.search(data):\n" " do_something(matching)" -#: ../../reference/expressions.rst:1837 +#: ../../reference/expressions.rst:1840 msgid "Or, when processing a file stream in chunks:" msgstr "" -#: ../../reference/expressions.rst:1839 +#: ../../reference/expressions.rst:1842 msgid "" "while chunk := file.read(9000):\n" " process(chunk)" @@ -2070,7 +2063,7 @@ msgstr "" "while chunk := file.read(9000):\n" " process(chunk)" -#: ../../reference/expressions.rst:1844 +#: ../../reference/expressions.rst:1847 msgid "" "Assignment expressions must be surrounded by parentheses when used as " "expression statements and when used as sub-expressions in slicing, " @@ -2080,36 +2073,36 @@ msgid "" "and ``while`` statements." msgstr "" -#: ../../reference/expressions.rst:1852 +#: ../../reference/expressions.rst:1855 msgid "See :pep:`572` for more details about assignment expressions." msgstr "" -#: ../../reference/expressions.rst:1859 +#: ../../reference/expressions.rst:1862 msgid "Conditional expressions" msgstr "" -#: ../../reference/expressions.rst:1871 +#: ../../reference/expressions.rst:1874 msgid "" "Conditional expressions (sometimes called a \"ternary operator\") have the " "lowest priority of all Python operations." msgstr "" -#: ../../reference/expressions.rst:1874 +#: ../../reference/expressions.rst:1877 msgid "" "The expression ``x if C else y`` first evaluates the condition, *C* rather " "than *x*. If *C* is true, *x* is evaluated and its value is returned; " "otherwise, *y* is evaluated and its value is returned." msgstr "" -#: ../../reference/expressions.rst:1878 +#: ../../reference/expressions.rst:1881 msgid "See :pep:`308` for more details about conditional expressions." msgstr "" -#: ../../reference/expressions.rst:1885 +#: ../../reference/expressions.rst:1888 msgid "Lambdas" msgstr "" -#: ../../reference/expressions.rst:1896 +#: ../../reference/expressions.rst:1899 msgid "" "Lambda expressions (sometimes called lambda forms) are used to create " "anonymous functions. The expression ``lambda parameters: expression`` yields " @@ -2117,7 +2110,7 @@ msgid "" "defined with:" msgstr "" -#: ../../reference/expressions.rst:1900 +#: ../../reference/expressions.rst:1903 msgid "" "def (parameters):\n" " return expression" @@ -2125,25 +2118,25 @@ msgstr "" "def (parameters):\n" " return expression" -#: ../../reference/expressions.rst:1905 +#: ../../reference/expressions.rst:1908 msgid "" "See section :ref:`function` for the syntax of parameter lists. Note that " "functions created with lambda expressions cannot contain statements or " "annotations." msgstr "" -#: ../../reference/expressions.rst:1913 +#: ../../reference/expressions.rst:1916 msgid "Expression lists" msgstr "" -#: ../../reference/expressions.rst:1929 +#: ../../reference/expressions.rst:1932 msgid "" "Except when part of a list or set display, an expression list containing at " "least one comma yields a tuple. The length of the tuple is the number of " "expressions in the list. The expressions are evaluated from left to right." msgstr "" -#: ../../reference/expressions.rst:1938 +#: ../../reference/expressions.rst:1941 msgid "" "An asterisk ``*`` denotes :dfn:`iterable unpacking`. Its operand must be " "an :term:`iterable`. The iterable is expanded into a sequence of items, " @@ -2151,42 +2144,42 @@ msgid "" "unpacking." msgstr "" -#: ../../reference/expressions.rst:1943 +#: ../../reference/expressions.rst:1946 msgid "" "Iterable unpacking in expression lists, originally proposed by :pep:`448`." msgstr "" -#: ../../reference/expressions.rst:1946 +#: ../../reference/expressions.rst:1949 msgid "Any item in an expression list may be starred. See :pep:`646`." msgstr "" -#: ../../reference/expressions.rst:1951 +#: ../../reference/expressions.rst:1954 msgid "" -"A trailing comma is required only to create a one-item tuple, such as " -"``1,``; it is optional in all other cases. A single expression without a " +"A trailing comma is required only to create a one-item tuple, such as ``1," +"``; it is optional in all other cases. A single expression without a " "trailing comma doesn't create a tuple, but rather yields the value of that " "expression. (To create an empty tuple, use an empty pair of parentheses: " "``()``.)" msgstr "" -#: ../../reference/expressions.rst:1962 +#: ../../reference/expressions.rst:1965 msgid "Evaluation order" msgstr "" -#: ../../reference/expressions.rst:1966 +#: ../../reference/expressions.rst:1969 msgid "" "Python evaluates expressions from left to right. Notice that while " "evaluating an assignment, the right-hand side is evaluated before the left-" "hand side." msgstr "" -#: ../../reference/expressions.rst:1969 +#: ../../reference/expressions.rst:1972 msgid "" "In the following lines, expressions will be evaluated in the arithmetic " "order of their suffixes::" msgstr "" -#: ../../reference/expressions.rst:1972 +#: ../../reference/expressions.rst:1975 msgid "" "expr1, expr2, expr3, expr4\n" "(expr1, expr2, expr3, expr4)\n" @@ -2202,11 +2195,11 @@ msgstr "" "expr1(expr2, expr3, *expr4, **expr5)\n" "expr3, expr4 = expr1, expr2" -#: ../../reference/expressions.rst:1983 +#: ../../reference/expressions.rst:1986 msgid "Operator precedence" msgstr "" -#: ../../reference/expressions.rst:1988 +#: ../../reference/expressions.rst:1991 msgid "" "The following table summarizes the operator precedence in Python, from " "highest precedence (most binding) to lowest precedence (least binding). " @@ -2216,176 +2209,176 @@ msgid "" "group from right to left)." msgstr "" -#: ../../reference/expressions.rst:1994 +#: ../../reference/expressions.rst:1997 msgid "" "Note that comparisons, membership tests, and identity tests, all have the " "same precedence and have a left-to-right chaining feature as described in " "the :ref:`comparisons` section." msgstr "" -#: ../../reference/expressions.rst:2000 +#: ../../reference/expressions.rst:2003 msgid "Operator" msgstr "運算子" -#: ../../reference/expressions.rst:2000 +#: ../../reference/expressions.rst:2003 msgid "Description" msgstr "描述" -#: ../../reference/expressions.rst:2002 +#: ../../reference/expressions.rst:2005 msgid "``(expressions...)``," msgstr "``(expressions...)``," -#: ../../reference/expressions.rst:2004 +#: ../../reference/expressions.rst:2007 msgid "``[expressions...]``, ``{key: value...}``, ``{expressions...}``" msgstr "``[expressions...]``, ``{key: value...}``, ``{expressions...}``" -#: ../../reference/expressions.rst:2002 +#: ../../reference/expressions.rst:2005 msgid "" "Binding or parenthesized expression, list display, dictionary display, set " "display" msgstr "" -#: ../../reference/expressions.rst:2008 +#: ../../reference/expressions.rst:2011 msgid "``x[index]``, ``x[index:index]``, ``x(arguments...)``, ``x.attribute``" msgstr "``x[index]``, ``x[index:index]``, ``x(arguments...)``, ``x.attribute``" -#: ../../reference/expressions.rst:2008 +#: ../../reference/expressions.rst:2011 msgid "Subscription, slicing, call, attribute reference" msgstr "" -#: ../../reference/expressions.rst:2011 +#: ../../reference/expressions.rst:2014 msgid ":keyword:`await x `" msgstr ":keyword:`await x `" -#: ../../reference/expressions.rst:2013 +#: ../../reference/expressions.rst:2016 msgid "``**``" msgstr "``**``" -#: ../../reference/expressions.rst:2013 +#: ../../reference/expressions.rst:2016 msgid "Exponentiation [#]_" msgstr "" -#: ../../reference/expressions.rst:2015 +#: ../../reference/expressions.rst:2018 msgid "``+x``, ``-x``, ``~x``" msgstr "``+x``, ``-x``, ``~x``" -#: ../../reference/expressions.rst:2015 +#: ../../reference/expressions.rst:2018 msgid "Positive, negative, bitwise NOT" msgstr "" -#: ../../reference/expressions.rst:2017 +#: ../../reference/expressions.rst:2020 msgid "``*``, ``@``, ``/``, ``//``, ``%``" msgstr "``*``, ``@``, ``/``, ``//``, ``%``" -#: ../../reference/expressions.rst:2017 +#: ../../reference/expressions.rst:2020 msgid "" "Multiplication, matrix multiplication, division, floor division, remainder " "[#]_" msgstr "" -#: ../../reference/expressions.rst:2021 +#: ../../reference/expressions.rst:2024 msgid "``+``, ``-``" msgstr "``+``, ``-``" -#: ../../reference/expressions.rst:2021 +#: ../../reference/expressions.rst:2024 msgid "Addition and subtraction" msgstr "" -#: ../../reference/expressions.rst:2023 +#: ../../reference/expressions.rst:2026 msgid "``<<``, ``>>``" msgstr "``<<``, ``>>``" -#: ../../reference/expressions.rst:2023 +#: ../../reference/expressions.rst:2026 msgid "Shifts" msgstr "" -#: ../../reference/expressions.rst:2025 +#: ../../reference/expressions.rst:2028 msgid "``&``" msgstr "``&``" -#: ../../reference/expressions.rst:2025 +#: ../../reference/expressions.rst:2028 msgid "Bitwise AND" msgstr "" -#: ../../reference/expressions.rst:2027 +#: ../../reference/expressions.rst:2030 msgid "``^``" msgstr "``^``" -#: ../../reference/expressions.rst:2027 +#: ../../reference/expressions.rst:2030 msgid "Bitwise XOR" msgstr "" -#: ../../reference/expressions.rst:2029 +#: ../../reference/expressions.rst:2032 msgid "``|``" msgstr "``|``" -#: ../../reference/expressions.rst:2029 +#: ../../reference/expressions.rst:2032 msgid "Bitwise OR" msgstr "" -#: ../../reference/expressions.rst:2031 +#: ../../reference/expressions.rst:2034 msgid "" ":keyword:`in`, :keyword:`not in`, :keyword:`is`, :keyword:`is not`, ``<``, " "``<=``, ``>``, ``>=``, ``!=``, ``==``" msgstr "" -#: ../../reference/expressions.rst:2031 +#: ../../reference/expressions.rst:2034 msgid "Comparisons, including membership tests and identity tests" msgstr "" -#: ../../reference/expressions.rst:2035 +#: ../../reference/expressions.rst:2038 msgid ":keyword:`not x `" msgstr ":keyword:`not x `" -#: ../../reference/expressions.rst:2035 +#: ../../reference/expressions.rst:2038 msgid "Boolean NOT" msgstr "" -#: ../../reference/expressions.rst:2037 +#: ../../reference/expressions.rst:2040 msgid ":keyword:`and`" msgstr ":keyword:`and`" -#: ../../reference/expressions.rst:2037 +#: ../../reference/expressions.rst:2040 msgid "Boolean AND" msgstr "" -#: ../../reference/expressions.rst:2039 +#: ../../reference/expressions.rst:2042 msgid ":keyword:`or`" msgstr ":keyword:`or`" -#: ../../reference/expressions.rst:2039 +#: ../../reference/expressions.rst:2042 msgid "Boolean OR" msgstr "" -#: ../../reference/expressions.rst:2041 +#: ../../reference/expressions.rst:2044 msgid ":keyword:`if ` -- :keyword:`!else`" msgstr ":keyword:`if ` -- :keyword:`!else`" -#: ../../reference/expressions.rst:2041 +#: ../../reference/expressions.rst:2044 msgid "Conditional expression" msgstr "" -#: ../../reference/expressions.rst:2043 +#: ../../reference/expressions.rst:2046 msgid ":keyword:`lambda`" msgstr ":keyword:`lambda`" -#: ../../reference/expressions.rst:2043 +#: ../../reference/expressions.rst:2046 msgid "Lambda expression" msgstr "" -#: ../../reference/expressions.rst:2045 +#: ../../reference/expressions.rst:2048 msgid "``:=``" msgstr "``:=``" -#: ../../reference/expressions.rst:2045 +#: ../../reference/expressions.rst:2048 msgid "Assignment expression" msgstr "" -#: ../../reference/expressions.rst:2050 +#: ../../reference/expressions.rst:2053 msgid "Footnotes" msgstr "註解" -#: ../../reference/expressions.rst:2051 +#: ../../reference/expressions.rst:2054 msgid "" "While ``abs(x%y) < abs(y)`` is true mathematically, for floats it may not be " "true numerically due to roundoff. For example, and assuming a platform on " @@ -2397,7 +2390,7 @@ msgid "" "approach is more appropriate depends on the application." msgstr "" -#: ../../reference/expressions.rst:2060 +#: ../../reference/expressions.rst:2063 msgid "" "If x is very close to an exact integer multiple of y, it's possible for ``x//" "y`` to be one larger than ``(x-x%y)//y`` due to rounding. In such cases, " @@ -2405,7 +2398,7 @@ msgid "" "* y + x % y`` be very close to ``x``." msgstr "" -#: ../../reference/expressions.rst:2065 +#: ../../reference/expressions.rst:2068 msgid "" "The Unicode standard distinguishes between :dfn:`code points` (e.g. U+0041) " "and :dfn:`abstract characters` (e.g. \"LATIN CAPITAL LETTER A\"). While most " @@ -2419,7 +2412,7 @@ msgid "" "(COMBINING CEDILLA)." msgstr "" -#: ../../reference/expressions.rst:2076 +#: ../../reference/expressions.rst:2079 msgid "" "The comparison operators on strings compare at the level of Unicode code " "points. This may be counter-intuitive to humans. For example, ``\"\\u00C7\" " @@ -2427,13 +2420,13 @@ msgid "" "same abstract character \"LATIN CAPITAL LETTER C WITH CEDILLA\"." msgstr "" -#: ../../reference/expressions.rst:2081 +#: ../../reference/expressions.rst:2084 msgid "" "To compare strings at the level of abstract characters (that is, in a way " "intuitive to humans), use :func:`unicodedata.normalize`." msgstr "" -#: ../../reference/expressions.rst:2084 +#: ../../reference/expressions.rst:2087 msgid "" "Due to automatic garbage-collection, free lists, and the dynamic nature of " "descriptors, you may notice seemingly unusual behaviour in certain uses of " @@ -2441,22 +2434,22 @@ msgid "" "instance methods, or constants. Check their documentation for more info." msgstr "" -#: ../../reference/expressions.rst:2089 +#: ../../reference/expressions.rst:2092 msgid "" "The power operator ``**`` binds less tightly than an arithmetic or bitwise " "unary operator on its right, that is, ``2**-1`` is ``0.5``." msgstr "" -#: ../../reference/expressions.rst:2092 +#: ../../reference/expressions.rst:2095 msgid "" "The ``%`` operator is also used for string formatting; the same precedence " "applies." msgstr "" #: ../../reference/expressions.rst:8 ../../reference/expressions.rst:393 -#: ../../reference/expressions.rst:448 ../../reference/expressions.rst:1770 -#: ../../reference/expressions.rst:1810 ../../reference/expressions.rst:1861 -#: ../../reference/expressions.rst:1887 ../../reference/expressions.rst:1915 +#: ../../reference/expressions.rst:449 ../../reference/expressions.rst:1773 +#: ../../reference/expressions.rst:1813 ../../reference/expressions.rst:1864 +#: ../../reference/expressions.rst:1890 ../../reference/expressions.rst:1918 msgid "expression" msgstr "" @@ -2464,8 +2457,8 @@ msgstr "" msgid "BNF" msgstr "BNF" -#: ../../reference/expressions.rst:28 ../../reference/expressions.rst:1262 -#: ../../reference/expressions.rst:1310 +#: ../../reference/expressions.rst:28 ../../reference/expressions.rst:1265 +#: ../../reference/expressions.rst:1313 msgid "arithmetic" msgstr "" @@ -2485,11 +2478,11 @@ msgstr "name(名稱)" msgid "identifier" msgstr "" -#: ../../reference/expressions.rst:74 ../../reference/expressions.rst:569 -#: ../../reference/expressions.rst:624 ../../reference/expressions.rst:753 -#: ../../reference/expressions.rst:808 ../../reference/expressions.rst:855 -#: ../../reference/expressions.rst:1299 ../../reference/expressions.rst:1348 -#: ../../reference/expressions.rst:1444 +#: ../../reference/expressions.rst:74 ../../reference/expressions.rst:570 +#: ../../reference/expressions.rst:625 ../../reference/expressions.rst:756 +#: ../../reference/expressions.rst:811 ../../reference/expressions.rst:858 +#: ../../reference/expressions.rst:1302 ../../reference/expressions.rst:1351 +#: ../../reference/expressions.rst:1447 msgid "exception" msgstr "" @@ -2528,12 +2521,12 @@ msgstr "type(型別)" #: ../../reference/expressions.rst:146 ../../reference/expressions.rst:275 #: ../../reference/expressions.rst:301 ../../reference/expressions.rst:329 #: ../../reference/expressions.rst:372 ../../reference/expressions.rst:393 -#: ../../reference/expressions.rst:557 ../../reference/expressions.rst:743 -#: ../../reference/expressions.rst:855 ../../reference/expressions.rst:884 -#: ../../reference/expressions.rst:961 ../../reference/expressions.rst:1005 -#: ../../reference/expressions.rst:1153 ../../reference/expressions.rst:1167 -#: ../../reference/expressions.rst:1181 ../../reference/expressions.rst:1188 -#: ../../reference/expressions.rst:1735 ../../reference/expressions.rst:1927 +#: ../../reference/expressions.rst:558 ../../reference/expressions.rst:746 +#: ../../reference/expressions.rst:858 ../../reference/expressions.rst:887 +#: ../../reference/expressions.rst:964 ../../reference/expressions.rst:1008 +#: ../../reference/expressions.rst:1156 ../../reference/expressions.rst:1170 +#: ../../reference/expressions.rst:1184 ../../reference/expressions.rst:1191 +#: ../../reference/expressions.rst:1738 ../../reference/expressions.rst:1930 msgid "object" msgstr "object(物件)" @@ -2542,7 +2535,7 @@ msgid "parenthesized form" msgstr "" #: ../../reference/expressions.rst:162 ../../reference/expressions.rst:393 -#: ../../reference/expressions.rst:1005 +#: ../../reference/expressions.rst:1008 msgid "() (parentheses)" msgstr "() (圓括號)" @@ -2554,19 +2547,19 @@ msgstr "" msgid "empty" msgstr "" -#: ../../reference/expressions.rst:175 ../../reference/expressions.rst:884 -#: ../../reference/expressions.rst:961 ../../reference/expressions.rst:1927 +#: ../../reference/expressions.rst:175 ../../reference/expressions.rst:887 +#: ../../reference/expressions.rst:964 ../../reference/expressions.rst:1930 msgid "tuple" msgstr "" -#: ../../reference/expressions.rst:181 ../../reference/expressions.rst:1949 +#: ../../reference/expressions.rst:181 ../../reference/expressions.rst:1952 msgid "comma" msgstr "" #: ../../reference/expressions.rst:181 ../../reference/expressions.rst:275 #: ../../reference/expressions.rst:301 ../../reference/expressions.rst:329 -#: ../../reference/expressions.rst:955 ../../reference/expressions.rst:1005 -#: ../../reference/expressions.rst:1915 +#: ../../reference/expressions.rst:958 ../../reference/expressions.rst:1008 +#: ../../reference/expressions.rst:1918 msgid ", (comma)" msgstr ", (逗號)" @@ -2583,7 +2576,7 @@ msgstr "for" msgid "in comprehensions" msgstr "於 comprehensions(綜合運算)" -#: ../../reference/expressions.rst:206 ../../reference/expressions.rst:1861 +#: ../../reference/expressions.rst:206 ../../reference/expressions.rst:1864 msgid "if" msgstr "if" @@ -2591,13 +2584,13 @@ msgstr "if" msgid "async for" msgstr "async for" -#: ../../reference/expressions.rst:241 ../../reference/expressions.rst:1206 +#: ../../reference/expressions.rst:241 ../../reference/expressions.rst:1209 msgid "await" msgstr "await" -#: ../../reference/expressions.rst:275 ../../reference/expressions.rst:855 -#: ../../reference/expressions.rst:884 ../../reference/expressions.rst:961 -#: ../../reference/expressions.rst:1915 +#: ../../reference/expressions.rst:275 ../../reference/expressions.rst:858 +#: ../../reference/expressions.rst:887 ../../reference/expressions.rst:964 +#: ../../reference/expressions.rst:1918 msgid "list" msgstr "list(串列)" @@ -2606,7 +2599,7 @@ msgstr "list(串列)" msgid "display" msgstr "" -#: ../../reference/expressions.rst:275 ../../reference/expressions.rst:880 +#: ../../reference/expressions.rst:275 ../../reference/expressions.rst:883 msgid "[] (square brackets)" msgstr "[] (方括號)" @@ -2615,7 +2608,7 @@ msgid "list expression" msgstr "list expression(串列運算式)" #: ../../reference/expressions.rst:275 ../../reference/expressions.rst:301 -#: ../../reference/expressions.rst:1915 +#: ../../reference/expressions.rst:1918 msgid "expression list" msgstr "expression list(運算式串列)" @@ -2632,7 +2625,7 @@ msgid "set expression" msgstr "set expression(集合運算式)" #: ../../reference/expressions.rst:329 ../../reference/expressions.rst:355 -#: ../../reference/expressions.rst:884 +#: ../../reference/expressions.rst:887 msgid "dictionary" msgstr "dictionary(字典)" @@ -2652,8 +2645,8 @@ msgstr "key/value pair(鍵/值對)" msgid "dictionary expression" msgstr "dictionary expression(字典運算式)" -#: ../../reference/expressions.rst:329 ../../reference/expressions.rst:955 -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:329 ../../reference/expressions.rst:958 +#: ../../reference/expressions.rst:1890 msgid ": (colon)" msgstr ": (冒號)" @@ -2665,13 +2658,13 @@ msgstr "於字典運算式" msgid "in dictionary displays" msgstr "於字典顯示" -#: ../../reference/expressions.rst:355 ../../reference/expressions.rst:1088 -#: ../../reference/expressions.rst:1934 +#: ../../reference/expressions.rst:355 ../../reference/expressions.rst:1091 +#: ../../reference/expressions.rst:1937 msgid "unpacking" msgstr "unpacking(解包)" -#: ../../reference/expressions.rst:355 ../../reference/expressions.rst:1118 -#: ../../reference/expressions.rst:1226 +#: ../../reference/expressions.rst:355 ../../reference/expressions.rst:1121 +#: ../../reference/expressions.rst:1229 msgid "**" msgstr "**" @@ -2679,8 +2672,8 @@ msgstr "**" msgid "hashable" msgstr "hashable(可雜湊)" -#: ../../reference/expressions.rst:393 ../../reference/expressions.rst:448 -#: ../../reference/expressions.rst:557 +#: ../../reference/expressions.rst:393 ../../reference/expressions.rst:449 +#: ../../reference/expressions.rst:558 msgid "generator" msgstr "generator(產生器)" @@ -2688,533 +2681,533 @@ msgstr "generator(產生器)" msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../reference/expressions.rst:448 ../../reference/expressions.rst:1206 +#: ../../reference/expressions.rst:449 ../../reference/expressions.rst:1209 msgid "keyword" msgstr "keyword(關鍵字)" -#: ../../reference/expressions.rst:448 ../../reference/expressions.rst:644 +#: ../../reference/expressions.rst:449 ../../reference/expressions.rst:647 msgid "yield" msgstr "yield" -#: ../../reference/expressions.rst:448 ../../reference/expressions.rst:516 +#: ../../reference/expressions.rst:449 ../../reference/expressions.rst:517 msgid "from" msgstr "from" -#: ../../reference/expressions.rst:448 ../../reference/expressions.rst:1153 -#: ../../reference/expressions.rst:1167 ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:449 ../../reference/expressions.rst:1156 +#: ../../reference/expressions.rst:1170 ../../reference/expressions.rst:1890 msgid "function" msgstr "function (函式)" -#: ../../reference/expressions.rst:502 +#: ../../reference/expressions.rst:503 msgid "coroutine" msgstr "coroutine(協程)" -#: ../../reference/expressions.rst:516 +#: ../../reference/expressions.rst:517 msgid "yield from expression" msgstr "yield from expression(yield from 運算式)" -#: ../../reference/expressions.rst:569 +#: ../../reference/expressions.rst:570 msgid "StopIteration" msgstr "StopIteration" -#: ../../reference/expressions.rst:624 ../../reference/expressions.rst:808 +#: ../../reference/expressions.rst:625 ../../reference/expressions.rst:811 msgid "GeneratorExit" msgstr "GeneratorExit" -#: ../../reference/expressions.rst:644 +#: ../../reference/expressions.rst:647 msgid "examples" msgstr "範例" -#: ../../reference/expressions.rst:743 +#: ../../reference/expressions.rst:746 msgid "asynchronous-generator" msgstr "asynchronous-generator(非同步產生器)" -#: ../../reference/expressions.rst:753 +#: ../../reference/expressions.rst:756 msgid "StopAsyncIteration" msgstr "StopAsyncIteration" -#: ../../reference/expressions.rst:832 +#: ../../reference/expressions.rst:835 msgid "primary" msgstr "primary(主要)" -#: ../../reference/expressions.rst:846 +#: ../../reference/expressions.rst:849 msgid "attribute" msgstr "attribute(屬性)" -#: ../../reference/expressions.rst:846 +#: ../../reference/expressions.rst:849 msgid "reference" msgstr "reference(參照)" -#: ../../reference/expressions.rst:846 +#: ../../reference/expressions.rst:849 msgid ". (dot)" msgstr ". (點)" -#: ../../reference/expressions.rst:846 +#: ../../reference/expressions.rst:849 msgid "attribute reference" msgstr "attribute reference(屬性參照)" -#: ../../reference/expressions.rst:855 +#: ../../reference/expressions.rst:858 msgid "AttributeError" msgstr "AttributeError" -#: ../../reference/expressions.rst:855 +#: ../../reference/expressions.rst:858 msgid "module" msgstr "module(模組)" -#: ../../reference/expressions.rst:880 +#: ../../reference/expressions.rst:883 msgid "subscription" msgstr "subscription(下標)" -#: ../../reference/expressions.rst:884 ../../reference/expressions.rst:961 -#: ../../reference/expressions.rst:1735 +#: ../../reference/expressions.rst:887 ../../reference/expressions.rst:964 +#: ../../reference/expressions.rst:1738 msgid "sequence" msgstr "sequence(序列)" -#: ../../reference/expressions.rst:884 +#: ../../reference/expressions.rst:887 msgid "mapping" msgstr "mapping(對映)" -#: ../../reference/expressions.rst:884 ../../reference/expressions.rst:941 -#: ../../reference/expressions.rst:961 +#: ../../reference/expressions.rst:887 ../../reference/expressions.rst:944 +#: ../../reference/expressions.rst:964 msgid "string" msgstr "string(字串)" -#: ../../reference/expressions.rst:884 ../../reference/expressions.rst:941 +#: ../../reference/expressions.rst:887 ../../reference/expressions.rst:944 msgid "item" msgstr "item(項目)" -#: ../../reference/expressions.rst:941 +#: ../../reference/expressions.rst:944 msgid "character" msgstr "character(字元)" -#: ../../reference/expressions.rst:955 +#: ../../reference/expressions.rst:958 msgid "slicing" msgstr "slicing(切片)" -#: ../../reference/expressions.rst:955 +#: ../../reference/expressions.rst:958 msgid "slice" msgstr "slice(切片)" -#: ../../reference/expressions.rst:987 +#: ../../reference/expressions.rst:990 msgid "start (slice object attribute)" msgstr "start(切片物件屬性)" -#: ../../reference/expressions.rst:987 +#: ../../reference/expressions.rst:990 msgid "stop (slice object attribute)" msgstr "stop(切片物件屬性)" -#: ../../reference/expressions.rst:987 +#: ../../reference/expressions.rst:990 msgid "step (slice object attribute)" msgstr "step(切片物件屬性)" -#: ../../reference/expressions.rst:1005 +#: ../../reference/expressions.rst:1008 msgid "callable" msgstr "callable(可呼叫物件)" -#: ../../reference/expressions.rst:1005 ../../reference/expressions.rst:1153 -#: ../../reference/expressions.rst:1167 ../../reference/expressions.rst:1181 -#: ../../reference/expressions.rst:1188 ../../reference/expressions.rst:1198 +#: ../../reference/expressions.rst:1008 ../../reference/expressions.rst:1156 +#: ../../reference/expressions.rst:1170 ../../reference/expressions.rst:1184 +#: ../../reference/expressions.rst:1191 ../../reference/expressions.rst:1201 msgid "call" msgstr "call(呼叫)" -#: ../../reference/expressions.rst:1005 +#: ../../reference/expressions.rst:1008 msgid "argument" msgstr "argument(引數)" -#: ../../reference/expressions.rst:1005 ../../reference/expressions.rst:1038 +#: ../../reference/expressions.rst:1008 ../../reference/expressions.rst:1041 msgid "call semantics" msgstr "call semantics(呼叫語意)" -#: ../../reference/expressions.rst:1005 +#: ../../reference/expressions.rst:1008 msgid "argument list" msgstr "argument list(引數列表)" -#: ../../reference/expressions.rst:1005 +#: ../../reference/expressions.rst:1008 msgid "= (equals)" msgstr "= (等號)" -#: ../../reference/expressions.rst:1005 ../../reference/expressions.rst:1088 -#: ../../reference/expressions.rst:1118 +#: ../../reference/expressions.rst:1008 ../../reference/expressions.rst:1091 +#: ../../reference/expressions.rst:1121 msgid "in function calls" msgstr "於函式呼叫中" -#: ../../reference/expressions.rst:1038 +#: ../../reference/expressions.rst:1041 msgid "parameter" msgstr "parameter(參數)" -#: ../../reference/expressions.rst:1088 ../../reference/expressions.rst:1323 -#: ../../reference/expressions.rst:1934 +#: ../../reference/expressions.rst:1091 ../../reference/expressions.rst:1326 +#: ../../reference/expressions.rst:1937 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../reference/expressions.rst:1153 +#: ../../reference/expressions.rst:1156 msgid "user-defined" msgstr "user-defined(使用者定義)" -#: ../../reference/expressions.rst:1153 +#: ../../reference/expressions.rst:1156 msgid "user-defined function" msgstr "user-defined function(使用者定義函式)" -#: ../../reference/expressions.rst:1167 +#: ../../reference/expressions.rst:1170 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../reference/expressions.rst:1167 +#: ../../reference/expressions.rst:1170 msgid "method" msgstr "method(方法)" -#: ../../reference/expressions.rst:1167 +#: ../../reference/expressions.rst:1170 msgid "built-in method" msgstr "built-in method(內建方法)" -#: ../../reference/expressions.rst:1181 +#: ../../reference/expressions.rst:1184 msgid "class" msgstr "class(類別)" -#: ../../reference/expressions.rst:1181 +#: ../../reference/expressions.rst:1184 msgid "class object" msgstr "class object(類別物件)" -#: ../../reference/expressions.rst:1188 +#: ../../reference/expressions.rst:1191 msgid "class instance" msgstr "class instance(類別實例)" -#: ../../reference/expressions.rst:1188 ../../reference/expressions.rst:1198 +#: ../../reference/expressions.rst:1191 ../../reference/expressions.rst:1201 msgid "instance" msgstr "instance(實例)" -#: ../../reference/expressions.rst:1198 +#: ../../reference/expressions.rst:1201 msgid "__call__() (object method)" msgstr "__call__() (物件方法)" -#: ../../reference/expressions.rst:1226 +#: ../../reference/expressions.rst:1229 msgid "power" msgstr "power(次方)" -#: ../../reference/expressions.rst:1226 ../../reference/expressions.rst:1262 -#: ../../reference/expressions.rst:1310 ../../reference/expressions.rst:1426 -#: ../../reference/expressions.rst:1455 ../../reference/expressions.rst:1770 +#: ../../reference/expressions.rst:1229 ../../reference/expressions.rst:1265 +#: ../../reference/expressions.rst:1313 ../../reference/expressions.rst:1429 +#: ../../reference/expressions.rst:1458 ../../reference/expressions.rst:1773 msgid "operation" msgstr "operation(操作)" -#: ../../reference/expressions.rst:1226 ../../reference/expressions.rst:1271 -#: ../../reference/expressions.rst:1280 ../../reference/expressions.rst:1288 -#: ../../reference/expressions.rst:1323 ../../reference/expressions.rst:1336 -#: ../../reference/expressions.rst:1348 ../../reference/expressions.rst:1366 -#: ../../reference/expressions.rst:1396 ../../reference/expressions.rst:1409 -#: ../../reference/expressions.rst:1426 ../../reference/expressions.rst:1464 -#: ../../reference/expressions.rst:1472 ../../reference/expressions.rst:1481 -#: ../../reference/expressions.rst:1496 ../../reference/expressions.rst:1735 -#: ../../reference/expressions.rst:1744 ../../reference/expressions.rst:1786 -#: ../../reference/expressions.rst:1791 ../../reference/expressions.rst:1796 -#: ../../reference/expressions.rst:1861 ../../reference/expressions.rst:1985 +#: ../../reference/expressions.rst:1229 ../../reference/expressions.rst:1274 +#: ../../reference/expressions.rst:1283 ../../reference/expressions.rst:1291 +#: ../../reference/expressions.rst:1326 ../../reference/expressions.rst:1339 +#: ../../reference/expressions.rst:1351 ../../reference/expressions.rst:1369 +#: ../../reference/expressions.rst:1399 ../../reference/expressions.rst:1412 +#: ../../reference/expressions.rst:1429 ../../reference/expressions.rst:1467 +#: ../../reference/expressions.rst:1475 ../../reference/expressions.rst:1484 +#: ../../reference/expressions.rst:1499 ../../reference/expressions.rst:1738 +#: ../../reference/expressions.rst:1747 ../../reference/expressions.rst:1789 +#: ../../reference/expressions.rst:1794 ../../reference/expressions.rst:1799 +#: ../../reference/expressions.rst:1864 ../../reference/expressions.rst:1988 msgid "operator" msgstr "operator(運算子)" -#: ../../reference/expressions.rst:1262 +#: ../../reference/expressions.rst:1265 msgid "unary" msgstr "unary(一元)" -#: ../../reference/expressions.rst:1262 ../../reference/expressions.rst:1455 -#: ../../reference/expressions.rst:1464 ../../reference/expressions.rst:1472 -#: ../../reference/expressions.rst:1481 +#: ../../reference/expressions.rst:1265 ../../reference/expressions.rst:1458 +#: ../../reference/expressions.rst:1467 ../../reference/expressions.rst:1475 +#: ../../reference/expressions.rst:1484 msgid "bitwise" msgstr "bitwise(位元)" -#: ../../reference/expressions.rst:1271 +#: ../../reference/expressions.rst:1274 msgid "negation" msgstr "negation(否定)" -#: ../../reference/expressions.rst:1271 +#: ../../reference/expressions.rst:1274 msgid "minus" msgstr "minus(減)" -#: ../../reference/expressions.rst:1271 ../../reference/expressions.rst:1409 +#: ../../reference/expressions.rst:1274 ../../reference/expressions.rst:1412 msgid "- (minus)" msgstr "- (減號)" -#: ../../reference/expressions.rst:1271 ../../reference/expressions.rst:1280 +#: ../../reference/expressions.rst:1274 ../../reference/expressions.rst:1283 msgid "unary operator" msgstr "unary operator(一元運算子)" -#: ../../reference/expressions.rst:1280 +#: ../../reference/expressions.rst:1283 msgid "plus" msgstr "plus(加)" -#: ../../reference/expressions.rst:1280 ../../reference/expressions.rst:1396 +#: ../../reference/expressions.rst:1283 ../../reference/expressions.rst:1399 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../reference/expressions.rst:1288 +#: ../../reference/expressions.rst:1291 msgid "inversion" msgstr "inversion(反轉)" -#: ../../reference/expressions.rst:1288 +#: ../../reference/expressions.rst:1291 msgid "~ (tilde)" msgstr "~ (波浪號)" -#: ../../reference/expressions.rst:1299 +#: ../../reference/expressions.rst:1302 msgid "TypeError" msgstr "TypeError" -#: ../../reference/expressions.rst:1310 ../../reference/expressions.rst:1455 +#: ../../reference/expressions.rst:1313 ../../reference/expressions.rst:1458 msgid "binary" msgstr "binary(二進位)" -#: ../../reference/expressions.rst:1323 +#: ../../reference/expressions.rst:1326 msgid "multiplication" msgstr "multiplication(乘)" -#: ../../reference/expressions.rst:1336 +#: ../../reference/expressions.rst:1339 msgid "matrix multiplication" msgstr "matrix multiplication(矩陣乘法)" -#: ../../reference/expressions.rst:1336 +#: ../../reference/expressions.rst:1339 msgid "@ (at)" msgstr "@ (在)" -#: ../../reference/expressions.rst:1348 +#: ../../reference/expressions.rst:1351 msgid "ZeroDivisionError" msgstr "ZeroDivisionError" -#: ../../reference/expressions.rst:1348 +#: ../../reference/expressions.rst:1351 msgid "division" msgstr "division(除)" -#: ../../reference/expressions.rst:1348 +#: ../../reference/expressions.rst:1351 msgid "/ (slash)" msgstr "/ (斜線)" -#: ../../reference/expressions.rst:1348 +#: ../../reference/expressions.rst:1351 msgid "//" msgstr "//" -#: ../../reference/expressions.rst:1366 +#: ../../reference/expressions.rst:1369 msgid "modulo" msgstr "modulo(餘數)" -#: ../../reference/expressions.rst:1366 +#: ../../reference/expressions.rst:1369 msgid "% (percent)" msgstr "% (百分號)" -#: ../../reference/expressions.rst:1396 +#: ../../reference/expressions.rst:1399 msgid "addition" msgstr "addition(加)" -#: ../../reference/expressions.rst:1396 ../../reference/expressions.rst:1409 +#: ../../reference/expressions.rst:1399 ../../reference/expressions.rst:1412 msgid "binary operator" msgstr "binary operator(二元運算子)" -#: ../../reference/expressions.rst:1409 +#: ../../reference/expressions.rst:1412 msgid "subtraction" msgstr "subtraction(減)" -#: ../../reference/expressions.rst:1426 +#: ../../reference/expressions.rst:1429 msgid "shifting" msgstr "shifting(移動)" -#: ../../reference/expressions.rst:1426 +#: ../../reference/expressions.rst:1429 msgid "<<" msgstr "<<" -#: ../../reference/expressions.rst:1426 +#: ../../reference/expressions.rst:1429 msgid ">>" msgstr ">>" -#: ../../reference/expressions.rst:1444 +#: ../../reference/expressions.rst:1447 msgid "ValueError" msgstr "ValueError" -#: ../../reference/expressions.rst:1464 ../../reference/expressions.rst:1791 +#: ../../reference/expressions.rst:1467 ../../reference/expressions.rst:1794 msgid "and" msgstr "and" -#: ../../reference/expressions.rst:1464 +#: ../../reference/expressions.rst:1467 msgid "& (ampersand)" msgstr "& (和號)" -#: ../../reference/expressions.rst:1472 +#: ../../reference/expressions.rst:1475 msgid "xor" msgstr "xor" -#: ../../reference/expressions.rst:1472 +#: ../../reference/expressions.rst:1475 msgid "exclusive" msgstr "exclusive(排外)" -#: ../../reference/expressions.rst:1472 ../../reference/expressions.rst:1481 -#: ../../reference/expressions.rst:1796 +#: ../../reference/expressions.rst:1475 ../../reference/expressions.rst:1484 +#: ../../reference/expressions.rst:1799 msgid "or" msgstr "or" -#: ../../reference/expressions.rst:1472 +#: ../../reference/expressions.rst:1475 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../reference/expressions.rst:1481 +#: ../../reference/expressions.rst:1484 msgid "inclusive" msgstr "inclusive(包含)" -#: ../../reference/expressions.rst:1481 +#: ../../reference/expressions.rst:1484 msgid "| (vertical bar)" msgstr "| (垂直線)" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "comparison" msgstr "comparison(比較)" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "C" msgstr "C" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "language" msgstr "language(語言)" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "< (less)" msgstr "< (小於)" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "> (greater)" msgstr "> (大於)" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "<=" msgstr "<=" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid ">=" msgstr ">=" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "==" msgstr "==" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1499 msgid "!=" msgstr "!=" -#: ../../reference/expressions.rst:1520 +#: ../../reference/expressions.rst:1523 msgid "chaining" msgstr "chaining(鏈接)" -#: ../../reference/expressions.rst:1520 +#: ../../reference/expressions.rst:1523 msgid "comparisons" msgstr "comparisons(比較)" -#: ../../reference/expressions.rst:1735 +#: ../../reference/expressions.rst:1738 msgid "in" msgstr "in" -#: ../../reference/expressions.rst:1735 +#: ../../reference/expressions.rst:1738 msgid "not in" msgstr "not in" -#: ../../reference/expressions.rst:1735 +#: ../../reference/expressions.rst:1738 msgid "membership" msgstr "membership(成員)" -#: ../../reference/expressions.rst:1735 ../../reference/expressions.rst:1744 +#: ../../reference/expressions.rst:1738 ../../reference/expressions.rst:1747 msgid "test" msgstr "test(測試)" -#: ../../reference/expressions.rst:1744 +#: ../../reference/expressions.rst:1747 msgid "is" msgstr "is" -#: ../../reference/expressions.rst:1744 +#: ../../reference/expressions.rst:1747 msgid "is not" msgstr "is not" -#: ../../reference/expressions.rst:1744 +#: ../../reference/expressions.rst:1747 msgid "identity" msgstr "identity" -#: ../../reference/expressions.rst:1770 +#: ../../reference/expressions.rst:1773 msgid "Conditional" msgstr "Conditional(條件式)" -#: ../../reference/expressions.rst:1770 +#: ../../reference/expressions.rst:1773 msgid "Boolean" msgstr "Boolean(布林)" -#: ../../reference/expressions.rst:1786 +#: ../../reference/expressions.rst:1789 msgid "not" msgstr "not" -#: ../../reference/expressions.rst:1810 +#: ../../reference/expressions.rst:1813 msgid ":= (colon equals)" msgstr ":= (冒號等於)" -#: ../../reference/expressions.rst:1810 +#: ../../reference/expressions.rst:1813 msgid "assignment expression" msgstr "assignment expression(賦值運算式)" -#: ../../reference/expressions.rst:1810 +#: ../../reference/expressions.rst:1813 msgid "walrus operator" msgstr "walrus operator(海象運算子)" -#: ../../reference/expressions.rst:1810 +#: ../../reference/expressions.rst:1813 msgid "named expression" msgstr "named expression(附名運算式)" -#: ../../reference/expressions.rst:1810 +#: ../../reference/expressions.rst:1813 msgid "assignment" msgstr "assignment(賦值)" -#: ../../reference/expressions.rst:1861 +#: ../../reference/expressions.rst:1864 msgid "conditional" msgstr "conditional(條件式)" -#: ../../reference/expressions.rst:1861 +#: ../../reference/expressions.rst:1864 msgid "ternary" msgstr "ternary(三元)" -#: ../../reference/expressions.rst:1861 +#: ../../reference/expressions.rst:1864 msgid "conditional expression" msgstr "conditional expression(條件運算式)" -#: ../../reference/expressions.rst:1861 +#: ../../reference/expressions.rst:1864 msgid "else" msgstr "else" -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:1890 msgid "lambda" msgstr "lambda" -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:1890 msgid "form" msgstr "form" -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:1890 msgid "anonymous" msgstr "anonymous(匿名)" -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:1890 msgid "lambda expression" msgstr "lambda expression(lambda 運算式)" -#: ../../reference/expressions.rst:1934 +#: ../../reference/expressions.rst:1937 msgid "iterable" msgstr "iterable(可疊代)" -#: ../../reference/expressions.rst:1934 +#: ../../reference/expressions.rst:1937 msgid "in expression lists" msgstr "於 expression list(運算式串列)" -#: ../../reference/expressions.rst:1949 +#: ../../reference/expressions.rst:1952 msgid "trailing" msgstr "trailing" -#: ../../reference/expressions.rst:1964 +#: ../../reference/expressions.rst:1967 msgid "evaluation" msgstr "evaluation" -#: ../../reference/expressions.rst:1964 +#: ../../reference/expressions.rst:1967 msgid "order" msgstr "order(順序)" -#: ../../reference/expressions.rst:1985 +#: ../../reference/expressions.rst:1988 msgid "precedence" msgstr "precedence(優先順序)" diff --git a/reference/grammar.po b/reference/grammar.po index 24d3eb9b2c..0c26ed357d 100644 --- a/reference/grammar.po +++ b/reference/grammar.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-11 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2017-09-22 18:27+0000\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -134,7 +134,7 @@ msgid "" "# ~\n" "# Commit to the current alternative, even if it fails to parse.\n" "# &&e\n" -"# Eager parse e. The parser will not backtrack and will immediately \n" +"# Eager parse e. The parser will not backtrack and will immediately\n" "# fail with SyntaxError if e cannot be parsed.\n" "#\n" "\n" @@ -780,7 +780,7 @@ msgid "" "# Type parameter declaration\n" "# --------------------------\n" "\n" -"type_params[asdl_type_param_seq*]: \n" +"type_params[asdl_type_param_seq*]:\n" " | invalid_type_params\n" " | '[' t=type_param_seq ']' {\n" " CHECK_VERSION(asdl_type_param_seq *, 12, \"Type parameter lists " @@ -1607,7 +1607,7 @@ msgid "" " | a='import' ','.dotted_name+ 'from' dotted_name {\n" " RAISE_SYNTAX_ERROR_STARTING_FROM(a, \"Did you mean to use 'from ... " "import ...' instead?\") }\n" -" | 'import' token=NEWLINE { \n" +" | 'import' token=NEWLINE {\n" " RAISE_SYNTAX_ERROR_STARTING_FROM(token, \"Expected one or more names " "after 'import'\") }\n" "\n" @@ -1615,7 +1615,7 @@ msgid "" " | import_from_as_names ',' NEWLINE {\n" " RAISE_SYNTAX_ERROR(\"trailing comma not allowed without surrounding " "parentheses\") }\n" -" | token=NEWLINE { \n" +" | token=NEWLINE {\n" " RAISE_SYNTAX_ERROR_STARTING_FROM(token, \"Expected one or more names " "after 'import'\") }\n" "\n" @@ -1805,6 +1805,6 @@ msgid "" "invalid_type_params:\n" " | '[' token=']' {\n" " RAISE_SYNTAX_ERROR_STARTING_FROM(\n" -" token, \n" +" token,\n" " \"Type parameter list cannot be empty\")}\n" msgstr "" diff --git a/sphinx.po b/sphinx.po index 5303cc5cfd..d7a2b6f202 100644 --- a/sphinx.po +++ b/sphinx.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-16 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-03-15 10:19+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,15 +29,15 @@ msgid "In development" msgstr "開發中" #: ../../tools/templates/customsourcelink.html:3 -msgid "This Page" +msgid "This page" msgstr "此頁面" #: ../../tools/templates/customsourcelink.html:5 -msgid "Report a Bug" +msgid "Report a bug" msgstr "回報錯誤" #: ../../tools/templates/customsourcelink.html:8 -msgid "Show Source" +msgid "Show source" msgstr "顯示原始碼" #: ../../tools/templates/download.html:2 @@ -46,7 +46,7 @@ msgid "Download" msgstr "下載" #: ../../tools/templates/download.html:30 -msgid "Download Python %(dl_version)s Documentation" +msgid "Download Python %(dl_version)s documentation" msgstr "下載 Python %(dl_version)s 說明文件" #: ../../tools/templates/download.html:32 @@ -458,7 +458,7 @@ msgid "Reporting issues" msgstr "回報問題" #: ../../tools/templates/indexcontent.html:75 -msgid "Contributing to Docs" +msgid "Contributing to docs" msgstr "貢獻說明文件" #: ../../tools/templates/indexcontent.html:76 @@ -494,23 +494,23 @@ msgid "Other resources" msgstr "其他資源" #: ../../tools/templates/indexsidebar.html:12 -msgid "PEP Index" +msgid "PEP index" msgstr "PEP 索引" #: ../../tools/templates/indexsidebar.html:13 -msgid "Beginner's Guide" +msgid "Beginner's guide" msgstr "初學者指南" #: ../../tools/templates/indexsidebar.html:14 -msgid "Book List" +msgid "Book list" msgstr "推薦書單" #: ../../tools/templates/indexsidebar.html:15 -msgid "Audio/Visual Talks" +msgid "Audio/visual talks" msgstr "音訊/視訊演講" #: ../../tools/templates/indexsidebar.html:16 -msgid "Python Developer’s Guide" +msgid "Python developer’s guide" msgstr "Python 開發者指南" #: ../../tools/templates/layout.html:6 diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index a33b54fa3a..fd2ee89755 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-31 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-07-24 14:52+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -64,9 +64,9 @@ msgstr "" msgid "" "There can be zero or more :keyword:`elif` parts, and the :keyword:`else` " "part is optional. The keyword ':keyword:`!elif`' is short for 'else if', " -"and is useful to avoid excessive indentation. An :keyword:`!" -"if` ... :keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute " -"for the ``switch`` or ``case`` statements found in other languages." +"and is useful to avoid excessive indentation. An :keyword:`!if` ... :" +"keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute for the " +"``switch`` or ``case`` statements found in other languages." msgstr "" "在陳述式中,可以沒有或有許多個 :keyword:`elif` 敘述,且 :keyword:`else` 敘述" "並不是必要的。關鍵字 :keyword:`!elif` 是「else if」的縮寫,用來避免過多的縮" @@ -91,10 +91,10 @@ msgid "" "The :keyword:`for` statement in Python differs a bit from what you may be " "used to in C or Pascal. Rather than always iterating over an arithmetic " "progression of numbers (like in Pascal), or giving the user the ability to " -"define both the iteration step and halting condition (as C), " -"Python's :keyword:`!for` statement iterates over the items of any sequence " -"(a list or a string), in the order that they appear in the sequence. For " -"example (no pun intended):" +"define both the iteration step and halting condition (as C), Python's :" +"keyword:`!for` statement iterates over the items of any sequence (a list or " +"a string), in the order that they appear in the sequence. For example (no " +"pun intended):" msgstr "" "在 Python 中的 :keyword:`for` 陳述式有點不同於在 C 或 Pascal 中的慣用方式。相" "較於只能疊代 (iterate) 一個等差數列(如 Pascal),或給予使用者定義疊代步驟與" @@ -145,9 +145,8 @@ msgstr ":func:`range` 函式" #: ../../tutorial/controlflow.rst:96 msgid "" -"If you do need to iterate over a sequence of numbers, the built-in " -"function :func:`range` comes in handy. It generates arithmetic " -"progressions::" +"If you do need to iterate over a sequence of numbers, the built-in function :" +"func:`range` comes in handy. It generates arithmetic progressions::" msgstr "" "如果你需要疊代一個數列的話,使用內建 :func:`range` 函式就很方便。它可以生成一" "等差數列: ::" @@ -267,9 +266,9 @@ msgstr "" msgid "" "We say such an object is :term:`iterable`, that is, suitable as a target for " "functions and constructs that expect something from which they can obtain " -"successive items until the supply is exhausted. We have seen that " -"the :keyword:`for` statement is such a construct, while an example of a " -"function that takes an iterable is :func:`sum`::" +"successive items until the supply is exhausted. We have seen that the :" +"keyword:`for` statement is such a construct, while an example of a function " +"that takes an iterable is :func:`sum`::" msgstr "" "我們稱這樣的物件為 :term:`iterable`\\ (可疊代物件),意即能作為函式及架構中" "可以一直取得項目直到取盡的對象。我們已經了解 :keyword:`for` 陳述式就是如此的" @@ -289,8 +288,8 @@ msgid "" "arguments. In chapter :ref:`tut-structures`, we will discuss in more detail " "about :func:`list`." msgstr "" -"待會我們可以看到更多回傳 iterable 和使用 iterable 為引數的函式。在" -"\\ :ref:`tut-structures`\\ 章節中,我們會討論更多關於 :func:`list` 的細節。" +"待會我們可以看到更多回傳 iterable 和使用 iterable 為引數的函式。在\\ :ref:" +"`tut-structures`\\ 章節中,我們會討論更多關於 :func:`list` 的細節。" #: ../../tutorial/controlflow.rst:164 msgid ":keyword:`!break` and :keyword:`!continue` Statements" @@ -298,11 +297,11 @@ msgstr ":keyword:`!break` 和 :keyword:`!continue` 陳述式" #: ../../tutorial/controlflow.rst:166 msgid "" -"The :keyword:`break` statement breaks out of the innermost " -"enclosing :keyword:`for` or :keyword:`while` loop::" +"The :keyword:`break` statement breaks out of the innermost enclosing :" +"keyword:`for` or :keyword:`while` loop::" msgstr "" -":keyword:`break` 陳述式,終止包含它的最內部 :keyword:`for` " -"或 :keyword:`while` 迴圈: ::" +":keyword:`break` 陳述式,終止包含它的最內部 :keyword:`for` 或 :keyword:" +"`while` 迴圈: ::" #: ../../tutorial/controlflow.rst:169 msgid "" @@ -455,11 +454,11 @@ msgid "" "occurs. For more on the ``try`` statement and exceptions, see :ref:`tut-" "handling`." msgstr "" -"當 ``else`` 子句用於迴圈時,相較於搭配 ``if`` 陳述式使用,它的行為" -"與 :keyword:`try` 陳述式中的 ``else`` 子句更為相似:``try`` 陳述式的 " -"``else`` 子句在沒有發生例外 (exception) 時執行,而迴圈的 ``else`` 子句在沒有" -"任何 ``break`` 發生時執行。更多有關 ``try`` 陳述式和例外的介紹,見" -"\\ :ref:`tut-handling`。" +"當 ``else`` 子句用於迴圈時,相較於搭配 ``if`` 陳述式使用,它的行為與 :" +"keyword:`try` 陳述式中的 ``else`` 子句更為相似:``try`` 陳述式的 ``else`` 子" +"句在沒有發生例外 (exception) 時執行,而迴圈的 ``else`` 子句在沒有任何 " +"``break`` 發生時執行。更多有關 ``try`` 陳述式和例外的介紹,見\\ :ref:`tut-" +"handling`。" #: ../../tutorial/controlflow.rst:257 msgid ":keyword:`!pass` Statements" @@ -698,8 +697,8 @@ msgid "" "A recommended way to read patterns is to look at them as an extended form of " "what you would put on the left of an assignment, to understand which " "variables would be set to what. Only the standalone names (like ``var`` " -"above) are assigned to by a match statement. Dotted names (like " -"``foo.bar``), attribute names (the ``x=`` and ``y=`` above) or class names " +"above) are assigned to by a match statement. Dotted names (like ``foo." +"bar``), attribute names (the ``x=`` and ``y=`` above) or class names " "(recognized by the \"(...)\" next to them like ``Point`` above) are never " "assigned to." msgstr "" @@ -884,8 +883,8 @@ msgstr "" #: ../../tutorial/controlflow.rst:454 msgid "" -"For a more detailed explanation and additional examples, you can look " -"into :pep:`636` which is written in a tutorial format." +"For a more detailed explanation and additional examples, you can look into :" +"pep:`636` which is written in a tutorial format." msgstr "" "關於更詳細的解釋和其他範例,你可以閱讀 :pep:`636`,它是以教學的格式編寫而成。" @@ -927,12 +926,12 @@ msgstr "" #: ../../tutorial/controlflow.rst:487 msgid "" "The first statement of the function body can optionally be a string literal; " -"this string literal is the function's documentation string, " -"or :dfn:`docstring`. (More about docstrings can be found in the " -"section :ref:`tut-docstrings`.) There are tools which use docstrings to " -"automatically produce online or printed documentation, or to let the user " -"interactively browse through code; it's good practice to include docstrings " -"in code that you write, so make a habit of it." +"this string literal is the function's documentation string, or :dfn:" +"`docstring`. (More about docstrings can be found in the section :ref:`tut-" +"docstrings`.) There are tools which use docstrings to automatically produce " +"online or printed documentation, or to let the user interactively browse " +"through code; it's good practice to include docstrings in code that you " +"write, so make a habit of it." msgstr "" "一個函式的第一個陳述式可以是一個字串文本;該字串文本被視為該函式的說明文件字" "串,即 :dfn:`docstring`。(關於 docstring 的細節請參見\\ :ref:`tut-" @@ -958,8 +957,8 @@ msgstr "" "域符號表。然而,在引用一個變數時,會先從區域符號表開始搜尋,其次為外層函式的" "區域符號表,其次為全域符號表 (global symbol table),最後為所有內建的名稱。因" "此,在函式中,全域變數及外層函式變數雖然可以被引用,但無法被直接賦值(除非全" -"域變數是在 :keyword:`global` 陳述式中被定義,或外層函式變數" -"在 :keyword:`nonlocal` 陳述式中被定義)。" +"域變數是在 :keyword:`global` 陳述式中被定義,或外層函式變數在 :keyword:" +"`nonlocal` 陳述式中被定義)。" #: ../../tutorial/controlflow.rst:505 msgid "" @@ -1007,8 +1006,8 @@ msgid "" "without a :keyword:`return` statement do return a value, albeit a rather " "boring one. This value is called ``None`` (it's a built-in name). Writing " "the value ``None`` is normally suppressed by the interpreter if it would be " -"the only value written. You can see it if you really want to " -"using :func:`print`::" +"the only value written. You can see it if you really want to using :func:" +"`print`::" msgstr "" "如果你是來自別的語言,你可能不同意 ``fib`` 是個函式,而是個程序 (procedure)," "因為它並沒有回傳值。實際上,即使一個函式缺少一個 :keyword:`return` 陳述式,它" @@ -1053,9 +1052,9 @@ msgstr "這個例子一樣示範了一些新的 Python 特性:" #: ../../tutorial/controlflow.rst:552 msgid "" -"The :keyword:`return` statement returns with a value from a " -"function. :keyword:`!return` without an expression argument returns " -"``None``. Falling off the end of a function also returns ``None``." +"The :keyword:`return` statement returns with a value from a function. :" +"keyword:`!return` without an expression argument returns ``None``. Falling " +"off the end of a function also returns ``None``." msgstr "" ":keyword:`return` 陳述式會讓一個函式回傳一個值。單獨使用 :keyword:`!return` " "不外加一個運算式作為引數時會回傳 ``None``。一個函式執行到結束也會回傳 " @@ -1069,8 +1068,8 @@ msgid "" "expression), and ``methodname`` is the name of a method that is defined by " "the object's type. Different types define different methods. Methods of " "different types may have the same name without causing ambiguity. (It is " -"possible to define your own object types and methods, using *classes*, " -"see :ref:`tut-classes`) The method :meth:`!append` shown in the example is " +"possible to define your own object types and methods, using *classes*, see :" +"ref:`tut-classes`) The method :meth:`!append` shown in the example is " "defined for list objects; it adds a new element at the end of the list. In " "this example it is equivalent to ``result = result + [a]``, but more " "efficient." @@ -1360,8 +1359,8 @@ msgid "" "positional arguments beyond the formal parameter list. (``*name`` must " "occur before ``**name``.) For example, if we define a function like this::" msgstr "" -"當最後一個參數為 ``**name`` 形式時,它接收一個 dictionary(字典,詳" -"見 :ref:`typesmapping`\\ ),該字典包含所有可對應形式參數以外的關鍵字引數。" +"當最後一個參數為 ``**name`` 形式時,它接收一個 dictionary(字典,詳見 :ref:" +"`typesmapping`\\ ),該字典包含所有可對應形式參數以外的關鍵字引數。" "``**name`` 可以與 ``*name`` 參數(下一小節介紹)組合使用,``*name`` 接收一" "個 :ref:`tuple `,該 tuple 包含一般參數以外的位置引數(\\ " "``*name`` 必須出現在 ``**name`` 前面)。例如,若我們定義這樣的函式: ::" @@ -1951,12 +1950,14 @@ msgstr "" #: ../../tutorial/controlflow.rst:1000 msgid "" "The above example uses a lambda expression to return a function. Another " -"use is to pass a small function as an argument::" +"use is to pass a small function as an argument. For instance, :meth:`list." +"sort` takes a sorting key function *key* which can be a lambda function::" msgstr "" "上面的例子用 lambda 運算式回傳了一個函式。另外的用法是傳遞一個小函式當作引" -"數: ::" +"數。舉例來說,:meth:`list.sort` 接受一個鍵排序函式 *key*," +"這個函式可以是 lambda 函式: ::" -#: ../../tutorial/controlflow.rst:1003 +#: ../../tutorial/controlflow.rst:1004 msgid "" ">>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]\n" ">>> pairs.sort(key=lambda pair: pair[1])\n" @@ -1968,17 +1969,17 @@ msgstr "" ">>> pairs\n" "[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]" -#: ../../tutorial/controlflow.rst:1012 +#: ../../tutorial/controlflow.rst:1013 msgid "Documentation Strings" msgstr "說明文件字串 (Documentation Strings)" -#: ../../tutorial/controlflow.rst:1019 +#: ../../tutorial/controlflow.rst:1020 msgid "" "Here are some conventions about the content and formatting of documentation " "strings." msgstr "以下是關於說明文件字串內容和格式的慣例。" -#: ../../tutorial/controlflow.rst:1022 +#: ../../tutorial/controlflow.rst:1023 msgid "" "The first line should always be a short, concise summary of the object's " "purpose. For brevity, it should not explicitly state the object's name or " @@ -1990,7 +1991,7 @@ msgstr "" "的名稱或型別,因為有其他方法可以達到相同目的(除非該名稱剛好是一個描述函式運" "算的動詞)。這一行應以大寫字母開頭,以句號結尾。" -#: ../../tutorial/controlflow.rst:1028 +#: ../../tutorial/controlflow.rst:1029 msgid "" "If there are more lines in the documentation string, the second line should " "be blank, visually separating the summary from the rest of the description. " @@ -2000,7 +2001,7 @@ msgstr "" "文件字串為多行時,第二行應為空白行,在視覺上將摘要與其餘描述分開。後面幾行可" "包含一或多個段落,描述此物件的呼叫慣例、副作用等。" -#: ../../tutorial/controlflow.rst:1033 +#: ../../tutorial/controlflow.rst:1034 msgid "" "The Python parser does not strip indentation from multi-line string literals " "in Python, so tools that process documentation have to strip indentation if " @@ -2022,11 +2023,11 @@ msgstr "" "出現了,這些行的全部前導空白字元都應被去除。展開 tab 鍵後(通常為八個空格)," "應測試空白字元量是否等價。" -#: ../../tutorial/controlflow.rst:1045 +#: ../../tutorial/controlflow.rst:1046 msgid "Here is an example of a multi-line docstring::" msgstr "下面是多行說明字串的一個範例: ::" -#: ../../tutorial/controlflow.rst:1047 +#: ../../tutorial/controlflow.rst:1048 msgid "" ">>> def my_function():\n" "... \"\"\"Do nothing, but document it.\n" @@ -2038,14 +2039,14 @@ msgid "" ">>> print(my_function.__doc__)\n" "Do nothing, but document it.\n" "\n" -" No, really, it doesn't do anything." +"No, really, it doesn't do anything." msgstr "" -#: ../../tutorial/controlflow.rst:1063 +#: ../../tutorial/controlflow.rst:1064 msgid "Function Annotations" msgstr "函式註釋 (Function Annotations)" -#: ../../tutorial/controlflow.rst:1071 +#: ../../tutorial/controlflow.rst:1072 msgid "" ":ref:`Function annotations ` are completely optional metadata " "information about the types used by user-defined functions (see :pep:`3107` " @@ -2054,7 +2055,7 @@ msgstr "" ":ref:`函式註釋 `\\ 是選擇性的元資料(metadata)資訊,描述使用者定義" "函式所使用的型別(更多資訊詳見 :pep:`3107` 和 :pep:`484`\\ )。" -#: ../../tutorial/controlflow.rst:1075 +#: ../../tutorial/controlflow.rst:1076 msgid "" ":term:`Annotations ` are stored in the :attr:`!" "__annotations__` attribute of the function as a dictionary and have no " @@ -2072,7 +2073,7 @@ msgstr "" ">`` 文字接著一個運算式。以下範例註釋了一個必要引數、一個選擇性引數,以及回傳" "值: ::" -#: ../../tutorial/controlflow.rst:1084 +#: ../../tutorial/controlflow.rst:1085 msgid "" ">>> def f(ham: str, eggs: str = 'eggs') -> str:\n" "... print(\"Annotations:\", f.__annotations__)\n" @@ -2096,11 +2097,11 @@ msgstr "" "Arguments: spam eggs\n" "'spam and eggs'" -#: ../../tutorial/controlflow.rst:1097 +#: ../../tutorial/controlflow.rst:1098 msgid "Intermezzo: Coding Style" msgstr "間奏曲:程式碼風格 (Coding Style)" -#: ../../tutorial/controlflow.rst:1102 +#: ../../tutorial/controlflow.rst:1103 msgid "" "Now that you are about to write longer, more complex pieces of Python, it is " "a good time to talk about *coding style*. Most languages can be written (or " @@ -2113,7 +2114,7 @@ msgstr "" "式比其他的更具可讀性。能讓其他人輕鬆閱讀你的程式碼永遠是一個好主意,而使用優" "良的編碼樣式對此有極大的幫助。" -#: ../../tutorial/controlflow.rst:1108 +#: ../../tutorial/controlflow.rst:1109 msgid "" "For Python, :pep:`8` has emerged as the style guide that most projects " "adhere to; it promotes a very readable and eye-pleasing coding style. Every " @@ -2123,11 +2124,11 @@ msgstr "" "對於 Python,大多數的專案都遵循 :pep:`8` 的樣式指南;它推行的編碼樣式相當可讀" "且賞心悅目。每個 Python 開發者都應該花點時間研讀;這裡是該指南的核心重點:" -#: ../../tutorial/controlflow.rst:1113 +#: ../../tutorial/controlflow.rst:1114 msgid "Use 4-space indentation, and no tabs." msgstr "用 4 個空格縮排,不要用 tab 鍵。" -#: ../../tutorial/controlflow.rst:1115 +#: ../../tutorial/controlflow.rst:1116 msgid "" "4 spaces are a good compromise between small indentation (allows greater " "nesting depth) and large indentation (easier to read). Tabs introduce " @@ -2136,11 +2137,11 @@ msgstr "" "4 個空格是小縮排(容許更大的巢套深度)和大縮排(較易閱讀)之間的折衷方案。" "Tab 鍵會造成混亂,最好別用。" -#: ../../tutorial/controlflow.rst:1119 +#: ../../tutorial/controlflow.rst:1120 msgid "Wrap lines so that they don't exceed 79 characters." msgstr "換行,使一行不超過 79 個字元。" -#: ../../tutorial/controlflow.rst:1121 +#: ../../tutorial/controlflow.rst:1122 msgid "" "This helps users with small displays and makes it possible to have several " "code files side-by-side on larger displays." @@ -2148,21 +2149,21 @@ msgstr "" "換行能讓使用小顯示器的使用者方便閱讀,也可以在較大顯示器上並排陳列多個程式碼" "檔案。" -#: ../../tutorial/controlflow.rst:1124 +#: ../../tutorial/controlflow.rst:1125 msgid "" "Use blank lines to separate functions and classes, and larger blocks of code " "inside functions." msgstr "用空行分隔函式和 class(類別),及函式內較大塊的程式碼。" -#: ../../tutorial/controlflow.rst:1127 +#: ../../tutorial/controlflow.rst:1128 msgid "When possible, put comments on a line of their own." msgstr "如果可以,把註解放在單獨一行。" -#: ../../tutorial/controlflow.rst:1129 +#: ../../tutorial/controlflow.rst:1130 msgid "Use docstrings." msgstr "使用說明字串。" -#: ../../tutorial/controlflow.rst:1131 +#: ../../tutorial/controlflow.rst:1132 msgid "" "Use spaces around operators and after commas, but not directly inside " "bracketing constructs: ``a = f(1, 2) + g(3, 4)``." @@ -2170,7 +2171,7 @@ msgstr "" "運算子前後、逗號後要加空格,但不要直接放在括號內側:``a = f(1, 2) + g(3, " "4)``。" -#: ../../tutorial/controlflow.rst:1134 +#: ../../tutorial/controlflow.rst:1135 msgid "" "Name your classes and functions consistently; the convention is to use " "``UpperCamelCase`` for classes and ``lowercase_with_underscores`` for " @@ -2182,7 +2183,7 @@ msgstr "" "底線)。永遠用 ``self`` 作為 method 第一個引數的名稱(關於 class 和 method," "詳見 :ref:`tut-firstclasses`\\ )。" -#: ../../tutorial/controlflow.rst:1139 +#: ../../tutorial/controlflow.rst:1140 msgid "" "Don't use fancy encodings if your code is meant to be used in international " "environments. Python's default, UTF-8, or even plain ASCII work best in any " @@ -2191,7 +2192,7 @@ msgstr "" "若程式碼是為了用於國際環境時,不要用花俏的編碼。Python 預設的 UTF-8 或甚至普" "通的 ASCII,就可以勝任各種情況。" -#: ../../tutorial/controlflow.rst:1143 +#: ../../tutorial/controlflow.rst:1144 msgid "" "Likewise, don't use non-ASCII characters in identifiers if there is only the " "slightest chance people speaking a different language will read or maintain " @@ -2200,11 +2201,11 @@ msgstr "" "同樣地,若不同語言使用者閱讀或維護程式碼的可能性微乎其微,就不要在命名時使用" "非 ASCII 字元。" -#: ../../tutorial/controlflow.rst:1149 +#: ../../tutorial/controlflow.rst:1150 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/controlflow.rst:1150 +#: ../../tutorial/controlflow.rst:1151 msgid "" "Actually, *call by object reference* would be a better description, since if " "a mutable object is passed, the caller will see any changes the callee makes " @@ -2222,15 +2223,15 @@ msgstr "statement(陳述式)" msgid "for" msgstr "for" -#: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1014 +#: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1015 msgid "documentation strings" msgstr "ddocumentation strings(說明字串)" -#: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1014 +#: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1015 msgid "docstrings" msgstr "docstrings(說明字串)" -#: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1014 +#: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1015 msgid "strings, documentation" msgstr "strings(字串), documentation(說明文件)" @@ -2246,31 +2247,31 @@ msgstr "於函式呼叫中" msgid "**" msgstr "**" -#: ../../tutorial/controlflow.rst:1066 +#: ../../tutorial/controlflow.rst:1067 msgid "function" msgstr "function(函式)" -#: ../../tutorial/controlflow.rst:1066 +#: ../../tutorial/controlflow.rst:1067 msgid "annotations" msgstr "annotations(註釋)" -#: ../../tutorial/controlflow.rst:1066 +#: ../../tutorial/controlflow.rst:1067 msgid "->" msgstr "->" -#: ../../tutorial/controlflow.rst:1066 +#: ../../tutorial/controlflow.rst:1067 msgid "function annotations" msgstr "function annotations(函式註釋)" -#: ../../tutorial/controlflow.rst:1066 +#: ../../tutorial/controlflow.rst:1067 msgid ": (colon)" msgstr ": (冒號)" -#: ../../tutorial/controlflow.rst:1100 +#: ../../tutorial/controlflow.rst:1101 msgid "coding" msgstr "coding(程式編寫)" -#: ../../tutorial/controlflow.rst:1100 +#: ../../tutorial/controlflow.rst:1101 msgid "style" msgstr "style(風格)" diff --git a/tutorial/index.po b/tutorial/index.po index 1ed8787fa7..151c6493a9 100644 --- a/tutorial/index.po +++ b/tutorial/index.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-26 16:47+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-06-17 11:39+0000\n" "Last-Translator: Ching-Hao Liu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,6 +27,14 @@ msgstr "Python 教學" #: ../../tutorial/index.rst:7 msgid "" +"This tutorial is designed for *programmers* that are new to the Python " +"language, **not** *beginners* who are new to programming." +msgstr "" +"這份教學是為了那些對 Python 語言有興趣的程式設計師而設計的,**不是**\\ 對於程式" +"設計\\ *新手*\\ 的入門教學。" + +#: ../../tutorial/index.rst:11 +msgid "" "Python is an easy to learn, powerful programming language. It has efficient " "high-level data structures and a simple but effective approach to object-" "oriented programming. Python's elegant syntax and dynamic typing, together " @@ -37,7 +45,7 @@ msgstr "" "效的方法去實現物件導向程式設計。Python 優雅的語法和動態型別,結合其直譯特性," "使它成為眾多領域和大多數平臺上,撰寫腳本和快速開發應用程式的理想語言。" -#: ../../tutorial/index.rst:13 +#: ../../tutorial/index.rst:17 msgid "" "The Python interpreter and the extensive standard library are freely " "available in source or binary form for all major platforms from the Python " @@ -51,7 +59,7 @@ msgstr "" "程式與工具、以及額外說明文件,有興趣的使用者,可在官網上找到相關的發行版本與" "連結網址。" -#: ../../tutorial/index.rst:19 +#: ../../tutorial/index.rst:23 msgid "" "The Python interpreter is easily extended with new functions and data types " "implemented in C or C++ (or other languages callable from C). Python is also " @@ -61,18 +69,20 @@ msgstr "" "增功能函式及資料型別。同時,對可讓使用者自製功能的應用程式來說,Python 也適合" "作為其擴充用介面語言 (extension language)。" -#: ../../tutorial/index.rst:23 +#: ../../tutorial/index.rst:27 +#, fuzzy msgid "" "This tutorial introduces the reader informally to the basic concepts and " -"features of the Python language and system. It helps to have a Python " -"interpreter handy for hands-on experience, but all examples are self-" +"features of the Python language and system. Be aware that it expects you to " +"have a basic understanding of programming in general. It helps to have a " +"Python interpreter handy for hands-on experience, but all examples are self-" "contained, so the tutorial can be read off-line as well." msgstr "" "這份教學將簡介 Python 語言與系統的基本概念及功能。除了閱讀之外、實際用 " "Python 直譯器寫程式跑範例,將有助於學習。但如果只用讀的,也是可行的學習方式," "因為所有範例的內容皆獨立且完整。" -#: ../../tutorial/index.rst:28 +#: ../../tutorial/index.rst:33 msgid "" "For a description of standard objects and modules, see :ref:`library-" "index`. :ref:`reference-index` gives a more formal definition of the " @@ -84,7 +94,7 @@ msgstr "" "伸套件 (extensions) 的讀者,請閱讀 :ref:`extending-index` 和 :ref:`c-api-" "index` 。此外,市面上也能找到更深入的 Python 學習書。" -#: ../../tutorial/index.rst:33 +#: ../../tutorial/index.rst:38 msgid "" "This tutorial does not attempt to be comprehensive and cover every single " "feature, or even every commonly used feature. Instead, it introduces many of " @@ -98,6 +108,6 @@ msgstr "" "語言的特色與風格。讀完教學後,你將有能力閱讀和撰寫 Python 模組與程式,也做好" "進一步學習 :ref:`library-index` 中各類型的 Python 函式庫模組的準備。" -#: ../../tutorial/index.rst:40 +#: ../../tutorial/index.rst:45 msgid "The :ref:`glossary` is also worth going through." msgstr ":ref:`glossary` 頁面也值得細讀。" diff --git a/tutorial/introduction.po b/tutorial/introduction.po index b327cb34c5..08a3720e9a 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-09 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-10-16 03:20+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,24 +34,19 @@ msgid "" "that a secondary prompt on a line by itself in an example means you must " "type a blank line; this is used to end a multi-line command." msgstr "" -"在下面的例子中,輸入與輸出的區別在於有無提示字元(prompt,:term:`>>>` " -"和 :term:`...`\\ ):如果要重做範例,你必須在提示字元出現的時候,輸入提示字元" -"後方的所有內容;那些非提示字元開始的文字行是直譯器的輸出。注意到在範例中,若" -"出現單行只有次提示字元時,代表該行你必須直接換行;這被使用在多行指令結束輸入" -"時。" +"在下面的例子中,輸入與輸出的區別在於有無提示字元(prompt,:term:`>>>` 和 :" +"term:`...`\\ ):如果要重做範例,你必須在提示字元出現的時候,輸入提示字元後方" +"的所有內容;那些非提示字元開始的文字行是直譯器的輸出。注意到在範例中,若出現" +"單行只有次提示字元時,代表該行你必須直接換行;這被使用在多行指令結束輸入時。" #: ../../tutorial/introduction.rst:16 msgid "" -"You can toggle the display of prompts and output by clicking on ``>>>`` in " -"the upper-right corner of an example box. If you hide the prompts and " -"output for an example, then you can easily copy and paste the input lines " -"into your interpreter." +"You can use the \"Copy\" button (it appears in the upper-right corner when " +"hovering over or tapping a code example), which strips prompts and omits " +"output, to copy and paste the input lines into your interpreter." msgstr "" -"在範例區域中,你可以點擊右上角的 ``>>>`` 來切換是否要顯示提示字元及輸出。若你" -"隱藏了範例中的提示字元及輸出,那麼你就能夠輕易地複製輸入的內容,並貼上到你的" -"直譯器中。" -#: ../../tutorial/introduction.rst:23 +#: ../../tutorial/introduction.rst:22 msgid "" "Many of the examples in this manual, even those entered at the interactive " "prompt, include comments. Comments in Python start with the hash character, " @@ -67,11 +62,11 @@ msgstr "" "字串文本之中時仍視為一 hash 字元。因為註解只是用來說明程式而不會被 Python 解" "讀,在練習範例時不一定要輸入。" -#: ../../tutorial/introduction.rst:31 +#: ../../tutorial/introduction.rst:30 msgid "Some examples::" msgstr "一些範例如下: ::" -#: ../../tutorial/introduction.rst:33 +#: ../../tutorial/introduction.rst:32 msgid "" "# this is the first comment\n" "spam = 1 # and this is the second comment\n" @@ -79,11 +74,11 @@ msgid "" "text = \"# This is not a comment because it's inside quotes.\"" msgstr "" -#: ../../tutorial/introduction.rst:42 +#: ../../tutorial/introduction.rst:41 msgid "Using Python as a Calculator" msgstr "把 Python 當作計算機使用" -#: ../../tutorial/introduction.rst:44 +#: ../../tutorial/introduction.rst:43 msgid "" "Let's try some simple Python commands. Start the interpreter and wait for " "the primary prompt, ``>>>``. (It shouldn't take long.)" @@ -91,11 +86,11 @@ msgstr "" "讓我們來試試一些簡單的 Python 指令。啟動直譯器並等待第一個主提示字元 ``>>>`` " "出現。(應該不會等太久)" -#: ../../tutorial/introduction.rst:51 +#: ../../tutorial/introduction.rst:50 msgid "Numbers" msgstr "數字 (Number)" -#: ../../tutorial/introduction.rst:53 +#: ../../tutorial/introduction.rst:52 msgid "" "The interpreter acts as a simple calculator: you can type an expression at " "it and it will write the value. Expression syntax is straightforward: the " @@ -106,7 +101,7 @@ msgstr "" "的值。Expression 的語法可以使用:運算子 ``+``、``-``、``*`` 和 ``/`` 可以用來" "執行運算;括號 ``()`` 可以用來分群。例如: ::" -#: ../../tutorial/introduction.rst:59 +#: ../../tutorial/introduction.rst:58 msgid "" ">>> 2 + 2\n" "4\n" @@ -118,18 +113,17 @@ msgid "" "1.6" msgstr "" -#: ../../tutorial/introduction.rst:68 +#: ../../tutorial/introduction.rst:67 msgid "" "The integer numbers (e.g. ``2``, ``4``, ``20``) have type :class:`int`, the " -"ones with a fractional part (e.g. ``5.0``, ``1.6``) have " -"type :class:`float`. We will see more about numeric types later in the " -"tutorial." +"ones with a fractional part (e.g. ``5.0``, ``1.6``) have type :class:" +"`float`. We will see more about numeric types later in the tutorial." msgstr "" "整數數字(即 ``2``、``4``、``20``)為 :class:`int` 型態,數字有小數點部份的" "(即 ``5.0``、``1.6``)為 :class:`float` 型態。我們將在之後的教學中看到更多數" "字相關的型態。" -#: ../../tutorial/introduction.rst:72 +#: ../../tutorial/introduction.rst:71 msgid "" "Division (``/``) always returns a float. To do :term:`floor division` and " "get an integer result you can use the ``//`` operator; to calculate the " @@ -138,7 +132,7 @@ msgstr "" "除法 (``/``) 永遠回傳一個 float。如果要做 :term:`floor division` 並拿到整數的" "結果,你可以使用 ``//`` 運算子;計算餘數可以使用 ``%``: ::" -#: ../../tutorial/introduction.rst:76 +#: ../../tutorial/introduction.rst:75 msgid "" ">>> 17 / 3 # classic division returns a float\n" "5.666666666666667\n" @@ -151,13 +145,13 @@ msgid "" "17" msgstr "" -#: ../../tutorial/introduction.rst:86 +#: ../../tutorial/introduction.rst:85 msgid "" "With Python, it is possible to use the ``**`` operator to calculate powers " "[#]_::" msgstr "在 Python 中,計算冪次 (powers) 可以使用 ``**`` 運算子 [#]_: ::" -#: ../../tutorial/introduction.rst:88 +#: ../../tutorial/introduction.rst:87 msgid "" ">>> 5 ** 2 # 5 squared\n" "25\n" @@ -165,7 +159,7 @@ msgid "" "128" msgstr "" -#: ../../tutorial/introduction.rst:93 +#: ../../tutorial/introduction.rst:92 msgid "" "The equal sign (``=``) is used to assign a value to a variable. Afterwards, " "no result is displayed before the next interactive prompt::" @@ -173,7 +167,7 @@ msgstr "" "等於符號 (``=``) 可以用於為變數賦值。賦值完之後,在下個指示字元前並不會顯示任" "何結果: ::" -#: ../../tutorial/introduction.rst:96 +#: ../../tutorial/introduction.rst:95 msgid "" ">>> width = 20\n" ">>> height = 5 * 9\n" @@ -185,7 +179,7 @@ msgstr "" ">>> width * height\n" "900" -#: ../../tutorial/introduction.rst:101 +#: ../../tutorial/introduction.rst:100 msgid "" "If a variable is not \"defined\" (assigned a value), trying to use it will " "give you an error::" @@ -193,7 +187,7 @@ msgstr "" "如果一個變數未被「定義 (defined)」(即變數未被賦值),試著使用它時會出現一個" "錯誤: ::" -#: ../../tutorial/introduction.rst:104 +#: ../../tutorial/introduction.rst:103 msgid "" ">>> n # try to access an undefined variable\n" "Traceback (most recent call last):\n" @@ -201,7 +195,7 @@ msgid "" "NameError: name 'n' is not defined" msgstr "" -#: ../../tutorial/introduction.rst:109 +#: ../../tutorial/introduction.rst:108 msgid "" "There is full support for floating point; operators with mixed type operands " "convert the integer operand to floating point::" @@ -209,7 +203,7 @@ msgstr "" "浮點數的運算有完善的支援,運算子 (operator) 遇上混合的運算元 (operand) 時會把" "整數的運算元轉換為浮點數: ::" -#: ../../tutorial/introduction.rst:112 +#: ../../tutorial/introduction.rst:111 msgid "" ">>> 4 * 3.75 - 1\n" "14.0" @@ -217,7 +211,7 @@ msgstr "" ">>> 4 * 3.75 - 1\n" "14.0" -#: ../../tutorial/introduction.rst:115 +#: ../../tutorial/introduction.rst:114 msgid "" "In interactive mode, the last printed expression is assigned to the variable " "``_``. This means that when you are using Python as a desk calculator, it " @@ -226,7 +220,7 @@ msgstr "" "在互動式模式中,最後一個印出的運算式的結果會被指派至變數 ``_`` 中。這表示當你" "把 Python 當作桌上計算機使用者,要接續計算變得容易許多: ::" -#: ../../tutorial/introduction.rst:119 +#: ../../tutorial/introduction.rst:118 msgid "" ">>> tax = 12.5 / 100\n" ">>> price = 100.50\n" @@ -246,7 +240,7 @@ msgstr "" ">>> round(_, 2)\n" "113.06" -#: ../../tutorial/introduction.rst:128 +#: ../../tutorial/introduction.rst:127 msgid "" "This variable should be treated as read-only by the user. Don't explicitly " "assign a value to it --- you would create an independent local variable with " @@ -255,24 +249,24 @@ msgstr "" "這個變數應該被使用者視為只能讀取。不應該明確地為它賦值 --- 你可以創一個獨立但" "名稱相同的本地變數來覆蓋掉預設變數和它的神奇行為。" -#: ../../tutorial/introduction.rst:132 +#: ../../tutorial/introduction.rst:131 msgid "" "In addition to :class:`int` and :class:`float`, Python supports other types " -"of numbers, such as :class:`~decimal.Decimal` " -"and :class:`~fractions.Fraction`. Python also has built-in support " -"for :ref:`complex numbers `, and uses the ``j`` or ``J`` " -"suffix to indicate the imaginary part (e.g. ``3+5j``)." +"of numbers, such as :class:`~decimal.Decimal` and :class:`~fractions." +"Fraction`. Python also has built-in support for :ref:`complex numbers " +"`, and uses the ``j`` or ``J`` suffix to indicate the " +"imaginary part (e.g. ``3+5j``)." msgstr "" -"除了 :class:`int` 和 :class:`float`,Python 還支援了其他的數字型態,包" -"含 :class:`~decimal.Decimal` 和 :class:`~fractions.Fraction`。Python 亦內建支" -"援\\ :ref:`複數 (complex numbers) `,並使用 ``j`` 和 ``J`` 後綴" -"來指定虛數的部份(即 ``3+5j``)。" +"除了 :class:`int` 和 :class:`float`,Python 還支援了其他的數字型態,包含 :" +"class:`~decimal.Decimal` 和 :class:`~fractions.Fraction`。Python 亦內建支援" +"\\ :ref:`複數 (complex numbers) `,並使用 ``j`` 和 ``J`` 後綴來" +"指定虛數的部份(即 ``3+5j``)。" -#: ../../tutorial/introduction.rst:142 +#: ../../tutorial/introduction.rst:141 msgid "Text" msgstr "文字" -#: ../../tutorial/introduction.rst:144 +#: ../../tutorial/introduction.rst:143 msgid "" "Python can manipulate text (represented by type :class:`str`, so-called " "\"strings\") as well as numbers. This includes characters \"``!``\", words " @@ -285,7 +279,7 @@ msgstr "" "\"``Got your back.``\" 等等。\"``Yay! :)``\"。它們可以用單引號 (``'...'``) 或" "雙引號 (``\"...\"``) 括起來,會具有相同的結果 [#]_。" -#: ../../tutorial/introduction.rst:150 +#: ../../tutorial/introduction.rst:149 msgid "" ">>> 'spam eggs' # single quotes\n" "'spam eggs'\n" @@ -295,7 +289,7 @@ msgid "" "'1975'" msgstr "" -#: ../../tutorial/introduction.rst:159 +#: ../../tutorial/introduction.rst:158 msgid "" "To quote a quote, we need to \"escape\" it, by preceding it with ``\\``. " "Alternatively, we can use the other type of quotation marks::" @@ -303,7 +297,7 @@ msgstr "" "要引用引文,我們需要在其前面加上 ``\\`` 來「跳脫」它。或者我們也可以使用其他" "種類的引號: ::" -#: ../../tutorial/introduction.rst:162 +#: ../../tutorial/introduction.rst:161 msgid "" ">>> 'doesn\\'t' # use \\' to escape the single quote...\n" "\"doesn't\"\n" @@ -317,7 +311,7 @@ msgid "" "'\"Isn\\'t,\" they said.'" msgstr "" -#: ../../tutorial/introduction.rst:173 +#: ../../tutorial/introduction.rst:172 msgid "" "In the Python shell, the string definition and output string can look " "different. The :func:`print` function produces a more readable output, by " @@ -327,7 +321,7 @@ msgstr "" "在 Python shell 中,字串定義和輸出字串可能看起來不同。:func:`print` 函式透過" "省略引號並印出跳脫字元和特殊字元來生成更具可讀性的輸出: ::" -#: ../../tutorial/introduction.rst:177 +#: ../../tutorial/introduction.rst:176 msgid "" ">>> s = 'First line.\\nSecond line.' # \\n means newline\n" ">>> s # without print(), special characters are included in the string\n" @@ -338,7 +332,7 @@ msgid "" "Second line." msgstr "" -#: ../../tutorial/introduction.rst:184 +#: ../../tutorial/introduction.rst:183 msgid "" "If you don't want characters prefaced by ``\\`` to be interpreted as special " "characters, you can use *raw strings* by adding an ``r`` before the first " @@ -347,7 +341,7 @@ msgstr "" "如果你不希望字元前出現 ``\\`` 就被當成特殊字元時,可以改使用 *raw string*,在" "第一個包圍引號前加上 ``r`` : ::" -#: ../../tutorial/introduction.rst:188 +#: ../../tutorial/introduction.rst:187 msgid "" ">>> print('C:\\some\\name') # here \\n means newline!\n" "C:\\some\n" @@ -356,7 +350,7 @@ msgid "" "C:\\some\\name" msgstr "" -#: ../../tutorial/introduction.rst:194 +#: ../../tutorial/introduction.rst:193 msgid "" "There is one subtle aspect to raw strings: a raw string may not end in an " "odd number of ``\\`` characters; see :ref:`the FAQ entry `\\ 來了解更多資訊" "和解決方法。" -#: ../../tutorial/introduction.rst:199 +#: ../../tutorial/introduction.rst:198 msgid "" "String literals can span multiple lines. One way is using triple-quotes: " "``\"\"\"...\"\"\"`` or ``'''...'''``. End-of-line characters are " @@ -378,7 +372,7 @@ msgstr "" "``'''...'''``。此時換行字元會被自動加入字串值中,但也可以在換行前加入 ``\\`` " "來取消這個行為。在以下的例子中,最初的換行符不會被包含: ::" -#: ../../tutorial/introduction.rst:205 +#: ../../tutorial/introduction.rst:204 msgid "" ">>> print(\"\"\"\\\n" "... Usage: thingy [OPTIONS]\n" @@ -402,21 +396,21 @@ msgstr "" "\n" ">>>" -#: ../../tutorial/introduction.rst:216 +#: ../../tutorial/introduction.rst:215 msgid "" "Strings can be concatenated (glued together) with the ``+`` operator, and " "repeated with ``*``::" msgstr "" "字串可以使用 ``+`` 運算子連接 (concatenate),並用 ``*`` 重覆該字串的內容: ::" -#: ../../tutorial/introduction.rst:219 +#: ../../tutorial/introduction.rst:218 msgid "" ">>> # 3 times 'un', followed by 'ium'\n" ">>> 3 * 'un' + 'ium'\n" "'unununium'" msgstr "" -#: ../../tutorial/introduction.rst:223 +#: ../../tutorial/introduction.rst:222 msgid "" "Two or more *string literals* (i.e. the ones enclosed between quotes) next " "to each other are automatically concatenated. ::" @@ -424,7 +418,7 @@ msgstr "" "兩個以上相鄰的字串文本(*string literal*,即被引號包圍的字串)會被自動連接起" "來: ::" -#: ../../tutorial/introduction.rst:226 +#: ../../tutorial/introduction.rst:225 msgid "" ">>> 'Py' 'thon'\n" "'Python'" @@ -432,13 +426,13 @@ msgstr "" ">>> 'Py' 'thon'\n" "'Python'" -#: ../../tutorial/introduction.rst:229 +#: ../../tutorial/introduction.rst:228 msgid "" "This feature is particularly useful when you want to break long strings::" msgstr "" "當你想要分段一個非常長的字串時,兩相鄰字串值自動連接的特性十分有用: ::" -#: ../../tutorial/introduction.rst:231 +#: ../../tutorial/introduction.rst:230 msgid "" ">>> text = ('Put several strings within parentheses '\n" "... 'to have them joined together.')\n" @@ -446,12 +440,12 @@ msgid "" "'Put several strings within parentheses to have them joined together.'" msgstr "" -#: ../../tutorial/introduction.rst:236 +#: ../../tutorial/introduction.rst:235 msgid "" "This only works with two literals though, not with variables or expressions::" msgstr "但這特性只限於兩相鄰的字串值間,而非兩相鄰變數或表達式: ::" -#: ../../tutorial/introduction.rst:238 +#: ../../tutorial/introduction.rst:237 msgid "" ">>> prefix = 'Py'\n" ">>> prefix 'thon' # can't concatenate a variable and a string literal\n" @@ -466,12 +460,12 @@ msgid "" "SyntaxError: invalid syntax" msgstr "" -#: ../../tutorial/introduction.rst:250 +#: ../../tutorial/introduction.rst:249 msgid "" "If you want to concatenate variables or a variable and a literal, use ``+``::" msgstr "如果要連接變數們或一個變數與一個字串值,使用 ``+``: ::" -#: ../../tutorial/introduction.rst:252 +#: ../../tutorial/introduction.rst:251 msgid "" ">>> prefix + 'thon'\n" "'Python'" @@ -479,7 +473,7 @@ msgstr "" ">>> prefix + 'thon'\n" "'Python'" -#: ../../tutorial/introduction.rst:255 +#: ../../tutorial/introduction.rst:254 msgid "" "Strings can be *indexed* (subscripted), with the first character having " "index 0. There is no separate character type; a character is simply a string " @@ -488,7 +482,7 @@ msgstr "" "字串可以被「索引 *indexed*」(下標,即 subscripted),第一個字元的索引值為 0。" "沒有獨立表示字元的型別;一個字元就是一個大小為 1 的字串: ::" -#: ../../tutorial/introduction.rst:259 +#: ../../tutorial/introduction.rst:258 msgid "" ">>> word = 'Python'\n" ">>> word[0] # character in position 0\n" @@ -497,12 +491,12 @@ msgid "" "'n'" msgstr "" -#: ../../tutorial/introduction.rst:265 +#: ../../tutorial/introduction.rst:264 msgid "" "Indices may also be negative numbers, to start counting from the right::" msgstr "索引值可以是負的,此時改成從右開始計數: ::" -#: ../../tutorial/introduction.rst:267 +#: ../../tutorial/introduction.rst:266 msgid "" ">>> word[-1] # last character\n" "'n'\n" @@ -512,11 +506,11 @@ msgid "" "'P'" msgstr "" -#: ../../tutorial/introduction.rst:274 +#: ../../tutorial/introduction.rst:273 msgid "Note that since -0 is the same as 0, negative indices start from -1." msgstr "注意到因為 -0 等同於 0,負的索引值由 -1 開始。" -#: ../../tutorial/introduction.rst:276 +#: ../../tutorial/introduction.rst:275 msgid "" "In addition to indexing, *slicing* is also supported. While indexing is " "used to obtain individual characters, *slicing* allows you to obtain a " @@ -525,7 +519,7 @@ msgstr "" "除了索引外,字串亦支援「切片 *slicing*」。索引用來拿到單獨的字元,而切片則可" "以讓你拿到一個子字串 (substring): ::" -#: ../../tutorial/introduction.rst:279 +#: ../../tutorial/introduction.rst:278 msgid "" ">>> word[0:2] # characters from position 0 (included) to 2 (excluded)\n" "'Py'\n" @@ -533,7 +527,7 @@ msgid "" "'tho'" msgstr "" -#: ../../tutorial/introduction.rst:284 +#: ../../tutorial/introduction.rst:283 msgid "" "Slice indices have useful defaults; an omitted first index defaults to zero, " "an omitted second index defaults to the size of the string being sliced. ::" @@ -541,7 +535,7 @@ msgstr "" "切片索引 (slice indices) 有很常用的預設值,省略起點索引值時預設為 0,而省略第" "二個索引值時預設整個字串被包含在 slice 中: ::" -#: ../../tutorial/introduction.rst:287 +#: ../../tutorial/introduction.rst:286 msgid "" ">>> word[:2] # character from the beginning to position 2 (excluded)\n" "'Py'\n" @@ -551,7 +545,7 @@ msgid "" "'on'" msgstr "" -#: ../../tutorial/introduction.rst:294 +#: ../../tutorial/introduction.rst:293 msgid "" "Note how the start is always included, and the end always excluded. This " "makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::" @@ -559,7 +553,7 @@ msgstr "" "注意到起點永遠被包含,而結尾永遠不被包含。這確保了 ``s[:i] + s[i:]`` 永遠等" "於 ``s``: ::" -#: ../../tutorial/introduction.rst:297 +#: ../../tutorial/introduction.rst:296 msgid "" ">>> word[:2] + word[2:]\n" "'Python'\n" @@ -571,7 +565,7 @@ msgstr "" ">>> word[:4] + word[4:]\n" "'Python'" -#: ../../tutorial/introduction.rst:302 +#: ../../tutorial/introduction.rst:301 msgid "" "One way to remember how slices work is to think of the indices as pointing " "*between* characters, with the left edge of the first character numbered 0. " @@ -582,7 +576,7 @@ msgstr "" "其中第一個字元的左側邊緣由 0 計數。則 *n* 個字元的字串中最後一個字元的右側邊" "緣會有索引值 *n*,例如: ::" -#: ../../tutorial/introduction.rst:307 +#: ../../tutorial/introduction.rst:306 msgid "" " +---+---+---+---+---+---+\n" " | P | y | t | h | o | n |\n" @@ -596,7 +590,7 @@ msgstr "" " 0 1 2 3 4 5 6\n" "-6 -5 -4 -3 -2 -1" -#: ../../tutorial/introduction.rst:313 +#: ../../tutorial/introduction.rst:312 msgid "" "The first row of numbers gives the position of the indices 0...6 in the " "string; the second row gives the corresponding negative indices. The slice " @@ -606,7 +600,7 @@ msgstr "" "第一行數字給定字串索引值為 0...6 的位置;第二行則標示了負索引值的位置。由 " "*i* 至 *j* 的 slice 包含了標示 *i* 和 *j* 邊緣間的所有字元。" -#: ../../tutorial/introduction.rst:318 +#: ../../tutorial/introduction.rst:317 msgid "" "For non-negative indices, the length of a slice is the difference of the " "indices, if both are within bounds. For example, the length of " @@ -615,25 +609,29 @@ msgstr "" "對非負數的索引值而言,一個 slice 的長度等於其索引值之差,如果索引值落在字串邊" "界內。例如,``word[1:3]`` 的長度是 2。" -#: ../../tutorial/introduction.rst:322 +#: ../../tutorial/introduction.rst:321 msgid "Attempting to use an index that is too large will result in an error::" msgstr "嘗試使用一個過大的索引值會造成錯誤: ::" -#: ../../tutorial/introduction.rst:324 +#: ../../tutorial/introduction.rst:323 msgid "" ">>> word[42] # the word only has 6 characters\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "IndexError: string index out of range" msgstr "" +">>> word[42] # 這只有六個字母\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"IndexError: string index out of range" -#: ../../tutorial/introduction.rst:329 +#: ../../tutorial/introduction.rst:328 msgid "" "However, out of range slice indexes are handled gracefully when used for " "slicing::" msgstr "然而,超出範圍的索引值在 slice 中會被妥善的處理: ::" -#: ../../tutorial/introduction.rst:332 +#: ../../tutorial/introduction.rst:331 msgid "" ">>> word[4:42]\n" "'on'\n" @@ -645,7 +643,7 @@ msgstr "" ">>> word[42:]\n" "''" -#: ../../tutorial/introduction.rst:337 +#: ../../tutorial/introduction.rst:336 msgid "" "Python strings cannot be changed --- they are :term:`immutable`. Therefore, " "assigning to an indexed position in the string results in an error::" @@ -653,7 +651,7 @@ msgstr "" "Python 字串無法被改變 --- 它們是 :term:`immutable`。因此,嘗試對字串中某個索" "引位置賦值會產生錯誤: ::" -#: ../../tutorial/introduction.rst:340 +#: ../../tutorial/introduction.rst:339 msgid "" ">>> word[0] = 'J'\n" "Traceback (most recent call last):\n" @@ -665,11 +663,11 @@ msgid "" "TypeError: 'str' object does not support item assignment" msgstr "" -#: ../../tutorial/introduction.rst:349 +#: ../../tutorial/introduction.rst:348 msgid "If you need a different string, you should create a new one::" msgstr "如果你需要一個不一樣的字串,你必須建立一個新的: ::" -#: ../../tutorial/introduction.rst:351 +#: ../../tutorial/introduction.rst:350 msgid "" ">>> 'J' + word[1:]\n" "'Jython'\n" @@ -681,11 +679,11 @@ msgstr "" ">>> word[:2] + 'py'\n" "'Pypy'" -#: ../../tutorial/introduction.rst:356 +#: ../../tutorial/introduction.rst:355 msgid "The built-in function :func:`len` returns the length of a string::" msgstr "內建的函式 :func:`len` 回傳一個字串的長度: ::" -#: ../../tutorial/introduction.rst:358 +#: ../../tutorial/introduction.rst:357 msgid "" ">>> s = 'supercalifragilisticexpialidocious'\n" ">>> len(s)\n" @@ -695,47 +693,47 @@ msgstr "" ">>> len(s)\n" "34" -#: ../../tutorial/introduction.rst:365 +#: ../../tutorial/introduction.rst:364 msgid ":ref:`textseq`" msgstr ":ref:`textseq`" -#: ../../tutorial/introduction.rst:366 +#: ../../tutorial/introduction.rst:365 msgid "" "Strings are examples of *sequence types*, and support the common operations " "supported by such types." msgstr "字串是 *sequence 型別*\\ 的範例之一,並支援該型別常用的操作。" -#: ../../tutorial/introduction.rst:369 +#: ../../tutorial/introduction.rst:368 msgid ":ref:`string-methods`" msgstr ":ref:`string-methods`" -#: ../../tutorial/introduction.rst:370 +#: ../../tutorial/introduction.rst:369 msgid "" "Strings support a large number of methods for basic transformations and " "searching." msgstr "字串支援非常多種基本轉換和搜尋的 method(方法)。" -#: ../../tutorial/introduction.rst:373 +#: ../../tutorial/introduction.rst:372 msgid ":ref:`f-strings`" msgstr ":ref:`f-strings`" -#: ../../tutorial/introduction.rst:374 +#: ../../tutorial/introduction.rst:373 msgid "String literals that have embedded expressions." msgstr "包含有運算式的字串文本。" -#: ../../tutorial/introduction.rst:376 +#: ../../tutorial/introduction.rst:375 msgid ":ref:`formatstrings`" msgstr ":ref:`formatstrings`" -#: ../../tutorial/introduction.rst:377 +#: ../../tutorial/introduction.rst:376 msgid "Information about string formatting with :meth:`str.format`." msgstr "關於透過 :meth:`str.format` 字串格式化 (string formatting) 的資訊。" -#: ../../tutorial/introduction.rst:379 +#: ../../tutorial/introduction.rst:378 msgid ":ref:`old-string-formatting`" msgstr ":ref:`old-string-formatting`" -#: ../../tutorial/introduction.rst:380 +#: ../../tutorial/introduction.rst:379 msgid "" "The old formatting operations invoked when strings are the left operand of " "the ``%`` operator are described in more detail here." @@ -743,11 +741,11 @@ msgstr "" "在字串為 ``%`` 運算子的左運算元時,將觸發舊的字串格式化操作,更多的細節在本連" "結中介紹。" -#: ../../tutorial/introduction.rst:387 +#: ../../tutorial/introduction.rst:386 msgid "Lists" msgstr "List(串列)" -#: ../../tutorial/introduction.rst:389 +#: ../../tutorial/introduction.rst:388 msgid "" "Python knows a number of *compound* data types, used to group together other " "values. The most versatile is the *list*, which can be written as a list of " @@ -758,7 +756,7 @@ msgstr "" "*list*,可以寫成一系列以逗號分隔的數值(稱之元素,即 item),包含在方括號之" "中。List 可以包合不同型別的元素,但通常這些元素會有相同的型別: ::" -#: ../../tutorial/introduction.rst:394 +#: ../../tutorial/introduction.rst:393 msgid "" ">>> squares = [1, 4, 9, 16, 25]\n" ">>> squares\n" @@ -768,7 +766,7 @@ msgstr "" ">>> squares\n" "[1, 4, 9, 16, 25]" -#: ../../tutorial/introduction.rst:398 +#: ../../tutorial/introduction.rst:397 msgid "" "Like strings (and all other built-in :term:`sequence` types), lists can be " "indexed and sliced::" @@ -776,7 +774,7 @@ msgstr "" "如同字串(以及其他內建的 :term:`sequence` 型別),list 可以被索引和切片 " "(slice): ::" -#: ../../tutorial/introduction.rst:401 +#: ../../tutorial/introduction.rst:400 msgid "" ">>> squares[0] # indexing returns the item\n" "1\n" @@ -786,11 +784,11 @@ msgid "" "[9, 16, 25]" msgstr "" -#: ../../tutorial/introduction.rst:408 +#: ../../tutorial/introduction.rst:407 msgid "Lists also support operations like concatenation::" msgstr "List 對支援如接合 (concatenation) 等操作: ::" -#: ../../tutorial/introduction.rst:410 +#: ../../tutorial/introduction.rst:409 msgid "" ">>> squares + [36, 49, 64, 81, 100]\n" "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]" @@ -798,7 +796,7 @@ msgstr "" ">>> squares + [36, 49, 64, 81, 100]\n" "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]" -#: ../../tutorial/introduction.rst:413 +#: ../../tutorial/introduction.rst:412 msgid "" "Unlike strings, which are :term:`immutable`, lists are a :term:`mutable` " "type, i.e. it is possible to change their content::" @@ -806,7 +804,7 @@ msgstr "" "不同於字串是 :term:`immutable`,list 是 :term:`mutable` 型別,即改變 list 的" "內容是可能的: ::" -#: ../../tutorial/introduction.rst:416 +#: ../../tutorial/introduction.rst:415 msgid "" ">>> cubes = [1, 8, 27, 65, 125] # something's wrong here\n" ">>> 4 ** 3 # the cube of 4 is 64, not 65!\n" @@ -816,15 +814,15 @@ msgid "" "[1, 8, 27, 64, 125]" msgstr "" -#: ../../tutorial/introduction.rst:423 +#: ../../tutorial/introduction.rst:422 msgid "" -"You can also add new items at the end of the list, by using the :meth:`!" -"list.append` *method* (we will see more about methods later)::" +"You can also add new items at the end of the list, by using the :meth:`!list." +"append` *method* (we will see more about methods later)::" msgstr "" "你也可以在 list 的最後加入新元素,透過使用 :meth:`!list.append` *方法* " "(method)(我們稍後會看到更多方法的說明): ::" -#: ../../tutorial/introduction.rst:426 +#: ../../tutorial/introduction.rst:425 msgid "" ">>> cubes.append(216) # add the cube of 6\n" ">>> cubes.append(7 ** 3) # and the cube of 7\n" @@ -832,7 +830,7 @@ msgid "" "[1, 8, 27, 64, 125, 216, 343]" msgstr "" -#: ../../tutorial/introduction.rst:431 +#: ../../tutorial/introduction.rst:430 msgid "" "Simple assignment in Python never copies data. When you assign a list to a " "variable, the variable refers to the *existing list*. Any changes you make " @@ -843,7 +841,7 @@ msgstr "" "\\ *現有 list*。任何透過一個變數對 list 所做的更改都將能夠透過參照該變數的所" "有其他變數看到。 ::" -#: ../../tutorial/introduction.rst:436 +#: ../../tutorial/introduction.rst:435 msgid "" ">>> rgb = [\"Red\", \"Green\", \"Blue\"]\n" ">>> rgba = rgb\n" @@ -861,7 +859,7 @@ msgstr "" ">>> rgb\n" "[\"Red\", \"Green\", \"Blue\", \"Alph\"]" -#: ../../tutorial/introduction.rst:444 +#: ../../tutorial/introduction.rst:443 msgid "" "All slice operations return a new list containing the requested elements. " "This means that the following slice returns a :ref:`shallow copy " @@ -870,7 +868,7 @@ msgstr "" "所有切片操作都會回傳一個新的 list ,包含要求的元素。這意謂著以下這個切片回傳" "了原本 list 的\\ :ref:`淺複製 `: ::" -#: ../../tutorial/introduction.rst:448 +#: ../../tutorial/introduction.rst:447 msgid "" ">>> correct_rgba = rgba[:]\n" ">>> correct_rgba[-1] = \"Alpha\"\n" @@ -886,13 +884,13 @@ msgstr "" ">>> rgba\n" "[\"Red\", \"Green\", \"Blue\", \"Alph\"]" -#: ../../tutorial/introduction.rst:455 +#: ../../tutorial/introduction.rst:454 msgid "" "Assignment to slices is also possible, and this can even change the size of " "the list or clear it entirely::" msgstr "也可以對 slice 賦值,這能改變 list 的大小,甚至是清空一個 list: ::" -#: ../../tutorial/introduction.rst:458 +#: ../../tutorial/introduction.rst:457 msgid "" ">>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n" ">>> letters\n" @@ -926,11 +924,11 @@ msgstr "" ">>> letters\n" "[]" -#: ../../tutorial/introduction.rst:474 +#: ../../tutorial/introduction.rst:473 msgid "The built-in function :func:`len` also applies to lists::" msgstr "內建的函式 :func:`len` 亦可以作用在 list 上: ::" -#: ../../tutorial/introduction.rst:476 +#: ../../tutorial/introduction.rst:475 msgid "" ">>> letters = ['a', 'b', 'c', 'd']\n" ">>> len(letters)\n" @@ -940,13 +938,13 @@ msgstr "" ">>> len(letters)\n" "4" -#: ../../tutorial/introduction.rst:480 +#: ../../tutorial/introduction.rst:479 msgid "" "It is possible to nest lists (create lists containing other lists), for " "example::" msgstr "也可以嵌套多層 list (建立 list 包含其他 list),例如: ::" -#: ../../tutorial/introduction.rst:483 +#: ../../tutorial/introduction.rst:482 msgid "" ">>> a = ['a', 'b', 'c']\n" ">>> n = [1, 2, 3]\n" @@ -968,11 +966,11 @@ msgstr "" ">>> x[0][1]\n" "'b'" -#: ../../tutorial/introduction.rst:496 +#: ../../tutorial/introduction.rst:495 msgid "First Steps Towards Programming" msgstr "初探程式設計的前幾步" -#: ../../tutorial/introduction.rst:498 +#: ../../tutorial/introduction.rst:497 msgid "" "Of course, we can use Python for more complicated tasks than adding two and " "two together. For instance, we can write an initial sub-sequence of the " @@ -983,7 +981,7 @@ msgstr "" "費氏數列 `_\\ 的首幾項序列: ::" -#: ../../tutorial/introduction.rst:503 +#: ../../tutorial/introduction.rst:502 msgid "" ">>> # Fibonacci series:\n" ">>> # the sum of two elements defines the next\n" @@ -1015,11 +1013,11 @@ msgstr "" "5\n" "8" -#: ../../tutorial/introduction.rst:518 +#: ../../tutorial/introduction.rst:517 msgid "This example introduces several new features." msgstr "這例子引入了許多新的特性。" -#: ../../tutorial/introduction.rst:520 +#: ../../tutorial/introduction.rst:519 msgid "" "The first line contains a *multiple assignment*: the variables ``a`` and " "``b`` simultaneously get the new values 0 and 1. On the last line this is " @@ -1031,7 +1029,7 @@ msgstr "" "同樣的賦值再被使用了一次,示範了等號的右項運算 (expression) 會先被計算 " "(evaluate),賦值再發生。右項的運算式由左至右依序被計算。" -#: ../../tutorial/introduction.rst:526 +#: ../../tutorial/introduction.rst:525 msgid "" "The :keyword:`while` loop executes as long as the condition (here: ``a < " "10``) remains true. In Python, like in C, any non-zero integer value is " @@ -1049,7 +1047,7 @@ msgstr "" "使用如同 C 語言一樣的符號:``<``\\ (小於)、``>``\\ (大於)、``==``\\ (等" "於)、``<=``\\ (小於等於)、``>=``\\ (大於等於)以及 ``!=``\\ (不等於)。" -#: ../../tutorial/introduction.rst:535 +#: ../../tutorial/introduction.rst:534 msgid "" "The *body* of the loop is *indented*: indentation is Python's way of " "grouping statements. At the interactive prompt, you have to type a tab or " @@ -1067,7 +1065,7 @@ msgstr "" "析器無法判斷你何時輸入複合陳述的最後一行)。注意在一個縮排段落內的縮排方式與" "數量必須維持一致。" -#: ../../tutorial/introduction.rst:544 +#: ../../tutorial/introduction.rst:543 msgid "" "The :func:`print` function writes the value of the argument(s) it is given. " "It differs from just writing the expression you want to write (as we did " @@ -1081,7 +1079,7 @@ msgstr "" "將不帶有引號,並且不同項目間會插入一個空白,因此可以讓你容易格式化輸出,例" "如: ::" -#: ../../tutorial/introduction.rst:551 +#: ../../tutorial/introduction.rst:550 msgid "" ">>> i = 256*256\n" ">>> print('The value of i is', i)\n" @@ -1091,7 +1089,7 @@ msgstr "" ">>> print('The value of i is', i)\n" "The value of i is 65536" -#: ../../tutorial/introduction.rst:555 +#: ../../tutorial/introduction.rst:554 msgid "" "The keyword argument *end* can be used to avoid the newline after the " "output, or end the output with a different string::" @@ -1099,7 +1097,7 @@ msgstr "" "關鍵字引數 *end* 可以被用來避免額外的換行符加入到輸出中,或者以不同的字串結束" "輸出: ::" -#: ../../tutorial/introduction.rst:558 +#: ../../tutorial/introduction.rst:557 msgid "" ">>> a, b = 0, 1\n" ">>> while a < 1000:\n" @@ -1115,11 +1113,11 @@ msgstr "" "...\n" "0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987," -#: ../../tutorial/introduction.rst:567 +#: ../../tutorial/introduction.rst:566 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/introduction.rst:568 +#: ../../tutorial/introduction.rst:567 msgid "" "Since ``**`` has higher precedence than ``-``, ``-3**2`` will be interpreted " "as ``-(3**2)`` and thus result in ``-9``. To avoid this and get ``9``, you " @@ -1128,7 +1126,7 @@ msgstr "" "因為 ``**`` 擁有較 ``-`` 高的優先次序,``-3**2`` 會被解釋為 ``-(3**2)`` 並得" "到 ``-9``。如果要避免這樣的優先順序以得到 ``9``,你可以使用 ``(-3)**2``。" -#: ../../tutorial/introduction.rst:572 +#: ../../tutorial/introduction.rst:571 msgid "" "Unlike other languages, special characters such as ``\\n`` have the same " "meaning with both single (``'...'``) and double (``\"...\"``) quotes. The " @@ -1139,10 +1137,10 @@ msgstr "" "相同的意思。兩種引號的唯一差別,在於使用單引號時,不需要跳脫 ``\"``\\ (但必" "須跳脫 ``\\'``\\ ),反之亦同。" -#: ../../tutorial/introduction.rst:21 +#: ../../tutorial/introduction.rst:20 msgid "# (hash)" msgstr "# (hash)" -#: ../../tutorial/introduction.rst:21 +#: ../../tutorial/introduction.rst:20 msgid "comment" msgstr "comment(註解)" diff --git a/tutorial/modules.po b/tutorial/modules.po index ba0132e688..10ae8543c9 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-10-23 20:30+0800\n" "Last-Translator: Phil Lin \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -73,14 +73,16 @@ msgstr "" msgid "" "# Fibonacci numbers module\n" "\n" -"def fib(n): # write Fibonacci series up to n\n" +"def fib(n):\n" +" \"\"\"Write Fibonacci series up to n.\"\"\"\n" " a, b = 0, 1\n" " while a < n:\n" " print(a, end=' ')\n" " a, b = b, a+b\n" " print()\n" "\n" -"def fib2(n): # return Fibonacci series up to n\n" +"def fib2(n):\n" +" \"\"\"Return Fibonacci series up to n.\"\"\"\n" " result = []\n" " a, b = 0, 1\n" " while a < n:\n" @@ -90,14 +92,16 @@ msgid "" msgstr "" "# 費波那契數模組\n" "\n" -"def fib(n): # 寫出費波那契數列至第 n 位\n" +"def fib(n):\n" +" \"\"\"寫出費波那契數列至第 n 位。\"\"\"\n" " a, b = 0, 1\n" " while a < n:\n" " print(a, end=' ')\n" " a, b = b, a+b\n" " print()\n" "\n" -"def fib2(n): # 回傳費波那契數列至第 n 位\n" +"def fib2(n):\n" +" \"\"\"回傳費波那契數列至第 n 位。\"\"\"\n" " result = []\n" " a, b = 0, 1\n" " while a < n:\n" @@ -105,17 +109,17 @@ msgstr "" " a, b = b, a+b\n" " return result" -#: ../../tutorial/modules.rst:45 +#: ../../tutorial/modules.rst:47 msgid "" "Now enter the Python interpreter and import this module with the following " "command::" msgstr "現在進入 Python 直譯器並用以下指令 import 這個模組: ::" -#: ../../tutorial/modules.rst:48 +#: ../../tutorial/modules.rst:50 msgid ">>> import fibo" msgstr ">>> import fibo" -#: ../../tutorial/modules.rst:50 +#: ../../tutorial/modules.rst:52 msgid "" "This does not add the names of the functions defined in ``fibo`` directly " "to the current :term:`namespace` (see :ref:`tut-scopes` for more details); " @@ -126,7 +130,7 @@ msgstr "" "請見 :ref:`tut-scopes`);它只會加入 ``fibo`` 的模組名稱。使用此模組名稱,就" "可以存取函式: ::" -#: ../../tutorial/modules.rst:55 +#: ../../tutorial/modules.rst:57 msgid "" ">>> fibo.fib(1000)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987\n" @@ -142,12 +146,12 @@ msgstr "" ">>> fibo.__name__\n" "'fibo'" -#: ../../tutorial/modules.rst:62 +#: ../../tutorial/modules.rst:64 msgid "" "If you intend to use a function often you can assign it to a local name::" msgstr "如果你打算經常使用其中某個函式,可以將其指定至區域變數: ::" -#: ../../tutorial/modules.rst:64 +#: ../../tutorial/modules.rst:66 msgid "" ">>> fib = fibo.fib\n" ">>> fib(500)\n" @@ -157,11 +161,11 @@ msgstr "" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" -#: ../../tutorial/modules.rst:72 +#: ../../tutorial/modules.rst:74 msgid "More on Modules" msgstr "深入了解模組" -#: ../../tutorial/modules.rst:74 +#: ../../tutorial/modules.rst:76 msgid "" "A module can contain executable statements as well as function definitions. " "These statements are intended to initialize the module. They are executed " @@ -172,7 +176,7 @@ msgstr "" "只會在\\ *第一次*\\ 被 import 時才會執行。[#]_\\ (如果檔案被當成腳本執行,也" "會執行它們)。" -#: ../../tutorial/modules.rst:79 +#: ../../tutorial/modules.rst:81 msgid "" "Each module has its own private namespace, which is used as the global " "namespace by all functions defined in the module. Thus, the author of a " @@ -184,10 +188,10 @@ msgstr "" "每個模組都有它自己的私有命名空間 (namespace),模組內定義的函式會把該模組的私" "有符號表當成全域命名空間使用。因此,模組的作者可以在模組中使用全域變數,而不" "必擔心和使用者的全域變數發生意外的名稱衝突。另一方面,如果你知道自己在做什" -"麼,你可以用這個方式取用模組的全域變數,以和引用函式一樣的寫法," -"``modname.itemname``。" +"麼,你可以用這個方式取用模組的全域變數,以和引用函式一樣的寫法,``modname." +"itemname``。" -#: ../../tutorial/modules.rst:86 +#: ../../tutorial/modules.rst:88 msgid "" "Modules can import other modules. It is customary but not required to place " "all :keyword:`import` statements at the beginning of a module (or script, " @@ -199,7 +203,7 @@ msgstr "" "(就這邊來說,腳本也是一樣)的最開頭是個慣例,但並沒有強制。如放置在模組的最" "高層(不在任何函式或 class 中),被 import 的模組名稱將被加入全域命名空間中。" -#: ../../tutorial/modules.rst:91 +#: ../../tutorial/modules.rst:93 msgid "" "There is a variant of the :keyword:`import` statement that imports names " "from a module directly into the importing module's namespace. For example::" @@ -207,7 +211,7 @@ msgstr "" ":keyword:`import` 陳述式有另一種變形寫法,可以直接將名稱從欲 import 的模組," "直接 import 至原模組的命名空間中。例如: ::" -#: ../../tutorial/modules.rst:94 +#: ../../tutorial/modules.rst:96 msgid "" ">>> from fibo import fib, fib2\n" ">>> fib(500)\n" @@ -217,7 +221,7 @@ msgstr "" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" -#: ../../tutorial/modules.rst:98 +#: ../../tutorial/modules.rst:100 msgid "" "This does not introduce the module name from which the imports are taken in " "the local namespace (so in the example, ``fibo`` is not defined)." @@ -225,11 +229,11 @@ msgstr "" "在 import 之後的名稱會被導入,但定義該函式的整個模組名稱並不會被引入在區域命" "名空間中(因此,示例中的 ``fibo`` 未被定義)。" -#: ../../tutorial/modules.rst:101 +#: ../../tutorial/modules.rst:103 msgid "There is even a variant to import all names that a module defines::" msgstr "甚至還有另一種變形寫法,可以 import 模組定義的所有名稱: ::" -#: ../../tutorial/modules.rst:103 +#: ../../tutorial/modules.rst:105 msgid "" ">>> from fibo import *\n" ">>> fib(500)\n" @@ -239,7 +243,7 @@ msgstr "" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" -#: ../../tutorial/modules.rst:107 +#: ../../tutorial/modules.rst:109 msgid "" "This imports all names except those beginning with an underscore (``_``). In " "most cases Python programmers do not use this facility since it introduces " @@ -250,7 +254,7 @@ msgstr "" "況下,Python 程式設計師不大使用這個功能,因為它在直譯器中引入了一組未知的名" "稱,並且可能覆蓋了某些你已經定義的內容。" -#: ../../tutorial/modules.rst:112 +#: ../../tutorial/modules.rst:114 msgid "" "Note that in general the practice of importing ``*`` from a module or " "package is frowned upon, since it often causes poorly readable code. " @@ -260,15 +264,15 @@ msgstr "" "致可讀性較差的程式碼。但若是使用它來在互動模式中節省打字時間,則是可以接受" "的。" -#: ../../tutorial/modules.rst:116 +#: ../../tutorial/modules.rst:118 msgid "" -"If the module name is followed by :keyword:`!as`, then the name " -"following :keyword:`!as` is bound directly to the imported module." +"If the module name is followed by :keyword:`!as`, then the name following :" +"keyword:`!as` is bound directly to the imported module." msgstr "" "如果模組名稱後面出現 :keyword:`!as`,則 :keyword:`!as` 之後的名稱將直接和被 " "import 模組綁定在一起。" -#: ../../tutorial/modules.rst:121 +#: ../../tutorial/modules.rst:123 msgid "" ">>> import fibo as fib\n" ">>> fib.fib(500)\n" @@ -278,7 +282,7 @@ msgstr "" ">>> fib.fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" -#: ../../tutorial/modules.rst:125 +#: ../../tutorial/modules.rst:127 msgid "" "This is effectively importing the module in the same way that ``import " "fibo`` will do, with the only difference of it being available as ``fib``." @@ -286,12 +290,12 @@ msgstr "" "這個 import 方式和 ``import fibo`` 實質上是一樣的,唯一的差別是現在要用 " "``fib`` 使用模組。" -#: ../../tutorial/modules.rst:128 +#: ../../tutorial/modules.rst:130 msgid "" "It can also be used when utilising :keyword:`from` with similar effects::" msgstr "在使用 :keyword:`from` 時也可以用同樣的方式獲得類似的效果: ::" -#: ../../tutorial/modules.rst:130 +#: ../../tutorial/modules.rst:132 msgid "" ">>> from fibo import fib as fibonacci\n" ">>> fibonacci(500)\n" @@ -301,32 +305,32 @@ msgstr "" ">>> fibonacci(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" -#: ../../tutorial/modules.rst:137 +#: ../../tutorial/modules.rst:139 msgid "" "For efficiency reasons, each module is only imported once per interpreter " "session. Therefore, if you change your modules, you must restart the " "interpreter -- or, if it's just one module you want to test interactively, " -"use :func:`importlib.reload`, e.g. ``import importlib; " -"importlib.reload(modulename)``." +"use :func:`importlib.reload`, e.g. ``import importlib; importlib." +"reload(modulename)``." msgstr "" "出於效率原因,每個模組在每個直譯器 session 中僅會被 import 一次。因此,如果你" "更改了模組,則必須重啟直譯器——或者,如果只是一個想要在互動模式下測試的模組," -"可以使用 :func:`importlib.reload`。例如:``import importlib; " -"importlib.reload(modulename)``。" +"可以使用 :func:`importlib.reload`。例如:``import importlib; importlib." +"reload(modulename)``。" -#: ../../tutorial/modules.rst:147 +#: ../../tutorial/modules.rst:149 msgid "Executing modules as scripts" msgstr "把模組當作腳本執行" -#: ../../tutorial/modules.rst:149 +#: ../../tutorial/modules.rst:151 msgid "When you run a Python module with ::" msgstr "當使用以下內容運行 Python 模組時: ::" -#: ../../tutorial/modules.rst:151 +#: ../../tutorial/modules.rst:153 msgid "python fibo.py " msgstr "python fibo.py " -#: ../../tutorial/modules.rst:153 +#: ../../tutorial/modules.rst:155 msgid "" "the code in the module will be executed, just as if you imported it, but " "with the ``__name__`` set to ``\"__main__\"``. That means that by adding " @@ -335,7 +339,7 @@ msgstr "" "如同使用 import 指令,模組中的程式碼會被執行,但 ``__name__`` 被設為 " "``\"__main__\"``。這意味著,透過在模組的末尾添加以下程式碼: ::" -#: ../../tutorial/modules.rst:157 +#: ../../tutorial/modules.rst:159 msgid "" "if __name__ == \"__main__\":\n" " import sys\n" @@ -345,7 +349,7 @@ msgstr "" " import sys\n" " fib(int(sys.argv[1]))" -#: ../../tutorial/modules.rst:161 +#: ../../tutorial/modules.rst:163 msgid "" "you can make the file usable as a script as well as an importable module, " "because the code that parses the command line only runs if the module is " @@ -354,7 +358,7 @@ msgstr "" "你可以將檔案作為腳本也同時可以作為被 import 的模組,因為剖析 (parse) 命令列的" "程式碼只會在當模組是「主」檔案時,才會執行:" -#: ../../tutorial/modules.rst:165 +#: ../../tutorial/modules.rst:167 msgid "" "$ python fibo.py 50\n" "0 1 1 2 3 5 8 13 21 34" @@ -362,11 +366,11 @@ msgstr "" "$ python fibo.py 50\n" "0 1 1 2 3 5 8 13 21 34" -#: ../../tutorial/modules.rst:170 +#: ../../tutorial/modules.rst:172 msgid "If the module is imported, the code is not run::" msgstr "如果此模組是被 import 的,則該段程式碼不會被執行: ::" -#: ../../tutorial/modules.rst:172 +#: ../../tutorial/modules.rst:174 msgid "" ">>> import fibo\n" ">>>" @@ -374,7 +378,7 @@ msgstr "" ">>> import fibo\n" ">>>" -#: ../../tutorial/modules.rst:175 +#: ../../tutorial/modules.rst:177 msgid "" "This is often used either to provide a convenient user interface to a " "module, or for testing purposes (running the module as a script executes a " @@ -383,31 +387,30 @@ msgstr "" "這通常是用來為模組提供方便的使用者介面,或者用於測試目的(執行測試套件時,以" "腳本的方式執行模組)。" -#: ../../tutorial/modules.rst:182 +#: ../../tutorial/modules.rst:184 msgid "The Module Search Path" msgstr "模組的搜尋路徑" -#: ../../tutorial/modules.rst:186 +#: ../../tutorial/modules.rst:188 msgid "" "When a module named :mod:`!spam` is imported, the interpreter first searches " -"for a built-in module with that name. These module names are listed " -"in :data:`sys.builtin_module_names`. If not found, it then searches for a " -"file named :file:`spam.py` in a list of directories given by the " -"variable :data:`sys.path`. :data:`sys.path` is initialized from these " -"locations:" +"for a built-in module with that name. These module names are listed in :data:" +"`sys.builtin_module_names`. If not found, it then searches for a file named :" +"file:`spam.py` in a list of directories given by the variable :data:`sys." +"path`. :data:`sys.path` is initialized from these locations:" msgstr "" "Import 一個名為 :mod:`!spam` 的模組時,直譯器首先會搜尋具有該名稱的內建模組。" "模組名稱列在 :data:`sys.builtin_module_names` 當中。如果找不到,接下來會在變" "數 :data:`sys.path` 所給定的資料夾清單之中,搜尋一個名為 :file:`spam.py` 的檔" "案。:data:`sys.path` 從這些位置開始進行初始化:" -#: ../../tutorial/modules.rst:192 +#: ../../tutorial/modules.rst:194 msgid "" "The directory containing the input script (or the current directory when no " "file is specified)." msgstr "輸入腳本所位在的資料夾(如未指定檔案時,則是目前資料夾)。" -#: ../../tutorial/modules.rst:194 +#: ../../tutorial/modules.rst:196 msgid "" ":envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the " "shell variable :envvar:`PATH`)." @@ -415,19 +418,19 @@ msgstr "" ":envvar:`PYTHONPATH`\\ (一連串和 shell 變數 :envvar:`PATH` 的語法相同的資料" "夾名稱)。" -#: ../../tutorial/modules.rst:196 +#: ../../tutorial/modules.rst:198 msgid "" "The installation-dependent default (by convention including a ``site-" "packages`` directory, handled by the :mod:`site` module)." msgstr "" -"與安裝相關的預設值(按慣例會包含一個 ``site-packages`` 資料夾,它是" -"由 :mod:`site` 模組所處理)。" +"與安裝相關的預設值(按慣例會包含一個 ``site-packages`` 資料夾,它是由 :mod:" +"`site` 模組所處理)。" -#: ../../tutorial/modules.rst:199 +#: ../../tutorial/modules.rst:201 msgid "More details are at :ref:`sys-path-init`." msgstr "在 :ref:`sys-path-init` 有更多的細節。" -#: ../../tutorial/modules.rst:202 +#: ../../tutorial/modules.rst:204 msgid "" "On file systems which support symlinks, the directory containing the input " "script is calculated after the symlink is followed. In other words the " @@ -437,7 +440,7 @@ msgstr "" "後才被計算的。換言之,包含符號連結的資料夾\\ **並沒有**\\ 增加到模組的搜尋路" "徑中。" -#: ../../tutorial/modules.rst:206 +#: ../../tutorial/modules.rst:208 msgid "" "After initialization, Python programs can modify :data:`sys.path`. The " "directory containing the script being run is placed at the beginning of the " @@ -451,11 +454,11 @@ msgstr "" "不是函式庫資料夾中相同名稱的模組。除非是有意要做這樣的替換,否則這是一個錯" "誤。 請參見\\ :ref:`tut-standardmodules`\\ 以瞭解更多資訊。" -#: ../../tutorial/modules.rst:219 +#: ../../tutorial/modules.rst:221 msgid "\"Compiled\" Python files" msgstr "「編譯」Python 檔案" -#: ../../tutorial/modules.rst:221 +#: ../../tutorial/modules.rst:223 msgid "" "To speed up loading modules, Python caches the compiled version of each " "module in the ``__pycache__`` directory under the name :file:`module." @@ -471,7 +474,7 @@ msgstr "" "spam.py 的編譯版本將被暫存為 ``__pycache__/spam.cpython-33.pyc``。此命名準則" "可以讓來自不同版本的編譯模組和 Python 的不同版本同時共存。" -#: ../../tutorial/modules.rst:229 +#: ../../tutorial/modules.rst:231 msgid "" "Python checks the modification date of the source against the compiled " "version to see if it's out of date and needs to be recompiled. This is a " @@ -483,7 +486,7 @@ msgstr "" "完全自動的過程。另外,編譯後的模組獨立於平台,因此不同架構的作業系統之間可以" "共用同一函式庫。" -#: ../../tutorial/modules.rst:234 +#: ../../tutorial/modules.rst:236 msgid "" "Python does not check the cache in two circumstances. First, it always " "recompiles and does not store the result for the module that's loaded " @@ -496,11 +499,11 @@ msgstr "" "列載入的模組的結果。第二,如果沒有源模組,則不會檢查快取。要支援非源模組(僅" "編譯)的發布,編譯後的模組必須位於原始資料夾中,並且不能有源模組。" -#: ../../tutorial/modules.rst:241 +#: ../../tutorial/modules.rst:243 msgid "Some tips for experts:" msgstr "一些給專家的秘訣:" -#: ../../tutorial/modules.rst:243 +#: ../../tutorial/modules.rst:245 msgid "" "You can use the :option:`-O` or :option:`-OO` switches on the Python command " "to reduce the size of a compiled module. The ``-O`` switch removes assert " @@ -516,32 +519,32 @@ msgstr "" "只有在你知道自己在做什麼時,才應使用此參數。「已優化」模組有 ``opt-`` 標記," "且通常較小。未來的版本可能會改變優化的效果。" -#: ../../tutorial/modules.rst:251 +#: ../../tutorial/modules.rst:253 msgid "" "A program doesn't run any faster when it is read from a ``.pyc`` file than " -"when it is read from a ``.py`` file; the only thing that's faster about " -"``.pyc`` files is the speed with which they are loaded." +"when it is read from a ``.py`` file; the only thing that's faster about ``." +"pyc`` files is the speed with which they are loaded." msgstr "" "讀取 ``.pyc`` 檔案時,程式的執行速度並不會比讀取 ``.py`` 檔案快。唯一比較快的" "地方是載入的速度。" -#: ../../tutorial/modules.rst:255 +#: ../../tutorial/modules.rst:257 msgid "" "The module :mod:`compileall` can create .pyc files for all modules in a " "directory." msgstr "模組 :mod:`compileall` 可以為資料夾中的所有模組建立 .pyc 檔。" -#: ../../tutorial/modules.rst:258 +#: ../../tutorial/modules.rst:260 msgid "" "There is more detail on this process, including a flow chart of the " "decisions, in :pep:`3147`." msgstr "更多的細節,包括決策流程圖,請參考\\ :pep:`3147`。" -#: ../../tutorial/modules.rst:265 +#: ../../tutorial/modules.rst:267 msgid "Standard Modules" msgstr "標準模組" -#: ../../tutorial/modules.rst:269 +#: ../../tutorial/modules.rst:271 msgid "" "Python comes with a library of standard modules, described in a separate " "document, the Python Library Reference (\"Library Reference\" hereafter). " @@ -563,7 +566,7 @@ msgstr "" "建在每個 Python 直譯器中。變數 ``sys.ps1`` 和 ``sys.ps2`` 則用來定義主、次提" "示字元的字串: ::" -#: ../../tutorial/modules.rst:281 +#: ../../tutorial/modules.rst:283 msgid "" ">>> import sys\n" ">>> sys.ps1\n" @@ -585,13 +588,13 @@ msgstr "" "Yuck!\n" "C>" -#: ../../tutorial/modules.rst:292 +#: ../../tutorial/modules.rst:294 msgid "" "These two variables are only defined if the interpreter is in interactive " "mode." msgstr "只有直譯器在互動模式時,才需要定義這兩個變數。" -#: ../../tutorial/modules.rst:294 +#: ../../tutorial/modules.rst:296 msgid "" "The variable ``sys.path`` is a list of strings that determines the " "interpreter's search path for modules. It is initialized to a default path " @@ -603,7 +606,7 @@ msgstr "" "境變數 :envvar:`PYTHONPATH` 中提取的預設路徑,或是當 :envvar:`PYTHONPATH` 未" "設定時,從內建預設值提取。你可以用標準的 list 操作修改該變數: ::" -#: ../../tutorial/modules.rst:300 +#: ../../tutorial/modules.rst:302 msgid "" ">>> import sys\n" ">>> sys.path.append('/ufs/guido/lib/python')" @@ -611,11 +614,11 @@ msgstr "" ">>> import sys\n" ">>> sys.path.append('/ufs/guido/lib/python')" -#: ../../tutorial/modules.rst:307 +#: ../../tutorial/modules.rst:309 msgid "The :func:`dir` Function" msgstr ":func:`dir` 函式" -#: ../../tutorial/modules.rst:309 +#: ../../tutorial/modules.rst:311 msgid "" "The built-in function :func:`dir` is used to find out which names a module " "defines. It returns a sorted list of strings::" @@ -623,7 +626,7 @@ msgstr "" "內建函式 :func:`dir` 用於找出模組定義的所有名稱。它回傳一個排序後的字串 " "list: ::" -#: ../../tutorial/modules.rst:312 +#: ../../tutorial/modules.rst:314 msgid "" ">>> import fibo, sys\n" ">>> dir(fibo)\n" @@ -691,12 +694,12 @@ msgstr "" "'version_info',\n" " 'warnoptions']" -#: ../../tutorial/modules.rst:338 +#: ../../tutorial/modules.rst:340 msgid "" "Without arguments, :func:`dir` lists the names you have defined currently::" msgstr "沒有給引數時,:func:`dir` 列出目前已定義的名稱: ::" -#: ../../tutorial/modules.rst:340 +#: ../../tutorial/modules.rst:342 msgid "" ">>> a = [1, 2, 3, 4, 5]\n" ">>> import fibo\n" @@ -710,21 +713,21 @@ msgstr "" ">>> dir()\n" "['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']" -#: ../../tutorial/modules.rst:346 +#: ../../tutorial/modules.rst:348 msgid "" "Note that it lists all types of names: variables, modules, functions, etc." msgstr "請注意,它列出所有類型的名稱:變數、模組、函式等。" -#: ../../tutorial/modules.rst:350 +#: ../../tutorial/modules.rst:352 msgid "" ":func:`dir` does not list the names of built-in functions and variables. If " -"you want a list of those, they are defined in the standard " -"module :mod:`builtins`::" +"you want a list of those, they are defined in the standard module :mod:" +"`builtins`::" msgstr "" ":func:`dir` 不會列出內建函式和變數的名稱。如果你想要列出它們,它們被定義在標" "準模組 :mod:`builtins` 內: ::" -#: ../../tutorial/modules.rst:354 +#: ../../tutorial/modules.rst:356 msgid "" ">>> import builtins\n" ">>> dir(builtins)\n" @@ -792,11 +795,11 @@ msgstr "" " 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars',\n" " 'zip']" -#: ../../tutorial/modules.rst:389 +#: ../../tutorial/modules.rst:391 msgid "Packages" msgstr "套件 (Package)" -#: ../../tutorial/modules.rst:391 +#: ../../tutorial/modules.rst:393 msgid "" "Packages are a way of structuring Python's module namespace by using " "\"dotted module names\". For example, the module name :mod:`!A.B` " @@ -811,29 +814,28 @@ msgstr "" "的作者不需擔心與其他模組的全域變數名稱重複,點分隔模組名稱的使用,也讓多模組" "套件(像 NumPy 或 Pillow)的作者們不須擔心其他套件的模組名稱。" -#: ../../tutorial/modules.rst:399 +#: ../../tutorial/modules.rst:401 msgid "" "Suppose you want to design a collection of modules (a \"package\") for the " "uniform handling of sound files and sound data. There are many different " -"sound file formats (usually recognized by their extension, for " -"example: :file:`.wav`, :file:`.aiff`, :file:`.au`), so you may need to " -"create and maintain a growing collection of modules for the conversion " -"between the various file formats. There are also many different operations " -"you might want to perform on sound data (such as mixing, adding echo, " -"applying an equalizer function, creating an artificial stereo effect), so in " -"addition you will be writing a never-ending stream of modules to perform " -"these operations. Here's a possible structure for your package (expressed " -"in terms of a hierarchical filesystem):" +"sound file formats (usually recognized by their extension, for example: :" +"file:`.wav`, :file:`.aiff`, :file:`.au`), so you may need to create and " +"maintain a growing collection of modules for the conversion between the " +"various file formats. There are also many different operations you might " +"want to perform on sound data (such as mixing, adding echo, applying an " +"equalizer function, creating an artificial stereo effect), so in addition " +"you will be writing a never-ending stream of modules to perform these " +"operations. Here's a possible structure for your package (expressed in " +"terms of a hierarchical filesystem):" msgstr "" "假設你想設計一個能統一處理音訊檔案及音訊數據的模組集(「套件」)。因為音訊檔" -"案有很多的不同的格式(通常以它們的副檔名來辨識,例" -"如::file:`.wav`、:file:`.aiff`、:file:`.au`\\ ),因此,為了不同檔案格式之間" -"的轉換,你會需要建立和維護一個不斷增長的模組集合。為了要達成對音訊數據的許多" -"不同作業(例如,音訊混合、增加回聲、套用等化器功能、創造人工立體音效),你將" -"編寫一系列無止盡的模組來執行這些作業。以下是你的套件可能的架構(以階層式檔案" -"系統的方式表示):" +"案有很多的不同的格式(通常以它們的副檔名來辨識,例如::file:`.wav`、:file:`." +"aiff`、:file:`.au`\\ ),因此,為了不同檔案格式之間的轉換,你會需要建立和維護" +"一個不斷增長的模組集合。為了要達成對音訊數據的許多不同作業(例如,音訊混合、" +"增加回聲、套用等化器功能、創造人工立體音效),你將編寫一系列無止盡的模組來執" +"行這些作業。以下是你的套件可能的架構(以階層式檔案系統的方式表示):" -#: ../../tutorial/modules.rst:410 +#: ../../tutorial/modules.rst:412 msgid "" "sound/ Top-level package\n" " __init__.py Initialize the sound package\n" @@ -860,13 +862,13 @@ msgid "" " ..." msgstr "" -#: ../../tutorial/modules.rst:436 +#: ../../tutorial/modules.rst:438 msgid "" -"When importing the package, Python searches through the directories on " -"``sys.path`` looking for the package subdirectory." +"When importing the package, Python searches through the directories on ``sys." +"path`` looking for the package subdirectory." msgstr "Import 套件時,Python 會搜尋 ``sys.path`` 裡的目錄,尋找套件的子目錄。" -#: ../../tutorial/modules.rst:439 +#: ../../tutorial/modules.rst:441 msgid "" "The :file:`__init__.py` files are required to make Python treat directories " "containing the file as packages (unless using a :term:`namespace package`, a " @@ -876,42 +878,42 @@ msgid "" "can just be an empty file, but it can also execute initialization code for " "the package or set the ``__all__`` variable, described later." msgstr "" -"目錄中必須含有 :file:`__init__.py` 檔案,才會被 Pyhon 當成套件(除非有使" -"用 :term:`namespace package`,為一個相對進階的功能);這樣可以避免一些以常用" -"名稱命名(例如 ``string``\\ )的目錄,無意中隱藏了較晚出現在模組搜尋路徑中的" -"有效模組。在最簡單的情況,:file:`__init__.py` 可以只是一個空白檔案;但它也可" -"以執行套件的初始化程式碼,或設置 ``__all__`` 變數,之後會詳述。" +"目錄中必須含有 :file:`__init__.py` 檔案,才會被 Pyhon 當成套件(除非有使用 :" +"term:`namespace package`,為一個相對進階的功能);這樣可以避免一些以常用名稱" +"命名(例如 ``string``\\ )的目錄,無意中隱藏了較晚出現在模組搜尋路徑中的有效" +"模組。在最簡單的情況,:file:`__init__.py` 可以只是一個空白檔案;但它也可以執" +"行套件的初始化程式碼,或設置 ``__all__`` 變數,之後會詳述。" -#: ../../tutorial/modules.rst:447 +#: ../../tutorial/modules.rst:449 msgid "" "Users of the package can import individual modules from the package, for " "example::" msgstr "套件使用者可以從套件中 import 個別模組,例如: ::" -#: ../../tutorial/modules.rst:450 +#: ../../tutorial/modules.rst:452 msgid "import sound.effects.echo" msgstr "import sound.effects.echo" -#: ../../tutorial/modules.rst:452 +#: ../../tutorial/modules.rst:454 msgid "" "This loads the submodule :mod:`!sound.effects.echo`. It must be referenced " "with its full name. ::" msgstr "" "這樣就載入了子模組 :mod:`!sound.effects.echo`。引用時必須用它的全名: ::" -#: ../../tutorial/modules.rst:455 +#: ../../tutorial/modules.rst:457 msgid "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" msgstr "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" -#: ../../tutorial/modules.rst:457 +#: ../../tutorial/modules.rst:459 msgid "An alternative way of importing the submodule is::" msgstr "另一種 import 子模組的方法是: ::" -#: ../../tutorial/modules.rst:459 +#: ../../tutorial/modules.rst:461 msgid "from sound.effects import echo" msgstr "from sound.effects import echo" -#: ../../tutorial/modules.rst:461 +#: ../../tutorial/modules.rst:463 msgid "" "This also loads the submodule :mod:`!echo`, and makes it available without " "its package prefix, so it can be used as follows::" @@ -919,47 +921,47 @@ msgstr "" "這段程式碼一樣可以載入子模組 :mod:`!echo`,並且不加套件前綴也可以使用,因此能" "以如下方式使用: ::" -#: ../../tutorial/modules.rst:464 +#: ../../tutorial/modules.rst:466 msgid "echo.echofilter(input, output, delay=0.7, atten=4)" msgstr "echo.echofilter(input, output, delay=0.7, atten=4)" -#: ../../tutorial/modules.rst:466 +#: ../../tutorial/modules.rst:468 msgid "" "Yet another variation is to import the desired function or variable " "directly::" msgstr "另一種變化是直接 import 所需的函式或變數: ::" -#: ../../tutorial/modules.rst:468 +#: ../../tutorial/modules.rst:470 msgid "from sound.effects.echo import echofilter" msgstr "from sound.effects.echo import echofilter" -#: ../../tutorial/modules.rst:470 +#: ../../tutorial/modules.rst:472 msgid "" -"Again, this loads the submodule :mod:`!echo`, but this makes its " -"function :func:`!echofilter` directly available::" +"Again, this loads the submodule :mod:`!echo`, but this makes its function :" +"func:`!echofilter` directly available::" msgstr "" "同樣地,這樣也會載入子模組 :mod:`!echo`,但它的函式 :func:`!echofilter` 就可" "以直接使用: ::" -#: ../../tutorial/modules.rst:473 +#: ../../tutorial/modules.rst:475 msgid "echofilter(input, output, delay=0.7, atten=4)" msgstr "echofilter(input, output, delay=0.7, atten=4)" -#: ../../tutorial/modules.rst:475 +#: ../../tutorial/modules.rst:477 msgid "" "Note that when using ``from package import item``, the item can be either a " "submodule (or subpackage) of the package, or some other name defined in the " "package, like a function, class or variable. The ``import`` statement first " "tests whether the item is defined in the package; if not, it assumes it is a " -"module and attempts to load it. If it fails to find it, " -"an :exc:`ImportError` exception is raised." +"module and attempts to load it. If it fails to find it, an :exc:" +"`ImportError` exception is raised." msgstr "" "請注意,使用 ``from package import item`` 時,item 可以是套件的子模組(或子套" "件),也可以是套件中被定義的名稱,像是函式、class (類別)或變數。``import`` " "陳述式首先測試套件中有沒有定義該 item;如果沒有,則會假設它是模組,並嘗試載" "入。如果還是找不到 item,則會引發 :exc:`ImportError` 例外。" -#: ../../tutorial/modules.rst:482 +#: ../../tutorial/modules.rst:484 msgid "" "Contrarily, when using syntax like ``import item.subitem.subsubitem``, each " "item except for the last must be a package; the last item can be a module or " @@ -970,11 +972,11 @@ msgstr "" "一項都必須是套件;最後一項可以是模組或套件,但不能是前一項中定義的 class、函" "式或變數。" -#: ../../tutorial/modules.rst:491 +#: ../../tutorial/modules.rst:493 msgid "Importing \\* From a Package" msgstr "從套件中 import \\*" -#: ../../tutorial/modules.rst:495 +#: ../../tutorial/modules.rst:497 msgid "" "Now what happens when the user writes ``from sound.effects import *``? " "Ideally, one would hope that this somehow goes out to the filesystem, finds " @@ -987,7 +989,7 @@ msgstr "" "會花費較長的時間,且 import 子模組的過程可能會有不必要的副作用,這些副作用只" "有在明確地 import 子模組時才會發生。" -#: ../../tutorial/modules.rst:501 +#: ../../tutorial/modules.rst:503 msgid "" "The only solution is for the package author to provide an explicit index of " "the package. The :keyword:`import` statement uses the following convention: " @@ -1003,14 +1005,14 @@ msgstr "" "慣例:如果套件的 :file:`__init__.py` 程式碼有定義一個名為 ``__all__`` 的 " "list,若遇到 ``from package import *`` 的時候,它就會是要被 import 的模組名" "稱。發布套件的新版本時,套件作者可自行決定是否更新此 list。如果套件作者認為沒" -"有人會從他的套件中 import \\*,他也可能會決定不支援這個 list。舉例來" -"說,:file:`sound/effects/__init__.py` 檔案可包含以下程式碼: ::" +"有人會從他的套件中 import \\*,他也可能會決定不支援這個 list。舉例來說,:" +"file:`sound/effects/__init__.py` 檔案可包含以下程式碼: ::" -#: ../../tutorial/modules.rst:511 +#: ../../tutorial/modules.rst:513 msgid "__all__ = [\"echo\", \"surround\", \"reverse\"]" msgstr "__all__ = [\"echo\", \"surround\", \"reverse\"]" -#: ../../tutorial/modules.rst:513 +#: ../../tutorial/modules.rst:515 msgid "" "This would mean that ``from sound.effects import *`` would import the three " "named submodules of the :mod:`!sound.effects` package." @@ -1018,7 +1020,7 @@ msgstr "" "意思是,``from sound.effects import *`` 將會 import :mod:`!sound.effects` 套" "件中,這三個被提名的子模組。" -#: ../../tutorial/modules.rst:516 +#: ../../tutorial/modules.rst:518 msgid "" "Be aware that submodules might become shadowed by locally defined names. For " "example, if you added a ``reverse`` function to the :file:`sound/effects/" @@ -1027,13 +1029,13 @@ msgid "" "submodule, because it is shadowed by the locally defined ``reverse`` " "function::" msgstr "" -"請注意,子模組可能會被區域定義 (locally defined) 的名稱遮蔽。例如,如果你" -"在 :file:`sound/effects/__init__.py` 檔案中新增了一個 ``reverse`` 函式,則 " +"請注意,子模組可能會被區域定義 (locally defined) 的名稱遮蔽。例如,如果你在 :" +"file:`sound/effects/__init__.py` 檔案中新增了一個 ``reverse`` 函式,則 " "``from sound.effects import *`` 只會引入兩個子模組 ``echo`` 和 ``surround``," "但\\ *不是* ``reverse`` 子模組,因為它被區域定義的 ``reverse`` 函式遮蔽" "了: ::" -#: ../../tutorial/modules.rst:523 +#: ../../tutorial/modules.rst:525 msgid "" "__all__ = [\n" " \"echo\", # refers to the 'echo.py' file\n" @@ -1045,13 +1047,13 @@ msgid "" " return msg[::-1] # in the case of a 'from sound.effects import *'" msgstr "" -#: ../../tutorial/modules.rst:532 +#: ../../tutorial/modules.rst:534 msgid "" "If ``__all__`` is not defined, the statement ``from sound.effects import *`` " "does *not* import all submodules from the package :mod:`!sound.effects` into " -"the current namespace; it only ensures that the package :mod:`!" -"sound.effects` has been imported (possibly running any initialization code " -"in :file:`__init__.py`) and then imports whatever names are defined in the " +"the current namespace; it only ensures that the package :mod:`!sound." +"effects` has been imported (possibly running any initialization code in :" +"file:`__init__.py`) and then imports whatever names are defined in the " "package. This includes any names defined (and submodules explicitly loaded) " "by :file:`__init__.py`. It also includes any submodules of the package that " "were explicitly loaded by previous :keyword:`import` statements. Consider " @@ -1060,11 +1062,11 @@ msgstr "" "如果 ``__all__`` 沒有被定義,``from sound.effects import *`` 陳述式\\ *並不會" "*\\ 把 :mod:`!sound.effects` 套件中所有子模組都 import 到目前的命名空間;它只" "保證 :mod:`!sound.effects` 套件有被 import(可能會運行 :file:`__init__.py` 中" -"的初始化程式碼),然後 import 套件中被定義的全部名稱。這包" -"含 :file:`__init__.py` 定義(以及被明確載入的子模組)的任何名稱。它也包括任何" -"之前被 :keyword:`import` 陳述式明確載入的套件子模組。請看以下程式碼: ::" +"的初始化程式碼),然後 import 套件中被定義的全部名稱。這包含 :file:`__init__." +"py` 定義(以及被明確載入的子模組)的任何名稱。它也包括任何之前被 :keyword:" +"`import` 陳述式明確載入的套件子模組。請看以下程式碼: ::" -#: ../../tutorial/modules.rst:541 +#: ../../tutorial/modules.rst:543 msgid "" "import sound.effects.echo\n" "import sound.effects.surround\n" @@ -1074,18 +1076,18 @@ msgstr "" "import sound.effects.surround\n" "from sound.effects import *" -#: ../../tutorial/modules.rst:545 +#: ../../tutorial/modules.rst:547 msgid "" "In this example, the :mod:`!echo` and :mod:`!surround` modules are imported " -"in the current namespace because they are defined in the :mod:`!" -"sound.effects` package when the ``from...import`` statement is executed. " -"(This also works when ``__all__`` is defined.)" +"in the current namespace because they are defined in the :mod:`!sound." +"effects` package when the ``from...import`` statement is executed. (This " +"also works when ``__all__`` is defined.)" msgstr "" "此例中,當 ``from...import`` 陳述式被執行時,:mod:`!echo` 和 :mod:`!" "surround` 模組被 import 進目前的命名空間,因為它們是在 :mod:`!sound.effects` " "套件裡定義的。(當 ``__all__`` 有被定義時,這規則也有效。)" -#: ../../tutorial/modules.rst:550 +#: ../../tutorial/modules.rst:552 msgid "" "Although certain modules are designed to export only names that follow " "certain patterns when you use ``import *``, it is still considered bad " @@ -1094,7 +1096,7 @@ msgstr "" "雖然,有些特定模組的設計,讓你使用 ``import *`` 時,該模組只會輸出遵循特定樣" "式的名稱,但在正式環境 (production) 的程式碼中這仍然被視為是不良習慣。" -#: ../../tutorial/modules.rst:554 +#: ../../tutorial/modules.rst:556 msgid "" "Remember, there is nothing wrong with using ``from package import " "specific_submodule``! In fact, this is the recommended notation unless the " @@ -1104,35 +1106,35 @@ msgstr "" "記住,使用 ``from package import specific_submodule`` 不會有任何問題!實際" "上,這是推薦用法,除非 import 的模組需要用到的子模組和其他套件的子模組同名。" -#: ../../tutorial/modules.rst:563 +#: ../../tutorial/modules.rst:565 msgid "Intra-package References" msgstr "套件內引用" -#: ../../tutorial/modules.rst:565 +#: ../../tutorial/modules.rst:567 msgid "" "When packages are structured into subpackages (as with the :mod:`!sound` " "package in the example), you can use absolute imports to refer to submodules " -"of siblings packages. For example, if the module :mod:`!" -"sound.filters.vocoder` needs to use the :mod:`!echo` module in the :mod:`!" -"sound.effects` package, it can use ``from sound.effects import echo``." +"of siblings packages. For example, if the module :mod:`!sound.filters." +"vocoder` needs to use the :mod:`!echo` module in the :mod:`!sound.effects` " +"package, it can use ``from sound.effects import echo``." msgstr "" "當套件的結構為多個子套件的組合時(如同範例中的 :mod:`!sound` 套件),可以使用" -"「絕對 (absolute) import」,引用同層套件中的子模組。例如,要在 :mod:`!" -"sound.filters.vocoder` 模組中使用 :mod:`!sound.effects` 中的 :mod:`!echo` 模" -"組時,可以用 ``from sound.effects import echo``。" +"「絕對 (absolute) import」,引用同層套件中的子模組。例如,要在 :mod:`!sound." +"filters.vocoder` 模組中使用 :mod:`!sound.effects` 中的 :mod:`!echo` 模組時," +"可以用 ``from sound.effects import echo``。" -#: ../../tutorial/modules.rst:571 +#: ../../tutorial/modules.rst:573 msgid "" "You can also write relative imports, with the ``from module import name`` " "form of import statement. These imports use leading dots to indicate the " -"current and parent packages involved in the relative import. From " -"the :mod:`!surround` module for example, you might use::" +"current and parent packages involved in the relative import. From the :mod:" +"`!surround` module for example, you might use::" msgstr "" "你也可以用 ``from module import name`` 的 import 陳述式,編寫「相對 " "(relative) import」。這些 import 使用前導句號指示相對 import 中的目前套件和母" "套件。例如,在 :mod:`!urround` 模組中,你可以使用: ::" -#: ../../tutorial/modules.rst:576 +#: ../../tutorial/modules.rst:578 msgid "" "from . import echo\n" "from .. import formats\n" @@ -1142,7 +1144,7 @@ msgstr "" "from .. import formats\n" "from ..filters import equalizer" -#: ../../tutorial/modules.rst:580 +#: ../../tutorial/modules.rst:582 msgid "" "Note that relative imports are based on the name of the current module. " "Since the name of the main module is always ``\"__main__\"``, modules " @@ -1153,11 +1155,11 @@ msgstr "" "``\"__main__\"``,所以如果一個模組預期被用作 Python 應用程式的主模組,那它必" "須永遠使用絕對 import。" -#: ../../tutorial/modules.rst:586 +#: ../../tutorial/modules.rst:588 msgid "Packages in Multiple Directories" msgstr "多目錄中的套件" -#: ../../tutorial/modules.rst:588 +#: ../../tutorial/modules.rst:590 msgid "" "Packages support one more special attribute, :attr:`~module.__path__`. This " "is initialized to be a :term:`sequence` of strings containing the name of " @@ -1165,22 +1167,22 @@ msgid "" "that file is executed. This variable can be modified; doing so affects " "future searches for modules and subpackages contained in the package." msgstr "" -"套件也支援一個特殊屬性 :attr:`~module.__path__`。它在初始化時是一個字串的" -"\\ :term:`序列 `\\ 的 :file:`__init__.py` 檔案所在的目錄名稱,初始" -"化時機是在這個檔案的程式碼被執行之前。這個變數可以被修改,但這樣做會影響將來" -"對套件內的模組和子套件的搜尋。" +"套件也支援一個特殊屬性 :attr:`~module.__path__`。它在初始化時是一個字串的\\ :" +"term:`序列 `\\ 的 :file:`__init__.py` 檔案所在的目錄名稱,初始化時" +"機是在這個檔案的程式碼被執行之前。這個變數可以被修改,但這樣做會影響將來對套" +"件內的模組和子套件的搜尋。" -#: ../../tutorial/modules.rst:595 +#: ../../tutorial/modules.rst:597 msgid "" "While this feature is not often needed, it can be used to extend the set of " "modules found in a package." msgstr "雖然這個特色不太常被需要,但它可用於擴充套件中的模組集合。" -#: ../../tutorial/modules.rst:600 +#: ../../tutorial/modules.rst:602 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/modules.rst:601 +#: ../../tutorial/modules.rst:603 msgid "" "In fact function definitions are also 'statements' that are 'executed'; the " "execution of a module-level function definition adds the function name to " @@ -1189,27 +1191,27 @@ msgstr "" "實際上,函式定義也是「被執行」的「陳述式」;在執行模組階層的函式定義時,會將" "函式名稱加到模組的全域命名空間。" -#: ../../tutorial/modules.rst:184 ../../tutorial/modules.rst:267 -#: ../../tutorial/modules.rst:348 +#: ../../tutorial/modules.rst:186 ../../tutorial/modules.rst:269 +#: ../../tutorial/modules.rst:350 msgid "module" msgstr "module(模組)" -#: ../../tutorial/modules.rst:184 +#: ../../tutorial/modules.rst:186 msgid "search" msgstr "search(搜尋)" -#: ../../tutorial/modules.rst:184 +#: ../../tutorial/modules.rst:186 msgid "path" msgstr "path(路徑)" -#: ../../tutorial/modules.rst:267 +#: ../../tutorial/modules.rst:269 msgid "sys" msgstr "sys" -#: ../../tutorial/modules.rst:348 +#: ../../tutorial/modules.rst:350 msgid "builtins" msgstr "builtins(內建)" -#: ../../tutorial/modules.rst:493 +#: ../../tutorial/modules.rst:495 msgid "__all__" msgstr "__all__" diff --git a/using/android.po b/using/android.po index 868d2e3659..fca1fb0dfc 100644 --- a/using/android.po +++ b/using/android.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-02 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -143,3 +143,16 @@ msgid "" "testbed/app/src/main/c/main_activity.c>`. This will need to be C code called " "via JNI." msgstr "" + +#: ../../using/android.rst:68 +msgid "Building a Python package for Android" +msgstr "建置用於 Android 的 Python 套件" + +#: ../../using/android.rst:70 +msgid "" +"Python packages can be built for Android as wheels and released on PyPI. The " +"recommended tool for doing this is `cibuildwheel `__, which automates all the details of " +"setting up a cross-compilation environment, building the wheel, and testing " +"it on an emulator." +msgstr "" diff --git a/using/ios.po b/using/ios.po index 504db08ea5..cd97f600af 100644 --- a/using/ios.po +++ b/using/ios.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-14 00:14+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -491,12 +491,12 @@ msgstr "" #: ../../using/ios.rst:299 msgid "" -"``PYTHONHOME`` for the interpreter is configured to point at the ``python`` " -"subfolder of your app's bundle; and" +":envvar:`PYTHONHOME` for the interpreter is configured to point at the " +"``python`` subfolder of your app's bundle; and" msgstr "" #: ../../using/ios.rst:301 -msgid "The ``PYTHONPATH`` for the interpreter includes:" +msgid "The :envvar:`PYTHONPATH` for the interpreter includes:" msgstr "" #: ../../using/ios.rst:303 @@ -544,14 +544,23 @@ msgstr "" #: ../../using/ios.rst:324 msgid "" "If you're using a separate folder for third-party packages, ensure that " -"folder is included as part of the ``PYTHONPATH`` configuration in step 10." +"folder is included as part of the :envvar:`PYTHONPATH` configuration in step " +"10." msgstr "" -#: ../../using/ios.rst:328 +#: ../../using/ios.rst:327 +msgid "" +"If any of the folders that contain third-party packages will contain ``." +"pth`` files, you should add that folder as a *site directory* (using :meth:" +"`site.addsitedir`), rather than adding to :envvar:`PYTHONPATH` or :attr:`sys." +"path` directly." +msgstr "" + +#: ../../using/ios.rst:333 msgid "Testing a Python package" msgstr "" -#: ../../using/ios.rst:330 +#: ../../using/ios.rst:335 msgid "" "The CPython source tree contains :source:`a testbed project ` " "that is used to run the CPython test suite on the iOS simulator. This " @@ -559,19 +568,19 @@ msgid "" "library's test suite on iOS." msgstr "" -#: ../../using/ios.rst:334 +#: ../../using/ios.rst:339 msgid "" "After building or obtaining an iOS XCFramework (See :source:`iOS/README.rst` " "for details), create a clone of the Python iOS testbed project by running:" msgstr "" -#: ../../using/ios.rst:337 +#: ../../using/ios.rst:342 msgid "" "$ python iOS/testbed clone --framework --app " " --app app-testbed" msgstr "" -#: ../../using/ios.rst:341 +#: ../../using/ios.rst:346 msgid "" "You will need to modify the ``iOS/testbed`` reference to point to that " "directory in the CPython source tree; any folders specified with the ``--" @@ -583,41 +592,41 @@ msgid "" "testbed/iOSTestbed/app_packages`` or similar)." msgstr "" -#: ../../using/ios.rst:350 +#: ../../using/ios.rst:355 msgid "" "You can then use the ``app-testbed`` folder to run the test suite for your " "app, For example, if ``module1.tests`` was the entry point to your test " "suite, you could run:" msgstr "" -#: ../../using/ios.rst:354 +#: ../../using/ios.rst:359 msgid "$ python app-testbed run -- module1.tests" msgstr "" -#: ../../using/ios.rst:358 +#: ../../using/ios.rst:363 msgid "" "This is the equivalent of running ``python -m module1.tests`` on a desktop " "Python build. Any arguments after the ``--`` will be passed to the testbed " "as if they were arguments to ``python -m`` on a desktop machine." msgstr "" -#: ../../using/ios.rst:362 +#: ../../using/ios.rst:367 msgid "You can also open the testbed project in Xcode by running:" msgstr "" -#: ../../using/ios.rst:364 +#: ../../using/ios.rst:369 msgid "$ open app-testbed/iOSTestbed.xcodeproj" msgstr "" -#: ../../using/ios.rst:368 +#: ../../using/ios.rst:373 msgid "This will allow you to use the full Xcode suite of tools for debugging." msgstr "" -#: ../../using/ios.rst:371 +#: ../../using/ios.rst:376 msgid "App Store Compliance" msgstr "" -#: ../../using/ios.rst:373 +#: ../../using/ios.rst:378 msgid "" "The only mechanism for distributing apps to third-party iOS devices is to " "submit the app to the iOS App Store; apps submitted for distribution must " @@ -626,7 +635,7 @@ msgid "" "problematic code." msgstr "" -#: ../../using/ios.rst:378 +#: ../../using/ios.rst:383 msgid "" "The Python standard library contains some code that is known to violate " "these automated rules. While these violations appear to be false positives, " @@ -634,7 +643,7 @@ msgid "" "Python standard library for an app to pass App Store review." msgstr "" -#: ../../using/ios.rst:383 +#: ../../using/ios.rst:388 msgid "" "The Python source tree contains :source:`a patch file ` that will remove all code that is known to cause " diff --git a/using/mac.po b/using/mac.po index 8d8653a3f1..27d11c78e6 100644 --- a/using/mac.po +++ b/using/mac.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-30 09:19+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-08-31 22:26+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -44,15 +44,15 @@ msgid "" "some other options." msgstr "" -#: ../../using/mac.rst:34 +#: ../../using/mac.rst:27 msgid "Using Python for macOS from ``python.org``" msgstr "" -#: ../../using/mac.rst:37 +#: ../../using/mac.rst:30 msgid "Installation steps" msgstr "安裝步驟" -#: ../../using/mac.rst:39 +#: ../../using/mac.rst:32 msgid "" "For `current Python versions `_ (other " "than those in ``security`` status), the release team produces a **Python for " @@ -65,7 +65,7 @@ msgid "" "versions, currently typically from at least **macOS 10.13 High Sierra** on." msgstr "" -#: ../../using/mac.rst:51 +#: ../../using/mac.rst:44 msgid "" "The downloaded file is a standard macOS installer package file (``.pkg``). " "File integrity information (checksum, size, sigstore signature, etc) for " @@ -75,24 +75,24 @@ msgid "" "`_." msgstr "" -#: ../../using/mac.rst:57 +#: ../../using/mac.rst:50 msgid "" "For a default installation, double-click on the downloaded installer package " "file. This should launch the standard macOS Installer app and display the " "first of several installer windows steps." msgstr "" -#: ../../using/mac.rst:63 +#: ../../using/mac.rst:56 msgid "" "Clicking on the **Continue** button brings up the **Read Me** for this " "installer. Besides other important information, the **Read Me** documents " "which Python version is going to be installed and on what versions of macOS " "it is supported. You may need to scroll through to read the whole file. By " "default, this **Read Me** will also be installed in |" -"usemac_applications_folder_version| and available to read anytime." +"applications_python_version_literal| and available to read anytime." msgstr "" -#: ../../using/mac.rst:71 +#: ../../using/mac.rst:64 msgid "" "Clicking on **Continue** proceeds to display the license for Python and for " "other included software. You will then need to **Agree** to the license " @@ -100,14 +100,14 @@ msgid "" "installed and available to be read later." msgstr "" -#: ../../using/mac.rst:78 +#: ../../using/mac.rst:71 msgid "" "After the license terms are accepted, the next step is the **Installation " "Type** display. For most uses, the standard set of installation operations " "is appropriate." msgstr "" -#: ../../using/mac.rst:83 +#: ../../using/mac.rst:76 msgid "" "By pressing the **Customize** button, you can choose to omit or select " "certain package components of the installer. Click on each package name to " @@ -116,7 +116,7 @@ msgid "" "macos`." msgstr "" -#: ../../using/mac.rst:91 +#: ../../using/mac.rst:84 msgid "" "In either case, clicking **Install** will begin the install process by " "asking permission to install new software. A macOS user name with " @@ -124,47 +124,48 @@ msgid "" "available to all users of the Mac." msgstr "" -#: ../../using/mac.rst:95 +#: ../../using/mac.rst:88 msgid "When the installation is complete, the **Summary** window will appear." msgstr "" -#: ../../using/mac.rst:99 +#: ../../using/mac.rst:92 msgid "" "Double-click on the :command:`Install Certificates.command` icon or file in " -"the |usemac_applications_folder_version| window to complete the installation." +"the |applications_python_version_literal| window to complete the " +"installation." msgstr "" -#: ../../using/mac.rst:105 +#: ../../using/mac.rst:98 msgid "" "This will open a temporary :program:`Terminal` shell window that will use " "the new Python to download and install SSL root certificates for its use." msgstr "" -#: ../../using/mac.rst:111 +#: ../../using/mac.rst:104 msgid "" "If ``Successfully installed certifi`` and ``update complete`` appears in the " "terminal window, the installation is complete. Close this terminal window " "and the installer window." msgstr "" -#: ../../using/mac.rst:115 +#: ../../using/mac.rst:108 msgid "A default install will include:" msgstr "預設安裝會包含:" -#: ../../using/mac.rst:117 +#: ../../using/mac.rst:110 msgid "" -"A |usemac_applications_folder_name| folder in your :file:`Applications` " -"folder. In here you find :program:`IDLE`, the development environment that " -"is a standard part of official Python distributions; and :program:`Python " +"A |python_version_literal| folder in your :file:`Applications` folder. In " +"here you find :program:`IDLE`, the development environment that is a " +"standard part of official Python distributions; and :program:`Python " "Launcher`, which handles double-clicking Python scripts from the macOS " "`Finder `_." msgstr "" -"會有一個 |usemac_applications_folder_name| 資料夾在你的 :file:`Applications` " +"會有一個 |python_version_literal| 資料夾在你的 :file:`Applications` " "資料夾中。在這裡你可以找到 :program:`IDLE`,它是作為官方 Python 發行版標準組" "成的開發環境;以及 :program:`Python Launcher`,它負責處理在 `Finder `_ 中雙擊 Python 腳本的操作。" -#: ../../using/mac.rst:122 +#: ../../using/mac.rst:115 msgid "" "A framework :file:`/Library/Frameworks/Python.framework`, which includes the " "Python executable and libraries. The installer adds this location to your " @@ -176,7 +177,7 @@ msgstr "" "裝 Python ,你可以移除這三個東西。Python 可執行檔案的符號連結 (symlink) 則放" "在 :file:`/usr/local/bin/` 中。" -#: ../../using/mac.rst:129 +#: ../../using/mac.rst:122 msgid "" "Recent versions of macOS include a :command:`python3` command in :file:`/usr/" "bin/python3` that links to a usually older and incomplete version of Python " @@ -190,21 +191,21 @@ msgid "" "used instead of the system :command:`python3`." msgstr "" -#: ../../using/mac.rst:140 +#: ../../using/mac.rst:133 msgid "How to run a Python script" msgstr "如何執行 Python 腳本" -#: ../../using/mac.rst:142 +#: ../../using/mac.rst:135 msgid "" "There are two ways to invoke the Python interpreter. If you are familiar " "with using a Unix shell in a terminal window, you can invoke |" -"usemac_python_x_dot_y_literal| or ``python3`` optionally followed by one or " -"more command line options (described in :ref:`using-on-general`). The Python " +"python_x_dot_y_literal| or ``python3`` optionally followed by one or more " +"command line options (described in :ref:`using-on-general`). The Python " "tutorial also has a useful section on :ref:`using Python interactively from " "a shell `." msgstr "" -#: ../../using/mac.rst:149 +#: ../../using/mac.rst:142 msgid "" "You can also invoke the interpreter through an integrated development " "environment. :ref:`idle` is a basic editor and interpreter environment which " @@ -214,31 +215,31 @@ msgid "" "document." msgstr "" -#: ../../using/mac.rst:157 +#: ../../using/mac.rst:150 msgid "" "There are many other editors and IDEs available, see :ref:`editors` for more " "information." msgstr "" -#: ../../using/mac.rst:160 +#: ../../using/mac.rst:153 msgid "" "To run a Python script file from the terminal window, you can invoke the " "interpreter with the name of the script file:" msgstr "" -#: ../../using/mac.rst:163 -msgid "|usemac_python_x_dot_y_literal| ``myscript.py``" -msgstr "" +#: ../../using/mac.rst:156 +msgid "|python_x_dot_y_literal| ``myscript.py``" +msgstr "|python_x_dot_y_literal| ``myscript.py``" -#: ../../using/mac.rst:165 +#: ../../using/mac.rst:158 msgid "To run your script from the Finder, you can either:" msgstr "從 Finder 執行你的腳本時,你可以:" -#: ../../using/mac.rst:167 +#: ../../using/mac.rst:160 msgid "Drag it to :program:`Python Launcher`." msgstr "把它拖曳到 :program:`Python Launcher`" -#: ../../using/mac.rst:169 +#: ../../using/mac.rst:162 msgid "" "Select :program:`Python Launcher` as the default application to open your " "script (or any ``.py`` script) through the Finder Info window and double-" @@ -251,7 +252,7 @@ msgstr "" "來控制腳本啟動方式的選項。拖曳選項可以讓你一次更改多個選項,或使用其 " "``Preferences`` 選單以全域性地更改內容。" -#: ../../using/mac.rst:175 +#: ../../using/mac.rst:168 msgid "" "Be aware that running the script directly from the macOS Finder might " "produce different results than when running from a terminal window as the " @@ -260,81 +261,81 @@ msgid "" "program, be certain of what you are about to run." msgstr "" -#: ../../using/mac.rst:185 +#: ../../using/mac.rst:178 msgid "Alternative Distributions" msgstr "" -#: ../../using/mac.rst:187 +#: ../../using/mac.rst:180 msgid "" "Besides the standard ``python.org`` for macOS installer, there are third-" "party distributions for macOS that may include additional functionality. " "Some popular distributions and their key features:" msgstr "" -#: ../../using/mac.rst:191 +#: ../../using/mac.rst:184 msgid "`ActivePython `_" msgstr "`ActivePython `_" -#: ../../using/mac.rst:192 +#: ../../using/mac.rst:185 msgid "Installer with multi-platform compatibility, documentation" msgstr "" -#: ../../using/mac.rst:194 +#: ../../using/mac.rst:187 msgid "`Anaconda `_" msgstr "`Anaconda `_" -#: ../../using/mac.rst:195 +#: ../../using/mac.rst:188 msgid "" "Popular scientific modules (such as numpy, scipy, and pandas) and the " "``conda`` package manager." msgstr "" -#: ../../using/mac.rst:198 +#: ../../using/mac.rst:191 msgid "`Homebrew `_" msgstr "`Homebrew `_" -#: ../../using/mac.rst:199 +#: ../../using/mac.rst:192 msgid "" "Package manager for macOS including multiple versions of Python and many " "third-party Python-based packages (including numpy, scipy, and pandas)." msgstr "" -#: ../../using/mac.rst:202 +#: ../../using/mac.rst:195 msgid "`MacPorts `_" msgstr "`MacPorts `_" -#: ../../using/mac.rst:203 +#: ../../using/mac.rst:196 msgid "" "Another package manager for macOS including multiple versions of Python and " "many third-party Python-based packages. May include pre-built versions of " "Python and many packages for older versions of macOS." msgstr "" -#: ../../using/mac.rst:207 +#: ../../using/mac.rst:200 msgid "" "Note that distributions might not include the latest versions of Python or " "other libraries, and are not maintained or supported by the core Python team." msgstr "" -#: ../../using/mac.rst:213 +#: ../../using/mac.rst:206 msgid "Installing Additional Python Packages" msgstr "安裝額外的 Python 套件" -#: ../../using/mac.rst:215 +#: ../../using/mac.rst:208 msgid "Refer to the `Python Packaging User Guide`_ for more information." msgstr "更多資訊請見 `Python Packaging User Guide`_。" -#: ../../using/mac.rst:225 +#: ../../using/mac.rst:218 msgid "GUI Programming" msgstr "開發 GUI 程式" -#: ../../using/mac.rst:227 +#: ../../using/mac.rst:220 msgid "" "There are several options for building GUI applications on the Mac with " "Python." msgstr "於 Mac 上使用 Python 來建立 GUI 應用程式有許多選項。" -#: ../../using/mac.rst:229 +#: ../../using/mac.rst:222 msgid "" "The standard Python GUI toolkit is :mod:`tkinter`, based on the cross-" "platform Tk toolkit (https://www.tcl.tk). A macOS-native version of Tk is " @@ -343,7 +344,7 @@ msgstr "" "標準的 Python GUI 工具套件是基於跨平臺 Tk 工具套件 (https://www.tcl.tk) 的 :" "mod:`tkinter`。macOS 原生版本的 Tk 有包含於安裝程式中。" -#: ../../using/mac.rst:233 +#: ../../using/mac.rst:226 msgid "" "*PyObjC* is a Python binding to Apple's Objective-C/Cocoa framework. " "Information on PyObjC is available from :pypi:`pyobjc`." @@ -351,11 +352,11 @@ msgstr "" "*PyObjC* 是一個 Apple Objective-C/Cocoa 框架的 Python 繫結 (binding)。有關 " "PyObjC 的資訊請見 :pypi:`pyobjc`。" -#: ../../using/mac.rst:236 +#: ../../using/mac.rst:229 msgid "A number of alternative macOS GUI toolkits are available including:" msgstr "有許多替代 macOS GUI 工具套件可用,包含:" -#: ../../using/mac.rst:238 +#: ../../using/mac.rst:231 msgid "" "`PySide `_: Official Python bindings to the " "`Qt GUI toolkit `_." @@ -363,7 +364,7 @@ msgstr "" "`PySide `_:`Qt GUI 工具包 `_\\ 的官方 Python 繫結。" -#: ../../using/mac.rst:241 +#: ../../using/mac.rst:234 msgid "" "`PyQt `_: Alternative Python " "bindings to Qt." @@ -371,14 +372,14 @@ msgstr "" "`PyQt `_:Qt 的替代 Python 繫" "結。" -#: ../../using/mac.rst:244 +#: ../../using/mac.rst:237 msgid "" "`Kivy `_: A cross-platform GUI toolkit that supports " "desktop and mobile platforms." msgstr "" "`Kivy `_:一個支援桌面和行動平臺的跨平臺 GUI 工具包。" -#: ../../using/mac.rst:247 +#: ../../using/mac.rst:240 msgid "" "`Toga `_: Part of the `BeeWare Project `_; supports desktop, mobile, web and console apps." @@ -386,42 +387,41 @@ msgstr "" "`Toga `_:`BeeWare 專案 `_\\ 的一部分;支援桌面、行動、網頁和控制台應用程式。" -#: ../../using/mac.rst:250 +#: ../../using/mac.rst:243 msgid "" "`wxPython `_: A cross-platform toolkit that supports " "desktop operating systems." msgstr "" "`wxPython `_:一個支援桌面作業系統的跨平臺工具包。" -#: ../../using/mac.rst:255 +#: ../../using/mac.rst:248 msgid "Advanced Topics" msgstr "進階主題" -#: ../../using/mac.rst:260 +#: ../../using/mac.rst:253 msgid "Installing Free-threaded Binaries" msgstr "" -#: ../../using/mac.rst:262 +#: ../../using/mac.rst:255 msgid "(Experimental)" msgstr "(實驗性的)" -#: ../../using/mac.rst:266 +#: ../../using/mac.rst:259 msgid "" "Everything described in this section is considered experimental, and should " "be expected to change in future releases." msgstr "" -#: ../../using/mac.rst:269 +#: ../../using/mac.rst:262 msgid "" "The ``python.org`` :ref:`Python for macOS ` installer package can optionally install an additional build of " -"Python |usemac_x_dot_y| that supports :pep:`703`, the experimental free-" -"threading feature (running with the :term:`global interpreter lock` " -"disabled). Check the release page on ``python.org`` for possible updated " -"information." +"Python |version| that supports :pep:`703`, the experimental free-threading " +"feature (running with the :term:`global interpreter lock` disabled). Check " +"the release page on ``python.org`` for possible updated information." msgstr "" -#: ../../using/mac.rst:275 +#: ../../using/mac.rst:268 msgid "" "Because this feature is still considered experimental, the support for it is " "not installed by default. It is packaged as a separate install option, " @@ -429,58 +429,57 @@ msgid "" "step of the installer as described above." msgstr "" -#: ../../using/mac.rst:282 +#: ../../using/mac.rst:275 msgid "" "If the box next to the **Free-threaded Python** package name is checked, a " "separate :file:`PythonT.framework` will also be installed alongside the " "normal :file:`Python.framework` in :file:`/Library/Frameworks`. This " -"configuration allows a free-threaded Python |usemac_x_dot_y| build to co-" -"exist on your system with a traditional (GIL only) Python |usemac_x_dot_y| " -"build with minimal risk while installing or testing. This installation " -"layout is itself experimental and is subject to change in future releases." +"configuration allows a free-threaded Python |version| build to co-exist on " +"your system with a traditional (GIL only) Python |version| build with " +"minimal risk while installing or testing. This installation layout is itself " +"experimental and is subject to change in future releases." msgstr "" -#: ../../using/mac.rst:290 +#: ../../using/mac.rst:283 msgid "Known cautions and limitations:" msgstr "" -#: ../../using/mac.rst:292 +#: ../../using/mac.rst:285 msgid "" "The **UNIX command-line tools** package, which is selected by default, will " -"install links in :file:`/usr/local/bin` for |" -"usemac_python_x_dot_y_t_literal|, the free-threaded interpreter, and |" -"usemac_python_x_dot_y_t_literal_config|, a configuration utility which may " -"be useful for package builders. Since :file:`/usr/local/bin` is typically " -"included in your shell ``PATH``, in most cases no changes to your ``PATH`` " -"environment variables should be needed to use |" -"usemac_python_x_dot_y_t_literal|." +"install links in :file:`/usr/local/bin` for |python_x_dot_y_t_literal|, the " +"free-threaded interpreter, and |python_x_dot_y_t_literal_config|, a " +"configuration utility which may be useful for package builders. Since :file:" +"`/usr/local/bin` is typically included in your shell ``PATH``, in most cases " +"no changes to your ``PATH`` environment variables should be needed to use |" +"python_x_dot_y_t_literal|." msgstr "" -#: ../../using/mac.rst:300 +#: ../../using/mac.rst:293 msgid "" "For this release, the **Shell profile updater** package and the :file:" -"`Update Shell Profile.command` in |usemac_applications_folder_version| do " +"`Update Shell Profile.command` in |applications_python_version_literal| do " "not support the free-threaded package." msgstr "" -#: ../../using/mac.rst:304 +#: ../../using/mac.rst:297 msgid "" "The free-threaded build and the traditional build have separate search paths " "and separate :file:`site-packages` directories so, by default, if you need a " "package available in both builds, it may need to be installed in both. The " "free-threaded package will install a separate instance of :program:`pip` for " -"use with |usemac_python_x_dot_y_t_literal|." +"use with |python_x_dot_y_t_literal|." msgstr "" -#: ../../using/mac.rst:310 +#: ../../using/mac.rst:303 msgid "To install a package using :command:`pip` without a :command:`venv`:" msgstr "" -#: ../../using/mac.rst:312 -msgid "|usemac_python_x_dot_y_t_literal| ``-m pip install ``" -msgstr "|usemac_python_x_dot_y_t_literal| ``-m pip install ``" +#: ../../using/mac.rst:307 +msgid "python\\ |version|\\ t -m pip install " +msgstr "python\\ |version|\\ t -m pip install " -#: ../../using/mac.rst:314 +#: ../../using/mac.rst:309 msgid "" "When working with multiple Python environments, it is usually safest and " "easiest to :ref:`create and use virtual environments `. This can " @@ -488,23 +487,23 @@ msgid "" "use:" msgstr "" -#: ../../using/mac.rst:318 -msgid "|usemac_python_x_dot_y_t_literal| ``-m venv ``" -msgstr "|usemac_python_x_dot_y_t_literal| ``-m venv ``" +#: ../../using/mac.rst:315 +msgid "python\\ |version|\\ t -m venv " +msgstr "python\\ |version|\\ t -m venv " -#: ../../using/mac.rst:320 +#: ../../using/mac.rst:318 msgid "then :command:`activate`." msgstr "然後 :command:`activate`。" -#: ../../using/mac.rst:322 +#: ../../using/mac.rst:320 msgid "To run a free-threaded version of IDLE:" msgstr "執行 free-threaded(自由執行緒)版本的 IDLE:" #: ../../using/mac.rst:324 -msgid "|usemac_python_x_dot_y_t_literal| ``-m idlelib``" -msgstr "|usemac_python_x_dot_y_t_literal| ``-m idlelib``" +msgid "python\\ |version|\\ t -m idlelib" +msgstr "python\\ |version|\\ t -m idlelib" -#: ../../using/mac.rst:326 +#: ../../using/mac.rst:327 msgid "" "The interpreters in both builds respond to the same :ref:`PYTHON environment " "variables ` which may have unexpected results, for " @@ -513,7 +512,7 @@ msgid "" "E`` to ignore these environment variables." msgstr "" -#: ../../using/mac.rst:333 +#: ../../using/mac.rst:334 msgid "" "The free-threaded build links to the third-party shared libraries, such as " "``OpenSSL`` and ``Tk``, installed in the traditional framework. This means " @@ -522,52 +521,52 @@ msgid "" "run once." msgstr "" -#: ../../using/mac.rst:339 +#: ../../using/mac.rst:340 msgid "" "If you cannot depend on the link in ``/usr/local/bin`` pointing to the " -"``python.org`` free-threaded |usemac_python_x_dot_y_t_literal| (for example, " -"if you want to install your own version there or some other distribution " -"does), you can explicitly set your shell ``PATH`` environment variable to " -"include the ``PythonT`` framework ``bin`` directory:" +"``python.org`` free-threaded |python_x_dot_y_t_literal| (for example, if you " +"want to install your own version there or some other distribution does), you " +"can explicitly set your shell ``PATH`` environment variable to include the " +"``PythonT`` framework ``bin`` directory:" msgstr "" -#: ../../using/mac.rst:345 +#: ../../using/mac.rst:348 msgid "" -"export PATH=\"/Library/Frameworks/PythonT.framework/Versions/3.13/bin\":" -"\"$PATH\"" +"export PATH=\"/Library/Frameworks/PythonT.framework/Versions/\\ |version|\\ /" +"bin\":\"$PATH\"" msgstr "" -"export PATH=\"/Library/Frameworks/PythonT.framework/Versions/3.13/bin\":" -"\"$PATH\"" +"export PATH=\"/Library/Frameworks/PythonT.framework/Versions/\\ |version|\\ /" +"bin\":\"$PATH\"" -#: ../../using/mac.rst:349 +#: ../../using/mac.rst:350 msgid "" "The traditional framework installation by default does something similar, " "except for :file:`Python.framework`. Be aware that having both framework " "``bin`` directories in ``PATH`` can lead to confusion if there are duplicate " -"names like ``python3.13`` in both; which one is actually used depends on the " -"order they appear in ``PATH``. The ``which python3.x`` or ``which python3." -"xt`` commands can show which path is being used. Using virtual environments " -"can help avoid such ambiguities. Another option might be to create a shell :" -"command:`alias` to the desired interpreter, like:" +"names like |python_x_dot_y_literal| in both; which one is actually used " +"depends on the order they appear in ``PATH``. The ``which python3.x`` or " +"``which python3.xt`` commands can show which path is being used. Using " +"virtual environments can help avoid such ambiguities. Another option might " +"be to create a shell :command:`alias` to the desired interpreter, like:" msgstr "" -#: ../../using/mac.rst:358 +#: ../../using/mac.rst:361 msgid "" -"alias py3.13=\"/Library/Frameworks/Python.framework/Versions/3.13/bin/" -"python3.13\"\n" -"alias py3.13t=\"/Library/Frameworks/PythonT.framework/Versions/3.13/bin/" -"python3.13t\"" +"alias py\\ |version|\\ =\"/Library/Frameworks/Python.framework/Versions/\\ |" +"version|\\ /bin/python\\ |version|\\ \"\n" +"alias py\\ |version|\\ t=\"/Library/Frameworks/PythonT.framework/Versions/\\ " +"|version|\\ /bin/python\\ |version|\\ t\"" msgstr "" -"alias py3.13=\"/Library/Frameworks/Python.framework/Versions/3.13/bin/" -"python3.13\"\n" -"alias py3.13t=\"/Library/Frameworks/PythonT.framework/Versions/3.13/bin/" -"python3.13t\"" +"alias py\\ |version|\\ =\"/Library/Frameworks/Python.framework/Versions/\\ |" +"version|\\ /bin/python\\ |version|\\ \"\n" +"alias py\\ |version|\\ t=\"/Library/Frameworks/PythonT.framework/Versions/\\ " +"|version|\\ /bin/python\\ |version|\\ t\"" -#: ../../using/mac.rst:364 +#: ../../using/mac.rst:365 msgid "Installing using the command line" msgstr "使用命令列安裝" -#: ../../using/mac.rst:366 +#: ../../using/mac.rst:367 msgid "" "If you want to use automation to install the ``python.org`` installer " "package (rather than by using the familiar macOS :program:`Installer` GUI " @@ -575,23 +574,23 @@ msgid "" "non-default options, too. If you are not familiar with :command:`installer`, " "it can be somewhat cryptic (see :command:`man installer` for more " "information). As an example, the following shell snippet shows one way to do " -"it, using the ``3.13.0b2`` release and selecting the free-threaded " +"it, using the |x_dot_y_b2_literal| release and selecting the free-threaded " "interpreter option:" msgstr "" -#: ../../using/mac.rst:375 +#: ../../using/mac.rst:378 msgid "" -"RELEASE=\"python-3.13.0b2-macos11.pkg\"\n" +"RELEASE=\"python-\\ |version|\\ 0b2-macos11.pkg\"\n" "\n" "# download installer pkg\n" -"curl -O https://www.python.org/ftp/python/3.13.0/${RELEASE}\n" +"curl -O \\https://www.python.org/ftp/python/\\ |version|\\ .0/${RELEASE}\n" "\n" "# create installer choicechanges to customize the install:\n" -"# enable the PythonTFramework-3.13 package\n" +"# enable the PythonTFramework-\\ |version|\\ package\n" "# while accepting the other defaults (install all other packages)\n" "cat > ./choicechanges.plist <\n" -"\n" "\n" "\n" @@ -601,7 +600,8 @@ msgid "" " choiceAttribute\n" " selected\n" " choiceIdentifier\n" -" org.python.Python.PythonTFramework-3.13\n" +" org.python.Python.PythonTFramework-\\ |version|\\ \n" " \n" "\n" "\n" @@ -611,34 +611,36 @@ msgid "" "plist -target /" msgstr "" -#: ../../using/mac.rst:405 +#: ../../using/mac.rst:406 msgid "" "You can then test that both installer builds are now available with " "something like:" msgstr "" -#: ../../using/mac.rst:407 +#: ../../using/mac.rst:410 msgid "" "$ # test that the free-threaded interpreter was installed if the Unix " "Command Tools package was enabled\n" -"$ /usr/local/bin/python3.13t -VV\n" -"Python 3.13.0b2 experimental free-threading build (v3.13.0b2:3a83b172af, " -"Jun 5 2024, 12:57:31) [Clang 15.0.0 (clang-1500.3.9.4)]\n" -"$ # and the traditional interpreter\n" -"$ /usr/local/bin/python3.13 -VV\n" -"Python 3.13.0b2 (v3.13.0b2:3a83b172af, Jun 5 2024, 12:50:24) [Clang 15.0.0 " +"$ /usr/local/bin/python\\ |version|\\ t -VV\n" +"Python \\ |version|\\ .0b2 experimental free-threading build (v\\ |version|" +"\\ .0b2:3a83b172af, Jun 5 2024, 12:57:31) [Clang 15.0.0 " "(clang-1500.3.9.4)]\n" +"$ # and the traditional interpreter\n" +"$ /usr/local/bin/python\\ |version|\\ -VV\n" +"Python \\ |version|\\ .0b2 (v\\ |version|\\ .0b2:3a83b172af, Jun 5 2024, " +"12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]\n" "$ # test that they are also available without the prefix if /usr/local/bin " "is on $PATH\n" -"$ python3.13t -VV\n" -"Python 3.13.0b2 experimental free-threading build (v3.13.0b2:3a83b172af, " -"Jun 5 2024, 12:57:31) [Clang 15.0.0 (clang-1500.3.9.4)]\n" -"$ python3.13 -VV\n" -"Python 3.13.0b2 (v3.13.0b2:3a83b172af, Jun 5 2024, 12:50:24) [Clang 15.0.0 " -"(clang-1500.3.9.4)]" +"$ python\\ |version|\\ t -VV\n" +"Python \\ |version|\\ .0b2 experimental free-threading build (v\\ |version|" +"\\ .0b2:3a83b172af, Jun 5 2024, 12:57:31) [Clang 15.0.0 " +"(clang-1500.3.9.4)]\n" +"$ python\\ |version|\\ -VV\n" +"Python \\ |version|\\ .0b2 (v\\ |version|\\ .0b2:3a83b172af, Jun 5 2024, " +"12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]" msgstr "" -#: ../../using/mac.rst:423 +#: ../../using/mac.rst:424 msgid "" "Current ``python.org`` installers only install to fixed locations like :file:" "`/Library/Frameworks/`, :file:`/Applications`, and :file:`/usr/local/bin`. " @@ -646,23 +648,23 @@ msgid "" "other locations." msgstr "" -#: ../../using/mac.rst:431 +#: ../../using/mac.rst:432 msgid "Distributing Python Applications" msgstr "發行 Python 應用程式" -#: ../../using/mac.rst:433 +#: ../../using/mac.rst:434 msgid "" "A range of tools exist for converting your Python code into a standalone " "distributable application:" msgstr "" -#: ../../using/mac.rst:436 +#: ../../using/mac.rst:437 msgid "" ":pypi:`py2app`: Supports creating macOS ``.app`` bundles from a Python " "project." msgstr ":pypi:`py2app`:支援從 Python 專案打包成 macOS ``.app``。" -#: ../../using/mac.rst:439 +#: ../../using/mac.rst:440 msgid "" "`Briefcase `_: Part of the `BeeWare " "Project `_; a cross-platform packaging tool that " @@ -673,7 +675,7 @@ msgstr "" "beeware.org>`__\\ 的一部分;支援建立 macOS ``.app`` 的跨平台打包工具,亦為管" "理簽署和驗證 (notarization) 的工具。" -#: ../../using/mac.rst:444 +#: ../../using/mac.rst:445 msgid "" "`PyInstaller `_: A cross-platform packaging tool " "that creates a single file or folder as a distributable artifact." @@ -681,11 +683,11 @@ msgstr "" "`PyInstaller `_:一個跨平臺打包工具,可以將單一檔案" "或資料夾打包成可分發的檔案。" -#: ../../using/mac.rst:448 +#: ../../using/mac.rst:449 msgid "App Store Compliance" msgstr "" -#: ../../using/mac.rst:450 +#: ../../using/mac.rst:451 msgid "" "Apps submitted for distribution through the macOS App Store must pass " "Apple's app review process. This process includes a set of automated " @@ -693,7 +695,7 @@ msgid "" "problematic code." msgstr "" -#: ../../using/mac.rst:454 +#: ../../using/mac.rst:455 msgid "" "The Python standard library contains some code that is known to violate " "these automated rules. While these violations appear to be false positives, " @@ -701,7 +703,7 @@ msgid "" "modify the Python standard library for an app to pass App Store review." msgstr "" -#: ../../using/mac.rst:459 +#: ../../using/mac.rst:460 msgid "" "The Python source tree contains :source:`a patch file ` that will remove all code that is known to cause " @@ -710,7 +712,7 @@ msgid "" "compliance` option." msgstr "" -#: ../../using/mac.rst:465 +#: ../../using/mac.rst:466 msgid "" "This patch is not normally required to use CPython on a Mac; nor is it " "required if you are distributing an app *outside* the macOS App Store. It is " @@ -718,11 +720,11 @@ msgid "" "channel." msgstr "" -#: ../../using/mac.rst:470 +#: ../../using/mac.rst:471 msgid "Other Resources" msgstr "其他資源" -#: ../../using/mac.rst:472 +#: ../../using/mac.rst:473 msgid "" "The `python.org Help page `_ has links " "to many useful resources. The `Pythonmac-SIG mailing list \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -32,8 +32,8 @@ msgstr "Pablo Galindo Salgado" #: ../../whatsnew/3.10.rst:47 msgid "" "This article explains the new features in Python 3.10, compared to 3.9. " -"Python 3.10 was released on October 4, 2021. For full details, see " -"the :ref:`changelog `." +"Python 3.10 was released on October 4, 2021. For full details, see the :ref:" +"`changelog `." msgstr "" "本文介紹了 Python 3.10 與 3.9 相比多了哪些新功能。Python 3.10 已於 2021 年 " "10 月 4 日發布。有關完整詳細資訊,請參閱 :ref:`changelog `。" @@ -125,7 +125,7 @@ msgstr ":pep:`624`,刪除 Py_UNICODE 編碼器 API" msgid ":pep:`597`, Add optional EncodingWarning" msgstr ":pep:`597`,新增可選的 EncodingWarning" -#: ../../whatsnew/3.10.rst:92 ../../whatsnew/3.10.rst:2053 +#: ../../whatsnew/3.10.rst:92 ../../whatsnew/3.10.rst:2054 msgid "New Features" msgstr "新增功能" @@ -216,15 +216,15 @@ msgstr "" #: ../../whatsnew/3.10.rst:142 msgid "" -"This new syntax uses the non LL(1) capacities of the new parser. " -"Check :pep:`617` for more details." +"This new syntax uses the non LL(1) capacities of the new parser. Check :pep:" +"`617` for more details." msgstr "" "此新語法使用新剖析器的非 LL(1) 功能。檢查 :pep:`617` 了解更多詳細資訊。" #: ../../whatsnew/3.10.rst:145 msgid "" -"(Contributed by Guido van Rossum, Pablo Galindo and Lysandros Nikolaou " -"in :issue:`12782` and :issue:`40334`.)" +"(Contributed by Guido van Rossum, Pablo Galindo and Lysandros Nikolaou in :" +"issue:`12782` and :issue:`40334`.)" msgstr "" "(由 Guido van Rossum、Pablo Galindo 和 Lysandros Nikolaou 在 :issue:`12782` " "和 :issue:`40334` 中貢獻。)" @@ -309,8 +309,8 @@ msgstr "這些改進是受到 PyPy 直譯器的啟發。" #: ../../whatsnew/3.10.rst:191 msgid "" -"(Contributed by Pablo Galindo in :issue:`42864` and Batuhan Taskaya " -"in :issue:`40176`.)" +"(Contributed by Pablo Galindo in :issue:`42864` and Batuhan Taskaya in :" +"issue:`40176`.)" msgstr "" "(由 Pablo Galindo 在 :issue:`42864` 和 Batuhan Taskaya 在 :issue:`40176` 中" "貢獻。)" @@ -718,12 +718,12 @@ msgstr "影格 (frame) 物件的 :attr:`~frame.f_lineno` 屬性總會包含預 msgid "" "The :attr:`~codeobject.co_lnotab` attribute of :ref:`code objects ` is deprecated and will be removed in 3.12. Code that needs to " -"convert from offset to line number should use the " -"new :meth:`~codeobject.co_lines` method instead." +"convert from offset to line number should use the new :meth:`~codeobject." +"co_lines` method instead." msgstr "" ":ref:`程式碼物件 `\\ 的 :attr:`~codeobject.co_lnotab` 屬性已棄" -"用,並將在 3.12 中刪除。需要從偏移量轉換為列號的程式碼應使用新" -"的 :meth:`~codeobject.co_lines` 方法。" +"用,並將在 3.12 中刪除。需要從偏移量轉換為列號的程式碼應使用新的 :meth:" +"`~codeobject.co_lines` 方法。" #: ../../whatsnew/3.10.rst:412 msgid "PEP 634: Structural Pattern Matching" @@ -990,16 +990,17 @@ msgstr "模式和類別" msgid "" "If you are using classes to structure your data, you can use as a pattern " "the class name followed by an argument list resembling a constructor. This " -"pattern has the ability to capture class attributes into variables::" +"pattern has the ability to capture instance attributes into variables::" msgstr "" "如果你使用類別來建構資料,則可以用類別名稱與後面的引數列表組合成的建構函式作" -"為模式。該模式能夠將類別屬性捕獲到變數中: ::" +"為模式。該模式能夠將實例屬性捕獲到變數中: ::" #: ../../whatsnew/3.10.rst:556 msgid "" "class Point:\n" -" x: int\n" -" y: int\n" +" def __init__(self, x, y):\n" +" self.x = x\n" +" self.y = y\n" "\n" "def location(point):\n" " match point:\n" @@ -1015,11 +1016,11 @@ msgid "" " print(\"Not a point\")" msgstr "" -#: ../../whatsnew/3.10.rst:574 +#: ../../whatsnew/3.10.rst:575 msgid "Patterns with positional parameters" msgstr "具有位置參數的模式" -#: ../../whatsnew/3.10.rst:576 +#: ../../whatsnew/3.10.rst:577 msgid "" "You can use positional parameters with some builtin classes that provide an " "ordering for their attributes (e.g. dataclasses). You can also define a " @@ -1033,7 +1034,7 @@ msgstr "" "置。如果它被設定為 (\"x\", \"y\"),則以下模式都是等效的(且都將 ``y`` 屬性繫" "結到 ``var`` 變數): ::" -#: ../../whatsnew/3.10.rst:582 +#: ../../whatsnew/3.10.rst:583 msgid "" "Point(1, var)\n" "Point(1, y=var)\n" @@ -1045,11 +1046,11 @@ msgstr "" "Point(x=1, y=var)\n" "Point(y=var, x=1)" -#: ../../whatsnew/3.10.rst:588 +#: ../../whatsnew/3.10.rst:589 msgid "Nested patterns" msgstr "巢狀模式" -#: ../../whatsnew/3.10.rst:590 +#: ../../whatsnew/3.10.rst:591 msgid "" "Patterns can be arbitrarily nested. For example, if our data is a short " "list of points, it could be matched like this::" @@ -1057,7 +1058,7 @@ msgstr "" "模式可以任意巢套。例如,如果我們的資料是一個簡短的座標點列表,則可以這樣匹" "配: ::" -#: ../../whatsnew/3.10.rst:593 +#: ../../whatsnew/3.10.rst:594 msgid "" "match points:\n" " case []:\n" @@ -1072,11 +1073,11 @@ msgid "" " print(\"Something else is found in the list.\")" msgstr "" -#: ../../whatsnew/3.10.rst:606 +#: ../../whatsnew/3.10.rst:607 msgid "Complex patterns and the wildcard" msgstr "複雜模式和萬用字元" -#: ../../whatsnew/3.10.rst:608 +#: ../../whatsnew/3.10.rst:609 msgid "" "To this point, the examples have used ``_`` alone in the last case " "statement. A wildcard can be used in more complex patterns, such as " @@ -1085,7 +1086,7 @@ msgstr "" "到目前為止,範例在最後一個 case 陳述式中單獨使用了 ``_``。萬用字元可以用在更" "複雜的模式中,像是 ``('error', code, _)``。例如: ::" -#: ../../whatsnew/3.10.rst:612 +#: ../../whatsnew/3.10.rst:613 msgid "" "match test_variable:\n" " case ('warning', code, 40):\n" @@ -1094,7 +1095,7 @@ msgid "" " print(f\"An error {code} occurred.\")" msgstr "" -#: ../../whatsnew/3.10.rst:618 +#: ../../whatsnew/3.10.rst:619 msgid "" "In the above case, ``test_variable`` will match for ('error', code, 100) and " "('error', code, 800)." @@ -1102,11 +1103,11 @@ msgstr "" "在上述情況下,值像是 ('error', code, 100) 和 ('error', code, 800) 的 " "``test_variable`` 將會成功匹配。" -#: ../../whatsnew/3.10.rst:622 +#: ../../whatsnew/3.10.rst:623 msgid "Guard" msgstr "Guard" -#: ../../whatsnew/3.10.rst:624 +#: ../../whatsnew/3.10.rst:625 msgid "" "We can add an ``if`` clause to a pattern, known as a \"guard\". If the " "guard is false, ``match`` goes on to try the next case block. Note that " @@ -1116,7 +1117,7 @@ msgstr "" "則 ``match`` 會繼續嘗試下一個 case 區塊。請注意,值的捕獲發生在 guard 的求值 " "(evaluate) 之前: ::" -#: ../../whatsnew/3.10.rst:628 +#: ../../whatsnew/3.10.rst:629 msgid "" "match point:\n" " case Point(x, y) if x == y:\n" @@ -1125,15 +1126,15 @@ msgid "" " print(f\"Point is not on the diagonal.\")" msgstr "" -#: ../../whatsnew/3.10.rst:635 +#: ../../whatsnew/3.10.rst:636 msgid "Other Key Features" msgstr "其他主要功能" -#: ../../whatsnew/3.10.rst:637 +#: ../../whatsnew/3.10.rst:638 msgid "Several other key features:" msgstr "其他幾個主要功能:" -#: ../../whatsnew/3.10.rst:639 +#: ../../whatsnew/3.10.rst:640 msgid "" "Like unpacking assignments, tuple and list patterns have exactly the same " "meaning and actually match arbitrary sequences. Technically, the subject " @@ -1145,7 +1146,7 @@ msgstr "" "列。從技術上來說,主語必須是一個序列。因此,一個重要的例外是模式不會去匹配疊" "代器。另外,為了防止常常出錯,序列模式也不會去匹配字串。" -#: ../../whatsnew/3.10.rst:645 +#: ../../whatsnew/3.10.rst:646 msgid "" "Sequence patterns support wildcards: ``[x, y, *rest]`` and ``(x, y, *rest)`` " "work similar to wildcards in unpacking assignments. The name after ``*`` " @@ -1156,7 +1157,7 @@ msgstr "" "用字元類似。 ``*`` 後面的名稱也可能是 ``_``,因此 ``(x, y, *_)`` 會匹配至少兩" "個項目的序列,且不繫結其餘項目。" -#: ../../whatsnew/3.10.rst:650 +#: ../../whatsnew/3.10.rst:651 msgid "" "Mapping patterns: ``{\"bandwidth\": b, \"latency\": l}`` captures the " "``\"bandwidth\"`` and ``\"latency\"`` values from a dict. Unlike sequence " @@ -1167,15 +1168,15 @@ msgstr "" "``\"bandwidth\"`` 和 ``\"latency\"`` 值。與序列模式不同,額外的鍵將被忽略。也" "支援萬用字元 ``**rest``。(但是 ``**_`` 是多餘的,所以是不允許的。)" -#: ../../whatsnew/3.10.rst:655 +#: ../../whatsnew/3.10.rst:656 msgid "Subpatterns may be captured using the ``as`` keyword::" msgstr "可以使用 ``as`` 關鍵字捕獲子模式: ::" -#: ../../whatsnew/3.10.rst:657 +#: ../../whatsnew/3.10.rst:658 msgid "case (Point(x1, y1), Point(x2, y2) as p2): ..." msgstr "case (Point(x1, y1), Point(x2, y2) as p2): ..." -#: ../../whatsnew/3.10.rst:659 +#: ../../whatsnew/3.10.rst:660 msgid "" "This binds x1, y1, x2, y2 like you would expect without the ``as`` clause, " "and p2 to the entire second item of the subject." @@ -1183,7 +1184,7 @@ msgstr "" "這將繫結 x1、y1、x2、y2,如同沒有 ``as`` 子句的情況下所預期的,並將 p2 繫結到" "主語的整個第二項目。" -#: ../../whatsnew/3.10.rst:662 +#: ../../whatsnew/3.10.rst:663 msgid "" "Most literals are compared by equality. However, the singletons ``True``, " "``False`` and ``None`` are compared by identity." @@ -1191,7 +1192,7 @@ msgstr "" "大多數字面值都是通過相等進行比較的。然而,單例 ``True``、``False`` 和 " "``None`` 是按標識值 (identity) 來進行比較的。" -#: ../../whatsnew/3.10.rst:665 +#: ../../whatsnew/3.10.rst:666 msgid "" "Named constants may be used in patterns. These named constants must be " "dotted names to prevent the constant from being interpreted as a capture " @@ -1200,7 +1201,7 @@ msgstr "" "附名常數 (named constant) 可以在模式中使用。這些附名常數必須有帶有點的名稱 " "(dotted name),以防止常數被直譯為捕獲的變數: ::" -#: ../../whatsnew/3.10.rst:669 +#: ../../whatsnew/3.10.rst:670 msgid "" "from enum import Enum\n" "class Color(Enum):\n" @@ -1218,19 +1219,19 @@ msgid "" " print(\"I'm feeling the blues :(\")" msgstr "" -#: ../../whatsnew/3.10.rst:684 +#: ../../whatsnew/3.10.rst:685 msgid "" -"For the full specification see :pep:`634`. Motivation and rationale are " -"in :pep:`635`, and a longer tutorial is in :pep:`636`." +"For the full specification see :pep:`634`. Motivation and rationale are in :" +"pep:`635`, and a longer tutorial is in :pep:`636`." msgstr "" "有關完整規範,請參閱 :pep:`634`。動機和基本原理位於 :pep:`635` 中,較完整的教" "學位於 :pep:`636` 中。" -#: ../../whatsnew/3.10.rst:691 +#: ../../whatsnew/3.10.rst:692 msgid "Optional ``EncodingWarning`` and ``encoding=\"locale\"`` option" msgstr "可選的 ``EncodingWarning`` 和 ``encoding=\"locale\"`` 選項" -#: ../../whatsnew/3.10.rst:693 +#: ../../whatsnew/3.10.rst:694 msgid "" "The default encoding of :class:`~io.TextIOWrapper` and :func:`open` is " "platform and locale dependent. Since UTF-8 is used on most Unix platforms, " @@ -1241,24 +1242,24 @@ msgstr "" "於大多數 Unix 平台都使用 UTF-8,因此在打開 UTF-8 檔案(例如 JSON、YAML、" "TOML、Markdown)時省略 ``encoding`` 選項是個常見的 bug,例如: ::" -#: ../../whatsnew/3.10.rst:698 +#: ../../whatsnew/3.10.rst:699 msgid "" "# BUG: \"rb\" mode or encoding=\"utf-8\" should be used.\n" "with open(\"data.json\") as f:\n" " data = json.load(f)" msgstr "" -#: ../../whatsnew/3.10.rst:702 +#: ../../whatsnew/3.10.rst:703 msgid "" "To find this type of bug, an optional ``EncodingWarning`` is added. It is " "emitted when :data:`sys.flags.warn_default_encoding ` is true and " "locale-specific default encoding is used." msgstr "" -"為了發現這種錯誤,新增了一個可選的 ``EncodingWarning``。" -"當 :data:`sys.flags.warn_default_encoding ` 為 true 且使用特定於語" -"言環境的預設編碼時,會發出該信號。" +"為了發現這種錯誤,新增了一個可選的 ``EncodingWarning``。當 :data:`sys.flags." +"warn_default_encoding ` 為 true 且使用特定於語言環境的預設編碼時," +"會發出該信號。" -#: ../../whatsnew/3.10.rst:706 +#: ../../whatsnew/3.10.rst:707 msgid "" "``-X warn_default_encoding`` option and :envvar:`PYTHONWARNDEFAULTENCODING` " "are added to enable the warning." @@ -1266,43 +1267,43 @@ msgstr "" "新增 ``-X warn_default_encoding`` 選項和 :envvar:`PYTHONWARNDEFAULTENCODING` " "來啟用警告。" -#: ../../whatsnew/3.10.rst:709 +#: ../../whatsnew/3.10.rst:710 msgid "See :ref:`io-text-encoding` for more information." msgstr "更多資訊請見 :ref:`io-text-encoding`。" -#: ../../whatsnew/3.10.rst:714 +#: ../../whatsnew/3.10.rst:715 msgid "New Features Related to Type Hints" msgstr "與型別提示相關的新功能" -#: ../../whatsnew/3.10.rst:716 +#: ../../whatsnew/3.10.rst:717 msgid "" -"This section covers major changes affecting :pep:`484` type hints and " -"the :mod:`typing` module." +"This section covers major changes affecting :pep:`484` type hints and the :" +"mod:`typing` module." msgstr "本節介紹影響 :pep:`484` 型別提示和 :mod:`typing` 模組的主要更改。" -#: ../../whatsnew/3.10.rst:721 +#: ../../whatsnew/3.10.rst:722 msgid "PEP 604: New Type Union Operator" msgstr "PEP 604:新型聯集運算子" -#: ../../whatsnew/3.10.rst:723 +#: ../../whatsnew/3.10.rst:724 msgid "" "A new type union operator was introduced which enables the syntax ``X | Y``. " "This provides a cleaner way of expressing 'either type X or type Y' instead " "of using :data:`typing.Union`, especially in type hints." msgstr "" "引入了一種新的聯集運算子,該運算子啟用像是 ``X | Y`` 的語法。這提供了一種在型" -"別提示中更清晰的方式來表達「型別 X 或型別 Y」,來取代使" -"用 :data:`typing.Union`。" +"別提示中更清晰的方式來表達「型別 X 或型別 Y」,來取代使用 :data:`typing." +"Union`。" -#: ../../whatsnew/3.10.rst:727 +#: ../../whatsnew/3.10.rst:728 msgid "" "In previous versions of Python, to apply a type hint for functions accepting " "arguments of multiple types, :data:`typing.Union` was used::" msgstr "" -"在以前版本的 Python 中,要使用接受多種型別參數之型別提示的函式,要使" -"用 :data:`typing.Union`: ::" +"在以前版本的 Python 中,要使用接受多種型別參數之型別提示的函式,要使用 :data:" +"`typing.Union`: ::" -#: ../../whatsnew/3.10.rst:730 +#: ../../whatsnew/3.10.rst:731 msgid "" "def square(number: Union[int, float]) -> Union[int, float]:\n" " return number ** 2" @@ -1310,11 +1311,11 @@ msgstr "" "def square(number: Union[int, float]) -> Union[int, float]:\n" " return number ** 2" -#: ../../whatsnew/3.10.rst:734 +#: ../../whatsnew/3.10.rst:735 msgid "Type hints can now be written in a more succinct manner::" msgstr "現在可以用更簡潔的方式編寫型別提示: ::" -#: ../../whatsnew/3.10.rst:736 +#: ../../whatsnew/3.10.rst:737 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" @@ -1322,15 +1323,15 @@ msgstr "" "def square(number: int | float) -> int | float:\n" " return number ** 2" -#: ../../whatsnew/3.10.rst:740 +#: ../../whatsnew/3.10.rst:741 msgid "" -"This new syntax is also accepted as the second argument " -"to :func:`isinstance` and :func:`issubclass`::" +"This new syntax is also accepted as the second argument to :func:" +"`isinstance` and :func:`issubclass`::" msgstr "" "這種新語法也接受作為 :func:`isinstance` 和 :func:`issubclass` 的第二個引" "數: ::" -#: ../../whatsnew/3.10.rst:743 +#: ../../whatsnew/3.10.rst:744 msgid "" ">>> isinstance(1, int | str)\n" "True" @@ -1338,11 +1339,11 @@ msgstr "" ">>> isinstance(1, int | str)\n" "True" -#: ../../whatsnew/3.10.rst:746 +#: ../../whatsnew/3.10.rst:747 msgid "See :ref:`types-union` and :pep:`604` for more details." msgstr "更多資訊請見 :ref:`types-union` 與 :pep:`604`。" -#: ../../whatsnew/3.10.rst:748 +#: ../../whatsnew/3.10.rst:749 msgid "" "(Contributed by Maggie Moss and Philippe Prados in :issue:`41428`, with " "additions by Yurii Karabas and Serhiy Storchaka in :issue:`44490`.)" @@ -1350,11 +1351,11 @@ msgstr "" "(由 Maggie Moss 和 Philippe Prados 在 :issue:`41428` 中貢獻,由 Yurii " "Karabas 和 Serhiy Storchaka 在 :issue:`44490` 中補充。)" -#: ../../whatsnew/3.10.rst:753 +#: ../../whatsnew/3.10.rst:754 msgid "PEP 612: Parameter Specification Variables" msgstr "PEP 612:參數規範變數" -#: ../../whatsnew/3.10.rst:755 +#: ../../whatsnew/3.10.rst:756 msgid "" "Two new options to improve the information provided to static type checkers " "for :pep:`484`\\ 's ``Callable`` have been added to the :mod:`typing` module." @@ -1362,7 +1363,7 @@ msgstr "" ":mod:`typing` 模組中新增了兩個新選項,用於改進為 :pep:`484` ``Callable`` 的靜" "態型別檢查器 (static type checker) 所提供的資訊。" -#: ../../whatsnew/3.10.rst:758 +#: ../../whatsnew/3.10.rst:759 msgid "" "The first is the parameter specification variable. They are used to forward " "the parameter types of one callable to another callable -- a pattern " @@ -1375,7 +1376,7 @@ msgstr "" "用範例可以在 :class:`typing.ParamSpec` 中找到。在過去是沒有簡單的方法可以如此" "精確地來為參數型別的依賴關係做型別註釋。" -#: ../../whatsnew/3.10.rst:764 +#: ../../whatsnew/3.10.rst:765 msgid "" "The second option is the new ``Concatenate`` operator. It's used in " "conjunction with parameter specification variables to type annotate a higher " @@ -1386,16 +1387,17 @@ msgstr "" "階、會新增或刪除另一個可呼叫物件參數的可呼叫物件進行型別註釋。使用範例可以" "在 :class:`typing.Concatenate` 中找到。" -#: ../../whatsnew/3.10.rst:769 +#: ../../whatsnew/3.10.rst:770 msgid "" -"See :class:`typing.Callable`, :class:`typing.ParamSpec`, :class:`typing.Concatenate`, :class:`typing.ParamSpecArgs`, :class:`typing.ParamSpecKwargs`, " -"and :pep:`612` for more details." +"See :class:`typing.Callable`, :class:`typing.ParamSpec`, :class:`typing." +"Concatenate`, :class:`typing.ParamSpecArgs`, :class:`typing." +"ParamSpecKwargs`, and :pep:`612` for more details." msgstr "" -"請參" -"閱 :class:`typing.Callable`、:class:`typing.ParamSpec`、:class:`typing.Concatenate`、:class:`typing.ParamSpecArgs`、:class:`typing.ParamSpecKwargs` " +"請參閱 :class:`typing.Callable`、:class:`typing.ParamSpec`、:class:`typing." +"Concatenate`、:class:`typing.ParamSpecArgs`、:class:`typing.ParamSpecKwargs` " "和 :pep:`612` 以了解更多詳情。" -#: ../../whatsnew/3.10.rst:773 +#: ../../whatsnew/3.10.rst:774 msgid "" "(Contributed by Ken Jin in :issue:`41559`, with minor enhancements by Jelle " "Zijlstra in :issue:`43783`. PEP written by Mark Mendoza.)" @@ -1403,11 +1405,11 @@ msgstr "" "(由 Ken Jin 在 :issue:`41559` 中貢獻、Jelle Zijlstra 在 :issue:`43783` 中進" "行了小幅改進。PEP 由 Mark Mendoza 編寫。)" -#: ../../whatsnew/3.10.rst:778 +#: ../../whatsnew/3.10.rst:779 msgid "PEP 613: TypeAlias" msgstr "PEP 613:型別別名 (TypeAlias)" -#: ../../whatsnew/3.10.rst:780 +#: ../../whatsnew/3.10.rst:781 msgid "" ":pep:`484` introduced the concept of type aliases, only requiring them to be " "top-level unannotated assignments. This simplicity sometimes made it " @@ -1420,13 +1422,13 @@ msgstr "" "型別別名和普通賦值,尤其是在涉及傳遞參照 (reference) 或無效型別時。比較如" "下: ::" -#: ../../whatsnew/3.10.rst:785 +#: ../../whatsnew/3.10.rst:786 msgid "" "StrCache = 'Cache[str]' # a type alias\n" "LOG_PREFIX = 'LOG[DEBUG]' # a module constant" msgstr "" -#: ../../whatsnew/3.10.rst:788 +#: ../../whatsnew/3.10.rst:789 msgid "" "Now the :mod:`typing` module has a special value :data:`~typing.TypeAlias` " "which lets you declare type aliases more explicitly::" @@ -1434,36 +1436,36 @@ msgstr "" "現在 :mod:`typing` 模組有一個特殊值 :data:`~typing.TypeAlias`,它可以讓你更明" "確地宣告型別別名: ::" -#: ../../whatsnew/3.10.rst:791 +#: ../../whatsnew/3.10.rst:792 msgid "" "StrCache: TypeAlias = 'Cache[str]' # a type alias\n" "LOG_PREFIX = 'LOG[DEBUG]' # a module constant" msgstr "" -#: ../../whatsnew/3.10.rst:794 +#: ../../whatsnew/3.10.rst:795 msgid "See :pep:`613` for more details." msgstr "更多資訊請見 :pep:`613`。" -#: ../../whatsnew/3.10.rst:796 +#: ../../whatsnew/3.10.rst:797 msgid "(Contributed by Mikhail Golubev in :issue:`41923`.)" msgstr "(由 Mikhail Golubev 在 :issue:`41923` 中貢獻。)" -#: ../../whatsnew/3.10.rst:799 +#: ../../whatsnew/3.10.rst:800 msgid "PEP 647: User-Defined Type Guards" msgstr "PEP 647:使用者定義的型別防護" -#: ../../whatsnew/3.10.rst:801 +#: ../../whatsnew/3.10.rst:802 msgid "" ":data:`~typing.TypeGuard` has been added to the :mod:`typing` module to " "annotate type guard functions and improve information provided to static " -"type checkers during type narrowing. For more information, please " -"see :data:`~typing.TypeGuard`\\ 's documentation, and :pep:`647`." +"type checkers during type narrowing. For more information, please see :data:" +"`~typing.TypeGuard`\\ 's documentation, and :pep:`647`." msgstr "" ":data:`~typing.TypeGuard`\\ (型別防護)已新增到 :mod:`typing` 模組中,用以註" "釋型別防護函式並改進在型別窄縮 (type narrowing) 期間提供給靜態型別檢查器的資" "訊。有關更多資訊,請參閱 :data:`~typing.TypeGuard` 的文件和 :pep:`647`。" -#: ../../whatsnew/3.10.rst:806 +#: ../../whatsnew/3.10.rst:807 msgid "" "(Contributed by Ken Jin and Guido van Rossum in :issue:`43766`. PEP written " "by Eric Traut.)" @@ -1471,33 +1473,33 @@ msgstr "" "(由 Ken Jin 和 Guido van Rossum 在 :issue:`43766` 中貢獻。PEP 由 Eric Traut " "編寫。)" -#: ../../whatsnew/3.10.rst:810 +#: ../../whatsnew/3.10.rst:811 msgid "Other Language Changes" msgstr "其他語言更動" -#: ../../whatsnew/3.10.rst:812 +#: ../../whatsnew/3.10.rst:813 msgid "" "The :class:`int` type has a new method :meth:`int.bit_count`, returning the " "number of ones in the binary expansion of a given integer, also known as the " "population count. (Contributed by Niklas Fiekas in :issue:`29882`.)" msgstr "" ":class:`int` 型別有一個新方法 :meth:`int.bit_count`,回傳給定整數的二進位展開" -"式中 1 的數量,也稱為總體計數 (population count)。(由 Niklas Fiekas " -"在 :issue:`29882` 中貢獻。)" +"式中 1 的數量,也稱為總體計數 (population count)。(由 Niklas Fiekas 在 :" +"issue:`29882` 中貢獻。)" -#: ../../whatsnew/3.10.rst:816 +#: ../../whatsnew/3.10.rst:817 msgid "" -"The views returned by :meth:`dict.keys`, :meth:`dict.values` " -"and :meth:`dict.items` now all have a ``mapping`` attribute that gives " -"a :class:`types.MappingProxyType` object wrapping the original dictionary. " -"(Contributed by Dennis Sweeney in :issue:`40890`.)" +"The views returned by :meth:`dict.keys`, :meth:`dict.values` and :meth:`dict." +"items` now all have a ``mapping`` attribute that gives a :class:`types." +"MappingProxyType` object wrapping the original dictionary. (Contributed by " +"Dennis Sweeney in :issue:`40890`.)" msgstr "" ":meth:`dict.keys`、:meth:`dict.values` 和 :meth:`dict.items` 回傳的視圖 " -"(view) 現在都有一個 ``mapping`` 屬性,該屬性提" -"供 :class:`types.MappingProxyType` 包裝原始的字典物件。(由 Dennis Sweeney " -"在 :issue:`40890` 中貢獻。)" +"(view) 現在都有一個 ``mapping`` 屬性,該屬性提供 :class:`types." +"MappingProxyType` 包裝原始的字典物件。(由 Dennis Sweeney 在 :issue:`40890` " +"中貢獻。)" -#: ../../whatsnew/3.10.rst:821 +#: ../../whatsnew/3.10.rst:822 msgid "" ":pep:`618`: The :func:`zip` function now has an optional ``strict`` flag, " "used to require that all the iterables have an equal length." @@ -1505,22 +1507,20 @@ msgstr "" ":pep:`618`::func:`zip` 函式現在有一個可選的 ``strict`` 旗標,用於要求所有可" "疊代物件具有相同的長度。" -#: ../../whatsnew/3.10.rst:824 +#: ../../whatsnew/3.10.rst:825 msgid "" "Builtin and extension functions that take integer arguments no longer " "accept :class:`~decimal.Decimal`\\ s, :class:`~fractions.Fraction`\\ s and " "other objects that can be converted to integers only with a loss (e.g. that " -"have the :meth:`~object.__int__` method but do not have " -"the :meth:`~object.__index__` method). (Contributed by Serhiy Storchaka " -"in :issue:`37999`.)" -msgstr "" -"採用整數引數的內建函式和擴充函式不再接" -"受 :class:`~decimal.Decimal`、:class:`~fractions.Fraction` 以及其他只能在有損" -"失的情況下轉換為整數的物件(例如有 :meth:`~object.__int__` 方法,但沒" -"有 :meth:`~object.__index__` 方法)。(由 Serhiy Storchaka 在 :issue:`37999` " -"中貢獻。)" +"have the :meth:`~object.__int__` method but do not have the :meth:`~object." +"__index__` method). (Contributed by Serhiy Storchaka in :issue:`37999`.)" +msgstr "" +"採用整數引數的內建函式和擴充函式不再接受 :class:`~decimal.Decimal`、:class:" +"`~fractions.Fraction` 以及其他只能在有損失的情況下轉換為整數的物件(例如有 :" +"meth:`~object.__int__` 方法,但沒有 :meth:`~object.__index__` 方法)。(由 " +"Serhiy Storchaka 在 :issue:`37999` 中貢獻。)" -#: ../../whatsnew/3.10.rst:831 +#: ../../whatsnew/3.10.rst:832 msgid "" "If :func:`object.__ipow__` returns :data:`NotImplemented`, the operator will " "correctly fall back to :func:`object.__pow__` and :func:`object.__rpow__` as " @@ -1530,7 +1530,7 @@ msgstr "" "正確回退到 :func:`object.__pow__` 和 :func:`object.__rpow__` 。(由 Alex " "Shkop 在 :issue:`38302` 中貢獻。)" -#: ../../whatsnew/3.10.rst:835 +#: ../../whatsnew/3.10.rst:836 msgid "" "Assignment expressions can now be used unparenthesized within set literals " "and set comprehensions, as well as in sequence indexes (but not slices)." @@ -1538,7 +1538,7 @@ msgstr "" "現在可以在集合字面值 (set literals) 和集合綜合運算 (set comprehensions) 以及" "序列索引(但不能是切片)中使用不帶括號的賦值運算式 (assignment expressions)。" -#: ../../whatsnew/3.10.rst:838 +#: ../../whatsnew/3.10.rst:839 msgid "" "Functions have a new ``__builtins__`` attribute which is used to look for " "builtin symbols when a function is executed, instead of looking into " @@ -1551,44 +1551,44 @@ msgstr "" "存在,則屬性會以此做初始化,否則從目前內建物件 (builtins) 初始化。(由 Mark " "Shannon 在 :issue:`42990` 中貢獻。)" -#: ../../whatsnew/3.10.rst:844 +#: ../../whatsnew/3.10.rst:845 msgid "" "Two new builtin functions -- :func:`aiter` and :func:`anext` have been added " "to provide asynchronous counterparts to :func:`iter` and :func:`next`, " "respectively. (Contributed by Joshua Bronson, Daniel Pope, and Justin Wang " "in :issue:`31861`.)" msgstr "" -"新增兩個內建函式 -- :func:`aiter` 和 :func:`anext`,分別為 :func:`iter` " -"和 :func:`next` 提供非同步的對應函式。(由 Joshua Bronson、Daniel Pope 和 " -"Justin Wang 在 :issue:`31861` 中貢獻。)" +"新增兩個內建函式 -- :func:`aiter` 和 :func:`anext`,分別為 :func:`iter` 和 :" +"func:`next` 提供非同步的對應函式。(由 Joshua Bronson、Daniel Pope 和 Justin " +"Wang 在 :issue:`31861` 中貢獻。)" -#: ../../whatsnew/3.10.rst:849 +#: ../../whatsnew/3.10.rst:850 msgid "" -"Static methods (:func:`@staticmethod `) and class methods " -"(:func:`@classmethod `) now inherit the method attributes " +"Static methods (:func:`@staticmethod `) and class methods (:" +"func:`@classmethod `) now inherit the method attributes " "(``__module__``, ``__name__``, ``__qualname__``, ``__doc__``, " "``__annotations__``) and have a new ``__wrapped__`` attribute. Moreover, " "static methods are now callable as regular functions. (Contributed by Victor " "Stinner in :issue:`43682`.)" msgstr "" -"靜態方法 (:func:`@staticmethod `) 和類別方法 " -"(:func:`@classmethod `) 現在繼承方法屬性 (``__module__``, " +"靜態方法 (:func:`@staticmethod `) 和類別方法 (:func:" +"`@classmethod `) 現在繼承方法屬性 (``__module__``, " "``__name__``, ``__qualname__``, ``__doc__``, ``__annotations__``) 並有一個新" "的 ``__wrapped__`` 屬性。此外,靜態方法現在可以像是常規函式般呼叫。(由 " "Victor Stinner 在 :issue:`43682` 中貢獻。)" -#: ../../whatsnew/3.10.rst:856 +#: ../../whatsnew/3.10.rst:857 msgid "" "Annotations for complex targets (everything beside ``simple name`` targets " "defined by :pep:`526`) no longer cause any runtime effects with ``from " -"__future__ import annotations``. (Contributed by Batuhan Taskaya " -"in :issue:`42737`.)" +"__future__ import annotations``. (Contributed by Batuhan Taskaya in :issue:" +"`42737`.)" msgstr "" "複雜目標(除 :pep:`526` 定義的 ``simple name`` 目標之外的所有內容)的註釋不再" "使用 ``from __future__ import comments`` 造成任何執行環境 (runtime) 影響。" "(由 Batuhan Taskaya 在 :issue:`42737` 中貢獻。)" -#: ../../whatsnew/3.10.rst:860 +#: ../../whatsnew/3.10.rst:861 msgid "" "Class and module objects now lazy-create empty annotations dicts on demand. " "The annotations dicts are stored in the object’s ``__dict__`` for backwards " @@ -1598,21 +1598,21 @@ msgid "" msgstr "" "類別和模組物件現在會根據需求來延遲建立 (lazy-create) 空的註釋字典 " "(annotations dicts)。註釋字典存儲在物件的 ``__dict__`` 中以達成向後相容性。這" -"改進了 ``__annotations__`` 使用方式的最佳實踐方法;有關更多資訊,請參" -"閱 :ref:`annotations-howto`。(由 Larry Hastings 在 :issue:`43901` 中貢獻。)" +"改進了 ``__annotations__`` 使用方式的最佳實踐方法;有關更多資訊,請參閱 :ref:" +"`annotations-howto`。(由 Larry Hastings 在 :issue:`43901` 中貢獻。)" -#: ../../whatsnew/3.10.rst:867 +#: ../../whatsnew/3.10.rst:868 msgid "" "Annotations consist of ``yield``, ``yield from``, ``await`` or named " "expressions are now forbidden under ``from __future__ import annotations`` " -"due to their side effects. (Contributed by Batuhan Taskaya " -"in :issue:`42725`.)" +"due to their side effects. (Contributed by Batuhan Taskaya in :issue:" +"`42725`.)" msgstr "" "附名運算式或由 ``yield``、``yield from``、``await`` 組成的註釋現在在 ``from " "__future__ import comments`` 下被禁止,因為它們有些不預期的行為。(由 " "Batuhan Taskaya 在 :issue:`42725` 中貢獻。)" -#: ../../whatsnew/3.10.rst:872 +#: ../../whatsnew/3.10.rst:873 msgid "" "Usage of unbound variables, ``super()`` and other expressions that might " "alter the processing of symbol table as annotations are now rendered " @@ -1623,14 +1623,14 @@ msgstr "" "(symbol table) 的運算式,現在在 ``from __future__ import comments`` 下變得無" "效。(由 Batuhan Taskaya 在 :issue:`42725` 中貢獻。)" -#: ../../whatsnew/3.10.rst:877 +#: ../../whatsnew/3.10.rst:878 msgid "" -"Hashes of NaN values of both :class:`float` type " -"and :class:`decimal.Decimal` type now depend on object identity. Formerly, " -"they always hashed to ``0`` even though NaN values are not equal to one " -"another. This caused potentially quadratic runtime behavior due to excessive " -"hash collisions when creating dictionaries and sets containing multiple " -"NaNs. (Contributed by Raymond Hettinger in :issue:`43475`.)" +"Hashes of NaN values of both :class:`float` type and :class:`decimal." +"Decimal` type now depend on object identity. Formerly, they always hashed to " +"``0`` even though NaN values are not equal to one another. This caused " +"potentially quadratic runtime behavior due to excessive hash collisions when " +"creating dictionaries and sets containing multiple NaNs. (Contributed by " +"Raymond Hettinger in :issue:`43475`.)" msgstr "" ":class:`float` 型別和 :class:`decimal.Decimal` 型別的 NaN 值的雜湊值現在取決" "於物件的標識值 (identity)。以前即使 NaN 值彼此不相等,它們也總是被雜湊為 " @@ -1638,16 +1638,16 @@ msgstr "" "collision),可能導致潛在的二次方執行環境行為 (quadratic runtime behavior)。" "(由 Raymond Hettinger 在 :issue:`43475` 中貢獻。)" -#: ../../whatsnew/3.10.rst:884 +#: ../../whatsnew/3.10.rst:885 msgid "" "A :exc:`SyntaxError` (instead of a :exc:`NameError`) will be raised when " -"deleting the :const:`__debug__` constant. (Contributed by Donghee Na " -"in :issue:`45000`.)" +"deleting the :const:`__debug__` constant. (Contributed by Donghee Na in :" +"issue:`45000`.)" msgstr "" -"刪除 :const:`__debug__` 常數時將引發 :exc:`SyntaxError` (而不" -"是 :exc:`NameError`)。(由 Donghee Na 在 :issue:`45000` 中貢獻。)" +"刪除 :const:`__debug__` 常數時將引發 :exc:`SyntaxError` (而不是 :exc:" +"`NameError`)。(由 Donghee Na 在 :issue:`45000` 中貢獻。)" -#: ../../whatsnew/3.10.rst:887 +#: ../../whatsnew/3.10.rst:888 msgid "" ":exc:`SyntaxError` exceptions now have ``end_lineno`` and ``end_offset`` " "attributes. They will be ``None`` if not determined. (Contributed by Pablo " @@ -1656,36 +1656,36 @@ msgstr "" ":exc:`SyntaxError` 例外現在具有 ``end_lineno`` 和 ``end_offset`` 屬性。如果未" "被決定,它們將會是 ``None``。(由 Pablo Galindo 在 :issue:`43914` 中貢獻。)" -#: ../../whatsnew/3.10.rst:892 +#: ../../whatsnew/3.10.rst:893 msgid "New Modules" msgstr "新模組" -#: ../../whatsnew/3.10.rst:894 +#: ../../whatsnew/3.10.rst:895 msgid "None." msgstr "無。" -#: ../../whatsnew/3.10.rst:898 +#: ../../whatsnew/3.10.rst:899 msgid "Improved Modules" msgstr "改進的模組" -#: ../../whatsnew/3.10.rst:901 +#: ../../whatsnew/3.10.rst:902 msgid "asyncio" msgstr "asyncio" -#: ../../whatsnew/3.10.rst:903 +#: ../../whatsnew/3.10.rst:904 msgid "" -"Add " -"missing :meth:`~asyncio.events.AbstractEventLoop.connect_accepted_socket` " -"method. (Contributed by Alex Grönholm in :issue:`41332`.)" +"Add missing :meth:`~asyncio.events.AbstractEventLoop." +"connect_accepted_socket` method. (Contributed by Alex Grönholm in :issue:" +"`41332`.)" msgstr "" "新增缺少的 :meth:`~asyncio.events.AbstractEventLoop.connect_accepted_socket` " "方法。(由 Alex Grönholm 在 :issue:`41332` 中貢獻。)" -#: ../../whatsnew/3.10.rst:908 +#: ../../whatsnew/3.10.rst:909 msgid "argparse" msgstr "argparse" -#: ../../whatsnew/3.10.rst:910 +#: ../../whatsnew/3.10.rst:911 msgid "" "Misleading phrase \"optional arguments\" was replaced with \"options\" in " "argparse help. Some tests might require adaptation if they rely on exact " @@ -1695,38 +1695,38 @@ msgstr "" "(options)」。某些依賴於精確輸出匹配的測試可能需要進行調整。(由 Raymond " "Hettinger 在 :issue:`9694` 中貢獻。)" -#: ../../whatsnew/3.10.rst:914 +#: ../../whatsnew/3.10.rst:915 msgid "array" msgstr "array" -#: ../../whatsnew/3.10.rst:916 +#: ../../whatsnew/3.10.rst:917 msgid "" "The :meth:`~array.array.index` method of :class:`array.array` now has " "optional *start* and *stop* parameters. (Contributed by Anders Lorentsen and " "Zackery Spytz in :issue:`31956`.)" msgstr "" ":class:`array.array` 的 :meth:`~array.array.index` 方法現在具有可選的 " -"*start* 和 *stop* 參數。(由 Anders Lorentsen 和 Zackery Spytz " -"在 :issue:`31956` 中貢獻。)" +"*start* 和 *stop* 參數。(由 Anders Lorentsen 和 Zackery Spytz 在 :issue:" +"`31956` 中貢獻。)" -#: ../../whatsnew/3.10.rst:921 +#: ../../whatsnew/3.10.rst:922 msgid "asynchat, asyncore, smtpd" msgstr "asynchat, asyncore, smtpd" -#: ../../whatsnew/3.10.rst:922 +#: ../../whatsnew/3.10.rst:923 msgid "" "These modules have been marked as deprecated in their module documentation " "since Python 3.6. An import-time :class:`DeprecationWarning` has now been " "added to all three of these modules." msgstr "" -"自 Python 3.6 起,這些模組在其文件中被標記為已棄用。引入時" -"的 :class:`DeprecationWarning` 現已新增到這三個模組中。" +"自 Python 3.6 起,這些模組在其文件中被標記為已棄用。引入時的 :class:" +"`DeprecationWarning` 現已新增到這三個模組中。" -#: ../../whatsnew/3.10.rst:927 +#: ../../whatsnew/3.10.rst:928 msgid "base64" msgstr "base64" -#: ../../whatsnew/3.10.rst:929 +#: ../../whatsnew/3.10.rst:930 msgid "" "Add :func:`base64.b32hexencode` and :func:`base64.b32hexdecode` to support " "the Base32 Encoding with Extended Hex Alphabet." @@ -1734,11 +1734,11 @@ msgstr "" "新增 :func:`base64.b32hexencode` 和 :func:`base64.b32hexdecode` 以支援擴充十" "六進位字母的 Base32 編碼 (Base32 Encoding with Extended Hex Alphabet)。" -#: ../../whatsnew/3.10.rst:933 +#: ../../whatsnew/3.10.rst:934 msgid "bdb" msgstr "bdb" -#: ../../whatsnew/3.10.rst:935 +#: ../../whatsnew/3.10.rst:936 msgid "" "Add :meth:`~bdb.Breakpoint.clearBreakpoints` to reset all set breakpoints. " "(Contributed by Irit Katriel in :issue:`24160`.)" @@ -1746,24 +1746,23 @@ msgstr "" "新增 :meth:`~bdb.Breakpoint.clearBreakpoints` 來重置所有設定的斷點。(由 " "Irit Katriel 在 :issue:`24160` 中貢獻。)" -#: ../../whatsnew/3.10.rst:939 +#: ../../whatsnew/3.10.rst:940 msgid "bisect" msgstr "bisect" -#: ../../whatsnew/3.10.rst:941 +#: ../../whatsnew/3.10.rst:942 msgid "" -"Added the possibility of providing a *key* function to the APIs in " -"the :mod:`bisect` module. (Contributed by Raymond Hettinger " -"in :issue:`4356`.)" +"Added the possibility of providing a *key* function to the APIs in the :mod:" +"`bisect` module. (Contributed by Raymond Hettinger in :issue:`4356`.)" msgstr "" "新增向 :mod:`bisect` 模組 API 提供 *key* 函式的可能性。(由 Raymond " "Hettinger 在 :issue:`4356` 中貢獻。)" -#: ../../whatsnew/3.10.rst:945 +#: ../../whatsnew/3.10.rst:946 msgid "codecs" msgstr "codecs" -#: ../../whatsnew/3.10.rst:947 +#: ../../whatsnew/3.10.rst:948 msgid "" "Add a :func:`codecs.unregister` function to unregister a codec search " "function. (Contributed by Hai Shi in :issue:`41842`.)" @@ -1771,42 +1770,41 @@ msgstr "" "新增 :func:`codecs.unregister` 函式來取消註冊 (unregister) 一個編解碼器的搜尋" "功能。(Hai Shi 在 :issue:`41842` 中貢獻。)" -#: ../../whatsnew/3.10.rst:951 +#: ../../whatsnew/3.10.rst:952 msgid "collections.abc" msgstr "collections.abc" -#: ../../whatsnew/3.10.rst:953 +#: ../../whatsnew/3.10.rst:954 msgid "" "The ``__args__`` of the :ref:`parameterized generic ` " -"for :class:`collections.abc.Callable` are now consistent " -"with :data:`typing.Callable`. :class:`collections.abc.Callable` generic now " -"flattens type parameters, similar to what :data:`typing.Callable` currently " -"does. This means that ``collections.abc.Callable[[int, str], str]`` will " -"have ``__args__`` of ``(int, str, str)``; previously this was ``([int, str], " +"for :class:`collections.abc.Callable` are now consistent with :data:`typing." +"Callable`. :class:`collections.abc.Callable` generic now flattens type " +"parameters, similar to what :data:`typing.Callable` currently does. This " +"means that ``collections.abc.Callable[[int, str], str]`` will have " +"``__args__`` of ``(int, str, str)``; previously this was ``([int, str], " "str)``. To allow this change, :class:`types.GenericAlias` can now be " -"subclassed, and a subclass will be returned when subscripting " -"the :class:`collections.abc.Callable` type. Note that a :exc:`TypeError` " -"may be raised for invalid forms of " -"parameterizing :class:`collections.abc.Callable` which may have passed " -"silently in Python 3.9. (Contributed by Ken Jin in :issue:`42195`.)" +"subclassed, and a subclass will be returned when subscripting the :class:" +"`collections.abc.Callable` type. Note that a :exc:`TypeError` may be raised " +"for invalid forms of parameterizing :class:`collections.abc.Callable` which " +"may have passed silently in Python 3.9. (Contributed by Ken Jin in :issue:" +"`42195`.)" msgstr "" ":class:`collections.abc.Callable` 的\\ :ref:`參數化泛型 (parameterized " -"generic) ` 的 ``__args__`` 現在" -"與 :data:`typing.Callable` 一致。:class:`collections.abc.Callable` 泛型現在會" -"將型別參數攤平,類似於 :data:`typing.Callable` 目前的做法。這意味著 " -"``collections.abc.Callable[[int, str], str]`` 將具有 ``(int, str, str)`` 的 " -"``__args__``;在以前這是 ``([int, str], str)``。為了允許此更改,現在可以" -"對 :class:`types.GenericAlias` 進行子類別化,並且在下標 " -"(subscript) :class:`collections.abc.Callable` 型別時將回傳子類別。請注意,對" -"於無效形式的 :class:`collections.abc.Callable` 參數化可能會引" -"發 :exc:`TypeError`,而在 Python 3.9 中該參數可能會無引發例外地傳遞。(由 " -"Ken Jin 在 :issue:`42195` 中貢獻。)" - -#: ../../whatsnew/3.10.rst:966 +"generic) ` 的 ``__args__`` 現在與 :data:`typing." +"Callable` 一致。:class:`collections.abc.Callable` 泛型現在會將型別參數攤平," +"類似於 :data:`typing.Callable` 目前的做法。這意味著 ``collections.abc." +"Callable[[int, str], str]`` 將具有 ``(int, str, str)`` 的 ``__args__``;在以" +"前這是 ``([int, str], str)``。為了允許此更改,現在可以對 :class:`types." +"GenericAlias` 進行子類別化,並且在下標 (subscript) :class:`collections.abc." +"Callable` 型別時將回傳子類別。請注意,對於無效形式的 :class:`collections.abc." +"Callable` 參數化可能會引發 :exc:`TypeError`,而在 Python 3.9 中該參數可能會無" +"引發例外地傳遞。(由 Ken Jin 在 :issue:`42195` 中貢獻。)" + +#: ../../whatsnew/3.10.rst:967 msgid "contextlib" msgstr "contextlib" -#: ../../whatsnew/3.10.rst:968 +#: ../../whatsnew/3.10.rst:969 msgid "" "Add a :func:`contextlib.aclosing` context manager to safely close async " "generators and objects representing asynchronously released resources. " @@ -1816,7 +1814,7 @@ msgstr "" "步釋放資源的物件。(由 Joongi Kim 和 John Belmonte 在 :issue:`41229` 中貢" "獻。)" -#: ../../whatsnew/3.10.rst:972 +#: ../../whatsnew/3.10.rst:973 msgid "" "Add asynchronous context manager support to :func:`contextlib.nullcontext`. " "(Contributed by Tom Gringauz in :issue:`41543`.)" @@ -1824,7 +1822,7 @@ msgstr "" "向 :func:`contextlib.nullcontext` 新增非同步情境管理器支援。(由 Tom " "Gringauz 在 :issue:`41543` 中貢獻。)" -#: ../../whatsnew/3.10.rst:975 +#: ../../whatsnew/3.10.rst:976 msgid "" "Add :class:`~contextlib.AsyncContextDecorator`, for supporting usage of " "async context managers as decorators." @@ -1832,27 +1830,26 @@ msgstr "" "新增 :class:`~contextlib.AsyncContextDecorator`,用於支援將非同步情境管理器作" "為裝飾器使用。" -#: ../../whatsnew/3.10.rst:979 +#: ../../whatsnew/3.10.rst:980 msgid "curses" msgstr "curses" -#: ../../whatsnew/3.10.rst:981 +#: ../../whatsnew/3.10.rst:982 msgid "" "The extended color functions added in ncurses 6.1 will be used transparently " -"by :func:`curses.color_content`, :func:`curses.init_color`, :func:`curses.init_pair`, " -"and :func:`curses.pair_content`. A new " -"function, :func:`curses.has_extended_color_support`, indicates whether " -"extended color support is provided by the underlying ncurses library. " -"(Contributed by Jeffrey Kintscher and Hans Petter Jansson in :issue:`36982`.)" +"by :func:`curses.color_content`, :func:`curses.init_color`, :func:`curses." +"init_pair`, and :func:`curses.pair_content`. A new function, :func:`curses." +"has_extended_color_support`, indicates whether extended color support is " +"provided by the underlying ncurses library. (Contributed by Jeffrey " +"Kintscher and Hans Petter Jansson in :issue:`36982`.)" msgstr "" -"ncurses 6.1 中新增的擴充顏色函式將" -"由 :func:`curses.color_content`、:func:`curses.init_color`、:func:`curses.init_pair` " -"和 :func:`curses.pair_content` 透明地使用。新函" -"式 :func:`curses.has_extended_color_support` 表示了底層的 ncurses 函式庫是否" -"支援擴充顏色。(由 Jeffrey Kintscher 和 Hans Petter Jansson " -"在 :issue:`36982` 中貢獻。)" +"ncurses 6.1 中新增的擴充顏色函式將由 :func:`curses.color_content`、:func:" +"`curses.init_color`、:func:`curses.init_pair` 和 :func:`curses.pair_content` " +"透明地使用。新函式 :func:`curses.has_extended_color_support` 表示了底層的 " +"ncurses 函式庫是否支援擴充顏色。(由 Jeffrey Kintscher 和 Hans Petter " +"Jansson 在 :issue:`36982` 中貢獻。)" -#: ../../whatsnew/3.10.rst:988 +#: ../../whatsnew/3.10.rst:989 msgid "" "The ``BUTTON5_*`` constants are now exposed in the :mod:`curses` module if " "they are provided by the underlying curses library. (Contributed by Zackery " @@ -1861,15 +1858,15 @@ msgstr "" "如果 ``BUTTON5_*`` 常數是由底層 :mod:`curses` 函式庫提供的,那麼它們現在會在 " "curses 模組中公開。(由 Zackery Spytz 在 :issue:`39273` 中貢獻。)" -#: ../../whatsnew/3.10.rst:993 +#: ../../whatsnew/3.10.rst:994 msgid "dataclasses" msgstr "dataclasses" -#: ../../whatsnew/3.10.rst:996 +#: ../../whatsnew/3.10.rst:997 msgid "__slots__" msgstr "__slots__" -#: ../../whatsnew/3.10.rst:998 +#: ../../whatsnew/3.10.rst:999 msgid "" "Added ``slots`` parameter in :func:`dataclasses.dataclass` decorator. " "(Contributed by Yurii Karabas in :issue:`42269`)" @@ -1877,11 +1874,11 @@ msgstr "" "在 :func:`dataclasses.dataclass` 裝飾器中新增了 ``slots`` 參數。(由 Yurii " "Karabas 在 :issue:`42269` 中貢獻)" -#: ../../whatsnew/3.10.rst:1002 +#: ../../whatsnew/3.10.rst:1003 msgid "Keyword-only fields" msgstr "僅限關鍵字欄位 (Keyword-only fields)" -#: ../../whatsnew/3.10.rst:1004 +#: ../../whatsnew/3.10.rst:1005 msgid "" "dataclasses now supports fields that are keyword-only in the generated " "__init__ method. There are a number of ways of specifying keyword-only " @@ -1890,11 +1887,11 @@ msgstr "" "dataclasses 現在支援在產生的 __init__ 方法中包含僅限關鍵字的欄位。有多種方法" "可以指定僅限關鍵字欄位。" -#: ../../whatsnew/3.10.rst:1008 +#: ../../whatsnew/3.10.rst:1009 msgid "You can say that every field is keyword-only:" msgstr "你可以說每個欄位都是關鍵字:" -#: ../../whatsnew/3.10.rst:1010 +#: ../../whatsnew/3.10.rst:1011 msgid "" "from dataclasses import dataclass\n" "\n" @@ -1910,17 +1907,17 @@ msgstr "" " name: str\n" " birthday: datetime.date" -#: ../../whatsnew/3.10.rst:1019 +#: ../../whatsnew/3.10.rst:1020 msgid "" "Both ``name`` and ``birthday`` are keyword-only parameters to the generated " "__init__ method." msgstr "``name`` 和 ``birthday`` 都是產生的 __init__ 方法的僅限關鍵字參數。" -#: ../../whatsnew/3.10.rst:1022 +#: ../../whatsnew/3.10.rst:1023 msgid "You can specify keyword-only on a per-field basis:" msgstr "你可以在每個欄位的基礎上指定僅限關鍵字:" -#: ../../whatsnew/3.10.rst:1024 +#: ../../whatsnew/3.10.rst:1025 msgid "" "from dataclasses import dataclass, field\n" "\n" @@ -1936,7 +1933,7 @@ msgstr "" " name: str\n" " birthday: datetime.date = field(kw_only=True)" -#: ../../whatsnew/3.10.rst:1033 +#: ../../whatsnew/3.10.rst:1034 msgid "" "Here only ``birthday`` is keyword-only. If you set ``kw_only`` on " "individual fields, be aware that there are rules about re-ordering fields " @@ -1947,7 +1944,7 @@ msgstr "" "意,由於僅限關鍵字欄位需要遵循非僅限關鍵字欄位,因此會有欄位重新排序的相關規" "則。詳細資訊請參閱完整的 dataclasses 文件。" -#: ../../whatsnew/3.10.rst:1038 +#: ../../whatsnew/3.10.rst:1039 msgid "" "You can also specify that all fields following a KW_ONLY marker are keyword-" "only. This will probably be the most common usage:" @@ -1955,7 +1952,7 @@ msgstr "" "你還可以指定 KW_ONLY 標記後面的所有欄位均為僅限關鍵字欄位。這可能是最常見的用" "法:" -#: ../../whatsnew/3.10.rst:1041 +#: ../../whatsnew/3.10.rst:1042 msgid "" "from dataclasses import dataclass, KW_ONLY\n" "\n" @@ -1977,7 +1974,7 @@ msgstr "" " z: float = 0.0\n" " t: float = 0.0" -#: ../../whatsnew/3.10.rst:1053 +#: ../../whatsnew/3.10.rst:1054 msgid "" "Here, ``z`` and ``t`` are keyword-only parameters, while ``x`` and ``y`` are " "not. (Contributed by Eric V. Smith in :issue:`43532`.)" @@ -1985,104 +1982,101 @@ msgstr "" "這裡的 ``z`` 和 ``t`` 是僅限關鍵字參數,而 ``x`` 和 ``y`` 則不是。(由 Eric " "V. Smith 在 :issue:`43532` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1060 +#: ../../whatsnew/3.10.rst:1061 msgid "distutils" msgstr "distutils" -#: ../../whatsnew/3.10.rst:1062 +#: ../../whatsnew/3.10.rst:1063 msgid "" "The entire ``distutils`` package is deprecated, to be removed in Python " "3.12. Its functionality for specifying package builds has already been " "completely replaced by third-party packages ``setuptools`` and " "``packaging``, and most other commonly used APIs are available elsewhere in " -"the standard library (such " -"as :mod:`platform`, :mod:`shutil`, :mod:`subprocess` or :mod:`sysconfig`). " -"There are no plans to migrate any other functionality from ``distutils``, " -"and applications that are using other functions should plan to make private " -"copies of the code. Refer to :pep:`632` for discussion." +"the standard library (such as :mod:`platform`, :mod:`shutil`, :mod:" +"`subprocess` or :mod:`sysconfig`). There are no plans to migrate any other " +"functionality from ``distutils``, and applications that are using other " +"functions should plan to make private copies of the code. Refer to :pep:" +"`632` for discussion." msgstr "" "整個 ``distutils`` 套件已被棄用,將在 Python 3.12 中刪除。它指定套件建置的功" "能已經完全被第三方套件 ``setuptools`` 和 ``packaging`` 所取代,並且大多數其他" -"常用的 API 都可以在標準函式庫的其他地方被找到(例" -"如 :mod:`platform` 、:mod:`shutil`、:mod:`subprocess` 或 :mod:`sysconfig`)。" -"目前沒有將 ``distutils`` 遷移任何其他地方的計畫,且使用其他功能的應用程式應該" -"開始規劃如何取得程式碼的私有副本。請參閱 :pep:`632` 的討論。" +"常用的 API 都可以在標準函式庫的其他地方被找到(例如 :mod:`platform` 、:mod:" +"`shutil`、:mod:`subprocess` 或 :mod:`sysconfig`)。目前沒有將 ``distutils`` " +"遷移任何其他地方的計畫,且使用其他功能的應用程式應該開始規劃如何取得程式碼的" +"私有副本。請參閱 :pep:`632` 的討論。" -#: ../../whatsnew/3.10.rst:1072 +#: ../../whatsnew/3.10.rst:1073 msgid "" "The ``bdist_wininst`` command deprecated in Python 3.8 has been removed. The " "``bdist_wheel`` command is now recommended to distribute binary packages on " "Windows. (Contributed by Victor Stinner in :issue:`42802`.)" msgstr "" "Python 3.8 中不推薦使用的 ``bdist_wininst`` 命令已被刪除。現在建議使用 " -"``bdist_wheel`` 命令來在 Windows 上發布二進位套件。(由 Victor Stinner " -"在 :issue:`42802` 中貢獻。)" +"``bdist_wheel`` 命令來在 Windows 上發布二進位套件。(由 Victor Stinner 在 :" +"issue:`42802` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1078 +#: ../../whatsnew/3.10.rst:1079 msgid "doctest" msgstr "doctest" -#: ../../whatsnew/3.10.rst:1080 ../../whatsnew/3.10.rst:1215 -#: ../../whatsnew/3.10.rst:1242 ../../whatsnew/3.10.rst:1341 +#: ../../whatsnew/3.10.rst:1081 ../../whatsnew/3.10.rst:1216 +#: ../../whatsnew/3.10.rst:1243 ../../whatsnew/3.10.rst:1342 msgid "" -"When a module does not define ``__loader__``, fall back to " -"``__spec__.loader``. (Contributed by Brett Cannon in :issue:`42133`.)" +"When a module does not define ``__loader__``, fall back to ``__spec__." +"loader``. (Contributed by Brett Cannon in :issue:`42133`.)" msgstr "" "當模組未定義 ``__loader__`` 時,回退到 ``__spec__.loader`` 。(由 Brett " "Cannon 在 :issue:`42133` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1084 +#: ../../whatsnew/3.10.rst:1085 msgid "encodings" msgstr "encodings" -#: ../../whatsnew/3.10.rst:1086 +#: ../../whatsnew/3.10.rst:1087 msgid "" ":func:`encodings.normalize_encoding` now ignores non-ASCII characters. " "(Contributed by Hai Shi in :issue:`39337`.)" msgstr "" -":func:`encodings.normalize_encoding` 現在會忽略非 ASCII 字元。(Hai Shi " -"在 :issue:`39337` 中貢獻。)" +":func:`encodings.normalize_encoding` 現在會忽略非 ASCII 字元。(Hai Shi 在 :" +"issue:`39337` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1090 +#: ../../whatsnew/3.10.rst:1091 msgid "enum" msgstr "enum" -#: ../../whatsnew/3.10.rst:1092 +#: ../../whatsnew/3.10.rst:1093 msgid "" -":class:`~enum.Enum` :func:`~object.__repr__` now returns " -"``enum_name.member_name`` and :func:`~object.__str__` now returns " -"``member_name``. Stdlib enums available as module constants have " -"a :func:`repr` of ``module_name.member_name``. (Contributed by Ethan Furman " -"in :issue:`40066`.)" +":class:`~enum.Enum` :func:`~object.__repr__` now returns ``enum_name." +"member_name`` and :func:`~object.__str__` now returns ``member_name``. " +"Stdlib enums available as module constants have a :func:`repr` of " +"``module_name.member_name``. (Contributed by Ethan Furman in :issue:`40066`.)" msgstr "" -":class:`~enum.Enum` :func:`~object.__repr__` 現在會回傳 " -"``enum_name.member_name`` 、:func:`~object.__str__` 現在會回傳 " -"``member_name`` 。可用作模組常數的標準函式庫列舉會有 " -"``module_name.member_name`` 的 :func:`repr`。(由 Ethan Furman " -"在 :issue:`40066` 中貢獻。)" +":class:`~enum.Enum` :func:`~object.__repr__` 現在會回傳 ``enum_name." +"member_name`` 、:func:`~object.__str__` 現在會回傳 ``member_name`` 。可用作模" +"組常數的標準函式庫列舉會有 ``module_name.member_name`` 的 :func:`repr`。(由 " +"Ethan Furman 在 :issue:`40066` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1097 +#: ../../whatsnew/3.10.rst:1098 msgid "" "Add :class:`enum.StrEnum` for enums where all members are strings. " "(Contributed by Ethan Furman in :issue:`41816`.)" msgstr "" -"新增 :class:`enum.StrEnum`,為所有成員都是字串的列舉。(由 Ethan Furman " -"在 :issue:`41816` 中貢獻。)" +"新增 :class:`enum.StrEnum`,為所有成員都是字串的列舉。(由 Ethan Furman 在 :" +"issue:`41816` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1101 +#: ../../whatsnew/3.10.rst:1102 msgid "fileinput" msgstr "fileinput" -#: ../../whatsnew/3.10.rst:1103 +#: ../../whatsnew/3.10.rst:1104 msgid "" -"Add *encoding* and *errors* parameters in :func:`fileinput.input` " -"and :class:`fileinput.FileInput`. (Contributed by Inada Naoki " -"in :issue:`43712`.)" +"Add *encoding* and *errors* parameters in :func:`fileinput.input` and :class:" +"`fileinput.FileInput`. (Contributed by Inada Naoki in :issue:`43712`.)" msgstr "" "在 :func:`fileinput.input` 和 :class:`fileinput.FileInput` 中新增 *encoding* " "和 *errors* 參數。(由 Inada Naoki 在 :issue:`43712` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1107 +#: ../../whatsnew/3.10.rst:1108 msgid "" ":func:`fileinput.hook_compressed` now returns :class:`~io.TextIOWrapper` " "object when *mode* is \"r\" and file is compressed, like uncompressed files. " @@ -2092,59 +2086,58 @@ msgstr "" "會回傳 :class:`~io.TextIOWrapper` 物件(和未壓縮檔案一樣)。(由 Inada Naoki " "在 :issue:`5758` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1112 +#: ../../whatsnew/3.10.rst:1113 msgid "faulthandler" msgstr "faulthandler" -#: ../../whatsnew/3.10.rst:1114 +#: ../../whatsnew/3.10.rst:1115 msgid "" "The :mod:`faulthandler` module now detects if a fatal error occurs during a " -"garbage collector collection. (Contributed by Victor Stinner " -"in :issue:`44466`.)" +"garbage collector collection. (Contributed by Victor Stinner in :issue:" +"`44466`.)" msgstr "" ":mod:`faulthandler` 模組現在可以檢測垃圾收集器 (garbage collector) 在收集期間" "是否發生嚴重錯誤。(由 Victor Stinner 在 :issue:`44466` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1119 +#: ../../whatsnew/3.10.rst:1120 msgid "gc" msgstr "gc" -#: ../../whatsnew/3.10.rst:1121 +#: ../../whatsnew/3.10.rst:1122 msgid "" -"Add audit hooks for :func:`gc.get_objects`, :func:`gc.get_referrers` " -"and :func:`gc.get_referents`. (Contributed by Pablo Galindo " -"in :issue:`43439`.)" +"Add audit hooks for :func:`gc.get_objects`, :func:`gc.get_referrers` and :" +"func:`gc.get_referents`. (Contributed by Pablo Galindo in :issue:`43439`.)" msgstr "" -"為 :func:`gc.get_objects`、:func:`gc.get_referrers` " -"和 :func:`gc.get_referents` 新增稽核掛鉤 (audit hooks)。(由 Pablo Galindo " -"在 :issue:`43439` 中貢獻。)" +"為 :func:`gc.get_objects`、:func:`gc.get_referrers` 和 :func:`gc." +"get_referents` 新增稽核掛鉤 (audit hooks)。(由 Pablo Galindo 在 :issue:" +"`43439` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1125 +#: ../../whatsnew/3.10.rst:1126 msgid "glob" msgstr "glob" -#: ../../whatsnew/3.10.rst:1127 +#: ../../whatsnew/3.10.rst:1128 msgid "" -"Add the *root_dir* and *dir_fd* parameters in :func:`~glob.glob` " -"and :func:`~glob.iglob` which allow to specify the root directory for " -"searching. (Contributed by Serhiy Storchaka in :issue:`38144`.)" +"Add the *root_dir* and *dir_fd* parameters in :func:`~glob.glob` and :func:" +"`~glob.iglob` which allow to specify the root directory for searching. " +"(Contributed by Serhiy Storchaka in :issue:`38144`.)" msgstr "" "在 :func:`~glob.glob` 和 :func:`~glob.iglob` 中新增 *root_dir* 和 *dir_fd* 參" "數,允許指定搜尋的根目錄。(由 Serhiy Storchaka 在 :issue:`38144` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1132 +#: ../../whatsnew/3.10.rst:1133 msgid "hashlib" msgstr "hashlib" -#: ../../whatsnew/3.10.rst:1134 +#: ../../whatsnew/3.10.rst:1135 msgid "" "The hashlib module requires OpenSSL 1.1.1 or newer. (Contributed by " "Christian Heimes in :pep:`644` and :issue:`43669`.)" msgstr "" -"hashlib 模組需要 OpenSSL 1.1.1 或更高版本。(由 Christian Heimes " -"在 :pep:`644` 和 :issue:`43669` 中貢獻。)" +"hashlib 模組需要 OpenSSL 1.1.1 或更高版本。(由 Christian Heimes 在 :pep:" +"`644` 和 :issue:`43669` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1137 +#: ../../whatsnew/3.10.rst:1138 msgid "" "The hashlib module has preliminary support for OpenSSL 3.0.0. (Contributed " "by Christian Heimes in :issue:`38820` and other issues.)" @@ -2152,51 +2145,51 @@ msgstr "" "hashlib 模組初步支援 OpenSSL 3.0.0。(由 Christian Heimes 在 :issue:`38820` " "和其他問題中貢獻。)" -#: ../../whatsnew/3.10.rst:1140 +#: ../../whatsnew/3.10.rst:1141 msgid "" "The pure-Python fallback of :func:`~hashlib.pbkdf2_hmac` is deprecated. In " "the future PBKDF2-HMAC will only be available when Python has been built " "with OpenSSL support. (Contributed by Christian Heimes in :issue:`43880`.)" msgstr "" "純 Python 的 :func:`~hashlib.pbkdf2_hmac` 回退已被棄用。將來只有在有 OpenSSL " -"支援的建置 Python 中才能夠使用 PBKDF2-HMAC。(由 Christian Heimes " -"在 :issue:`43880` 中貢獻。)" +"支援的建置 Python 中才能夠使用 PBKDF2-HMAC。(由 Christian Heimes 在 :issue:" +"`43880` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1146 +#: ../../whatsnew/3.10.rst:1147 msgid "hmac" msgstr "hmac" -#: ../../whatsnew/3.10.rst:1148 +#: ../../whatsnew/3.10.rst:1149 msgid "" "The hmac module now uses OpenSSL's HMAC implementation internally. " "(Contributed by Christian Heimes in :issue:`40645`.)" msgstr "" -"hmac 模組現在在內部使用 OpenSSL 的 HMAC 實作。(由 Christian Heimes " -"在 :issue:`40645` 中貢獻。)" +"hmac 模組現在在內部使用 OpenSSL 的 HMAC 實作。(由 Christian Heimes 在 :" +"issue:`40645` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1152 +#: ../../whatsnew/3.10.rst:1153 msgid "IDLE and idlelib" msgstr "IDLE 和 idlelib" -#: ../../whatsnew/3.10.rst:1154 +#: ../../whatsnew/3.10.rst:1155 msgid "" "Make IDLE invoke :func:`sys.excepthook` (when started without '-n'). User " -"hooks were previously ignored. (Contributed by Ken Hilton " -"in :issue:`43008`.)" +"hooks were previously ignored. (Contributed by Ken Hilton in :issue:" +"`43008`.)" msgstr "" "讓 IDLE 叫用 :func:`sys.excepthook` (在沒有 ``-n`` 的情況下啟動時)。使用者" "掛鉤 (user hooks) 在以前是被忽略的。(由 Ken Hilton 在 :issue:`43008` 中貢" "獻。)" -#: ../../whatsnew/3.10.rst:1158 +#: ../../whatsnew/3.10.rst:1159 msgid "" "Rearrange the settings dialog. Split the General tab into Windows and Shell/" "Ed tabs. Move help sources, which extend the Help menu, to the Extensions " "tab. Make space for new options and shorten the dialog. The latter makes " -"the dialog better fit small screens. (Contributed by Terry Jan Reedy " -"in :issue:`40468`.) Move the indent space setting from the Font tab to the " -"new Windows tab. (Contributed by Mark Roseman and Terry Jan Reedy " -"in :issue:`33962`.)" +"the dialog better fit small screens. (Contributed by Terry Jan Reedy in :" +"issue:`40468`.) Move the indent space setting from the Font tab to the new " +"Windows tab. (Contributed by Mark Roseman and Terry Jan Reedy in :issue:" +"`33962`.)" msgstr "" "重新排列設定對話框。將 General 分頁拆分為 Windows 和 Shell/Ed 分頁。將擴充 " "Help 選單的幫助來源移至 Extensions 分頁。為新選項騰出空間並縮短對話框,而後者" @@ -2204,11 +2197,11 @@ msgstr "" "獻。)將縮排空間設定從 Font 分頁移至新的 Windows 分頁。(由 Mark Roseman 和 " "Terry Jan Reedy 在 :issue:`33962` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1166 +#: ../../whatsnew/3.10.rst:1167 msgid "The changes above were backported to a 3.9 maintenance release." msgstr "上述更改已向後移植到 3.9 維護版本。" -#: ../../whatsnew/3.10.rst:1168 +#: ../../whatsnew/3.10.rst:1169 msgid "" "Add a Shell sidebar. Move the primary prompt ('>>>') to the sidebar. Add " "secondary prompts ('...') to the sidebar. Left click and optional drag " @@ -2218,13 +2211,13 @@ msgid "" "the selected text. This option also appears on the context menu for the " "text. (Contributed by Tal Einat in :issue:`37903`.)" msgstr "" -"新增 Shell 側邊欄。將主要提示字元 (``>>>``) 移至側邊欄。將輔助提示字元" -"(``...``)新增到側邊欄。點擊左鍵再拖動能夠選擇一行或多行文字,和編輯器列號側" -"邊欄操作一樣。選擇文字列後點擊右鍵會顯示帶有「一併複製提示字元 (copy with " +"新增 Shell 側邊欄。將主要提示字元 (``>>>``) 移至側邊欄。將輔助提示字元(``..." +"``)新增到側邊欄。點擊左鍵再拖動能夠選擇一行或多行文字,和編輯器列號側邊欄操" +"作一樣。選擇文字列後點擊右鍵會顯示帶有「一併複製提示字元 (copy with " "prompts)」的情境選單,這會將側邊欄中提示字元與所選文字並排,此選項也會出現在" "文字的情境選單上。(由 Tal Einat 在 :issue:`37903` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1177 +#: ../../whatsnew/3.10.rst:1178 msgid "" "Use spaces instead of tabs to indent interactive code. This makes " "interactive code entries 'look right'. Making this feasible was a major " @@ -2235,25 +2228,24 @@ msgstr "" "起來正確」。新增 shell 側邊欄的主要動機是實現這一點。(由 Terry Jan Reedy " "在 :issue:`37892` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1182 +#: ../../whatsnew/3.10.rst:1183 msgid "" -"Highlight the new :ref:`soft keywords ` :keyword:`match`, :keyword:`case `, and :keyword:`_ " -"` in pattern-matching statements. However, this " -"highlighting is not perfect and will be incorrect in some rare cases, " -"including some ``_``-s in ``case`` patterns. (Contributed by Tal Einat " -"in :issue:`44010`.)" +"Highlight the new :ref:`soft keywords ` :keyword:`match`, :" +"keyword:`case `, and :keyword:`_ ` in pattern-" +"matching statements. However, this highlighting is not perfect and will be " +"incorrect in some rare cases, including some ``_``-s in ``case`` patterns. " +"(Contributed by Tal Einat in :issue:`44010`.)" msgstr "" "突顯 (highlight) 模式匹配陳述式中的新\\ :ref:`軟關鍵字 (soft keywords) ` :keyword:`match`、:keyword:`case ` 和 :keyword:`_ " "`。然而這種突顯並不完美,並且在某些罕見的情況下會出錯,包" "括 ``case`` 模式中的一些 ``_``。(由 Tal Einat 在 :issue:`44010` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1188 +#: ../../whatsnew/3.10.rst:1189 msgid "New in 3.10 maintenance releases." msgstr "3.10 維護版本中的新增功能。" -#: ../../whatsnew/3.10.rst:1190 +#: ../../whatsnew/3.10.rst:1191 msgid "" "Apply syntax highlighting to ``.pyi`` files. (Contributed by Alex Waygood " "and Terry Jan Reedy in :issue:`45447`.)" @@ -2261,119 +2253,117 @@ msgstr "" "將語法突顯 (syntax highlighting) 應用於 ``.pyi`` 檔案。(由 Alex Waygood 和 " "Terry Jan Reedy 在 :issue:`45447` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1193 +#: ../../whatsnew/3.10.rst:1194 msgid "" "Include prompts when saving Shell with inputs and outputs. (Contributed by " "Terry Jan Reedy in :gh:`95191`.)" msgstr "" -"保存帶有輸入和輸出的 Shell 時,會包含提示字元。(由 Terry Jan Reedy " -"在 :gh:`95191` 中貢獻。)" +"保存帶有輸入和輸出的 Shell 時,會包含提示字元。(由 Terry Jan Reedy 在 :gh:" +"`95191` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1197 +#: ../../whatsnew/3.10.rst:1198 msgid "importlib.metadata" msgstr "importlib.metadata" -#: ../../whatsnew/3.10.rst:1199 +#: ../../whatsnew/3.10.rst:1200 msgid "" "Feature parity with ``importlib_metadata`` 4.6 (`history `_)." msgstr "" -"與 ``importlib_metadata`` 4.6 功能相同(`歷史 `_)。" +"與 ``importlib_metadata`` 4.6 功能相同(`歷史 `_)。" -#: ../../whatsnew/3.10.rst:1202 +#: ../../whatsnew/3.10.rst:1203 msgid "" ":ref:`importlib.metadata entry points ` now provide a nicer " -"experience for selecting entry points by group and name through a " -"new :ref:`importlib.metadata.EntryPoints ` class. See the " -"Compatibility Note in the docs for more info on the deprecation and usage." +"experience for selecting entry points by group and name through a new :ref:" +"`importlib.metadata.EntryPoints ` class. See the Compatibility " +"Note in the docs for more info on the deprecation and usage." msgstr "" -":ref:`importlib.metadata 入口點 `\\ 現在透過新" -"的 :ref:`importlib.metadata.EntryPoints ` 類別提供了以群組和名" -"稱選擇入口點的更好體驗。有關棄用與用法的更多資訊,請參閱文件中的相容性說明。" +":ref:`importlib.metadata 入口點 `\\ 現在透過新的 :ref:" +"`importlib.metadata.EntryPoints ` 類別提供了以群組和名稱選擇入" +"口點的更好體驗。有關棄用與用法的更多資訊,請參閱文件中的相容性說明。" -#: ../../whatsnew/3.10.rst:1208 +#: ../../whatsnew/3.10.rst:1209 msgid "" "Added :ref:`importlib.metadata.packages_distributions() ` for resolving top-level Python modules and packages to " "their :ref:`importlib.metadata.Distribution `." msgstr "" "新增了 :ref:`importlib.metadata.packages_distributions() ` 用於將頂階 Python 模組和套件解析" -"出 :ref:`importlib.metadata.Distribution `。" +"distributions>` 用於將頂階 Python 模組和套件解析出 :ref:`importlib.metadata." +"Distribution `。" -#: ../../whatsnew/3.10.rst:1213 +#: ../../whatsnew/3.10.rst:1214 msgid "inspect" msgstr "inspect" -#: ../../whatsnew/3.10.rst:1218 +#: ../../whatsnew/3.10.rst:1219 msgid "" "Add :func:`inspect.get_annotations`, which safely computes the annotations " "defined on an object. It works around the quirks of accessing the " "annotations on various types of objects, and makes very few assumptions " "about the object it examines. :func:`inspect.get_annotations` can also " -"correctly un-stringize stringized " -"annotations. :func:`inspect.get_annotations` is now considered best " -"practice for accessing the annotations dict defined on any Python object; " -"for more information on best practices for working with annotations, please " -"see :ref:`annotations-howto`. " -"Relatedly, :func:`inspect.signature`, :func:`inspect.Signature.from_callable`, " -"and :func:`!inspect.Signature.from_function` now " -"call :func:`inspect.get_annotations` to retrieve annotations. This " -"means :func:`inspect.signature` and :func:`inspect.Signature.from_callable` " -"can also now un-stringize stringized annotations. (Contributed by Larry " -"Hastings in :issue:`43817`.)" +"correctly un-stringize stringized annotations. :func:`inspect." +"get_annotations` is now considered best practice for accessing the " +"annotations dict defined on any Python object; for more information on best " +"practices for working with annotations, please see :ref:`annotations-howto`. " +"Relatedly, :func:`inspect.signature`, :func:`inspect.Signature." +"from_callable`, and :func:`!inspect.Signature.from_function` now call :func:" +"`inspect.get_annotations` to retrieve annotations. This means :func:`inspect." +"signature` and :func:`inspect.Signature.from_callable` can also now un-" +"stringize stringized annotations. (Contributed by Larry Hastings in :issue:" +"`43817`.)" msgstr "" "新增 :func:`inspect.get_annotations`,它可以安全地計算物件上定義的註釋。它是" "存取各種型別物件註釋的怪作法 (quirks) 的變通解法 (work around),並且對其檢查" "的物件做出很少的假設。 :func:`inspect.get_annotations` 也可以正確地取消字串化" "註釋 (stringized annotations)。 :func:`inspect.get_annotations` 現在被認為是" "存取任何 Python 物件上定義的註釋字典的最佳實踐;有關使用註釋的最佳實踐的更多" -"資訊,請參閱 :ref:`annotations-howto`。相關" -"地,:func:`inspect.signature`、:func:`inspect.Signature.from_callable` " -"和 :func:`!inspect.Signature.from_function` 現在呼" -"叫 :func:`inspect.get_annotations` 來檢索註釋。這意味" +"資訊,請參閱 :ref:`annotations-howto`。相關地,:func:`inspect.signature`、:" +"func:`inspect.Signature.from_callable` 和 :func:`!inspect.Signature." +"from_function` 現在呼叫 :func:`inspect.get_annotations` 來檢索註釋。這意味" "著 :func:`inspect.signature` 和 :func:`inspect.Signature.from_callable` 現在" "也可以取消字串化註釋。(由 Larry Hastings 在 :issue:`43817` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1234 +#: ../../whatsnew/3.10.rst:1235 msgid "itertools" msgstr "itertools" -#: ../../whatsnew/3.10.rst:1236 +#: ../../whatsnew/3.10.rst:1237 msgid "" -"Add :func:`itertools.pairwise`. (Contributed by Raymond Hettinger " -"in :issue:`38200`.)" +"Add :func:`itertools.pairwise`. (Contributed by Raymond Hettinger in :issue:" +"`38200`.)" msgstr "" "新增 :func:`itertools.pairwise`。(由 Raymond Hettinger 在 :issue:`38200` 中" "貢獻。)" -#: ../../whatsnew/3.10.rst:1240 +#: ../../whatsnew/3.10.rst:1241 msgid "linecache" msgstr "linecache" -#: ../../whatsnew/3.10.rst:1246 +#: ../../whatsnew/3.10.rst:1247 msgid "os" msgstr "os" -#: ../../whatsnew/3.10.rst:1248 +#: ../../whatsnew/3.10.rst:1249 msgid "" "Add :func:`os.cpu_count` support for VxWorks RTOS. (Contributed by Peixing " "Xin in :issue:`41440`.)" msgstr "" -"為 VxWorks RTOS 新增 :func:`os.cpu_count` 支援。(由 Peixing Xin " -"在 :issue:`41440` 中貢獻。)" +"為 VxWorks RTOS 新增 :func:`os.cpu_count` 支援。(由 Peixing Xin 在 :issue:" +"`41440` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1251 +#: ../../whatsnew/3.10.rst:1252 msgid "" "Add a new function :func:`os.eventfd` and related helpers to wrap the " -"``eventfd2`` syscall on Linux. (Contributed by Christian Heimes " -"in :issue:`41001`.)" +"``eventfd2`` syscall on Linux. (Contributed by Christian Heimes in :issue:" +"`41001`.)" msgstr "" "新增函式 :func:`os.eventfd` 和相關幫助程式來包裝 Linux 上的 ``eventfd2`` 系統" "呼叫。(由 Christian Heimes 在 :issue:`41001` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1255 +#: ../../whatsnew/3.10.rst:1256 msgid "" "Add :func:`os.splice` that allows to move data between two file descriptors " "without copying between kernel address space and user address space, where " @@ -2385,35 +2375,35 @@ msgstr "" "address space) 之間進行複製,其中檔案描述器之一必須是個 pipe。(由 Pablo " "Galindo 在 :issue:`41625` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1260 +#: ../../whatsnew/3.10.rst:1261 msgid "" "Add :const:`~os.O_EVTONLY`, :const:`~os.O_FSYNC`, :const:`~os.O_SYMLINK` " -"and :const:`~os.O_NOFOLLOW_ANY` for macOS. (Contributed by Donghee Na " -"in :issue:`43106`.)" +"and :const:`~os.O_NOFOLLOW_ANY` for macOS. (Contributed by Donghee Na in :" +"issue:`43106`.)" msgstr "" -"為 macOS 新" -"增 :const:`~os.O_EVTONLY`、:const:`~os.O_FSYNC`、:const:`~os.O_SYMLINK` " -"和 :const:`~os.O_NOFOLLOW_ANY`。(由 Donghee Na 在 :issue:`43106` 中貢獻。)" +"為 macOS 新增 :const:`~os.O_EVTONLY`、:const:`~os.O_FSYNC`、:const:`~os." +"O_SYMLINK` 和 :const:`~os.O_NOFOLLOW_ANY`。(由 Donghee Na 在 :issue:`43106` " +"中貢獻。)" -#: ../../whatsnew/3.10.rst:1265 +#: ../../whatsnew/3.10.rst:1266 msgid "os.path" msgstr "os.path" -#: ../../whatsnew/3.10.rst:1267 +#: ../../whatsnew/3.10.rst:1268 msgid "" ":func:`os.path.realpath` now accepts a *strict* keyword-only argument. When " "set to ``True``, :exc:`OSError` is raised if a path doesn't exist or a " "symlink loop is encountered. (Contributed by Barney Gale in :issue:`43757`.)" msgstr "" ":func:`os.path.realpath` 現在接受一個 *strict* 僅限關鍵字引數。當設定為 " -"``True`` 時,如果路徑不存在或遇到符號鏈接循環 (symlink loop),則會引" -"發 :exc:`OSError`。(由 Barney Gale 在 :issue:`43757` 中貢獻。)" +"``True`` 時,如果路徑不存在或遇到符號鏈接循環 (symlink loop),則會引發 :exc:" +"`OSError`。(由 Barney Gale 在 :issue:`43757` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1273 +#: ../../whatsnew/3.10.rst:1274 msgid "pathlib" msgstr "pathlib" -#: ../../whatsnew/3.10.rst:1275 +#: ../../whatsnew/3.10.rst:1276 msgid "" "Add slice support to :attr:`PurePath.parents `. " "(Contributed by Joshua Cannon in :issue:`35498`.)" @@ -2421,42 +2411,41 @@ msgstr "" "新增 :attr:`PurePath.parents ` 對於切片的支援。 " "(由 Joshua Cannon 在 :issue:`35498` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1278 +#: ../../whatsnew/3.10.rst:1279 msgid "" -"Add negative indexing support to :attr:`PurePath.parents " -"`. (Contributed by Yaroslav Pankovych " -"in :issue:`21041`.)" +"Add negative indexing support to :attr:`PurePath.parents `. (Contributed by Yaroslav Pankovych in :issue:`21041`.)" msgstr "" "向 :attr:`PurePath.parents ` 新增負索引支援。(由 " "Yaroslav Pankovych 在 :issue:`21041` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1282 +#: ../../whatsnew/3.10.rst:1283 msgid "" "Add :meth:`Path.hardlink_to ` method that " -"supersedes :meth:`!link_to`. The new method has the same argument order " -"as :meth:`~pathlib.Path.symlink_to`. (Contributed by Barney Gale " -"in :issue:`39950`.)" +"supersedes :meth:`!link_to`. The new method has the same argument order as :" +"meth:`~pathlib.Path.symlink_to`. (Contributed by Barney Gale in :issue:" +"`39950`.)" msgstr "" -"新增替代 :meth:`!link_to` 的 :meth:`Path.hardlink_to " -"` 方法。新方法與 :meth:`~pathlib.Path.symlink_to` " -"具有相同的引數順序。(由 Barney Gale 在 :issue:`39950` 中貢獻。)" +"新增替代 :meth:`!link_to` 的 :meth:`Path.hardlink_to ` 方法。新方法與 :meth:`~pathlib.Path.symlink_to` 具有相同的引數" +"順序。(由 Barney Gale 在 :issue:`39950` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1287 +#: ../../whatsnew/3.10.rst:1288 msgid "" ":meth:`pathlib.Path.stat` and :meth:`~pathlib.Path.chmod` now accept a " "*follow_symlinks* keyword-only argument for consistency with corresponding " -"functions in the :mod:`os` module. (Contributed by Barney Gale " -"in :issue:`39906`.)" +"functions in the :mod:`os` module. (Contributed by Barney Gale in :issue:" +"`39906`.)" msgstr "" ":meth:`pathlib.Path.stat` 和 :meth:`~pathlib.Path.chmod` 現在接受 " "*follow_symlinks* 僅限關鍵字引數,以與 :mod:`os` 模組中的相應函式保持一致。" "(由 Barney Gale 在 :issue:`39906` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1293 +#: ../../whatsnew/3.10.rst:1294 msgid "platform" msgstr "platform" -#: ../../whatsnew/3.10.rst:1295 +#: ../../whatsnew/3.10.rst:1296 msgid "" "Add :func:`platform.freedesktop_os_release` to retrieve operation system " "identification from `freedesktop.org os-release ` has a list of deprecated features. " -"(Contributed by Christian Heimes in :issue:`43880`.)" +"Deprecated function and use of deprecated constants now result in a :exc:" +"`DeprecationWarning`. :attr:`ssl.SSLContext.options` has :data:`~ssl." +"OP_NO_SSLv2` and :data:`~ssl.OP_NO_SSLv3` set by default and therefore " +"cannot warn about setting the flag again. The :ref:`deprecation section " +"` has a list of deprecated features. (Contributed by " +"Christian Heimes in :issue:`43880`.)" msgstr "" -"已棄用函式和使用已棄用常數現在會導" -"致 :exc:`DeprecationWarning`。 :attr:`ssl.SSLContext.options` 預設設定" -"有 :data:`~ssl.OP_NO_SSLv2` 和 :data:`~ssl.OP_NO_SSLv3`,因此無法再次發出設定" -"該旗標的警告。:ref:`棄用部分 `\\ 包含已棄用功能的列" -"表。(由 Christian Heimes 在 :issue:`43880` 中貢獻。)" +"已棄用函式和使用已棄用常數現在會導致 :exc:`DeprecationWarning`。 :attr:`ssl." +"SSLContext.options` 預設設定有 :data:`~ssl.OP_NO_SSLv2` 和 :data:`~ssl." +"OP_NO_SSLv3`,因此無法再次發出設定該旗標的警告。:ref:`棄用部分 `\\ 包含已棄用功能的列表。(由 Christian Heimes 在 :issue:`43880` " +"中貢獻。)" -#: ../../whatsnew/3.10.rst:1376 +#: ../../whatsnew/3.10.rst:1377 msgid "" "The ssl module now has more secure default settings. Ciphers without forward " "secrecy or SHA-1 MAC are disabled by default. Security level 2 prohibits " -"weak RSA, DH, and ECC keys with less than 112 bits of " -"security. :class:`~ssl.SSLContext` defaults to minimum protocol version TLS " -"1.2. Settings are based on Hynek Schlawack's research. (Contributed by " -"Christian Heimes in :issue:`43998`.)" +"weak RSA, DH, and ECC keys with less than 112 bits of security. :class:`~ssl." +"SSLContext` defaults to minimum protocol version TLS 1.2. Settings are based " +"on Hynek Schlawack's research. (Contributed by Christian Heimes in :issue:" +"`43998`.)" msgstr "" "ssl 模組現在具有更安全的預設設定。預設情況下禁用沒有前向保密或 SHA-1 MAC 的密" -"碼。安全級別 2 禁止安全性低於 112 位元的弱 RSA、DH 和 ECC 密" -"鑰。 :class:`~ssl.SSLContext` 預設為最低協議版本 TLS 1.2。設定基於 Hynek " -"Schlawack 的研究。(由 Christian Heimes 在 :issue:`43998` 中貢獻。)" +"碼。安全級別 2 禁止安全性低於 112 位元的弱 RSA、DH 和 ECC 密鑰。 :class:" +"`~ssl.SSLContext` 預設為最低協議版本 TLS 1.2。設定基於 Hynek Schlawack 的研" +"究。(由 Christian Heimes 在 :issue:`43998` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1383 +#: ../../whatsnew/3.10.rst:1384 msgid "" "The deprecated protocols SSL 3.0, TLS 1.0, and TLS 1.1 are no longer " "officially supported. Python does not block them actively. However OpenSSL " @@ -2642,7 +2628,7 @@ msgstr "" "們。然而,OpenSSL 建置選項、發行版配置、發行商補丁和密碼套件可能會阻止交握的" "成功。" -#: ../../whatsnew/3.10.rst:1388 +#: ../../whatsnew/3.10.rst:1389 msgid "" "Add a *timeout* parameter to the :func:`ssl.get_server_certificate` " "function. (Contributed by Zackery Spytz in :issue:`31870`.)" @@ -2650,7 +2636,7 @@ msgstr "" "向 :func:`ssl.get_server_certificate` 函式新增 *timeout* 參數。(由 Zackery " "Spytz 在 :issue:`31870` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1391 +#: ../../whatsnew/3.10.rst:1392 msgid "" "The ssl module uses heap-types and multi-phase initialization. (Contributed " "by Christian Heimes in :issue:`42333`.)" @@ -2658,35 +2644,33 @@ msgstr "" "ssl 模組使用堆疊類型 (heap-types) 和多階段初始化 (multi-phase " "initialization)。(由 Christian Heimes 在 :issue:`42333` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1394 +#: ../../whatsnew/3.10.rst:1395 msgid "" "A new verify flag :const:`~ssl.VERIFY_X509_PARTIAL_CHAIN` has been added. " "(Contributed by l0x in :issue:`40849`.)" msgstr "" -"新增驗證旗標 :const:`~ssl.VERIFY_X509_PARTIAL_CHAIN`。(由 l0x " -"在 :issue:`40849` 中貢獻。)" +"新增驗證旗標 :const:`~ssl.VERIFY_X509_PARTIAL_CHAIN`。(由 l0x 在 :issue:" +"`40849` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1398 +#: ../../whatsnew/3.10.rst:1399 msgid "sqlite3" msgstr "sqlite3" -#: ../../whatsnew/3.10.rst:1400 +#: ../../whatsnew/3.10.rst:1401 msgid "" -"Add audit events for :func:`~sqlite3.connect/" -"handle`, :meth:`~sqlite3.Connection.enable_load_extension`, " -"and :meth:`~sqlite3.Connection.load_extension`. (Contributed by Erlend E. " -"Aasland in :issue:`43762`.)" +"Add audit events for :func:`~sqlite3.connect/handle`, :meth:`~sqlite3." +"Connection.enable_load_extension`, and :meth:`~sqlite3.Connection." +"load_extension`. (Contributed by Erlend E. Aasland in :issue:`43762`.)" msgstr "" -"新增 :func:`~sqlite3.connect/" -"handle`、:meth:`~sqlite3.Connection.enable_load_extension` " -"和 :meth:`~sqlite3.Connection.load_extension` 的稽核事件。(由 Erlend E. " -"Aasland 在 :issue:`43762` 中貢獻。)" +"新增 :func:`~sqlite3.connect/handle`、:meth:`~sqlite3.Connection." +"enable_load_extension` 和 :meth:`~sqlite3.Connection.load_extension` 的稽核事" +"件。(由 Erlend E. Aasland 在 :issue:`43762` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1406 +#: ../../whatsnew/3.10.rst:1407 msgid "sys" msgstr "sys" -#: ../../whatsnew/3.10.rst:1408 +#: ../../whatsnew/3.10.rst:1409 msgid "" "Add :data:`sys.orig_argv` attribute: the list of the original command line " "arguments passed to the Python executable. (Contributed by Victor Stinner " @@ -2695,7 +2679,7 @@ msgstr "" "新增 :data:`sys.orig_argv` 屬性:傳遞給 Python 可執行檔案的原始命令列引數列" "表。(由 Victor Stinner 在 :issue:`23427` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1412 +#: ../../whatsnew/3.10.rst:1413 msgid "" "Add :data:`sys.stdlib_module_names`, containing the list of the standard " "library module names. (Contributed by Victor Stinner in :issue:`42955`.)" @@ -2703,11 +2687,11 @@ msgstr "" "新增 :data:`sys.stdlib_module_names`,其中包含標準函式庫模組的名稱列表。 " "(由 Victor Stinner 在 :issue:`42955` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1417 +#: ../../whatsnew/3.10.rst:1418 msgid "_thread" msgstr "_thread" -#: ../../whatsnew/3.10.rst:1419 +#: ../../whatsnew/3.10.rst:1420 msgid "" ":func:`_thread.interrupt_main` now takes an optional signal number to " "simulate (the default is still :const:`signal.SIGINT`). (Contributed by " @@ -2717,88 +2701,87 @@ msgstr "" "然是 :const:`signal.SIGINT`)。(由 Antoine Pitrou 在 :issue:`43356` 中貢" "獻。)" -#: ../../whatsnew/3.10.rst:1424 +#: ../../whatsnew/3.10.rst:1425 msgid "threading" msgstr "threading" -#: ../../whatsnew/3.10.rst:1426 +#: ../../whatsnew/3.10.rst:1427 msgid "" "Add :func:`threading.gettrace` and :func:`threading.getprofile` to retrieve " -"the functions set by :func:`threading.settrace` " -"and :func:`threading.setprofile` respectively. (Contributed by Mario " -"Corchero in :issue:`42251`.)" +"the functions set by :func:`threading.settrace` and :func:`threading." +"setprofile` respectively. (Contributed by Mario Corchero in :issue:`42251`.)" msgstr "" -"新增 :func:`threading.gettrace` 和 :func:`threading.getprofile` 分別取" -"得 :func:`threading.settrace` 和 :func:`threading.setprofile` 設定的函式。" -"(由 Mario Corchero 在 :issue:`42251` 中貢獻。)" +"新增 :func:`threading.gettrace` 和 :func:`threading.getprofile` 分別取得 :" +"func:`threading.settrace` 和 :func:`threading.setprofile` 設定的函式。(由 " +"Mario Corchero 在 :issue:`42251` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1431 +#: ../../whatsnew/3.10.rst:1432 msgid "" "Add :data:`threading.__excepthook__` to allow retrieving the original value " "of :func:`threading.excepthook` in case it is set to a broken or a different " "value. (Contributed by Mario Corchero in :issue:`42308`.)" msgstr "" -"新增 :data:`threading.__excepthook__` 以允許取" -"得 :func:`threading.excepthook` 的原始值,以防它被設定為損壞或不同的值。(由 " -"Mario Corchero 在 :issue:`42308` 中貢獻。)" +"新增 :data:`threading.__excepthook__` 以允許取得 :func:`threading." +"excepthook` 的原始值,以防它被設定為損壞或不同的值。(由 Mario Corchero 在 :" +"issue:`42308` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1437 +#: ../../whatsnew/3.10.rst:1438 msgid "traceback" msgstr "traceback" -#: ../../whatsnew/3.10.rst:1439 +#: ../../whatsnew/3.10.rst:1440 msgid "" -"The :func:`~traceback.format_exception`, :func:`~traceback.format_exception_only`, " -"and :func:`~traceback.print_exception` functions can now take an exception " -"object as a positional-only argument. (Contributed by Zackery Spytz and " -"Matthias Bussonnier in :issue:`26389`.)" +"The :func:`~traceback.format_exception`, :func:`~traceback." +"format_exception_only`, and :func:`~traceback.print_exception` functions can " +"now take an exception object as a positional-only argument. (Contributed by " +"Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)" msgstr "" -":func:`~traceback.format_exception`、:func:`~traceback.format_exception_only` " -"和 :func:`~traceback.print_exception` 函式現在可以將例外物件作為僅限位置引" -"數。(由 Zackery Spytz 和 Matthias Bussonnier 在 :issue:`26389` 中貢獻。)" +":func:`~traceback.format_exception`、:func:`~traceback." +"format_exception_only` 和 :func:`~traceback.print_exception` 函式現在可以將例" +"外物件作為僅限位置引數。(由 Zackery Spytz 和 Matthias Bussonnier 在 :issue:" +"`26389` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1446 +#: ../../whatsnew/3.10.rst:1447 msgid "types" msgstr "types" -#: ../../whatsnew/3.10.rst:1448 +#: ../../whatsnew/3.10.rst:1449 msgid "" -"Reintroduce the :data:`types.EllipsisType`, :data:`types.NoneType` " -"and :data:`types.NotImplementedType` classes, providing a new set of types " -"readily interpretable by type checkers. (Contributed by Bas van Beek " -"in :issue:`41810`.)" +"Reintroduce the :data:`types.EllipsisType`, :data:`types.NoneType` and :data:" +"`types.NotImplementedType` classes, providing a new set of types readily " +"interpretable by type checkers. (Contributed by Bas van Beek in :issue:" +"`41810`.)" msgstr "" -"重新引入 :data:`types.EllipsisType`、:data:`types.NoneType` " -"和 :data:`types.NotImplementedType` 類別,提供一組易於型別檢查器直譯的新型" -"別。(由 Bas van Beek 在 :issue:`41810` 中貢獻。)" +"重新引入 :data:`types.EllipsisType`、:data:`types.NoneType` 和 :data:`types." +"NotImplementedType` 類別,提供一組易於型別檢查器直譯的新型別。(由 Bas van " +"Beek 在 :issue:`41810` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1454 +#: ../../whatsnew/3.10.rst:1455 msgid "typing" msgstr "typing" -#: ../../whatsnew/3.10.rst:1456 +#: ../../whatsnew/3.10.rst:1457 msgid "For major changes, see :ref:`new-feat-related-type-hints`." msgstr "有關重大更改,請參閱\\ :ref:`new-feat-related-type-hints`。" -#: ../../whatsnew/3.10.rst:1458 +#: ../../whatsnew/3.10.rst:1459 msgid "" -"The behavior of :class:`typing.Literal` was changed to conform " -"with :pep:`586` and to match the behavior of static type checkers specified " -"in the PEP." +"The behavior of :class:`typing.Literal` was changed to conform with :pep:" +"`586` and to match the behavior of static type checkers specified in the PEP." msgstr "" ":class:`typing.Literal` 的行為已更改為符合 :pep:`586` 並匹配 PEP 中指定的靜態" "型別檢查器的行為。" -#: ../../whatsnew/3.10.rst:1461 +#: ../../whatsnew/3.10.rst:1462 msgid "``Literal`` now de-duplicates parameters." msgstr "``Literal`` 現在可以刪除重複參數。" -#: ../../whatsnew/3.10.rst:1462 +#: ../../whatsnew/3.10.rst:1463 msgid "" "Equality comparisons between ``Literal`` objects are now order independent." msgstr "``Literal`` 物件之間的相等性比較現在與順序無關。" -#: ../../whatsnew/3.10.rst:1463 +#: ../../whatsnew/3.10.rst:1464 msgid "" "``Literal`` comparisons now respect types. For example, ``Literal[0] == " "Literal[False]`` previously evaluated to ``True``. It is now ``False``. To " @@ -2809,7 +2792,7 @@ msgstr "" "Literal[False]`` 先前之求值為 ``True``,但現在它是 ``False``。為了支援此更" "改,內部使用的型別快取現在支援了型別的辨認。" -#: ../../whatsnew/3.10.rst:1467 +#: ../../whatsnew/3.10.rst:1468 msgid "" "``Literal`` objects will now raise a :exc:`TypeError` exception during " "equality comparisons if any of their parameters are not :term:`hashable`. " @@ -2820,7 +2803,7 @@ msgstr "" "在將在相等性比較期間引發 :exc:`TypeError` 例外。請注意,使用不可雜湊的參數宣" "告 ``Literal`` 不會引發錯誤: ::" -#: ../../whatsnew/3.10.rst:1472 +#: ../../whatsnew/3.10.rst:1473 msgid "" ">>> from typing import Literal\n" ">>> Literal[{0}]\n" @@ -2836,27 +2819,26 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: unhashable type: 'set'" -#: ../../whatsnew/3.10.rst:1479 +#: ../../whatsnew/3.10.rst:1480 msgid "(Contributed by Yurii Karabas in :issue:`42345`.)" msgstr "(由 Yurii Karabas 在 :issue:`42345` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1481 +#: ../../whatsnew/3.10.rst:1482 msgid "" "Add new function :func:`typing.is_typeddict` to introspect if an annotation " -"is a :class:`typing.TypedDict`. (Contributed by Patrick Reader " -"in :issue:`41792`.)" +"is a :class:`typing.TypedDict`. (Contributed by Patrick Reader in :issue:" +"`41792`.)" msgstr "" -"新增函式 :func:`typing.is_typeddict` 來自我審查 (introspect) 註釋是否" -"為 :class:`typing.TypedDict`。(由 Patrick Reader 在 :issue:`41792` 中貢" -"獻。)" +"新增函式 :func:`typing.is_typeddict` 來自我審查 (introspect) 註釋是否為 :" +"class:`typing.TypedDict`。(由 Patrick Reader 在 :issue:`41792` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1485 +#: ../../whatsnew/3.10.rst:1486 msgid "" "Subclasses of ``typing.Protocol`` which only have data variables declared " "will now raise a ``TypeError`` when checked with ``isinstance`` unless they " "are decorated with :func:`~typing.runtime_checkable`. Previously, these " -"checks passed silently. Users should decorate their subclasses with " -"the :func:`!runtime_checkable` decorator if they want runtime protocols. " +"checks passed silently. Users should decorate their subclasses with the :" +"func:`!runtime_checkable` decorator if they want runtime protocols. " "(Contributed by Yurii Karabas in :issue:`38908`.)" msgstr "" "僅宣告了資料變數的 ``typing.Protocol`` 子類別現在在使用 ``isinstance`` 檢查時" @@ -2865,98 +2847,96 @@ msgstr "" "protocol),則應該使用 :func:`!runtime_checkable` 裝飾器來裝飾其子類別。(由 " "Yurii Karabas 在 :issue:`38908` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1493 +#: ../../whatsnew/3.10.rst:1494 msgid "" -"Importing from the ``typing.io`` and ``typing.re`` submodules will now " -"emit :exc:`DeprecationWarning`. These submodules have been deprecated since " +"Importing from the ``typing.io`` and ``typing.re`` submodules will now emit :" +"exc:`DeprecationWarning`. These submodules have been deprecated since " "Python 3.8 and will be removed in a future version of Python. Anything " "belonging to those submodules should be imported directly from :mod:`typing` " "instead. (Contributed by Sebastian Rittau in :issue:`38291`.)" msgstr "" -"從 ``typing.io`` 和 ``typing.re`` 子模組引入現在將發" -"出 :exc:`DeprecationWarning`。這些子模組自 Python 3.8 起已被棄用,並將在未來" -"版本的 Python 中刪除。屬於這些子模組的任何內容都應該直接從 :mod:`typing` 引" -"入。 (由 Sebastian Rittau 在 :issue:`38291` 中貢獻。)" +"從 ``typing.io`` 和 ``typing.re`` 子模組引入現在將發出 :exc:" +"`DeprecationWarning`。這些子模組自 Python 3.8 起已被棄用,並將在未來版本的 " +"Python 中刪除。屬於這些子模組的任何內容都應該直接從 :mod:`typing` 引入。 " +"(由 Sebastian Rittau 在 :issue:`38291` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1501 +#: ../../whatsnew/3.10.rst:1502 msgid "unittest" msgstr "unittest" -#: ../../whatsnew/3.10.rst:1503 +#: ../../whatsnew/3.10.rst:1504 msgid "" "Add new method :meth:`~unittest.TestCase.assertNoLogs` to complement the " "existing :meth:`~unittest.TestCase.assertLogs`. (Contributed by Kit Yan Choi " "in :issue:`39385`.)" msgstr "" -"新增方法 :meth:`~unittest.TestCase.assertNoLogs` 以補足現有" -"的 :meth:`~unittest.TestCase.assertLogs`。(由 Kit Yan Choi " -"在 :issue:`39385` 中貢獻。)" +"新增方法 :meth:`~unittest.TestCase.assertNoLogs` 以補足現有的 :meth:" +"`~unittest.TestCase.assertLogs`。(由 Kit Yan Choi 在 :issue:`39385` 中貢" +"獻。)" -#: ../../whatsnew/3.10.rst:1508 +#: ../../whatsnew/3.10.rst:1509 msgid "urllib.parse" msgstr "urllib.parse" -#: ../../whatsnew/3.10.rst:1510 +#: ../../whatsnew/3.10.rst:1511 msgid "" "Python versions earlier than Python 3.10 allowed using both ``;`` and ``&`` " -"as query parameter separators in :func:`urllib.parse.parse_qs` " -"and :func:`urllib.parse.parse_qsl`. Due to security concerns, and to " -"conform with newer W3C recommendations, this has been changed to allow only " -"a single separator key, with ``&`` as the default. This change also " -"affects :func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the " -"affected functions internally. For more details, please see their " -"respective documentation. (Contributed by Adam Goldschmidt, Senthil Kumaran " -"and Ken Jin in :issue:`42967`.)" -msgstr "" -"Python 3.10 之前的 Python 版本允許在 :func:`urllib.parse.parse_qs` " -"和 :func:`urllib.parse.parse_qsl` 中使用 ``;`` 和 ``&`` 作為查詢參數 (query " +"as query parameter separators in :func:`urllib.parse.parse_qs` and :func:" +"`urllib.parse.parse_qsl`. Due to security concerns, and to conform with " +"newer W3C recommendations, this has been changed to allow only a single " +"separator key, with ``&`` as the default. This change also affects :func:`!" +"cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected " +"functions internally. For more details, please see their respective " +"documentation. (Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin " +"in :issue:`42967`.)" +msgstr "" +"Python 3.10 之前的 Python 版本允許在 :func:`urllib.parse.parse_qs` 和 :func:" +"`urllib.parse.parse_qsl` 中使用 ``;`` 和 ``&`` 作為查詢參數 (query " "parameter) 的分隔符號。出於安全考慮,並且為了符合更新的 W3C 建議,已將其更改" -"為僅允許單個分隔符號鍵,預設為 ``&``。此更改還會影響 :func:`!cgi.parse` " -"和 :func:`!cgi.parse_multipart`,因為它們在內部使用受影響的函式。有關更多詳細" -"資訊,請參閱各自的文件。(由 Adam Goldschmidt、Senthil Kumaran 和 Ken Jin " -"在 :issue:`42967` 中貢獻。)" +"為僅允許單個分隔符號鍵,預設為 ``&``。此更改還會影響 :func:`!cgi.parse` 和 :" +"func:`!cgi.parse_multipart`,因為它們在內部使用受影響的函式。有關更多詳細資" +"訊,請參閱各自的文件。(由 Adam Goldschmidt、Senthil Kumaran 和 Ken Jin 在 :" +"issue:`42967` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1520 +#: ../../whatsnew/3.10.rst:1521 msgid "" "The presence of newline or tab characters in parts of a URL allows for some " -"forms of attacks. Following the WHATWG specification that " -"updates :rfc:`3986`, ASCII newline ``\\n``, ``\\r`` and tab ``\\t`` " -"characters are stripped from the URL by the parser in :mod:`urllib.parse` " -"preventing such attacks. The removal characters are controlled by a new " -"module level variable ``urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE``. " -"(See :gh:`88048`)" +"forms of attacks. Following the WHATWG specification that updates :rfc:" +"`3986`, ASCII newline ``\\n``, ``\\r`` and tab ``\\t`` characters are " +"stripped from the URL by the parser in :mod:`urllib.parse` preventing such " +"attacks. The removal characters are controlled by a new module level " +"variable ``urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE``. (See :gh:`88048`)" msgstr "" -#: ../../whatsnew/3.10.rst:1528 +#: ../../whatsnew/3.10.rst:1529 msgid "xml" msgstr "xml" -#: ../../whatsnew/3.10.rst:1530 +#: ../../whatsnew/3.10.rst:1531 msgid "" -"Add a :class:`~xml.sax.handler.LexicalHandler` class to " -"the :mod:`xml.sax.handler` module. (Contributed by Jonathan Gossage and " -"Zackery Spytz in :issue:`35018`.)" +"Add a :class:`~xml.sax.handler.LexicalHandler` class to the :mod:`xml.sax." +"handler` module. (Contributed by Jonathan Gossage and Zackery Spytz in :" +"issue:`35018`.)" msgstr "" "新增 :class:`~xml.sax.handler.LexicalHandler` 類別到 :mod:`xml.sax.handler` " "模組。(由 Jonathan Gossage 和 Zackery Spytz 在 :issue:`35018` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1535 +#: ../../whatsnew/3.10.rst:1536 msgid "zipimport" msgstr "zipimport" -#: ../../whatsnew/3.10.rst:1536 +#: ../../whatsnew/3.10.rst:1537 msgid "" -"Add methods related " -"to :pep:`451`: :meth:`~zipimport.zipimporter.find_spec`, :meth:`zipimport.zipimporter.create_module`, " -"and :meth:`zipimport.zipimporter.exec_module`. (Contributed by Brett Cannon " -"in :issue:`42131`.)" +"Add methods related to :pep:`451`: :meth:`~zipimport.zipimporter." +"find_spec`, :meth:`zipimport.zipimporter.create_module`, and :meth:" +"`zipimport.zipimporter.exec_module`. (Contributed by Brett Cannon in :issue:" +"`42131`.)" msgstr "" -"新增與 :pep:`451` 相關的方" -"法::meth:`~zipimport.zipimporter.find_spec`、:meth:`zipimport.zipimporter.create_module` " -"和 :meth:`zipimport.zipimporter.exec_module`。(由 Brett Cannon " -"在 :issue:`42131` 中貢獻。)" +"新增與 :pep:`451` 相關的方法::meth:`~zipimport.zipimporter.find_spec`、:" +"meth:`zipimport.zipimporter.create_module` 和 :meth:`zipimport.zipimporter." +"exec_module`。(由 Brett Cannon 在 :issue:`42131` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1541 +#: ../../whatsnew/3.10.rst:1542 msgid "" "Add :meth:`~zipimport.zipimporter.invalidate_caches` method. (Contributed by " "Desmond Cheong in :issue:`14678`.)" @@ -2964,33 +2944,33 @@ msgstr "" "新增 :meth:`~zipimport.zipimporter.invalidate_caches` 方法。(由 Desmond " "Cheong 在 :issue:`14678` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1546 +#: ../../whatsnew/3.10.rst:1547 msgid "Optimizations" msgstr "最佳化" -#: ../../whatsnew/3.10.rst:1548 +#: ../../whatsnew/3.10.rst:1549 msgid "" "Constructors :func:`str`, :func:`bytes` and :func:`bytearray` are now faster " -"(around 30--40% for small objects). (Contributed by Serhiy Storchaka " -"in :issue:`41334`.)" +"(around 30--40% for small objects). (Contributed by Serhiy Storchaka in :" +"issue:`41334`.)" msgstr "" "建構函式 :func:`str`、:func:`bytes` 和 :func:`bytearray` 現在更快了(對於小型" "物件大約快了 30--40%)。(由 Serhiy Storchaka 在 :issue:`41334` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1552 +#: ../../whatsnew/3.10.rst:1553 msgid "" "The :mod:`runpy` module now imports fewer modules. The ``python3 -m module-" -"name`` command startup time is 1.4x faster in average. On Linux, ``python3 " -"-I -m module-name`` imports 69 modules on Python 3.9, whereas it only " -"imports 51 modules (-18) on Python 3.10. (Contributed by Victor Stinner " -"in :issue:`41006` and :issue:`41718`.)" +"name`` command startup time is 1.4x faster in average. On Linux, ``python3 -" +"I -m module-name`` imports 69 modules on Python 3.9, whereas it only imports " +"51 modules (-18) on Python 3.10. (Contributed by Victor Stinner in :issue:" +"`41006` and :issue:`41718`.)" msgstr "" ":mod:`runpy` 模組現在引入更少的模組。``python3 -m module-name`` 指令啟動時間" "平均快了 1.4 倍。在 Linux 上,``python3 -I -m module-name`` 在 Python 3.9 上" "引入 69 個模組,而在 Python 3.10 上僅引入 51 個模組 (-18)。(由 Victor " "Stinner 在 :issue:`41006` 和 :issue:`41718` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1558 +#: ../../whatsnew/3.10.rst:1559 msgid "" "The ``LOAD_ATTR`` instruction now uses new \"per opcode cache\" mechanism. " "It is about 36% faster now for regular attributes and 44% faster for slots. " @@ -3003,15 +2983,15 @@ msgstr "" "Yury Selivanov 在 :issue:`42093` 中以及 Guido van Rossum 在 :issue:`42927` 中" "貢獻,基於最初在 PyPy 和 MicroPython 中實作的想法。)" -#: ../../whatsnew/3.10.rst:1564 +#: ../../whatsnew/3.10.rst:1565 msgid "" "When building Python with :option:`--enable-optimizations` now ``-fno-" "semantic-interposition`` is added to both the compile and link line. This " "speeds builds of the Python interpreter created with :option:`--enable-" -"shared` with ``gcc`` by up to 30%. See `this article `_ for more details. (Contributed by Victor " -"Stinner and Pablo Galindo in :issue:`38980`.)" +"shared` with ``gcc`` by up to 30%. See `this article `_ for more details. (Contributed by Victor Stinner " +"and Pablo Galindo in :issue:`38980`.)" msgstr "" "當使用 :option:`--enable-optimizations` 建置 Python 時,現在 ``-fno-semantic-" "interposition`` 被新增到編譯和鏈接列 (link line) 中。這使得使用 :option:`--" @@ -3020,22 +3000,22 @@ msgstr "" "linux-8-2-brings-faster-python-3-8-run-speeds/>`_ 以了解詳情。(由 Victor " "Stinner 和 Pablo Galindo 在 :issue:`38980` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1572 +#: ../../whatsnew/3.10.rst:1573 msgid "" -"Use a new output buffer management code " -"for :mod:`bz2` / :mod:`lzma` / :mod:`zlib` modules, and add ``.readall()`` " -"function to ``_compression.DecompressReader`` class. bz2 decompression is " -"now 1.09x ~ 1.17x faster, lzma decompression 1.20x ~ 1.32x faster, " -"``GzipFile.read(-1)`` 1.11x ~ 1.18x faster. (Contributed by Ma Lin, reviewed " -"by Gregory P. Smith, in :issue:`41486`)" +"Use a new output buffer management code for :mod:`bz2` / :mod:`lzma` / :mod:" +"`zlib` modules, and add ``.readall()`` function to ``_compression." +"DecompressReader`` class. bz2 decompression is now 1.09x ~ 1.17x faster, " +"lzma decompression 1.20x ~ 1.32x faster, ``GzipFile.read(-1)`` 1.11x ~ 1.18x " +"faster. (Contributed by Ma Lin, reviewed by Gregory P. Smith, in :issue:" +"`41486`)" msgstr "" "對 :mod:`bz2` / :mod:`lzma` / :mod:`zlib` 模組使用新的輸出緩衝區管理程式碼," "並將 ``.readall()`` 函式新增到 ``_compression.DecompressReader`` 類別。 bz2 " "解壓縮速度提高了 1.09x ~ 1.17x,lzma 解壓縮速度提高了 1.20x ~ 1.32x," -"``GzipFile.read(-1)`` 速度提高了 1.11x ~ 1.18x。(由 Ma Lin " -"於 :issue:`41486` 貢獻、由 Gregory P. Smith 審閱)" +"``GzipFile.read(-1)`` 速度提高了 1.11x ~ 1.18x。(由 Ma Lin 於 :issue:" +"`41486` 貢獻、由 Gregory P. Smith 審閱)" -#: ../../whatsnew/3.10.rst:1578 +#: ../../whatsnew/3.10.rst:1579 msgid "" "When using stringized annotations, annotations dicts for functions are no " "longer created when the function is created. Instead, they are stored as a " @@ -3049,7 +3029,7 @@ msgstr "" "最佳化將定義帶有註釋的函式所需的 CPU 時間減少了一半。(由 Yurii Karabas 和 " "Inada Naoki 在 :issue:`42202` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1585 +#: ../../whatsnew/3.10.rst:1586 msgid "" "Substring search functions such as ``str1 in str2`` and ``str2.find(str1)`` " "now sometimes use Crochemore & Perrin's \"Two-Way\" string searching " @@ -3060,33 +3040,31 @@ msgstr "" "用 Crochemore & Perrin 的「雙向」字串搜尋演算法來避免作用於長字串上時發生二次" "方行為 (quadratic behavior)。(由 Dennis Sweeney 在 :issue:`41972` 中貢獻)" -#: ../../whatsnew/3.10.rst:1590 +#: ../../whatsnew/3.10.rst:1591 msgid "" "Add micro-optimizations to ``_PyType_Lookup()`` to improve type attribute " "cache lookup performance in the common case of cache hits. This makes the " -"interpreter 1.04 times faster on average. (Contributed by Dino Viehland " -"in :issue:`43452`.)" +"interpreter 1.04 times faster on average. (Contributed by Dino Viehland in :" +"issue:`43452`.)" msgstr "" "向 ``_PyType_Lookup()`` 新增微最佳化以提高快取命中的常見情況下的型別屬性快取" -"查找性能。這使得直譯器平均速度提高了 1.04 倍。(由 Dino Viehland " -"在 :issue:`43452` 中貢獻。)" +"查找性能。這使得直譯器平均速度提高了 1.04 倍。(由 Dino Viehland 在 :issue:" +"`43452` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1594 +#: ../../whatsnew/3.10.rst:1595 msgid "" "The following built-in functions now support the faster :pep:`590` " -"vectorcall calling " -"convention: :func:`map`, :func:`filter`, :func:`reversed`, :func:`bool` " -"and :func:`float`. (Contributed by Donghee Na and Jeroen Demeyer " -"in :issue:`43575`, :issue:`43287`, :issue:`41922`, :issue:`41873` " -"and :issue:`41870`.)" +"vectorcall calling convention: :func:`map`, :func:`filter`, :func:" +"`reversed`, :func:`bool` and :func:`float`. (Contributed by Donghee Na and " +"Jeroen Demeyer in :issue:`43575`, :issue:`43287`, :issue:`41922`, :issue:" +"`41873` and :issue:`41870`.)" msgstr "" -"以下內建函式現在支援更快的 :pep:`590` vectorcall 呼叫慣" -"例::func:`map`、:func:`filter`、:func:`reversed`、:func:`bool` " -"和 :func:`float`。(由 Donghee Na 和 Jeroen Demeyer " -"在 :issue:`43575`、:issue:`43287`、:issue:`41922`、:issue:`41873` " -"和 :issue:`41870` 中貢獻。)" +"以下內建函式現在支援更快的 :pep:`590` vectorcall 呼叫慣例::func:`map`、:" +"func:`filter`、:func:`reversed`、:func:`bool` 和 :func:`float`。(由 Donghee " +"Na 和 Jeroen Demeyer 在 :issue:`43575`、:issue:`43287`、:issue:`41922`、:" +"issue:`41873` 和 :issue:`41870` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1598 +#: ../../whatsnew/3.10.rst:1599 msgid "" ":class:`~bz2.BZ2File` performance is improved by removing internal " "``RLock``. This makes :class:`!BZ2File` thread unsafe in the face of " @@ -3094,64 +3072,62 @@ msgid "" "in :mod:`gzip` and :mod:`lzma` have always been. (Contributed by Inada " "Naoki in :issue:`43785`.)" msgstr "" -"通過刪除內部 ``RLock``,:class:`~bz2.BZ2File` 的性能得到了改進。這使" -"得 :class:`!BZ2File` 在面對多個同時的讀取器或寫入器時執行緒不安全,就" -"像 :mod:`gzip` 和 :mod:`lzma` 中的等效類別一樣。(由 Inada Naoki " -"在 :issue:`43785` 中貢獻。)" +"通過刪除內部 ``RLock``,:class:`~bz2.BZ2File` 的性能得到了改進。這使得 :" +"class:`!BZ2File` 在面對多個同時的讀取器或寫入器時執行緒不安全,就像 :mod:" +"`gzip` 和 :mod:`lzma` 中的等效類別一樣。(由 Inada Naoki 在 :issue:`43785` 中" +"貢獻。)" -#: ../../whatsnew/3.10.rst:1606 ../../whatsnew/3.10.rst:2212 +#: ../../whatsnew/3.10.rst:1607 ../../whatsnew/3.10.rst:2213 msgid "Deprecated" msgstr "已棄用" -#: ../../whatsnew/3.10.rst:1608 +#: ../../whatsnew/3.10.rst:1609 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " "ambiguous expressions like ``[0x1for x in y]`` (which can be interpreted as " "``[0x1 for x in y]`` or ``[0x1f or x in y]``). Starting in this release, a " "deprecation warning is raised if the numeric literal is immediately followed " -"by one of " -"keywords :keyword:`and`, :keyword:`else`, :keyword:`for`, :keyword:`if`, :keyword:`in`, :keyword:`is` " -"and :keyword:`or`. In future releases it will be changed to syntax warning, " -"and finally to syntax error. (Contributed by Serhiy Storchaka " -"in :issue:`43833`.)" +"by one of keywords :keyword:`and`, :keyword:`else`, :keyword:`for`, :keyword:" +"`if`, :keyword:`in`, :keyword:`is` and :keyword:`or`. In future releases it " +"will be changed to syntax warning, and finally to syntax error. (Contributed " +"by Serhiy Storchaka in :issue:`43833`.)" msgstr "" "目前 Python 接受緊跟關鍵字的數字字面值 (numeric literals),例如 ``0in x``、" "``1or x``、``0if 1else 2``。它允許了令人困惑和不明確的運算式,例如 ``[0x1for " "x in y]`` (可以直譯為 ``[0x1 for x in y]`` 或 ``[0x1f or x in y]`` )。從此" -"版本開始,如果數字字面值後緊跟關鍵" -"字 :keyword:`and`、:keyword:`else`、:keyword:`for`、:keyword:`if`、:keyword:`in`、:keyword:`is` " -"與 :keyword:`or` 其中之一,則會引發棄用警告。在未來的版本中,它將被變更為語法" -"警告,最後成為為語法錯誤。(由 Serhiy Storchaka 在 :issue:`43833` 中貢獻。)" +"版本開始,如果數字字面值後緊跟關鍵字 :keyword:`and`、:keyword:`else`、:" +"keyword:`for`、:keyword:`if`、:keyword:`in`、:keyword:`is` 與 :keyword:`or` " +"其中之一,則會引發棄用警告。在未來的版本中,它將被變更為語法警告,最後成為為" +"語法錯誤。(由 Serhiy Storchaka 在 :issue:`43833` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1619 +#: ../../whatsnew/3.10.rst:1620 msgid "" "Starting in this release, there will be a concerted effort to begin cleaning " "up old import semantics that were kept for Python 2.7 compatibility. " -"Specifically, :meth:`!find_loader`/:meth:`!find_module` (superseded " -"by :meth:`~importlib.abc.MetaPathFinder.find_spec`), :meth:`~importlib.abc.Loader.load_module` " -"(superseded by :meth:`~importlib.abc.Loader.exec_module`), :meth:`!" -"module_repr` (which the import system takes care of for you), the " +"Specifically, :meth:`!find_loader`/:meth:`!find_module` (superseded by :meth:" +"`~importlib.abc.MetaPathFinder.find_spec`), :meth:`~importlib.abc.Loader." +"load_module` (superseded by :meth:`~importlib.abc.Loader.exec_module`), :" +"meth:`!module_repr` (which the import system takes care of for you), the " "``__package__`` attribute (superseded by ``__spec__.parent``), the " "``__loader__`` attribute (superseded by ``__spec__.loader``), and the " "``__cached__`` attribute (superseded by ``__spec__.cached``) will slowly be " -"removed (as well as other classes and methods " -"in :mod:`importlib`). :exc:`ImportWarning` and/or :exc:`DeprecationWarning` " -"will be raised as appropriate to help identify code which needs updating " -"during this transition." +"removed (as well as other classes and methods in :mod:`importlib`). :exc:" +"`ImportWarning` and/or :exc:`DeprecationWarning` will be raised as " +"appropriate to help identify code which needs updating during this " +"transition." msgstr "" "從這個版本開始,我們將齊心協力開始清理為相容 Python 2.7 而保留的舊引入語義。" -"具體來說, :meth:`!find_loader`/:meth:`!find_module` " -"(被 :meth:`~importlib.abc.MetaPathFinder.find_spec` 取" -"代)、:meth:`~importlib.abc.Loader.load_module` " -"(被 :meth:`~importlib.abc.Loader.exec_module` 取代)、 :meth:`!module_repr` " -"(引入系統負責處理你)、``__package__`` 屬性(由 ``__spec__.parent`` 取" -"代)、 ``__loader__`` 屬性(由 ``__spec__.loader`` 取代)和 ``__cached__`` 屬" -"性(由 ``__spec__.cached`` 取代)將慢慢被刪除(以及 :mod:`importlib` 中的其他" -"類別和方法)。將酌情引發 :exc:`ImportWarning` 和/" -"或 :exc:`DeprecationWarning` 以幫助識別在此轉換期間需要更新的程式碼。" - -#: ../../whatsnew/3.10.rst:1636 +"具體來說, :meth:`!find_loader`/:meth:`!find_module` (被 :meth:`~importlib." +"abc.MetaPathFinder.find_spec` 取代)、:meth:`~importlib.abc.Loader." +"load_module` (被 :meth:`~importlib.abc.Loader.exec_module` 取代)、 :meth:`!" +"module_repr` (引入系統負責處理你)、``__package__`` 屬性(由 ``__spec__." +"parent`` 取代)、 ``__loader__`` 屬性(由 ``__spec__.loader`` 取代)和 " +"``__cached__`` 屬性(由 ``__spec__.cached`` 取代)將慢慢被刪除(以及 :mod:" +"`importlib` 中的其他類別和方法)。將酌情引發 :exc:`ImportWarning` 和/或 :exc:" +"`DeprecationWarning` 以幫助識別在此轉換期間需要更新的程式碼。" + +#: ../../whatsnew/3.10.rst:1637 msgid "" "The entire ``distutils`` namespace is deprecated, to be removed in Python " "3.12. Refer to the :ref:`module changes ` section for " @@ -3160,50 +3136,47 @@ msgstr "" "整個 ``distutils`` 命名空間已棄用,將在 Python 3.12 中刪除。請參閱\\ :ref:`模" "組更改 ` 以取得更多資訊。" -#: ../../whatsnew/3.10.rst:1640 +#: ../../whatsnew/3.10.rst:1641 msgid "" -"Non-integer arguments to :func:`random.randrange` are deprecated. " -"The :exc:`ValueError` is deprecated in favor of a :exc:`TypeError`. " -"(Contributed by Serhiy Storchaka and Raymond Hettinger in :issue:`37319`.)" +"Non-integer arguments to :func:`random.randrange` are deprecated. The :exc:" +"`ValueError` is deprecated in favor of a :exc:`TypeError`. (Contributed by " +"Serhiy Storchaka and Raymond Hettinger in :issue:`37319`.)" msgstr "" ":func:`random.randrange` 的非整數引數已棄用。:exc:`ValueError` 已被棄用,取而" -"代之的是 :exc:`TypeError`。(由 Serhiy Storchaka 和 Raymond Hettinger " -"在 :issue:`37319` 中貢獻。)" +"代之的是 :exc:`TypeError`。(由 Serhiy Storchaka 和 Raymond Hettinger 在 :" +"issue:`37319` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1644 +#: ../../whatsnew/3.10.rst:1645 msgid "" "The various ``load_module()`` methods of :mod:`importlib` have been " -"documented as deprecated since Python 3.6, but will now also trigger " -"a :exc:`DeprecationWarning`. Use :meth:`~importlib.abc.Loader.exec_module` " -"instead. (Contributed by Brett Cannon in :issue:`26131`.)" +"documented as deprecated since Python 3.6, but will now also trigger a :exc:" +"`DeprecationWarning`. Use :meth:`~importlib.abc.Loader.exec_module` instead. " +"(Contributed by Brett Cannon in :issue:`26131`.)" msgstr "" ":mod:`importlib` 的各種 ``load_module()`` 方法自 Python 3.6 起已被記錄為已棄" -"用,但現在也會觸發 :exc:`DeprecationWarning`。請改" -"用 :meth:`~importlib.abc.Loader.exec_module`。(由 Brett Cannon " -"在 :issue:`26131` 中貢獻。)" +"用,但現在也會觸發 :exc:`DeprecationWarning`。請改用 :meth:`~importlib.abc." +"Loader.exec_module`。(由 Brett Cannon 在 :issue:`26131` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1650 +#: ../../whatsnew/3.10.rst:1651 msgid "" ":meth:`!zimport.zipimporter.load_module` has been deprecated in preference " "for :meth:`~zipimport.zipimporter.exec_module`. (Contributed by Brett Cannon " "in :issue:`26131`.)" msgstr "" -":meth:`!zimport.zipimporter.load_module` 已被棄用,請" -"用 :meth:`~zipimport.zipimporter.exec_module`。(由 Brett Cannon " -"在 :issue:`26131` 中貢獻。)" +":meth:`!zimport.zipimporter.load_module` 已被棄用,請用 :meth:`~zipimport." +"zipimporter.exec_module`。(由 Brett Cannon 在 :issue:`26131` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1654 +#: ../../whatsnew/3.10.rst:1655 msgid "" "The use of :meth:`~importlib.abc.Loader.load_module` by the import system " -"now triggers an :exc:`ImportWarning` " -"as :meth:`~importlib.abc.Loader.exec_module` is preferred. (Contributed by " -"Brett Cannon in :issue:`26131`.)" +"now triggers an :exc:`ImportWarning` as :meth:`~importlib.abc.Loader." +"exec_module` is preferred. (Contributed by Brett Cannon in :issue:`26131`.)" msgstr "" -"引入系統使用 :meth:`~importlib.abc.Loader.load_module` 現在會觸" -"發 :exc:`ImportWarning`,因為 :meth:`~importlib.abc.Loader.exec_module` 是目" -"前首選。(由 Brett Cannon 在 :issue:`26131` 中貢獻。)" +"引入系統使用 :meth:`~importlib.abc.Loader.load_module` 現在會觸發 :exc:" +"`ImportWarning`,因為 :meth:`~importlib.abc.Loader.exec_module` 是目前首選。" +"(由 Brett Cannon 在 :issue:`26131` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1659 +#: ../../whatsnew/3.10.rst:1660 msgid "" "The use of :meth:`!importlib.abc.MetaPathFinder.find_module` and :meth:`!" "importlib.abc.PathEntryFinder.find_module` by the import system now trigger " @@ -3214,88 +3187,80 @@ msgid "" msgstr "" "引入系統使用 :meth:`!importlib.abc.MetaPathFinder.find_module` 和 :meth:`!" "importlib.abc.PathEntryFinder.find_module` 現在會觸發 :exc:`ImportWarning`," -"因為 :meth:`importlib.abc.MetaPathFinder.find_spec` " -"和 :meth:`importlib.abc.PathEntryFinder.find_spec` 分別是替代方案的首選。你可" -"以使用 :func:`importlib.util.spec_from_loader` 來幫助移植。(由 Brett Cannon " -"在 :issue:`42134` 中貢獻。)" +"因為 :meth:`importlib.abc.MetaPathFinder.find_spec` 和 :meth:`importlib.abc." +"PathEntryFinder.find_spec` 分別是替代方案的首選。你可以使用 :func:`importlib." +"util.spec_from_loader` 來幫助移植。(由 Brett Cannon 在 :issue:`42134` 中貢" +"獻。)" -#: ../../whatsnew/3.10.rst:1668 +#: ../../whatsnew/3.10.rst:1669 msgid "" "The use of :meth:`!importlib.abc.PathEntryFinder.find_loader` by the import " -"system now triggers an :exc:`ImportWarning` " -"as :meth:`importlib.abc.PathEntryFinder.find_spec` is preferred. You can " -"use :func:`importlib.util.spec_from_loader` to help in porting. (Contributed " -"by Brett Cannon in :issue:`43672`.)" -msgstr "" -"引入系統使用 :meth:`!importlib.abc.PathEntryFinder.find_loader` 現在會觸" -"發 :exc:`ImportWarning`,因" -"為 :meth:`importlib.abc.PathEntryFinder.find_spec` 是首選。你可以使" -"用 :func:`importlib.util.spec_from_loader` 來幫助移植。(由 Brett Cannon " -"在 :issue:`43672` 中貢獻。)" - -#: ../../whatsnew/3.10.rst:1674 -msgid "" -"The various implementations of :meth:`!" -"importlib.abc.MetaPathFinder.find_module` ( :meth:`!" -"importlib.machinery.BuiltinImporter.find_module`, :meth:`!" -"importlib.machinery.FrozenImporter.find_module`, :meth:`!" -"importlib.machinery.WindowsRegistryFinder.find_module`, :meth:`!" -"importlib.machinery.PathFinder.find_module`, :meth:`!" -"importlib.abc.MetaPathFinder.find_module` ), :meth:`!" -"importlib.abc.PathEntryFinder.find_module` ( :meth:`!" -"importlib.machinery.FileFinder.find_module` ), and :meth:`!" -"importlib.abc.PathEntryFinder.find_loader` ( :meth:`!" -"importlib.machinery.FileFinder.find_loader` ) now " -"raise :exc:`DeprecationWarning` and are slated for removal in Python 3.12 " -"(previously they were documented as deprecated in Python 3.4). (Contributed " -"by Brett Cannon in :issue:`42135`.)" +"system now triggers an :exc:`ImportWarning` as :meth:`importlib.abc." +"PathEntryFinder.find_spec` is preferred. You can use :func:`importlib.util." +"spec_from_loader` to help in porting. (Contributed by Brett Cannon in :issue:" +"`43672`.)" +msgstr "" +"引入系統使用 :meth:`!importlib.abc.PathEntryFinder.find_loader` 現在會觸發 :" +"exc:`ImportWarning`,因為 :meth:`importlib.abc.PathEntryFinder.find_spec` 是" +"首選。你可以使用 :func:`importlib.util.spec_from_loader` 來幫助移植。(由 " +"Brett Cannon 在 :issue:`43672` 中貢獻。)" + +#: ../../whatsnew/3.10.rst:1675 +msgid "" +"The various implementations of :meth:`!importlib.abc.MetaPathFinder." +"find_module` ( :meth:`!importlib.machinery.BuiltinImporter.find_module`, :" +"meth:`!importlib.machinery.FrozenImporter.find_module`, :meth:`!importlib." +"machinery.WindowsRegistryFinder.find_module`, :meth:`!importlib.machinery." +"PathFinder.find_module`, :meth:`!importlib.abc.MetaPathFinder." +"find_module` ), :meth:`!importlib.abc.PathEntryFinder.find_module` ( :meth:`!" +"importlib.machinery.FileFinder.find_module` ), and :meth:`!importlib.abc." +"PathEntryFinder.find_loader` ( :meth:`!importlib.machinery.FileFinder." +"find_loader` ) now raise :exc:`DeprecationWarning` and are slated for " +"removal in Python 3.12 (previously they were documented as deprecated in " +"Python 3.4). (Contributed by Brett Cannon in :issue:`42135`.)" msgstr "" ":meth:`!importlib.abc.MetaPathFinder.find_module` 的各種實作(:meth:`!" -"importlib.machinery.BuiltinImporter.find_module`、:meth:`!" -"importlib.machinery.FrozenImporter.find_module`、:meth:`!" -"importlib.machinery.WindowsRegistryFinder.find_module`、:meth:`!" -"importlib.machinery.PathFinder.find_module`、:meth:`!" -"importlib.abc.MetaPathFinder.find_module` )、:meth:`!" -"importlib.abc.PathEntryFinder.find_module` (:meth:`!" -"importlib.machinery.FileFinder.find_module` ) 和 :meth:`!" -"importlib.abc.PathEntryFinder.find_loader` (:meth:`!" -"importlib.machinery.FileFinder.find_loader` ) 現在引" +"importlib.machinery.BuiltinImporter.find_module`、:meth:`!importlib." +"machinery.FrozenImporter.find_module`、:meth:`!importlib.machinery." +"WindowsRegistryFinder.find_module`、:meth:`!importlib.machinery.PathFinder." +"find_module`、:meth:`!importlib.abc.MetaPathFinder.find_module` )、:meth:`!" +"importlib.abc.PathEntryFinder.find_module` (:meth:`!importlib.machinery." +"FileFinder.find_module` ) 和 :meth:`!importlib.abc.PathEntryFinder." +"find_loader` (:meth:`!importlib.machinery.FileFinder.find_loader` ) 現在引" "發 :exc:`DeprecationWarning` 並計劃在 Python 3.12 中刪除(之前它們已在 " "Python 3.4 中被記錄為已棄用)。(由 Brett Cannon 在 :issue:`42135` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1689 +#: ../../whatsnew/3.10.rst:1690 msgid "" -":class:`!importlib.abc.Finder` is deprecated (including its sole " -"method, :meth:`!find_module`). Both :class:`importlib.abc.MetaPathFinder` " -"and :class:`importlib.abc.PathEntryFinder` no longer inherit from the class. " -"Users should inherit from one of these two classes as appropriate instead. " +":class:`!importlib.abc.Finder` is deprecated (including its sole method, :" +"meth:`!find_module`). Both :class:`importlib.abc.MetaPathFinder` and :class:" +"`importlib.abc.PathEntryFinder` no longer inherit from the class. Users " +"should inherit from one of these two classes as appropriate instead. " "(Contributed by Brett Cannon in :issue:`42135`.)" msgstr "" ":class:`!importlib.abc.Finder` 已被棄用(包括其唯一方法 :meth:`!" -"find_module`)。:class:`importlib.abc.MetaPathFinder` " -"和 :class:`importlib.abc.PathEntryFinder` 都不再從該類別繼承。使用者應該根據" -"需求來選擇其一以繼承。(由 Brett Cannon 在 :issue:`42135` 中貢獻。)" +"find_module`)。:class:`importlib.abc.MetaPathFinder` 和 :class:`importlib." +"abc.PathEntryFinder` 都不再從該類別繼承。使用者應該根據需求來選擇其一以繼承。" +"(由 Brett Cannon 在 :issue:`42135` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1696 +#: ../../whatsnew/3.10.rst:1697 msgid "" "The deprecations of :mod:`!imp`, :func:`!importlib.find_loader`, :func:`!" -"importlib.util.set_package_wrapper`, :func:`!" -"importlib.util.set_loader_wrapper`, :func:`!" -"importlib.util.module_for_loader`, :class:`!pkgutil.ImpImporter`, " -"and :class:`!pkgutil.ImpLoader` have all been updated to list Python 3.12 as " -"the slated version of removal (they began raising :exc:`DeprecationWarning` " -"in previous versions of Python). (Contributed by Brett Cannon " -"in :issue:`43720`.)" -msgstr "" -"棄用 :mod:`!imp`、:func:`!importlib.find_loader`、:func:`!" -"importlib.util.set_package_wrapper`、:func:`!" -"importlib.util.set_loader_wrapper`、:func:`!" +"importlib.util.set_package_wrapper`, :func:`!importlib.util." +"set_loader_wrapper`, :func:`!importlib.util.module_for_loader`, :class:`!" +"pkgutil.ImpImporter`, and :class:`!pkgutil.ImpLoader` have all been updated " +"to list Python 3.12 as the slated version of removal (they began raising :" +"exc:`DeprecationWarning` in previous versions of Python). (Contributed by " +"Brett Cannon in :issue:`43720`.)" +msgstr "" +"棄用 :mod:`!imp`、:func:`!importlib.find_loader`、:func:`!importlib.util." +"set_package_wrapper`、:func:`!importlib.util.set_loader_wrapper`、:func:`!" "importlib.util.module_for_loader`、:class:`!pkgutil.ImpImporter` 和 :class:`!" "pkgutil.ImpLoader` 均已更新,將於 Python 3.12 列為預定的刪除版本(它們開始在" -"過去版本的 Python 中引發 :exc:`DeprecationWarning`) 。(由 Brett Cannon " -"在 :issue:`43720` 中貢獻。)" +"過去版本的 Python 中引發 :exc:`DeprecationWarning`) 。(由 Brett Cannon 在 :" +"issue:`43720` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1706 +#: ../../whatsnew/3.10.rst:1707 msgid "" "The import system now uses the ``__spec__`` attribute on modules before " "falling back on :meth:`!module_repr` for a module's ``__repr__()`` method. " @@ -3306,30 +3271,30 @@ msgstr "" "module_repr` 作為模組的 ``__repr__()`` 方法。計劃在 Python 3.12 中刪除 " "``module_repr()`` 的使用。(由 Brett Cannon 在 :issue:`42137` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1712 +#: ../../whatsnew/3.10.rst:1713 msgid "" -":meth:`!importlib.abc.Loader.module_repr`, :meth:`!" -"importlib.machinery.FrozenLoader.module_repr`, and :meth:`!" -"importlib.machinery.BuiltinLoader.module_repr` are deprecated and slated for " -"removal in Python 3.12. (Contributed by Brett Cannon in :issue:`42136`.)" +":meth:`!importlib.abc.Loader.module_repr`, :meth:`!importlib.machinery." +"FrozenLoader.module_repr`, and :meth:`!importlib.machinery.BuiltinLoader." +"module_repr` are deprecated and slated for removal in Python 3.12. " +"(Contributed by Brett Cannon in :issue:`42136`.)" msgstr "" -":meth:`!importlib.abc.Loader.module_repr`、:meth:`!" -"importlib.machinery.FrozenLoader.module_repr` 和 :meth:`!" -"importlib.machinery.BuiltinLoader.module_repr` 已棄用並計劃在 Python 3.12 中" -"刪除。(由 Brett Cannon 在 :issue:`42136` 中貢獻。)" +":meth:`!importlib.abc.Loader.module_repr`、:meth:`!importlib.machinery." +"FrozenLoader.module_repr` 和 :meth:`!importlib.machinery.BuiltinLoader." +"module_repr` 已棄用並計劃在 Python 3.12 中刪除。(由 Brett Cannon 在 :issue:" +"`42136` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1718 +#: ../../whatsnew/3.10.rst:1719 msgid "" "``sqlite3.OptimizedUnicode`` has been undocumented and obsolete since Python " "3.3, when it was made an alias to :class:`str`. It is now deprecated, " -"scheduled for removal in Python 3.12. (Contributed by Erlend E. Aasland " -"in :issue:`42264`.)" +"scheduled for removal in Python 3.12. (Contributed by Erlend E. Aasland in :" +"issue:`42264`.)" msgstr "" "自 Python 3.3 起,``sqlite3.OptimizedUnicode`` 就沒有文件記錄並且已過時,當時" "它被用作 :class:`str` 的別名。它現已被棄用,並計劃在 Python 3.12 中刪除。" "(由 Erlend E. Aasland 在 :issue:`42264` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1723 +#: ../../whatsnew/3.10.rst:1724 msgid "" "The undocumented built-in function ``sqlite3.enable_shared_cache`` is now " "deprecated, scheduled for removal in Python 3.12. Its use is strongly " @@ -3344,67 +3309,67 @@ msgstr "" "使用共享快取,請使用 ``cache=shared`` 查詢參數以 URI 模式打開資料庫。(由 " "Erlend E. Aasland 在 :issue:`24464` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1731 +#: ../../whatsnew/3.10.rst:1732 msgid "The following ``threading`` methods are now deprecated:" msgstr "以下 ``threading`` 方法現已棄用:" -#: ../../whatsnew/3.10.rst:1733 +#: ../../whatsnew/3.10.rst:1734 msgid "``threading.currentThread`` => :func:`threading.current_thread`" msgstr "``threading.currentThread`` => :func:`threading.current_thread`" -#: ../../whatsnew/3.10.rst:1735 +#: ../../whatsnew/3.10.rst:1736 msgid "``threading.activeCount`` => :func:`threading.active_count`" msgstr "``threading.activeCount`` => :func:`threading.active_count`" -#: ../../whatsnew/3.10.rst:1737 +#: ../../whatsnew/3.10.rst:1738 msgid "" "``threading.Condition.notifyAll`` => :meth:`threading.Condition.notify_all`" msgstr "" "``threading.Condition.notifyAll`` => :meth:`threading.Condition.notify_all`" -#: ../../whatsnew/3.10.rst:1740 +#: ../../whatsnew/3.10.rst:1741 msgid "``threading.Event.isSet`` => :meth:`threading.Event.is_set`" msgstr "``threading.Event.isSet`` => :meth:`threading.Event.is_set`" -#: ../../whatsnew/3.10.rst:1742 +#: ../../whatsnew/3.10.rst:1743 msgid "``threading.Thread.setName`` => :attr:`threading.Thread.name`" msgstr "``threading.Thread.setName`` => :attr:`threading.Thread.name`" -#: ../../whatsnew/3.10.rst:1744 +#: ../../whatsnew/3.10.rst:1745 msgid "``threading.thread.getName`` => :attr:`threading.Thread.name`" msgstr "``threading.thread.getName`` => :attr:`threading.Thread.name`" -#: ../../whatsnew/3.10.rst:1746 +#: ../../whatsnew/3.10.rst:1747 msgid "``threading.Thread.isDaemon`` => :attr:`threading.Thread.daemon`" msgstr "``threading.Thread.isDaemon`` => :attr:`threading.Thread.daemon`" -#: ../../whatsnew/3.10.rst:1748 +#: ../../whatsnew/3.10.rst:1749 msgid "``threading.Thread.setDaemon`` => :attr:`threading.Thread.daemon`" msgstr "``threading.Thread.setDaemon`` => :attr:`threading.Thread.daemon`" -#: ../../whatsnew/3.10.rst:1750 +#: ../../whatsnew/3.10.rst:1751 msgid "(Contributed by Jelle Zijlstra in :gh:`87889`.)" msgstr "(由 Jelle Zijlstra 在 :gh:`87889` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1752 +#: ../../whatsnew/3.10.rst:1753 msgid "" ":meth:`!pathlib.Path.link_to` is deprecated and slated for removal in Python " "3.12. Use :meth:`pathlib.Path.hardlink_to` instead. (Contributed by Barney " "Gale in :issue:`39950`.)" msgstr "" -":meth:`!pathlib.Path.link_to` 已棄用並計劃在 Python 3.12 中刪除。請改" -"用 :meth:`pathlib.Path.hardlink_to`。(由 Barney Gale 在 :issue:`39950` 中貢" +":meth:`!pathlib.Path.link_to` 已棄用並計劃在 Python 3.12 中刪除。請改用 :" +"meth:`pathlib.Path.hardlink_to`。(由 Barney Gale 在 :issue:`39950` 中貢" "獻。)" -#: ../../whatsnew/3.10.rst:1756 +#: ../../whatsnew/3.10.rst:1757 msgid "" "``cgi.log()`` is deprecated and slated for removal in Python 3.12. " "(Contributed by Inada Naoki in :issue:`41139`.)" msgstr "" -"``cgi.log()`` 已棄用並計劃在 Python 3.12 中刪除。(由 Inada Naoki " -"在 :issue:`41139` 中貢獻。)" +"``cgi.log()`` 已棄用並計劃在 Python 3.12 中刪除。(由 Inada Naoki 在 :issue:" +"`41139` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1759 +#: ../../whatsnew/3.10.rst:1760 msgid "" "The following :mod:`ssl` features have been deprecated since Python 3.6, " "Python 3.7, or OpenSSL 1.1.0 and will be removed in 3.11:" @@ -3412,53 +3377,51 @@ msgstr "" "自 Python 3.6、Python 3.7 或 OpenSSL 1.1.0 起,以下 :mod:`ssl` 功能已被棄用," "並將在 3.11 中刪除:" -#: ../../whatsnew/3.10.rst:1762 +#: ../../whatsnew/3.10.rst:1763 msgid "" ":data:`!OP_NO_SSLv2`, :data:`!OP_NO_SSLv3`, :data:`!OP_NO_TLSv1`, :data:`!" "OP_NO_TLSv1_1`, :data:`!OP_NO_TLSv1_2`, and :data:`!OP_NO_TLSv1_3` are " -"replaced by :attr:`~ssl.SSLContext.minimum_version` " -"and :attr:`~ssl.SSLContext.maximum_version`." +"replaced by :attr:`~ssl.SSLContext.minimum_version` and :attr:`~ssl." +"SSLContext.maximum_version`." msgstr "" ":data:`!OP_NO_SSLv2`、:data:`!OP_NO_SSLv3`、:data:`!OP_NO_TLSv1`、:data:`!" "OP_NO_TLSv1_1`、:data:`!OP_NO_TLSv1_2`、和 :data:`!OP_NO_TLSv1_3` 已被替換" -"為 :attr:`~ssl.sslSSLContext.minimum_version` " -"和 :attr:`~ssl.sslSSLContext.maximum_version`。" +"為 :attr:`~ssl.sslSSLContext.minimum_version` 和 :attr:`~ssl.sslSSLContext." +"maximum_version`。" -#: ../../whatsnew/3.10.rst:1768 +#: ../../whatsnew/3.10.rst:1769 msgid "" -":data:`!PROTOCOL_SSLv2`, :data:`!PROTOCOL_SSLv3`, :data:`!" -"PROTOCOL_SSLv23`, :data:`!PROTOCOL_TLSv1`, :data:`!" -"PROTOCOL_TLSv1_1`, :data:`!PROTOCOL_TLSv1_2`, and :const:`!PROTOCOL_TLS` are " -"deprecated in favor of :const:`~ssl.PROTOCOL_TLS_CLIENT` " -"and :const:`~ssl.PROTOCOL_TLS_SERVER`" +":data:`!PROTOCOL_SSLv2`, :data:`!PROTOCOL_SSLv3`, :data:`!PROTOCOL_SSLv23`, :" +"data:`!PROTOCOL_TLSv1`, :data:`!PROTOCOL_TLSv1_1`, :data:`!" +"PROTOCOL_TLSv1_2`, and :const:`!PROTOCOL_TLS` are deprecated in favor of :" +"const:`~ssl.PROTOCOL_TLS_CLIENT` and :const:`~ssl.PROTOCOL_TLS_SERVER`" msgstr "" -":data:`!PROTOCOL_SSLv2`、:data:`!PROTOCOL_SSLv3`、:data:`!" -"PROTOCOL_SSLv23`、:data:`!PROTOCOL_TLSv1`、:data:`!" -"PROTOCOL_TLSv1_1`、:data:`!PROTOCOL_TLSv1_2` 和 :const:`!PROTOCOL_TLS` 已棄" -"用,取而代之的是 :const:`~ssl.PROTOCOL_TLS_CLIENT` " -"和 :const:`~ssl.PROTOCOL_TLS_SERVER`" +":data:`!PROTOCOL_SSLv2`、:data:`!PROTOCOL_SSLv3`、:data:`!PROTOCOL_SSLv23`、:" +"data:`!PROTOCOL_TLSv1`、:data:`!PROTOCOL_TLSv1_1`、:data:`!PROTOCOL_TLSv1_2` " +"和 :const:`!PROTOCOL_TLS` 已棄用,取而代之的是 :const:`~ssl." +"PROTOCOL_TLS_CLIENT` 和 :const:`~ssl.PROTOCOL_TLS_SERVER`" -#: ../../whatsnew/3.10.rst:1774 +#: ../../whatsnew/3.10.rst:1775 msgid ":func:`!wrap_socket` is replaced by :meth:`ssl.SSLContext.wrap_socket`" msgstr ":func:`!wrap_socket` 被替換為 :meth:`ssl.SSLContext.wrap_socket`" -#: ../../whatsnew/3.10.rst:1776 +#: ../../whatsnew/3.10.rst:1777 msgid ":func:`!match_hostname`" msgstr ":func:`!match_hostname`" -#: ../../whatsnew/3.10.rst:1778 +#: ../../whatsnew/3.10.rst:1779 msgid ":func:`!RAND_pseudo_bytes`, :func:`!RAND_egd`" msgstr ":func:`!RAND_pseudo_bytes`, :func:`!RAND_egd`" -#: ../../whatsnew/3.10.rst:1780 +#: ../../whatsnew/3.10.rst:1781 msgid "" -"NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` " -"and :meth:`ssl.SSLContext.set_npn_protocols` are replaced by ALPN." +"NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` and :meth:`ssl." +"SSLContext.set_npn_protocols` are replaced by ALPN." msgstr "" -"NPN 功能如 :meth:`ssl.SSLSocket.selected_npn_protocol` " -"和 :meth:`ssl.SSLContext.set_npn_protocols` 已被 ALPN 取代。" +"NPN 功能如 :meth:`ssl.SSLSocket.selected_npn_protocol` 和 :meth:`ssl." +"SSLContext.set_npn_protocols` 已被 ALPN 取代。" -#: ../../whatsnew/3.10.rst:1783 +#: ../../whatsnew/3.10.rst:1784 msgid "" "The threading debug (:envvar:`!PYTHONTHREADDEBUG` environment variable) is " "deprecated in Python 3.10 and will be removed in Python 3.12. This feature " @@ -3469,60 +3432,60 @@ msgstr "" "並將在 Python 3.12 中刪除。此功能需要一個 :ref:`Python 的除錯用建置版本 " "`。(由 Victor Stinner 在 :issue:`44584` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1788 +#: ../../whatsnew/3.10.rst:1789 msgid "" -"Importing from the ``typing.io`` and ``typing.re`` submodules will now " -"emit :exc:`DeprecationWarning`. These submodules will be removed in a " -"future version of Python. Anything belonging to these submodules should be " +"Importing from the ``typing.io`` and ``typing.re`` submodules will now emit :" +"exc:`DeprecationWarning`. These submodules will be removed in a future " +"version of Python. Anything belonging to these submodules should be " "imported directly from :mod:`typing` instead. (Contributed by Sebastian " "Rittau in :issue:`38291`.)" msgstr "" -"從 ``typing.io`` 和 ``typing.re`` 子模組引入現在將發" -"出 :exc:`DeprecationWarning`。這些子模組將在 Python 的未來版本中刪除。屬於這" -"些子模組的任何內容都應該直接從 :mod:`typing` 引入。(由 Sebastian Rittau " -"在 :issue:`38291` 中貢獻。)" +"從 ``typing.io`` 和 ``typing.re`` 子模組引入現在將發出 :exc:" +"`DeprecationWarning`。這些子模組將在 Python 的未來版本中刪除。屬於這些子模組" +"的任何內容都應該直接從 :mod:`typing` 引入。(由 Sebastian Rittau 在 :issue:" +"`38291` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1797 ../../whatsnew/3.10.rst:2220 +#: ../../whatsnew/3.10.rst:1798 ../../whatsnew/3.10.rst:2221 msgid "Removed" msgstr "已刪除" -#: ../../whatsnew/3.10.rst:1799 +#: ../../whatsnew/3.10.rst:1800 msgid "" "Removed special methods ``__int__``, ``__float__``, ``__floordiv__``, " "``__mod__``, ``__divmod__``, ``__rfloordiv__``, ``__rmod__`` and " -"``__rdivmod__`` of the :class:`complex` class. They always raised " -"a :exc:`TypeError`. (Contributed by Serhiy Storchaka in :issue:`41974`.)" +"``__rdivmod__`` of the :class:`complex` class. They always raised a :exc:" +"`TypeError`. (Contributed by Serhiy Storchaka in :issue:`41974`.)" msgstr "" "刪除了 :class:`complex` 類別的特殊方法 ``__int__``、``__float__``、" "``__floordiv__``、``__mod__``、``__divmod__``、``__rfloordiv__``、" "``__rmod__`` 和 ``__rdivmod__`` 。它們都會引發 :exc:`TypeError`。(由 Serhiy " "Storchaka 在 :issue:`41974` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1805 +#: ../../whatsnew/3.10.rst:1806 msgid "" "The ``ParserBase.error()`` method from the private and undocumented " "``_markupbase`` module has been removed. :class:`html.parser.HTMLParser` is " "the only subclass of ``ParserBase`` and its ``error()`` implementation was " -"already removed in Python 3.5. (Contributed by Berker Peksag " -"in :issue:`31844`.)" +"already removed in Python 3.5. (Contributed by Berker Peksag in :issue:" +"`31844`.)" msgstr "" "``_markupbase`` 模組中私有、未於文件記錄的 ``ParserBase.error()`` 方法已被刪" "除。:class:`html.parser.HTMLParser` 是 ``ParserBase`` 的唯一子類別,它的 " "``error()`` 實作已在 Python 3.5 中刪除。(由 Berker Peksag 在 :issue:`31844` " "中貢獻。)" -#: ../../whatsnew/3.10.rst:1811 +#: ../../whatsnew/3.10.rst:1812 msgid "" "Removed the ``unicodedata.ucnhash_CAPI`` attribute which was an internal " "PyCapsule object. The related private ``_PyUnicode_Name_CAPI`` structure was " -"moved to the internal C API. (Contributed by Victor Stinner " -"in :issue:`42157`.)" +"moved to the internal C API. (Contributed by Victor Stinner in :issue:" +"`42157`.)" msgstr "" "刪除了 ``unicodedata.ucnhash_CAPI`` 屬性,該屬性是內部 PyCapsule 物件。相關的" -"私有 ``_PyUnicode_Name_CAPI`` 結構已移至內部 C API。(由 Victor Stinner " -"在 :issue:`42157` 中貢獻。)" +"私有 ``_PyUnicode_Name_CAPI`` 結構已移至內部 C API。(由 Victor Stinner 在 :" +"issue:`42157` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1816 +#: ../../whatsnew/3.10.rst:1817 msgid "" "Removed the ``parser`` module, which was deprecated in 3.9 due to the switch " "to the new PEG parser, as well as all the C source and header files that " @@ -3533,7 +3496,7 @@ msgstr "" "析器使用的所有 C 原始碼和標頭檔也已被刪除,包括 ``node.h``、``parser.h``、" "``graminit.h`` 和 ``grammar.h``。" -#: ../../whatsnew/3.10.rst:1821 +#: ../../whatsnew/3.10.rst:1822 msgid "" "Removed the Public C API functions ``PyParser_SimpleParseStringFlags``, " "``PyParser_SimpleParseStringFlagsFilename``, " @@ -3545,7 +3508,7 @@ msgstr "" "``PyParser_SimpleParseFileFlags`` 和 ``PyNode_Compile``,這些函式由於切換到新" "的 PEG 剖析器而在 3.9 中被棄用。" -#: ../../whatsnew/3.10.rst:1826 +#: ../../whatsnew/3.10.rst:1827 msgid "" "Removed the ``formatter`` module, which was deprecated in Python 3.4. It is " "somewhat obsolete, little used, and not tested. It was originally scheduled " @@ -3558,39 +3521,39 @@ msgstr "" "Python 2.7 EOL 之後。現有使用者應該將他們使用的任何類別複製到他們的程式碼中。" "(由 Donghee Na 和 Terry J. Reedy 在 :issue:`42299` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1833 +#: ../../whatsnew/3.10.rst:1834 msgid "" "Removed the :c:func:`!PyModule_GetWarningsModule` function that was useless " "now due to the :mod:`!_warnings` module was converted to a builtin module in " "2.6. (Contributed by Hai Shi in :issue:`42599`.)" msgstr "" -"刪除了 :c:func:`!PyModule_GetWarningsModule` 函式,該函式現在無用,因" -"為 :mod:`!_warnings` 模組在 2.6 中已轉換為內建模組。(由 Hai Shi " -"在 :issue:`42599` 中貢獻。)" +"刪除了 :c:func:`!PyModule_GetWarningsModule` 函式,該函式現在無用,因為 :mod:" +"`!_warnings` 模組在 2.6 中已轉換為內建模組。(由 Hai Shi 在 :issue:`42599` 中" +"貢獻。)" -#: ../../whatsnew/3.10.rst:1837 +#: ../../whatsnew/3.10.rst:1838 msgid "" "Remove deprecated aliases to :ref:`collections-abstract-base-classes` from " -"the :mod:`collections` module. (Contributed by Victor Stinner " -"in :issue:`37324`.)" +"the :mod:`collections` module. (Contributed by Victor Stinner in :issue:" +"`37324`.)" msgstr "" "從 :mod:`collections` 模組中刪除已棄用的、對 :ref:`collections-abstract-base-" "classes` 的別名。(由 Victor Stinner 在 :issue:`37324` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1841 +#: ../../whatsnew/3.10.rst:1842 msgid "" -"The ``loop`` parameter has been removed from most of :mod:`asyncio`\\ " -"'s :doc:`high-level API <../library/asyncio-api-index>` following " -"deprecation in Python 3.8. The motivation behind this change is multifold:" +"The ``loop`` parameter has been removed from most of :mod:`asyncio`\\ 's :" +"doc:`high-level API <../library/asyncio-api-index>` following deprecation in " +"Python 3.8. The motivation behind this change is multifold:" msgstr "" "在 Python 3.8 中棄用後,``loop`` 參數已從大多數 :mod:`asyncio` 的\\ :doc:`高" "階 API <../library/asyncio-api-index>` 中刪除。這一變化的背後動機是多方面的:" -#: ../../whatsnew/3.10.rst:1845 +#: ../../whatsnew/3.10.rst:1846 msgid "This simplifies the high-level API." msgstr "這簡化了高階 API。" -#: ../../whatsnew/3.10.rst:1846 +#: ../../whatsnew/3.10.rst:1847 msgid "" "The functions in the high-level API have been implicitly getting the current " "thread's running event loop since Python 3.7. There isn't a need to pass " @@ -3599,43 +3562,43 @@ msgstr "" "自 Python 3.7 以來,高階 API 中的函式一直隱式取得目前執行緒正在運行的事件循" "環。在大多數正常用例中,不需要將事件循環傳遞給 API。" -#: ../../whatsnew/3.10.rst:1849 +#: ../../whatsnew/3.10.rst:1850 msgid "" "Event loop passing is error-prone especially when dealing with loops running " "in different threads." msgstr "事件循環的傳遞很容易出錯,尤其是在處理在不同執行緒中運行的循環時。" -#: ../../whatsnew/3.10.rst:1852 +#: ../../whatsnew/3.10.rst:1853 msgid "" "Note that the low-level API will still accept ``loop``. See :ref:`changes-" "python-api` for examples of how to replace existing code." msgstr "" -"請注意,低階 API 仍會接受 ``loop``。有關如何替換現有程式碼的範例,請參" -"閱 :ref:`changes-python-api`。" +"請注意,低階 API 仍會接受 ``loop``。有關如何替換現有程式碼的範例,請參閱 :" +"ref:`changes-python-api`。" -#: ../../whatsnew/3.10.rst:1855 ../../whatsnew/3.10.rst:1927 +#: ../../whatsnew/3.10.rst:1856 ../../whatsnew/3.10.rst:1928 msgid "" "(Contributed by Yurii Karabas, Andrew Svetlov, Yury Selivanov and Kyle " "Stanley in :issue:`42392`.)" msgstr "" -"(由 Yurii Karabas、Andrew Svetlov、Yury Selivanov 和 Kyle Stanley " -"在 :issue:`42392` 中貢獻。)" +"(由 Yurii Karabas、Andrew Svetlov、Yury Selivanov 和 Kyle Stanley 在 :issue:" +"`42392` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1860 ../../whatsnew/3.10.rst:2147 +#: ../../whatsnew/3.10.rst:1861 ../../whatsnew/3.10.rst:2148 msgid "Porting to Python 3.10" msgstr "移植到 Python 3.10" -#: ../../whatsnew/3.10.rst:1862 +#: ../../whatsnew/3.10.rst:1863 msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." msgstr "本節列出了前面描述的更改以及可能需要更改程式碼的其他錯誤修復。" -#: ../../whatsnew/3.10.rst:1867 +#: ../../whatsnew/3.10.rst:1868 msgid "Changes in the Python syntax" msgstr "Python 語法的變化" -#: ../../whatsnew/3.10.rst:1869 +#: ../../whatsnew/3.10.rst:1870 msgid "" "Deprecation warning is now emitted when compiling previously valid syntax if " "the numeric literal is immediately followed by a keyword (like in ``0in " @@ -3649,35 +3612,34 @@ msgstr "" "要消除警告並使程式碼與未來版本相容,只需在數字字面值和以下關鍵字之間新增一個" "空格即可。(由 Serhiy Storchaka 在 :issue:`43833` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1880 +#: ../../whatsnew/3.10.rst:1881 msgid "Changes in the Python API" msgstr "Python API 的變更" -#: ../../whatsnew/3.10.rst:1882 +#: ../../whatsnew/3.10.rst:1883 msgid "" -"The *etype* parameters of " -"the :func:`~traceback.format_exception`, :func:`~traceback.format_exception_only`, " -"and :func:`~traceback.print_exception` functions in the :mod:`traceback` " -"module have been renamed to *exc*. (Contributed by Zackery Spytz and " -"Matthias Bussonnier in :issue:`26389`.)" +"The *etype* parameters of the :func:`~traceback.format_exception`, :func:" +"`~traceback.format_exception_only`, and :func:`~traceback.print_exception` " +"functions in the :mod:`traceback` module have been renamed to *exc*. " +"(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)" msgstr "" -":func:`~traceback.format_exception`、:func:`~traceback.format_exception_only` " -"和 :mod:`traceback` 模組中的 :func:`~traceback.print_exception` 函式的 " -"*etype* 參數已重命名為 *exc*。(由 Zackery Spytz 和 Matthias Bussonnier " -"在 :issue:`26389` 中貢獻。)" +":func:`~traceback.format_exception`、:func:`~traceback." +"format_exception_only` 和 :mod:`traceback` 模組中的 :func:`~traceback." +"print_exception` 函式的 *etype* 參數已重命名為 *exc*。(由 Zackery Spytz 和 " +"Matthias Bussonnier 在 :issue:`26389` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1888 +#: ../../whatsnew/3.10.rst:1889 msgid "" -":mod:`atexit`: At Python exit, if a callback registered " -"with :func:`atexit.register` fails, its exception is now logged. Previously, " -"only some exceptions were logged, and the last exception was always silently " -"ignored. (Contributed by Victor Stinner in :issue:`42639`.)" +":mod:`atexit`: At Python exit, if a callback registered with :func:`atexit." +"register` fails, its exception is now logged. Previously, only some " +"exceptions were logged, and the last exception was always silently ignored. " +"(Contributed by Victor Stinner in :issue:`42639`.)" msgstr "" ":mod:`atexit`:在 Python 退出時,如果一個使用 :func:`atexit.register` 註冊的" "回呼 (callback) 失敗,該例外現在會被記錄下來。在以前只記錄一些例外,並且最後" "一個例外總是被默默地忽略。(由 Victor Stinner 在 :issue:`42639` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1894 +#: ../../whatsnew/3.10.rst:1895 msgid "" ":class:`collections.abc.Callable` generic now flattens type parameters, " "similar to what :data:`typing.Callable` currently does. This means that " @@ -3686,44 +3648,43 @@ msgid "" "accesses the arguments via :func:`typing.get_args` or ``__args__`` need to " "account for this change. Furthermore, :exc:`TypeError` may be raised for " "invalid forms of parameterizing :class:`collections.abc.Callable` which may " -"have passed silently in Python 3.9. (Contributed by Ken Jin " -"in :issue:`42195`.)" -msgstr "" -":class:`collections.abc.Callable` 泛型現在會攤平型別參數,類似" -"於 :data:`typing.Callable` 目前的做法。這意味著 " -"``collections.abc.Callable[[int, str], str]`` 將具有 ``(int, str, str)`` 的 " -"``__args__``;以前這是 ``([int, str], str)``。透過 :func:`typing.get_args` " -"或 ``__args__`` 存取參數的程式碼需要考慮此變更。此外,對於無效形式的參數" -"化 :class:`collections.abc.Callable`,可能會引發 :exc:`TypeError`,而在 " -"Python 3.9 中,該參數可能已被默默地傳遞。(由 Ken Jin 在 :issue:`42195` 中貢" -"獻。)" +"have passed silently in Python 3.9. (Contributed by Ken Jin in :issue:" +"`42195`.)" +msgstr "" +":class:`collections.abc.Callable` 泛型現在會攤平型別參數,類似於 :data:" +"`typing.Callable` 目前的做法。這意味著 ``collections.abc.Callable[[int, " +"str], str]`` 將具有 ``(int, str, str)`` 的 ``__args__``;以前這是 ``([int, " +"str], str)``。透過 :func:`typing.get_args` 或 ``__args__`` 存取參數的程式碼需" +"要考慮此變更。此外,對於無效形式的參數化 :class:`collections.abc.Callable`," +"可能會引發 :exc:`TypeError`,而在 Python 3.9 中,該參數可能已被默默地傳遞。" +"(由 Ken Jin 在 :issue:`42195` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1904 +#: ../../whatsnew/3.10.rst:1905 msgid "" ":meth:`socket.htons` and :meth:`socket.ntohs` now raise :exc:`OverflowError` " "instead of :exc:`DeprecationWarning` if the given parameter will not fit in " -"a 16-bit unsigned integer. (Contributed by Erlend E. Aasland " -"in :issue:`42393`.)" +"a 16-bit unsigned integer. (Contributed by Erlend E. Aasland in :issue:" +"`42393`.)" msgstr "" -"如果給定參數不適合 16 位元無符號整數 (16-bit unsigned " -"integer),:meth:`socket.htons` 和 :meth:`socket.ntohs` 現在會引" -"發 :exc:`OverflowError` 而不是 :exc:`DeprecationWarning`。(由 Erlend E. " -"Aasland 在 :issue:`42393` 中貢獻。)" +"如果給定參數不適合 16 位元無符號整數 (16-bit unsigned integer),:meth:" +"`socket.htons` 和 :meth:`socket.ntohs` 現在會引發 :exc:`OverflowError` 而不" +"是 :exc:`DeprecationWarning`。(由 Erlend E. Aasland 在 :issue:`42393` 中貢" +"獻。)" -#: ../../whatsnew/3.10.rst:1909 +#: ../../whatsnew/3.10.rst:1910 msgid "" -"The ``loop`` parameter has been removed from most of :mod:`asyncio`\\ " -"'s :doc:`high-level API <../library/asyncio-api-index>` following " -"deprecation in Python 3.8." +"The ``loop`` parameter has been removed from most of :mod:`asyncio`\\ 's :" +"doc:`high-level API <../library/asyncio-api-index>` following deprecation in " +"Python 3.8." msgstr "" "在 Python 3.8 中棄用後,``loop`` 參數已從大多數 :mod:`asyncio` 的\\ :doc:`高" "階 API <../library/asyncio-api-index>` 中刪除。" -#: ../../whatsnew/3.10.rst:1913 +#: ../../whatsnew/3.10.rst:1914 msgid "A coroutine that currently looks like this::" msgstr "目前如下所示的協程: ::" -#: ../../whatsnew/3.10.rst:1915 +#: ../../whatsnew/3.10.rst:1916 msgid "" "async def foo(loop):\n" " await asyncio.sleep(1, loop=loop)" @@ -3731,11 +3692,11 @@ msgstr "" "async def foo(loop):\n" " await asyncio.sleep(1, loop=loop)" -#: ../../whatsnew/3.10.rst:1918 +#: ../../whatsnew/3.10.rst:1919 msgid "Should be replaced with this::" msgstr "應替換為: ::" -#: ../../whatsnew/3.10.rst:1920 +#: ../../whatsnew/3.10.rst:1921 msgid "" "async def foo():\n" " await asyncio.sleep(1)" @@ -3743,7 +3704,7 @@ msgstr "" "async def foo():\n" " await asyncio.sleep(1)" -#: ../../whatsnew/3.10.rst:1923 +#: ../../whatsnew/3.10.rst:1924 msgid "" "If ``foo()`` was specifically designed *not* to run in the current thread's " "running event loop (e.g. running in another thread's event loop), consider " @@ -3752,28 +3713,27 @@ msgstr "" "如果 ``foo()`` 被專門設計為 *不* 在目前執行緒的事件循環中運行(例如在另一個執" "行緒的事件循環中運行),請考慮改用 :func:`asyncio.run_coroutine_threadsafe`。" -#: ../../whatsnew/3.10.rst:1930 +#: ../../whatsnew/3.10.rst:1931 msgid "" "The :data:`types.FunctionType` constructor now inherits the current builtins " "if the *globals* dictionary has no ``\"__builtins__\"`` key, rather than " -"using ``{\"None\": None}`` as builtins: same behavior as :func:`eval` " -"and :func:`exec` functions. Defining a function with ``def " -"function(...): ...`` in Python is not affected, globals cannot be overridden " -"with this syntax: it also inherits the current builtins. (Contributed by " -"Victor Stinner in :issue:`42990`.)" -msgstr "" -"如果 *globals* 字典沒有 ``\"__builtins__\"`` 鍵," -"則 :data:`types.FunctionType` 建構函式現在會繼承目前的內建物件,而不是使用 " -"``{\"None\": None}``:相同行為如 :func:`eval` 和 :func:`exec` 函式。在 " -"Python 中使用 ``def function(...): ...`` 定義函式不受影響,全域變數不能用此語" -"法覆蓋:它也繼承目前的內建物件。(由 Victor Stinner 在 :issue:`42990` 中貢" -"獻。)" - -#: ../../whatsnew/3.10.rst:1939 +"using ``{\"None\": None}`` as builtins: same behavior as :func:`eval` and :" +"func:`exec` functions. Defining a function with ``def function(...): ...`` " +"in Python is not affected, globals cannot be overridden with this syntax: it " +"also inherits the current builtins. (Contributed by Victor Stinner in :issue:" +"`42990`.)" +msgstr "" +"如果 *globals* 字典沒有 ``\"__builtins__\"`` 鍵,則 :data:`types." +"FunctionType` 建構函式現在會繼承目前的內建物件,而不是使用 ``{\"None\": None}" +"``:相同行為如 :func:`eval` 和 :func:`exec` 函式。在 Python 中使用 ``def " +"function(...): ...`` 定義函式不受影響,全域變數不能用此語法覆蓋:它也繼承目前" +"的內建物件。(由 Victor Stinner 在 :issue:`42990` 中貢獻。)" + +#: ../../whatsnew/3.10.rst:1940 msgid "Changes in the C API" msgstr "C API 中的改動" -#: ../../whatsnew/3.10.rst:1941 +#: ../../whatsnew/3.10.rst:1942 msgid "" "The C API functions ``PyParser_SimpleParseStringFlags``, " "``PyParser_SimpleParseStringFlagsFilename``, " @@ -3786,7 +3746,7 @@ msgstr "" "``PyParser_SimpleParseFileFlags``、``PyNode_Compile`` 和被這些函式使用的型別 " "``struct _node`` 被刪除。" -#: ../../whatsnew/3.10.rst:1947 +#: ../../whatsnew/3.10.rst:1948 msgid "" "Source should be now be compiled directly to a code object using, for " "example, :c:func:`Py_CompileString`. The resulting code object can then be " @@ -3796,11 +3756,11 @@ msgstr "" "件。然後可以(例如透過 :c:func:`PyEval_EvalCode`)為產生的程式碼物件求值 " "(evaluated)。" -#: ../../whatsnew/3.10.rst:1951 +#: ../../whatsnew/3.10.rst:1952 msgid "Specifically:" msgstr "具體來說:" -#: ../../whatsnew/3.10.rst:1953 +#: ../../whatsnew/3.10.rst:1954 msgid "" "A call to ``PyParser_SimpleParseStringFlags`` followed by ``PyNode_Compile`` " "can be replaced by calling :c:func:`Py_CompileString`." @@ -3808,7 +3768,7 @@ msgstr "" "後跟有 ``PyNode_Compile`` 呼叫的 ``PyParser_SimpleParseStringFlags`` 呼叫,可" "以替換為呼叫 :c:func:`Py_CompileString`。" -#: ../../whatsnew/3.10.rst:1956 +#: ../../whatsnew/3.10.rst:1957 msgid "" "There is no direct replacement for ``PyParser_SimpleParseFileFlags``. To " "compile code from a ``FILE *`` argument, you will need to read the file in C " @@ -3817,21 +3777,20 @@ msgstr "" "沒有 ``PyParser_SimpleParseFileFlags`` 的直接替代品。要從 ``FILE *`` 引數編譯" "程式碼,你需要用 C 讀取檔案並將結果緩衝區傳遞給 :c:func:`Py_CompileString`。" -#: ../../whatsnew/3.10.rst:1960 +#: ../../whatsnew/3.10.rst:1961 msgid "" "To compile a file given a ``char *`` filename, explicitly open the file, " "read it and compile the result. One way to do this is using the :py:mod:`io` " -"module " -"with :c:func:`PyImport_ImportModule`, :c:func:`PyObject_CallMethod`, :c:func:`PyBytes_AsString` " -"and :c:func:`Py_CompileString`, as sketched below. (Declarations and error " -"handling are omitted.) ::" +"module with :c:func:`PyImport_ImportModule`, :c:func:`PyObject_CallMethod`, :" +"c:func:`PyBytes_AsString` and :c:func:`Py_CompileString`, as sketched below. " +"(Declarations and error handling are omitted.) ::" msgstr "" "要編譯給定 ``char *`` 檔案名稱的檔案,請顯式打開該檔案,讀取它並編譯結果。一" -"種方法是使用 :py:mod:`io` 模組" -"和 :c:func:`PyImport_ImportModule`、:c:func:`PyObject_CallMethod`、:c:func:`PyBytes_AsString` " -"和 :c:func:`Py_CompileString`,如下所示。(宣告和錯誤處理在此被省略。): ::" +"種方法是使用 :py:mod:`io` 模組和 :c:func:`PyImport_ImportModule`、:c:func:" +"`PyObject_CallMethod`、:c:func:`PyBytes_AsString` 和 :c:func:" +"`Py_CompileString`,如下所示。(宣告和錯誤處理在此被省略。): ::" -#: ../../whatsnew/3.10.rst:1966 +#: ../../whatsnew/3.10.rst:1967 msgid "" "io_module = Import_ImportModule(\"io\");\n" "fileobject = PyObject_CallMethod(io_module, \"open\", \"ss\", filename, " @@ -3849,15 +3808,15 @@ msgstr "" "source_buf = PyBytes_AsString(source_bytes_object);\n" "code = Py_CompileString(source_buf, filename, Py_file_input);" -#: ../../whatsnew/3.10.rst:1973 +#: ../../whatsnew/3.10.rst:1974 msgid "" "For ``FrameObject`` objects, the :attr:`~frame.f_lasti` member now " "represents a wordcode offset instead of a simple offset into the bytecode " "string. This means that this number needs to be multiplied by 2 to be used " "with APIs that expect a byte offset instead (like :c:func:`PyCode_Addr2Line` " "for example). Notice as well that the :attr:`!f_lasti` member of " -"``FrameObject`` objects is not considered stable: please " -"use :c:func:`PyFrame_GetLineNumber` instead." +"``FrameObject`` objects is not considered stable: please use :c:func:" +"`PyFrame_GetLineNumber` instead." msgstr "" "對於 ``FrameObject`` 物件,:attr:`~frame.f_lasti` 成員現在表示了字碼偏移量 " "(wordcode offset),而不是位元組碼字串的簡單偏移量。這意味著這個數字需要乘以 " @@ -3865,11 +3824,11 @@ msgstr "" "還要注意,``FrameObject`` 物件的 :attr:`!f_lasti` 成員不被認為是穩定的:請改" "用 :c:func:`PyFrame_GetLineNumber`。" -#: ../../whatsnew/3.10.rst:1981 +#: ../../whatsnew/3.10.rst:1982 msgid "CPython bytecode changes" msgstr "CPython 位元組碼變更" -#: ../../whatsnew/3.10.rst:1983 +#: ../../whatsnew/3.10.rst:1984 msgid "" "The ``MAKE_FUNCTION`` instruction now accepts either a dict or a tuple of " "strings as the function's annotations. (Contributed by Yurii Karabas and " @@ -3878,11 +3837,11 @@ msgstr "" "``MAKE_FUNCTION`` 指令現在接受字典或字串元組作為函式的註釋。(由 Yurii " "Karabas 和 Inada Naoki 在 :issue:`42202` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1988 +#: ../../whatsnew/3.10.rst:1989 msgid "Build Changes" msgstr "建置變更" -#: ../../whatsnew/3.10.rst:1990 +#: ../../whatsnew/3.10.rst:1991 msgid "" ":pep:`644`: Python now requires OpenSSL 1.1.1 or newer. OpenSSL 1.0.2 is no " "longer supported. (Contributed by Christian Heimes in :issue:`43669`.)" @@ -3890,7 +3849,7 @@ msgstr "" ":pep:`644`:Python 現在需要 OpenSSL 1.1.1 或更高版本。不再支援 OpenSSL " "1.0.2。(由 Christian Heimes 在 :issue:`43669` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1994 +#: ../../whatsnew/3.10.rst:1995 msgid "" "The C99 functions :c:func:`snprintf` and :c:func:`vsnprintf` are now " "required to build Python. (Contributed by Victor Stinner in :issue:`36020`.)" @@ -3898,7 +3857,7 @@ msgstr "" "現在需要 C99 函式 :c:func:`snprintf` 和 :c:func:`vsnprintf` 來建置 Python。 " "(由 Victor Stinner 在 :issue:`36020` 中貢獻。)" -#: ../../whatsnew/3.10.rst:1998 +#: ../../whatsnew/3.10.rst:1999 msgid "" ":mod:`sqlite3` requires SQLite 3.7.15 or higher. (Contributed by Sergey " "Fedoseev and Erlend E. Aasland in :issue:`40744` and :issue:`40810`.)" @@ -3906,25 +3865,25 @@ msgstr "" ":mod:`sqlite3` 需要 SQLite 3.7.15 或更新版本。(由 Sergey Fedoseev 和 Erlend " "E. Aasland 在 :issue:`40744` 和 :issue:`40810` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2001 +#: ../../whatsnew/3.10.rst:2002 msgid "" "The :mod:`atexit` module must now always be built as a built-in module. " "(Contributed by Victor Stinner in :issue:`42639`.)" msgstr "" -":mod:`atexit` 模組現在必須都被建置為內建模組。(由 Victor Stinner " -"在 :issue:`42639` 中貢獻。)" +":mod:`atexit` 模組現在必須都被建置為內建模組。(由 Victor Stinner 在 :issue:" +"`42639` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2004 +#: ../../whatsnew/3.10.rst:2005 msgid "" "Add :option:`--disable-test-modules` option to the ``configure`` script: " "don't build nor install test modules. (Contributed by Xavier de Gaye, Thomas " "Petazzoni and Peixing Xin in :issue:`27640`.)" msgstr "" "將 :option:`--disable-test-modules` 選項新增到 ``configure`` 腳本中:不建置也" -"不安裝測試模組。(由 Xavier de Gaye、Thomas Petazzoni 和 Peixing Xin " -"在 :issue:`27640` 中貢獻。)" +"不安裝測試模組。(由 Xavier de Gaye、Thomas Petazzoni 和 Peixing Xin 在 :" +"issue:`27640` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2008 +#: ../../whatsnew/3.10.rst:2009 msgid "" "Add :option:`--with-wheel-pkg-dir=PATH option <--with-wheel-pkg-dir>` to the " "``./configure`` script. If specified, the :mod:`ensurepip` module looks for " @@ -3937,36 +3896,36 @@ msgstr "" "``setuptools`` 和 ``pip`` wheel 套件:如果兩者都存在,則使用這些 wheel 套件而" "不是 ensurepip 捆綁的 wheel 套件。" -#: ../../whatsnew/3.10.rst:2014 +#: ../../whatsnew/3.10.rst:2015 msgid "" "Some Linux distribution packaging policies recommend against bundling " "dependencies. For example, Fedora installs wheel packages in the ``/usr/" -"share/python-wheels/`` directory and don't install the " -"``ensurepip._bundled`` package." +"share/python-wheels/`` directory and don't install the ``ensurepip." +"_bundled`` package." msgstr "" "一些 Linux 發行版的打包策略建議不要一併包入依賴項目。例如,Fedora 在 ``/usr/" -"share/python-wheels/`` 目錄中安裝 wheel 套件,並且不安裝 " -"``ensurepip._bundled`` 套件。" +"share/python-wheels/`` 目錄中安裝 wheel 套件,並且不安裝 ``ensurepip." +"_bundled`` 套件。" -#: ../../whatsnew/3.10.rst:2019 +#: ../../whatsnew/3.10.rst:2020 msgid "(Contributed by Victor Stinner in :issue:`42856`.)" msgstr "(由 Victor Stinner 在 :issue:`42856` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2021 +#: ../../whatsnew/3.10.rst:2022 msgid "" "Add a new :option:`configure --without-static-libpython option <--without-" "static-libpython>` to not build the ``libpythonMAJOR.MINOR.a`` static " "library and not install the ``python.o`` object file." msgstr "" "新增 :option:`configure --without-static-libpython 選項 <--without-static-" -"libpython>` 以不建置 ``libpythonMAJOR.MINOR.a`` 靜態函式庫且不安裝 " -"``python.o`` 目標檔案。" +"libpython>` 以不建置 ``libpythonMAJOR.MINOR.a`` 靜態函式庫且不安裝 ``python." +"o`` 目標檔案。" -#: ../../whatsnew/3.10.rst:2025 +#: ../../whatsnew/3.10.rst:2026 msgid "(Contributed by Victor Stinner in :issue:`43103`.)" msgstr "(由 Victor Stinner 在 :issue:`43103` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2027 +#: ../../whatsnew/3.10.rst:2028 msgid "" "The ``configure`` script now uses the ``pkg-config`` utility, if available, " "to detect the location of Tcl/Tk headers and libraries. As before, those " @@ -3979,7 +3938,7 @@ msgstr "" "includes`` 和 ``--with-tcltk-libs`` 配置選項顯式指定這些位置。(由 Manolis " "Stamatogiannakis 在 :issue:`42603` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2033 +#: ../../whatsnew/3.10.rst:2034 msgid "" "Add :option:`--with-openssl-rpath` option to ``configure`` script. The " "option simplifies building Python with a custom OpenSSL installation, e.g. " @@ -3991,63 +3950,61 @@ msgstr "" "openssl=/path/to/openssl --with-openssl-rpath=auto``。(由 Christian Heimes " "在 :issue:`43466` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2040 +#: ../../whatsnew/3.10.rst:2041 msgid "C API Changes" msgstr "C API 變更" -#: ../../whatsnew/3.10.rst:2043 +#: ../../whatsnew/3.10.rst:2044 msgid "PEP 652: Maintaining the Stable ABI" msgstr "PEP 652:維護穩定 ABI" -#: ../../whatsnew/3.10.rst:2045 +#: ../../whatsnew/3.10.rst:2046 msgid "" "The Stable ABI (Application Binary Interface) for extension modules or " "embedding Python is now explicitly defined. :ref:`stable` describes C API " "and ABI stability guarantees along with best practices for using the Stable " "ABI." msgstr "" -"用於擴充模組或嵌入 Python 的穩定 ABI(應用程式二進位介面)現已明確定" -"義。 :ref:`stable` 描述了 C API 和 ABI 穩定性保證以及使用穩定 ABI 的最佳實" -"踐。" +"用於擴充模組或嵌入 Python 的穩定 ABI(應用程式二進位介面)現已明確定義。 :" +"ref:`stable` 描述了 C API 和 ABI 穩定性保證以及使用穩定 ABI 的最佳實踐。" -#: ../../whatsnew/3.10.rst:2050 +#: ../../whatsnew/3.10.rst:2051 msgid "(Contributed by Petr Viktorin in :pep:`652` and :issue:`43795`.)" msgstr "(由 Petr Viktorin 在 :pep:`652` 和 :issue:`43795` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2055 +#: ../../whatsnew/3.10.rst:2056 msgid "" -"The result of :c:func:`PyNumber_Index` now always has exact " -"type :class:`int`. Previously, the result could have been an instance of a " -"subclass of ``int``. (Contributed by Serhiy Storchaka in :issue:`40792`.)" +"The result of :c:func:`PyNumber_Index` now always has exact type :class:" +"`int`. Previously, the result could have been an instance of a subclass of " +"``int``. (Contributed by Serhiy Storchaka in :issue:`40792`.)" msgstr "" ":c:func:`PyNumber_Index` 的結果現在都具有精確的 :class:`int` 型別。在以前,結" "果可能是 ``int`` 子類別的實例。(由 Serhiy Storchaka 在 :issue:`40792` 中貢" "獻。)" -#: ../../whatsnew/3.10.rst:2059 +#: ../../whatsnew/3.10.rst:2060 msgid "" "Add a new :c:member:`~PyConfig.orig_argv` member to the :c:type:`PyConfig` " "structure: the list of the original command line arguments passed to the " "Python executable. (Contributed by Victor Stinner in :issue:`23427`.)" msgstr "" "將新的 :c:member:`~PyConfig.orig_argv` 成員新增到 :c:type:`PyConfig` 結構:傳" -"遞給 Python 可執行檔案的原始命令列參數列表。(由 Victor Stinner " -"在 :issue:`23427` 中貢獻。)" +"遞給 Python 可執行檔案的原始命令列參數列表。(由 Victor Stinner 在 :issue:" +"`23427` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2064 +#: ../../whatsnew/3.10.rst:2065 msgid "" -"The :c:func:`PyDateTime_DATE_GET_TZINFO` " -"and :c:func:`PyDateTime_TIME_GET_TZINFO` macros have been added for " -"accessing the ``tzinfo`` attributes of :class:`datetime.datetime` " -"and :class:`datetime.time` objects. (Contributed by Zackery Spytz " -"in :issue:`30155`.)" +"The :c:func:`PyDateTime_DATE_GET_TZINFO` and :c:func:" +"`PyDateTime_TIME_GET_TZINFO` macros have been added for accessing the " +"``tzinfo`` attributes of :class:`datetime.datetime` and :class:`datetime." +"time` objects. (Contributed by Zackery Spytz in :issue:`30155`.)" msgstr "" -"新增了 :c:func:`PyDateTime_DATE_GET_TZINFO` " -"和 :c:func:`PyDateTime_TIME_GET_TZINFO` 巨集,用於存" -"取 :class:`datetime.datetime` 和 :class:`datetime.time` 物件的 ``tzinfo`` 屬" -"性。(由 Zackery Spytz 在 :issue:`30155` 中貢獻。)" +"新增了 :c:func:`PyDateTime_DATE_GET_TZINFO` 和 :c:func:" +"`PyDateTime_TIME_GET_TZINFO` 巨集,用於存取 :class:`datetime.datetime` 和 :" +"class:`datetime.time` 物件的 ``tzinfo`` 屬性。(由 Zackery Spytz 在 :issue:" +"`30155` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2070 +#: ../../whatsnew/3.10.rst:2071 msgid "" "Add a :c:func:`PyCodec_Unregister` function to unregister a codec search " "function. (Contributed by Hai Shi in :issue:`41842`.)" @@ -4055,7 +4012,7 @@ msgstr "" "新增 :c:func:`PyCodec_Unregister` 函式來取消註冊編解碼器搜尋函式。(由 Hai " "Shi 在 :issue:`41842` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2074 +#: ../../whatsnew/3.10.rst:2075 msgid "" "The :c:func:`PyIter_Send` function was added to allow sending value into " "iterator without raising ``StopIteration`` exception. (Contributed by " @@ -4064,7 +4021,7 @@ msgstr "" "新增了 :c:func:`PyIter_Send` 函式,以允許將值發送到疊代器中,而不會引發 " "``StopIteration`` 例外。(由 Vladimir Matveev 在 :issue:`41756` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2078 +#: ../../whatsnew/3.10.rst:2079 msgid "" "Add :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API. (Contributed by " "Alex Gaynor in :issue:`41784`.)" @@ -4072,17 +4029,17 @@ msgstr "" "將 :c:func:`PyUnicode_AsUTF8AndSize` 新增到受限 C API (limited C API) 中。" "(由 Alex Gaynor 在 :issue:`41784` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2081 +#: ../../whatsnew/3.10.rst:2082 msgid "" -"Add :c:func:`PyModule_AddObjectRef` function: similar " -"to :c:func:`PyModule_AddObject` but don't steal a reference to the value on " -"success. (Contributed by Victor Stinner in :issue:`1635741`.)" +"Add :c:func:`PyModule_AddObjectRef` function: similar to :c:func:" +"`PyModule_AddObject` but don't steal a reference to the value on success. " +"(Contributed by Victor Stinner in :issue:`1635741`.)" msgstr "" -"新增 :c:func:`PyModule_AddObjectRef` 函式:類似" -"於 :c:func:`PyModule_AddObject` 但成功時不竊取對值的參照。(由 Victor " -"Stinner 在 :issue:`1635741` 中貢獻。)" +"新增 :c:func:`PyModule_AddObjectRef` 函式:類似於 :c:func:" +"`PyModule_AddObject` 但成功時不竊取對值的參照。(由 Victor Stinner 在 :issue:" +"`1635741` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2086 +#: ../../whatsnew/3.10.rst:2087 msgid "" "Add :c:func:`Py_NewRef` and :c:func:`Py_XNewRef` functions to increment the " "reference count of an object and return the object. (Contributed by Victor " @@ -4091,17 +4048,17 @@ msgstr "" "新增 :c:func:`Py_NewRef` 和 :c:func:`Py_XNewRef` 函式來增加物件的參照計數並回" "傳物件。(由 Victor Stinner 在 :issue:`42262` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2090 +#: ../../whatsnew/3.10.rst:2091 msgid "" -"The :c:func:`PyType_FromSpecWithBases` " -"and :c:func:`PyType_FromModuleAndSpec` functions now accept a single class " -"as the *bases* argument. (Contributed by Serhiy Storchaka in :issue:`42423`.)" +"The :c:func:`PyType_FromSpecWithBases` and :c:func:" +"`PyType_FromModuleAndSpec` functions now accept a single class as the " +"*bases* argument. (Contributed by Serhiy Storchaka in :issue:`42423`.)" msgstr "" ":c:func:`PyType_FromSpecWithBases` 和 :c:func:`PyType_FromModuleAndSpec` 函式" "現在接受單個類別作為 *bases* 引數。(由 Serhiy Storchaka 在 :issue:`42423` 中" "貢獻。)" -#: ../../whatsnew/3.10.rst:2094 +#: ../../whatsnew/3.10.rst:2095 msgid "" "The :c:func:`PyType_FromModuleAndSpec` function now accepts NULL ``tp_doc`` " "slot. (Contributed by Hai Shi in :issue:`41832`.)" @@ -4109,7 +4066,7 @@ msgstr "" ":c:func:`PyType_FromModuleAndSpec` 函式現在接受 NULL ``tp_doc`` 槽位。(由 " "Hai Shi 在 :issue:`41832` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2098 +#: ../../whatsnew/3.10.rst:2099 msgid "" "The :c:func:`PyType_GetSlot` function can accept :ref:`static types `. (Contributed by Hai Shi and Petr Viktorin in :issue:`41073`.)" @@ -4117,7 +4074,7 @@ msgstr "" ":c:func:`PyType_GetSlot` 函式可以接受\\ :ref:`靜態型別 (static type) `。(由 Hai Shi 和 Petr Viktorin 在 :issue:`41073` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2102 +#: ../../whatsnew/3.10.rst:2103 msgid "" "Add a new :c:func:`PySet_CheckExact` function to the C-API to check if an " "object is an instance of :class:`set` but not an instance of a subtype. " @@ -4126,7 +4083,7 @@ msgstr "" "向 C-API 新增 :c:func:`PySet_CheckExact` 函式,以檢查物件是否是 :class:`set` " "的實例而不是子型別的實例。(由 Pablo Galindo 在 :issue:`43277` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2106 +#: ../../whatsnew/3.10.rst:2107 msgid "" "Add :c:func:`PyErr_SetInterruptEx` which allows passing a signal number to " "simulate. (Contributed by Antoine Pitrou in :issue:`43356`.)" @@ -4134,17 +4091,17 @@ msgstr "" "新增 :c:func:`PyErr_SetInterruptEx`,它允許傳遞信號編號來進行模擬。(由 " "Antoine Pitrou 在 :issue:`43356` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2110 +#: ../../whatsnew/3.10.rst:2111 msgid "" "The limited C API is now supported if :ref:`Python is built in debug mode " "` (if the ``Py_DEBUG`` macro is defined). In the limited C API, " "the :c:func:`Py_INCREF` and :c:func:`Py_DECREF` functions are now " -"implemented as opaque function calls, rather than accessing directly " -"the :c:member:`PyObject.ob_refcnt` member, if Python is built in debug mode " -"and the ``Py_LIMITED_API`` macro targets Python 3.10 or newer. It became " -"possible to support the limited C API in debug mode because " -"the :c:type:`PyObject` structure is the same in release and debug mode since " -"Python 3.8 (see :issue:`36465`)." +"implemented as opaque function calls, rather than accessing directly the :c:" +"member:`PyObject.ob_refcnt` member, if Python is built in debug mode and the " +"``Py_LIMITED_API`` macro targets Python 3.10 or newer. It became possible to " +"support the limited C API in debug mode because the :c:type:`PyObject` " +"structure is the same in release and debug mode since Python 3.8 (see :issue:" +"`36465`)." msgstr "" "如 :ref:`Python 是在除錯模式 (debug mode) ` 下建置的(如果有定" "義 ``Py_DEBUG`` 巨集),現在會支援受限 C API。在受限 C API 中,如果 Python 是" @@ -4154,43 +4111,42 @@ msgstr "" "C API 成為可能,因為自 Python 3.8 以來,:c:type:`PyObject` 結構在發布和除錯模" "式下是相同的(請參閱:issue:`36465`)。" -#: ../../whatsnew/3.10.rst:2120 +#: ../../whatsnew/3.10.rst:2121 msgid "" "The limited C API is still not supported in the :option:`--with-trace-refs` " -"special build (``Py_TRACE_REFS`` macro). (Contributed by Victor Stinner " -"in :issue:`43688`.)" +"special build (``Py_TRACE_REFS`` macro). (Contributed by Victor Stinner in :" +"issue:`43688`.)" msgstr "" ":option:`--with-trace-refs` 特殊建置(``Py_TRACE_REFS`` 巨集)仍不支援受限 C " "API。(由 Victor Stinner 在 :issue:`43688` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2124 +#: ../../whatsnew/3.10.rst:2125 msgid "" "Add the :c:func:`Py_Is(x, y) ` function to test if the *x* object is " -"the *y* object, the same as ``x is y`` in Python. Add also " -"the :c:func:`Py_IsNone`, :c:func:`Py_IsTrue`, :c:func:`Py_IsFalse` functions " -"to test if an object is, respectively, the ``None`` singleton, the ``True`` " -"singleton or the ``False`` singleton. (Contributed by Victor Stinner " -"in :issue:`43753`.)" +"the *y* object, the same as ``x is y`` in Python. Add also the :c:func:" +"`Py_IsNone`, :c:func:`Py_IsTrue`, :c:func:`Py_IsFalse` functions to test if " +"an object is, respectively, the ``None`` singleton, the ``True`` singleton " +"or the ``False`` singleton. (Contributed by Victor Stinner in :issue:" +"`43753`.)" msgstr "" "新增 :c:func:`Py_Is(x, y) ` 函式來測試 *x* 物件是否為 *y* 物件,與 " -"Python 中的 ``x is y`` 相同。還新" -"增 :c:func:`Py_IsNone`、:c:func:`Py_IsTrue`、:c:func:`Py_IsFalse` 函式來分別" -"測試物件是否為 ``None`` 單例、 ``True`` 單例或 ``False`` 單例。(由 Victor " -"Stinner 在 :issue:`43753` 中貢獻。)" +"Python 中的 ``x is y`` 相同。還新增 :c:func:`Py_IsNone`、:c:func:" +"`Py_IsTrue`、:c:func:`Py_IsFalse` 函式來分別測試物件是否為 ``None`` 單例、 " +"``True`` 單例或 ``False`` 單例。(由 Victor Stinner 在 :issue:`43753` 中貢" +"獻。)" -#: ../../whatsnew/3.10.rst:2131 +#: ../../whatsnew/3.10.rst:2132 msgid "" -"Add new functions to control the garbage collector from C " -"code: :c:func:`PyGC_Enable()`, :c:func:`PyGC_Disable()`, :c:func:`PyGC_IsEnabled()`. " -"These functions allow to activate, deactivate and query the state of the " -"garbage collector from C code without having to import the :mod:`gc` module." +"Add new functions to control the garbage collector from C code: :c:func:" +"`PyGC_Enable()`, :c:func:`PyGC_Disable()`, :c:func:`PyGC_IsEnabled()`. These " +"functions allow to activate, deactivate and query the state of the garbage " +"collector from C code without having to import the :mod:`gc` module." msgstr "" -"新增函式以從 C 程式碼控制垃圾收集" -"器::c:func:`PyGC_Enable()`、:c:func:`PyGC_Disable()`、:c:func:`PyGC_IsEnabled()`。" -"這些函式使得能夠從 C 程式碼啟用、停用和查詢垃圾收集器的狀態,而無需引" -"入 :mod:`gc` 模組。" +"新增函式以從 C 程式碼控制垃圾收集器::c:func:`PyGC_Enable()`、:c:func:" +"`PyGC_Disable()`、:c:func:`PyGC_IsEnabled()`。這些函式使得能夠從 C 程式碼啟" +"用、停用和查詢垃圾收集器的狀態,而無需引入 :mod:`gc` 模組。" -#: ../../whatsnew/3.10.rst:2138 +#: ../../whatsnew/3.10.rst:2139 msgid "" "Add a new :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` type flag to disallow " "creating type instances. (Contributed by Victor Stinner in :issue:`43916`.)" @@ -4198,30 +4154,30 @@ msgstr "" "新增 :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` 型別旗標以禁止建立型別實" "例。(由 Victor Stinner 在 :issue:`43916` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2142 +#: ../../whatsnew/3.10.rst:2143 msgid "" "Add a new :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` type flag for creating " "immutable type objects: type attributes cannot be set nor deleted. " "(Contributed by Victor Stinner and Erlend E. Aasland in :issue:`43908`.)" msgstr "" "新增 :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` 型別旗標用於建立不可變型別物件:無法" -"設定或刪除型別屬性。(由 Victor Stinner 和 Erlend E. Aasland " -"在 :issue:`43908` 中貢獻。)" +"設定或刪除型別屬性。(由 Victor Stinner 和 Erlend E. Aasland 在 :issue:" +"`43908` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2149 +#: ../../whatsnew/3.10.rst:2150 msgid "" -"The ``PY_SSIZE_T_CLEAN`` macro must now be defined to " -"use :c:func:`PyArg_ParseTuple` and :c:func:`Py_BuildValue` formats which use " -"``#``: ``es#``, ``et#``, ``s#``, ``u#``, ``y#``, ``z#``, ``U#`` and ``Z#``. " -"See :ref:`arg-parsing` and :pep:`353`. (Contributed by Victor Stinner " -"in :issue:`40943`.)" +"The ``PY_SSIZE_T_CLEAN`` macro must now be defined to use :c:func:" +"`PyArg_ParseTuple` and :c:func:`Py_BuildValue` formats which use ``#``: " +"``es#``, ``et#``, ``s#``, ``u#``, ``y#``, ``z#``, ``U#`` and ``Z#``. See :" +"ref:`arg-parsing` and :pep:`353`. (Contributed by Victor Stinner in :issue:" +"`40943`.)" msgstr "" -"現在必須定義 ``PY_SSIZE_T_CLEAN`` 巨集以使用 :c:func:`PyArg_ParseTuple` " -"和 :c:func:`Py_BuildValue` 格式,這些格式使用 ``#``: ``es#``, ``et#``、" -"``s#``、``u#``、``y#``、``z#``、``U#`` 和 ``Z#``。請參閱 :ref:`arg-parsing` " -"和 :pep:`353`。(由 Victor Stinner 在 :issue:`40943` 中貢獻。)" +"現在必須定義 ``PY_SSIZE_T_CLEAN`` 巨集以使用 :c:func:`PyArg_ParseTuple` 和 :" +"c:func:`Py_BuildValue` 格式,這些格式使用 ``#``: ``es#``, ``et#``、``s#``、" +"``u#``、``y#``、``z#``、``U#`` 和 ``Z#``。請參閱 :ref:`arg-parsing` 和 :pep:" +"`353`。(由 Victor Stinner 在 :issue:`40943` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2155 +#: ../../whatsnew/3.10.rst:2156 msgid "" "Since :c:func:`Py_REFCNT()` is changed to the inline static function, " "``Py_REFCNT(obj) = new_refcnt`` must be replaced with ``Py_SET_REFCNT(obj, " @@ -4233,7 +4189,7 @@ msgstr "" "new_refcnt)`` :參見 :c:func:`Py_SET_REFCNT()` (自 Python 3.9 起可用)。為了" "向後相容,可以使用該巨集: ::" -#: ../../whatsnew/3.10.rst:2160 +#: ../../whatsnew/3.10.rst:2161 msgid "" "#if PY_VERSION_HEX < 0x030900A4\n" "# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)\n" @@ -4243,21 +4199,21 @@ msgstr "" "# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)\n" "#endif" -#: ../../whatsnew/3.10.rst:2164 +#: ../../whatsnew/3.10.rst:2165 msgid "(Contributed by Victor Stinner in :issue:`39573`.)" msgstr "(由 Victor Stinner 在 :issue:`39573` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2166 +#: ../../whatsnew/3.10.rst:2167 msgid "" "Calling :c:func:`PyDict_GetItem` without :term:`GIL` held had been allowed " "for historical reason. It is no longer allowed. (Contributed by Victor " "Stinner in :issue:`40839`.)" msgstr "" -"由於過去的種種原因,過去在不持有 :term:`GIL` 的情況下呼" -"叫 :c:func:`PyDict_GetItem` 是被允許的。目前已被禁止。(由 Victor Stinner " -"在 :issue:`40839` 中貢獻。)" +"由於過去的種種原因,過去在不持有 :term:`GIL` 的情況下呼叫 :c:func:" +"`PyDict_GetItem` 是被允許的。目前已被禁止。(由 Victor Stinner 在 :issue:" +"`40839` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2170 +#: ../../whatsnew/3.10.rst:2171 msgid "" "``PyUnicode_FromUnicode(NULL, size)`` and " "``PyUnicode_FromStringAndSize(NULL, size)`` raise ``DeprecationWarning`` " @@ -4269,7 +4225,7 @@ msgstr "" "分配沒有初始資料的 Unicode 物件。(由 Inada Naoki 在 :issue:`36346` 中貢" "獻。)" -#: ../../whatsnew/3.10.rst:2175 +#: ../../whatsnew/3.10.rst:2176 msgid "" "The private ``_PyUnicode_Name_CAPI`` structure of the PyCapsule API " "``unicodedata.ucnhash_CAPI`` has been moved to the internal C API. " @@ -4278,67 +4234,66 @@ msgstr "" "PyCapsule API ``unicodedata.ucnhash_CAPI`` 的私有 ``_PyUnicode_Name_CAPI`` 結" "構已移至內部 C API。(由 Victor Stinner 在 :issue:`42157` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2179 +#: ../../whatsnew/3.10.rst:2180 msgid "" -":c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` " -"and :c:func:`Py_GetProgramName` functions now return ``NULL`` if called " -"before :c:func:`Py_Initialize` (before Python is initialized). Use the " -"new :ref:`init-config` API to get the :ref:`init-path-config`. (Contributed " -"by Victor Stinner in :issue:`42260`.)" +":c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:" +"func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and :c:func:" +"`Py_GetProgramName` functions now return ``NULL`` if called before :c:func:" +"`Py_Initialize` (before Python is initialized). Use the new :ref:`init-" +"config` API to get the :ref:`init-path-config`. (Contributed by Victor " +"Stinner in :issue:`42260`.)" msgstr "" -"如果在 :c:func:`Py_Initialize` 之前(Python 初始化之前)被呼" -"叫,:c:func:`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:func:`Py_GetExecPrefix`、:c:func:`Py_GetProgramFullPath`、:c:func:`Py_GetPythonHome` " -"和 :c:func:`Py_GetProgramName` 現在會回傳 ``NULL``。使用新的 :ref:`init-" -"config` API 來取得 :ref:`init-path-config`。(由 Victor Stinner " -"在 :issue:`42260` 中貢獻。)" +"如果在 :c:func:`Py_Initialize` 之前(Python 初始化之前)被呼叫,:c:func:" +"`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:func:`Py_GetExecPrefix`、:c:func:" +"`Py_GetProgramFullPath`、:c:func:`Py_GetPythonHome` 和 :c:func:" +"`Py_GetProgramName` 現在會回傳 ``NULL``。使用新的 :ref:`init-config` API 來取" +"得 :ref:`init-path-config`。(由 Victor Stinner 在 :issue:`42260` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2186 +#: ../../whatsnew/3.10.rst:2187 msgid "" -":c:func:`PyList_SET_ITEM`, :c:func:`PyTuple_SET_ITEM` " -"and :c:func:`PyCell_SET` macros can no longer be used as l-value or r-value. " -"For example, ``x = PyList_SET_ITEM(a, b, c)`` and ``PyList_SET_ITEM(a, b, c) " -"= x`` now fail with a compiler error. It prevents bugs like ``if " +":c:func:`PyList_SET_ITEM`, :c:func:`PyTuple_SET_ITEM` and :c:func:" +"`PyCell_SET` macros can no longer be used as l-value or r-value. For " +"example, ``x = PyList_SET_ITEM(a, b, c)`` and ``PyList_SET_ITEM(a, b, c) = " +"x`` now fail with a compiler error. It prevents bugs like ``if " "(PyList_SET_ITEM (a, b, c) < 0) ...`` test. (Contributed by Zackery Spytz " "and Victor Stinner in :issue:`30459`.)" msgstr "" -":c:func:`PyList_SET_ITEM`、:c:func:`PyTuple_SET_ITEM` " -"和 :c:func:`PyCell_SET` 巨集不能再用作左值 (l-value) 或右值 (r-value)。例如," -"``x = PyList_SET_ITEM(a, b, c)`` 和 ``PyList_SET_ITEM(a, b, c) = x`` 現在會失" -"敗並出現編譯器錯誤。它可以防止如 ``if (PyList_SET_ITEM (a, b, c) < 0) ...`` " -"測試之類的錯誤。(由 Zackery Spytz 和 Victor Stinner 在 :issue:`30459` 中貢" -"獻。)" +":c:func:`PyList_SET_ITEM`、:c:func:`PyTuple_SET_ITEM` 和 :c:func:" +"`PyCell_SET` 巨集不能再用作左值 (l-value) 或右值 (r-value)。例如,``x = " +"PyList_SET_ITEM(a, b, c)`` 和 ``PyList_SET_ITEM(a, b, c) = x`` 現在會失敗並出" +"現編譯器錯誤。它可以防止如 ``if (PyList_SET_ITEM (a, b, c) < 0) ...`` 測試之" +"類的錯誤。(由 Zackery Spytz 和 Victor Stinner 在 :issue:`30459` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2193 +#: ../../whatsnew/3.10.rst:2194 msgid "" "The non-limited API files ``odictobject.h``, ``parser_interface.h``, " -"``picklebufobject.h``, ``pyarena.h``, ``pyctype.h``, ``pydebug.h``, " -"``pyfpe.h``, and ``pytime.h`` have been moved to the ``Include/cpython`` " -"directory. These files must not be included directly, as they are already " -"included in ``Python.h``; see :ref:`api-includes`. If they have been " -"included directly, consider including ``Python.h`` instead. (Contributed by " -"Nicholas Sim in :issue:`35134`.)" -msgstr "" -"非受限 API 檔案 ``odictobject.h``、``parser_interface.h``、" -"``picklebufobject.h``、``pyarena.h``、``pyctype.h``、``pydebug.h``、" -"``pyfpe.h`` 和 ``pytime.h`` 已移至 ``Include/cpython`` 目錄。這些檔案不得直接" -"被引入,因為它們已於 ``Python.h`` 中引入;請參閱 :ref:`api-includes`。如果直" -"接引入它們,請考慮改為引入 ``Python.h``。(由 Nicholas Sim 在 :issue:`35134` " -"中貢獻。)" +"``picklebufobject.h``, ``pyarena.h``, ``pyctype.h``, ``pydebug.h``, ``pyfpe." +"h``, and ``pytime.h`` have been moved to the ``Include/cpython`` directory. " +"These files must not be included directly, as they are already included in " +"``Python.h``; see :ref:`api-includes`. If they have been included directly, " +"consider including ``Python.h`` instead. (Contributed by Nicholas Sim in :" +"issue:`35134`.)" +msgstr "" +"非受限 API 檔案 ``odictobject.h``、``parser_interface.h``、``picklebufobject." +"h``、``pyarena.h``、``pyctype.h``、``pydebug.h``、``pyfpe.h`` 和 ``pytime." +"h`` 已移至 ``Include/cpython`` 目錄。這些檔案不得直接被引入,因為它們已於 " +"``Python.h`` 中引入;請參閱 :ref:`api-includes`。如果直接引入它們,請考慮改為" +"引入 ``Python.h``。(由 Nicholas Sim 在 :issue:`35134` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2201 +#: ../../whatsnew/3.10.rst:2202 msgid "" "Use the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` type flag to create immutable " "type objects. Do not rely on :c:macro:`Py_TPFLAGS_HEAPTYPE` to decide if a " "type object is mutable or not; check if :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` " -"is set instead. (Contributed by Victor Stinner and Erlend E. Aasland " -"in :issue:`43908`.)" +"is set instead. (Contributed by Victor Stinner and Erlend E. Aasland in :" +"issue:`43908`.)" msgstr "" "使用 :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` 型別旗標來建立不可變型別物件。不要依" "賴 :c:macro:`Py_TPFLAGS_HEAPTYPE` 來決定型別物件是否可變;應改為檢查是否設定" "了 :c:macro:`Py_TPFLAGS_IMMUTABLETYPE`。(由 Victor Stinner 和 Erlend E. " "Aasland 在 :issue:`35134` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2207 +#: ../../whatsnew/3.10.rst:2208 msgid "" "The undocumented function ``Py_FrozenMain`` has been removed from the " "limited API. The function is mainly useful for custom builds of Python. " @@ -4347,7 +4302,7 @@ msgstr "" "未以說明文件記錄的函式 ``Py_FrozenMain`` 已從受限 API 中刪除。該函式主要用於 " "Python 的自定義建置。(由 Petr Viktorin 在 :issue:`26241` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2214 +#: ../../whatsnew/3.10.rst:2215 msgid "" "The ``PyUnicode_InternImmortal()`` function is now deprecated and will be " "removed in Python 3.12: use :c:func:`PyUnicode_InternInPlace` instead. " @@ -4357,7 +4312,7 @@ msgstr "" "用 :c:func:`PyUnicode_InternInPlace`。(由 Victor Stinner 在 :issue:`41692` " "中貢獻。)" -#: ../../whatsnew/3.10.rst:2222 +#: ../../whatsnew/3.10.rst:2223 msgid "" "Removed ``Py_UNICODE_str*`` functions manipulating ``Py_UNICODE*`` strings. " "(Contributed by Inada Naoki in :issue:`41123`.)" @@ -4365,47 +4320,47 @@ msgstr "" "刪除了操作 ``Py_UNICODE*`` 字串的 ``Py_UNICODE_str*`` 函式。(由 Inada Naoki " "在 :issue:`41123` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2225 +#: ../../whatsnew/3.10.rst:2226 msgid "" -"``Py_UNICODE_strlen``: use :c:func:`PyUnicode_GetLength` " -"or :c:macro:`PyUnicode_GET_LENGTH`" +"``Py_UNICODE_strlen``: use :c:func:`PyUnicode_GetLength` or :c:macro:" +"`PyUnicode_GET_LENGTH`" msgstr "" -"``Py_UNICODE_strlen``:使用 :c:func:`PyUnicode_GetLength` " -"或 :c:macro:`PyUnicode_GET_LENGTH`" +"``Py_UNICODE_strlen``:使用 :c:func:`PyUnicode_GetLength` 或 :c:macro:" +"`PyUnicode_GET_LENGTH`" -#: ../../whatsnew/3.10.rst:2227 +#: ../../whatsnew/3.10.rst:2228 msgid "" -"``Py_UNICODE_strcat``: use :c:func:`PyUnicode_CopyCharacters` " -"or :c:func:`PyUnicode_FromFormat`" +"``Py_UNICODE_strcat``: use :c:func:`PyUnicode_CopyCharacters` or :c:func:" +"`PyUnicode_FromFormat`" msgstr "" -"``Py_UNICODE_strcat``:使用 :c:func:`PyUnicode_CopyCharacters` " -"或 :c:func:`PyUnicode_FromFormat`" +"``Py_UNICODE_strcat``:使用 :c:func:`PyUnicode_CopyCharacters` 或 :c:func:" +"`PyUnicode_FromFormat`" -#: ../../whatsnew/3.10.rst:2229 +#: ../../whatsnew/3.10.rst:2230 msgid "" -"``Py_UNICODE_strcpy``, ``Py_UNICODE_strncpy``: " -"use :c:func:`PyUnicode_CopyCharacters` or :c:func:`PyUnicode_Substring`" +"``Py_UNICODE_strcpy``, ``Py_UNICODE_strncpy``: use :c:func:" +"`PyUnicode_CopyCharacters` or :c:func:`PyUnicode_Substring`" msgstr "" -"``Py_UNICODE_strcpy``、``Py_UNICODE_strncpy``:使" -"用 :c:func:`PyUnicode_CopyCharacters` 或 :c:func:`PyUnicode_Substring`" +"``Py_UNICODE_strcpy``、``Py_UNICODE_strncpy``:使用 :c:func:" +"`PyUnicode_CopyCharacters` 或 :c:func:`PyUnicode_Substring`" -#: ../../whatsnew/3.10.rst:2231 +#: ../../whatsnew/3.10.rst:2232 msgid "``Py_UNICODE_strcmp``: use :c:func:`PyUnicode_Compare`" msgstr "``Py_UNICODE_strcmp``:使用 :c:func:`PyUnicode_Compare`" -#: ../../whatsnew/3.10.rst:2232 +#: ../../whatsnew/3.10.rst:2233 msgid "``Py_UNICODE_strncmp``: use :c:func:`PyUnicode_Tailmatch`" msgstr "``Py_UNICODE_strncmp``:使用 :c:func:`PyUnicode_Tailmatch`" -#: ../../whatsnew/3.10.rst:2233 +#: ../../whatsnew/3.10.rst:2234 msgid "" -"``Py_UNICODE_strchr``, ``Py_UNICODE_strrchr``: " -"use :c:func:`PyUnicode_FindChar`" +"``Py_UNICODE_strchr``, ``Py_UNICODE_strrchr``: use :c:func:" +"`PyUnicode_FindChar`" msgstr "" -"``Py_UNICODE_strchr``、``Py_UNICODE_strrchr``:使" -"用 :c:func:`PyUnicode_FindChar`" +"``Py_UNICODE_strchr``、``Py_UNICODE_strrchr``:使用 :c:func:" +"`PyUnicode_FindChar`" -#: ../../whatsnew/3.10.rst:2236 +#: ../../whatsnew/3.10.rst:2237 msgid "" "Removed ``PyUnicode_GetMax()``. Please migrate to new (:pep:`393`) APIs. " "(Contributed by Inada Naoki in :issue:`41103`.)" @@ -4413,26 +4368,25 @@ msgstr "" "刪除了 ``PyUnicode_GetMax()``。請改用新的 (:pep:`393`) API。(由 Inada Naoki " "在 :issue:`41103` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2239 +#: ../../whatsnew/3.10.rst:2240 msgid "" -"Removed ``PyLong_FromUnicode()``. Please migrate " -"to :c:func:`PyLong_FromUnicodeObject`. (Contributed by Inada Naoki " -"in :issue:`41103`.)" +"Removed ``PyLong_FromUnicode()``. Please migrate to :c:func:" +"`PyLong_FromUnicodeObject`. (Contributed by Inada Naoki in :issue:`41103`.)" msgstr "" "刪除了 ``PyLong_FromUnicode()``。請改用 :c:func:`PyLong_FromUnicodeObject`。" "(由 Inada Naoki 在 :issue:`41103` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2242 +#: ../../whatsnew/3.10.rst:2243 msgid "" -"Removed ``PyUnicode_AsUnicodeCopy()``. Please " -"use :c:func:`PyUnicode_AsUCS4Copy` or :c:func:`PyUnicode_AsWideCharString` " -"(Contributed by Inada Naoki in :issue:`41103`.)" +"Removed ``PyUnicode_AsUnicodeCopy()``. Please use :c:func:" +"`PyUnicode_AsUCS4Copy` or :c:func:`PyUnicode_AsWideCharString` (Contributed " +"by Inada Naoki in :issue:`41103`.)" msgstr "" "刪除了 ``PyUnicode_AsUnicodeCopy()``。請改用 :c:func:`PyUnicode_AsUCS4Copy` " "或 :c:func:`PyUnicode_AsWideCharString` (由 Inada Naoki 在 :issue:`41103` 中" "貢獻。)" -#: ../../whatsnew/3.10.rst:2246 +#: ../../whatsnew/3.10.rst:2247 msgid "" "Removed ``_Py_CheckRecursionLimit`` variable: it has been replaced by " "``ceval.recursion_limit`` of the :c:type:`PyInterpreterState` structure. " @@ -4442,29 +4396,28 @@ msgstr "" "結構的 ``ceval.recursion_limit`` 取代。(由 Victor Stinner 在 :issue:`41834` " "中貢獻。)" -#: ../../whatsnew/3.10.rst:2250 +#: ../../whatsnew/3.10.rst:2251 msgid "" "Removed undocumented macros ``Py_ALLOW_RECURSION`` and " -"``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of " -"the :c:type:`PyInterpreterState` structure. (Contributed by Serhiy Storchaka " -"in :issue:`41936`.)" +"``Py_END_ALLOW_RECURSION`` and the ``recursion_critical`` field of the :c:" +"type:`PyInterpreterState` structure. (Contributed by Serhiy Storchaka in :" +"issue:`41936`.)" msgstr "" "刪除了未被說明文件記錄的巨集 ``Py_ALLOW_RECURSION`` 和 " "``Py_END_ALLOW_RECURSION`` 以及 :c:type:`PyInterpreterState` 結構的 " "``recursion_ritic`` 欄位。(由 Serhiy Storchaka 在 :issue:`41936` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2255 +#: ../../whatsnew/3.10.rst:2256 msgid "" "Removed the undocumented ``PyOS_InitInterrupts()`` function. Initializing " -"Python already implicitly installs signal handlers: " -"see :c:member:`PyConfig.install_signal_handlers`. (Contributed by Victor " -"Stinner in :issue:`41713`.)" +"Python already implicitly installs signal handlers: see :c:member:`PyConfig." +"install_signal_handlers`. (Contributed by Victor Stinner in :issue:`41713`.)" msgstr "" "刪除了未被說明文件記錄的 ``PyOS_InitInterrupts()`` 函式。初始化 Python 已經隱" "式安裝信號處理程式:請參閱 :c:member:`PyConfig.install_signal_handlers`。" "(由 Victor Stinner 在 :issue:`41713` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2260 +#: ../../whatsnew/3.10.rst:2261 msgid "" "Remove the ``PyAST_Validate()`` function. It is no longer possible to build " "a AST object (``mod_ty`` type) with the public C API. The function was " @@ -4475,44 +4428,44 @@ msgstr "" "(``mod_ty`` 類型)。該函式已被排除在受限 C API 之外 (:pep:`384`)。(由 " "Victor Stinner 在 :issue:`43244` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2265 +#: ../../whatsnew/3.10.rst:2266 msgid "Remove the ``symtable.h`` header file and the undocumented functions:" msgstr "刪除 ``symtable.h`` 標頭檔和未被說明文件記錄的函式:" -#: ../../whatsnew/3.10.rst:2267 +#: ../../whatsnew/3.10.rst:2268 msgid "``PyST_GetScope()``" msgstr "``PyST_GetScope()``" -#: ../../whatsnew/3.10.rst:2268 +#: ../../whatsnew/3.10.rst:2269 msgid "``PySymtable_Build()``" msgstr "``PySymtable_Build()``" -#: ../../whatsnew/3.10.rst:2269 +#: ../../whatsnew/3.10.rst:2270 msgid "``PySymtable_BuildObject()``" msgstr "``PySymtable_BuildObject()``" -#: ../../whatsnew/3.10.rst:2270 +#: ../../whatsnew/3.10.rst:2271 msgid "``PySymtable_Free()``" msgstr "``PySymtable_Free()``" -#: ../../whatsnew/3.10.rst:2271 +#: ../../whatsnew/3.10.rst:2272 msgid "``Py_SymtableString()``" msgstr "``Py_SymtableString()``" -#: ../../whatsnew/3.10.rst:2272 +#: ../../whatsnew/3.10.rst:2273 msgid "``Py_SymtableStringObject()``" msgstr "``Py_SymtableStringObject()``" -#: ../../whatsnew/3.10.rst:2274 +#: ../../whatsnew/3.10.rst:2275 msgid "" "The ``Py_SymtableString()`` function was part the stable ABI by mistake but " "it could not be used, because the ``symtable.h`` header file was excluded " "from the limited C API." msgstr "" -"``Py_SymtableString()`` 函式錯誤地成為穩定 ABI 的一部分,但它因為 " -"``symtable.h`` 標頭檔被排除在受限 C API 之外而無法使用。" +"``Py_SymtableString()`` 函式錯誤地成為穩定 ABI 的一部分,但它因為 ``symtable." +"h`` 標頭檔被排除在受限 C API 之外而無法使用。" -#: ../../whatsnew/3.10.rst:2278 +#: ../../whatsnew/3.10.rst:2279 msgid "" "Use Python :mod:`symtable` module instead. (Contributed by Victor Stinner " "in :issue:`43244`.)" @@ -4520,7 +4473,7 @@ msgstr "" "請改用 Python :mod:`symtable` 模組。(由 Victor Stinner 在 :issue:`43244` 中" "貢獻。)" -#: ../../whatsnew/3.10.rst:2281 +#: ../../whatsnew/3.10.rst:2282 msgid "" "Remove :c:func:`PyOS_ReadlineFunctionPointer` from the limited C API headers " "and from ``python3.dll``, the library that provides the stable ABI on " @@ -4531,7 +4484,7 @@ msgstr "" "刪除 :c:func:`PyOS_ReadlineFunctionPointer`。由於該函式採用 FILE* 引數,因此" "無法保證其 ABI 穩定性。(由 Petr Viktorin 在 :issue:`43868` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2287 +#: ../../whatsnew/3.10.rst:2288 msgid "" "Remove ``ast.h``, ``asdl.h``, and ``Python-ast.h`` header files. These " "functions were undocumented and excluded from the limited C API. Most names " @@ -4544,94 +4497,94 @@ msgstr "" "刪除 ``ast.h``、``asdl.h`` 和 ``Python-ast.h`` 標頭檔。這些函式沒有文件記錄," "並且被排除在受限 C API 之外。這些標頭檔定義的大多數名稱都沒有前綴 ``Py``,因" "此可能會產生名稱衝突。例如,``Python-ast.h`` 定義了一個 ``Yield`` 巨集,它與 " -"Windows ```` 標頭使用的 ``Yield`` 有名稱衝突。請改用 " -"Python :mod:`ast` 模組。(由 Victor Stinner 在 :issue:`43244` 中貢獻。)" +"Windows ```` 標頭使用的 ``Yield`` 有名稱衝突。請改用 Python :mod:" +"`ast` 模組。(由 Victor Stinner 在 :issue:`43244` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2295 +#: ../../whatsnew/3.10.rst:2296 msgid "" "Remove the compiler and parser functions using ``struct _mod`` type, because " "the public AST C API was removed:" msgstr "" "刪除編譯器和使用 ``struct _mod`` 的剖析器函式,因為公開 AST C API 已被刪除:" -#: ../../whatsnew/3.10.rst:2298 +#: ../../whatsnew/3.10.rst:2299 msgid "``PyAST_Compile()``" msgstr "``PyAST_Compile()``" -#: ../../whatsnew/3.10.rst:2299 +#: ../../whatsnew/3.10.rst:2300 msgid "``PyAST_CompileEx()``" msgstr "``PyAST_CompileEx()``" -#: ../../whatsnew/3.10.rst:2300 +#: ../../whatsnew/3.10.rst:2301 msgid "``PyAST_CompileObject()``" msgstr "``PyAST_CompileObject()``" -#: ../../whatsnew/3.10.rst:2301 +#: ../../whatsnew/3.10.rst:2302 msgid "``PyFuture_FromAST()``" msgstr "``PyFuture_FromAST()``" -#: ../../whatsnew/3.10.rst:2302 +#: ../../whatsnew/3.10.rst:2303 msgid "``PyFuture_FromASTObject()``" msgstr "``PyFuture_FromASTObject()``" -#: ../../whatsnew/3.10.rst:2303 +#: ../../whatsnew/3.10.rst:2304 msgid "``PyParser_ASTFromFile()``" msgstr "``PyParser_ASTFromFile()``" -#: ../../whatsnew/3.10.rst:2304 +#: ../../whatsnew/3.10.rst:2305 msgid "``PyParser_ASTFromFileObject()``" msgstr "``PyParser_ASTFromFileObject()``" -#: ../../whatsnew/3.10.rst:2305 +#: ../../whatsnew/3.10.rst:2306 msgid "``PyParser_ASTFromFilename()``" msgstr "``PyParser_ASTFromFilename()``" -#: ../../whatsnew/3.10.rst:2306 +#: ../../whatsnew/3.10.rst:2307 msgid "``PyParser_ASTFromString()``" msgstr "``PyParser_ASTFromString()``" -#: ../../whatsnew/3.10.rst:2307 +#: ../../whatsnew/3.10.rst:2308 msgid "``PyParser_ASTFromStringObject()``" msgstr "``PyParser_ASTFromStringObject()``" -#: ../../whatsnew/3.10.rst:2309 +#: ../../whatsnew/3.10.rst:2310 msgid "" "These functions were undocumented and excluded from the limited C API. " "(Contributed by Victor Stinner in :issue:`43244`.)" msgstr "" -"這些函式沒有文件記錄,並且被排除在受限 C API 之外。(由 Victor Stinner " -"在 :issue:`43244` 中貢獻。)" +"這些函式沒有文件記錄,並且被排除在受限 C API 之外。(由 Victor Stinner 在 :" +"issue:`43244` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2312 +#: ../../whatsnew/3.10.rst:2313 msgid "Remove the ``pyarena.h`` header file with functions:" msgstr "刪除包含以下函式的 ``pyarena.h`` 標頭檔:" -#: ../../whatsnew/3.10.rst:2314 +#: ../../whatsnew/3.10.rst:2315 msgid "``PyArena_New()``" msgstr "``PyArena_New()``" -#: ../../whatsnew/3.10.rst:2315 +#: ../../whatsnew/3.10.rst:2316 msgid "``PyArena_Free()``" msgstr "``PyArena_Free()``" -#: ../../whatsnew/3.10.rst:2316 +#: ../../whatsnew/3.10.rst:2317 msgid "``PyArena_Malloc()``" msgstr "``PyArena_Malloc()``" -#: ../../whatsnew/3.10.rst:2317 +#: ../../whatsnew/3.10.rst:2318 msgid "``PyArena_AddPyObject()``" msgstr "``PyArena_AddPyObject()``" -#: ../../whatsnew/3.10.rst:2319 +#: ../../whatsnew/3.10.rst:2320 msgid "" "These functions were undocumented, excluded from the limited C API, and were " -"only used internally by the compiler. (Contributed by Victor Stinner " -"in :issue:`43244`.)" +"only used internally by the compiler. (Contributed by Victor Stinner in :" +"issue:`43244`.)" msgstr "" "這些函式沒有文件記錄、被排除在受限 C API 之外,並僅被編譯器於內部使用。(由 " "Victor Stinner 在 :issue:`43244` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2323 +#: ../../whatsnew/3.10.rst:2324 msgid "" "The ``PyThreadState.use_tracing`` member has been removed to optimize " "Python. (Contributed by Mark Shannon in :issue:`43760`.)" @@ -4639,11 +4592,11 @@ msgstr "" "為了 Python 最佳化,已刪除 ``PyThreadState.use_tracing`` 成員。(由 Mark " "Shannon 在 :issue:`43760` 中貢獻。)" -#: ../../whatsnew/3.10.rst:2328 +#: ../../whatsnew/3.10.rst:2329 msgid "Notable security feature in 3.10.7" msgstr "" -#: ../../whatsnew/3.10.rst:2330 +#: ../../whatsnew/3.10.rst:2331 msgid "" "Converting between :class:`int` and :class:`str` in bases other than 2 " "(binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal) " @@ -4656,28 +4609,28 @@ msgid "" "digits in string form." msgstr "" -#: ../../whatsnew/3.10.rst:2341 +#: ../../whatsnew/3.10.rst:2342 msgid "Notable security feature in 3.10.8" msgstr "" -#: ../../whatsnew/3.10.rst:2343 +#: ../../whatsnew/3.10.rst:2344 msgid "" "The deprecated :mod:`!mailcap` module now refuses to inject unsafe text " "(filenames, MIME types, parameters) into shell commands. Instead of using " "such text, it will warn and act as if a match was not found (or for test " -"commands, as if the test failed). (Contributed by Petr Viktorin " -"in :gh:`98966`.)" +"commands, as if the test failed). (Contributed by Petr Viktorin in :gh:" +"`98966`.)" msgstr "" -#: ../../whatsnew/3.10.rst:2350 +#: ../../whatsnew/3.10.rst:2351 msgid "Notable changes in 3.10.12" msgstr "" -#: ../../whatsnew/3.10.rst:2353 +#: ../../whatsnew/3.10.rst:2354 msgid "tarfile" msgstr "tarfile" -#: ../../whatsnew/3.10.rst:2355 +#: ../../whatsnew/3.10.rst:2356 msgid "" "The extraction methods in :mod:`tarfile`, and :func:`shutil.unpack_archive`, " "have a new a *filter* argument that allows limiting tar features than may be " diff --git a/whatsnew/3.12.po b/whatsnew/3.12.po index b03e6092a8..eece8f6a4f 100644 --- a/whatsnew/3.12.po +++ b/whatsnew/3.12.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-30 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -31,8 +31,8 @@ msgstr "Adam Turner" #: ../../whatsnew/3.12.rst:48 msgid "" "This article explains the new features in Python 3.12, compared to 3.11. " -"Python 3.12 was released on October 2, 2023. For full details, see " -"the :ref:`changelog `." +"Python 3.12 was released on October 2, 2023. For full details, see the :ref:" +"`changelog `." msgstr "" "本文介紹了 Python 3.12 與 3.11 相比多了哪些新功能。 Python 3.12 於 2023 年 " "10 月 2 日發布。完整詳情請見 :ref:`changelog `。" @@ -55,18 +55,18 @@ msgid "" "improvements, and several modules have better performance." msgstr "" "Python 3.12 是 Python 程式語言的穩定版本,包含了語言和標準函式庫的綜合變更。" -"標準函式庫的變更主要集中在清理棄用的 API、可用性和正確性。值得注意的" -"是,:mod:`!distutils` 套件已從標準函式庫中移除。:mod:`os` 和 :mod:`pathlib` " -"中的檔案系統支援進行了許多改進,並且有數個模組得到更好的效能。" +"標準函式庫的變更主要集中在清理棄用的 API、可用性和正確性。值得注意的是,:mod:" +"`!distutils` 套件已從標準函式庫中移除。:mod:`os` 和 :mod:`pathlib` 中的檔案系" +"統支援進行了許多改進,並且有數個模組得到更好的效能。" #: ../../whatsnew/3.12.rst:69 msgid "" "The language changes focus on usability, as :term:`f-strings ` " "have had many limitations removed and 'Did you mean ...' suggestions " "continue to improve. The new :ref:`type parameter syntax ` and :keyword:`type` statement improve ergonomics for " -"using :term:`generic types ` and :term:`type aliases ` with static type checkers." +"pep695>` and :keyword:`type` statement improve ergonomics for using :term:" +"`generic types ` and :term:`type aliases ` with " +"static type checkers." msgstr "" "語言變更主要集中在可用性,因為 :term:`f-字串 `\\ 已經移除了許多限" "制,並且持續改進 'Did you mean ...' 建議。新的\\ :ref:`型別參數語法 " @@ -95,8 +95,8 @@ msgstr "新增語法特性:" #: ../../whatsnew/3.12.rst:92 msgid "" -":ref:`PEP 695 `, type parameter syntax and " -"the :keyword:`type` statement" +":ref:`PEP 695 `, type parameter syntax and the :keyword:" +"`type` statement" msgstr "" ":ref:`PEP 695 `,型別參數語法和 :keyword:`type` 陳述式" @@ -129,8 +129,8 @@ msgstr ":ref:`PEP 669 `,低影響監控" #: ../../whatsnew/3.12.rst:103 msgid "" -"`Improved 'Did you mean ...' suggestions `_ " -"for :exc:`NameError`, :exc:`ImportError`, and :exc:`SyntaxError` exceptions" +"`Improved 'Did you mean ...' suggestions `_ for :" +"exc:`NameError`, :exc:`ImportError`, and :exc:`SyntaxError` exceptions" msgstr "" #: ../../whatsnew/3.12.rst:106 @@ -157,15 +157,15 @@ msgstr ":mod:`os` 模組在 Windows 支援上有了數項改進" #: ../../whatsnew/3.12.rst:115 msgid "" -"A :ref:`command-line interface ` has been added to " -"the :mod:`sqlite3` module" +"A :ref:`command-line interface ` has been added to the :mod:" +"`sqlite3` module" msgstr "" "一個\\ :ref:`命令列介面 `\\ 已被加入 :mod:`sqlite3` 模組中" #: ../../whatsnew/3.12.rst:117 msgid "" -":func:`isinstance` checks against :func:`runtime-checkable protocols " -"` enjoy a speed up of between two and 20 times" +":func:`isinstance` checks against :func:`runtime-checkable protocols ` enjoy a speed up of between two and 20 times" msgstr "" #: ../../whatsnew/3.12.rst:119 @@ -236,8 +236,8 @@ msgid "" ":ref:`PEP 692 `, using :class:`~typing.TypedDict` to " "annotate :term:`**kwargs `" msgstr "" -":ref:`PEP 692 `、使用 :class:`~typing.TypedDict` 來標" -"註 :term:`**kwargs `" +":ref:`PEP 692 `、使用 :class:`~typing.TypedDict` 來標註 :" +"term:`**kwargs `" #: ../../whatsnew/3.12.rst:149 msgid ":ref:`PEP 698 `, :func:`typing.override` decorator" @@ -277,9 +277,9 @@ msgid "" "removed, along with several :class:`unittest.TestCase` `method aliases " "`_." msgstr "" -":mod:`!asynchat`、:mod:`!asyncore` 和 :mod:`!imp` 模組以及幾" -"個 :class:`unittest.TestCase` 的\\ `方法別名 `_\\ 已被刪除。" +":mod:`!asynchat`、:mod:`!asyncore` 和 :mod:`!imp` 模組以及幾個 :class:" +"`unittest.TestCase` 的\\ `方法別名 `_\\ " +"已被刪除。" #: ../../whatsnew/3.12.rst:176 ../../whatsnew/3.12.rst:1840 msgid "New Features" @@ -298,8 +298,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:187 msgid "" -":pep:`695` introduces a new, more compact and explicit way to " -"create :ref:`generic classes ` and :ref:`functions ` and :ref:`functions `::" msgstr "" @@ -346,9 +346,9 @@ msgstr "type Point[T] = tuple[T, T]" #: ../../whatsnew/3.12.rst:210 msgid "" -"The new syntax allows declaring :class:`~typing.TypeVarTuple` " -"and :class:`~typing.ParamSpec` parameters, as well " -"as :class:`~typing.TypeVar` parameters with bounds or constraints::" +"The new syntax allows declaring :class:`~typing.TypeVarTuple` and :class:" +"`~typing.ParamSpec` parameters, as well as :class:`~typing.TypeVar` " +"parameters with bounds or constraints::" msgstr "" #: ../../whatsnew/3.12.rst:214 @@ -444,11 +444,10 @@ msgstr "" #: ../../whatsnew/3.12.rst:290 msgid "" "Backslashes and unicode characters: before Python 3.12 f-string expressions " -"couldn't contain any ``\\`` character. This also affected " -"unicode :ref:`escape sequences ` (such as ``\\N{snowman}" -"``) as these contain the ``\\N`` part that previously could not be part of " -"expression components of f-strings. Now, you can define expressions like " -"this:" +"couldn't contain any ``\\`` character. This also affected unicode :ref:" +"`escape sequences ` (such as ``\\N{snowman}``) as these " +"contain the ``\\N`` part that previously could not be part of expression " +"components of f-strings. Now, you can define expressions like this:" msgstr "" #: ../../whatsnew/3.12.rst:303 @@ -588,17 +587,16 @@ msgstr "" #: ../../whatsnew/3.12.rst:386 msgid "" ":pep:`688` introduces a way to use the :ref:`buffer protocol " -"` from Python code. Classes that implement " -"the :meth:`~object.__buffer__` method are now usable as buffer types." +"` from Python code. Classes that implement the :meth:`~object." +"__buffer__` method are now usable as buffer types." msgstr "" #: ../../whatsnew/3.12.rst:390 msgid "" "The new :class:`collections.abc.Buffer` ABC provides a standard way to " -"represent buffer objects, for example in type annotations. The " -"new :class:`inspect.BufferFlags` enum represents the flags that can be used " -"to customize buffer creation. (Contributed by Jelle Zijlstra " -"in :gh:`102500`.)" +"represent buffer objects, for example in type annotations. The new :class:" +"`inspect.BufferFlags` enum represents the flags that can be used to " +"customize buffer creation. (Contributed by Jelle Zijlstra in :gh:`102500`.)" msgstr "" #: ../../whatsnew/3.12.rst:399 @@ -677,8 +675,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:459 msgid "" "Improve the :exc:`SyntaxError` error message when the user types ``import x " -"from y`` instead of ``from y import x``. (Contributed by Pablo Galindo " -"in :gh:`98931`.)" +"from y`` instead of ``from y import x``. (Contributed by Pablo Galindo in :" +"gh:`98931`.)" msgstr "" #: ../../whatsnew/3.12.rst:469 @@ -695,8 +693,8 @@ msgstr "型別提示相關的新特性" #: ../../whatsnew/3.12.rst:482 msgid "" -"This section covers major changes affecting :pep:`type hints <484>` and " -"the :mod:`typing` module." +"This section covers major changes affecting :pep:`type hints <484>` and the :" +"mod:`typing` module." msgstr "" "本節涵蓋了影響\\ :pep:`型別提示 <484>`\\ 和 :mod:`typing` 模組的主要變更。" @@ -803,18 +801,17 @@ msgid "" "a :exc:`SyntaxWarning`, instead of :exc:`DeprecationWarning`. For example, " "``re.compile(\"\\d+\\.\\d+\")`` now emits a :exc:`SyntaxWarning` " "(``\"\\d\"`` is an invalid escape sequence, use raw strings for regular " -"expression: ``re.compile(r\"\\d+\\.\\d+\")``). In a future Python " -"version, :exc:`SyntaxError` will eventually be raised, instead " -"of :exc:`SyntaxWarning`. (Contributed by Victor Stinner in :gh:`98401`.)" +"expression: ``re.compile(r\"\\d+\\.\\d+\")``). In a future Python version, :" +"exc:`SyntaxError` will eventually be raised, instead of :exc:" +"`SyntaxWarning`. (Contributed by Victor Stinner in :gh:`98401`.)" msgstr "" #: ../../whatsnew/3.12.rst:557 msgid "" "Octal escapes with value larger than ``0o377`` (ex: ``\"\\477\"``), " -"deprecated in Python 3.11, now produce a :exc:`SyntaxWarning`, instead " -"of :exc:`DeprecationWarning`. In a future Python version they will be " -"eventually a :exc:`SyntaxError`. (Contributed by Victor Stinner " -"in :gh:`98401`.)" +"deprecated in Python 3.11, now produce a :exc:`SyntaxWarning`, instead of :" +"exc:`DeprecationWarning`. In a future Python version they will be eventually " +"a :exc:`SyntaxError`. (Contributed by Victor Stinner in :gh:`98401`.)" msgstr "" #: ../../whatsnew/3.12.rst:563 @@ -837,9 +834,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:574 msgid "" "When a ``try-except*`` construct handles the entire :exc:`ExceptionGroup` " -"and raises one other exception, that exception is no longer wrapped in " -"an :exc:`ExceptionGroup`. Also changed in version 3.11.4. (Contributed by " -"Irit Katriel in :gh:`103590`.)" +"and raises one other exception, that exception is no longer wrapped in an :" +"exc:`ExceptionGroup`. Also changed in version 3.11.4. (Contributed by Irit " +"Katriel in :gh:`103590`.)" msgstr "" #: ../../whatsnew/3.12.rst:579 @@ -848,8 +845,8 @@ msgid "" "Python bytecode evaluation loop instead of object allocations. The GC can " "also run when :c:func:`PyErr_CheckSignals` is called so C extensions that " "need to run for a long time without executing any Python code also have a " -"chance to execute the GC periodically. (Contributed by Pablo Galindo " -"in :gh:`97922`.)" +"chance to execute the GC periodically. (Contributed by Pablo Galindo in :gh:" +"`97922`.)" msgstr "" #: ../../whatsnew/3.12.rst:586 @@ -905,13 +902,12 @@ msgstr "" #: ../../whatsnew/3.12.rst:616 msgid "" "Add :ref:`support for the perf profiler ` through the new " -"environment variable :envvar:`PYTHONPERFSUPPORT` and command-line " -"option :option:`-X perf <-X>`, as well as the " -"new :func:`sys.activate_stack_trampoline`, :func:`sys.deactivate_stack_trampoline`, " -"and :func:`sys.is_stack_trampoline_active` functions. (Design by Pablo " -"Galindo. Contributed by Pablo Galindo and Christian Heimes with " -"contributions from Gregory P. Smith [Google] and Mark Shannon " -"in :gh:`96123`.)" +"environment variable :envvar:`PYTHONPERFSUPPORT` and command-line option :" +"option:`-X perf <-X>`, as well as the new :func:`sys." +"activate_stack_trampoline`, :func:`sys.deactivate_stack_trampoline`, and :" +"func:`sys.is_stack_trampoline_active` functions. (Design by Pablo Galindo. " +"Contributed by Pablo Galindo and Christian Heimes with contributions from " +"Gregory P. Smith [Google] and Mark Shannon in :gh:`96123`.)" msgstr "" #: ../../whatsnew/3.12.rst:628 @@ -932,8 +928,8 @@ msgstr "array" #: ../../whatsnew/3.12.rst:639 msgid "" -"The :class:`array.array` class now supports subscripting, making it " -"a :term:`generic type`. (Contributed by Jelle Zijlstra in :gh:`98658`.)" +"The :class:`array.array` class now supports subscripting, making it a :term:" +"`generic type`. (Contributed by Jelle Zijlstra in :gh:`98658`.)" msgstr "" #: ../../whatsnew/3.12.rst:643 @@ -950,28 +946,25 @@ msgstr "" #: ../../whatsnew/3.12.rst:650 msgid "" -"Add :func:`asyncio.eager_task_factory` " -"and :func:`asyncio.create_eager_task_factory` functions to allow opting an " -"event loop in to eager task execution, making some use-cases 2x to 5x " -"faster. (Contributed by Jacob Bower & Itamar Oren " -"in :gh:`102853`, :gh:`104140`, and :gh:`104138`)" +"Add :func:`asyncio.eager_task_factory` and :func:`asyncio." +"create_eager_task_factory` functions to allow opting an event loop in to " +"eager task execution, making some use-cases 2x to 5x faster. (Contributed by " +"Jacob Bower & Itamar Oren in :gh:`102853`, :gh:`104140`, and :gh:`104138`)" msgstr "" #: ../../whatsnew/3.12.rst:655 msgid "" "On Linux, :mod:`asyncio` uses :class:`asyncio.PidfdChildWatcher` by default " -"if :func:`os.pidfd_open` is available and functional instead " -"of :class:`asyncio.ThreadedChildWatcher`. (Contributed by Kumar Aditya " -"in :gh:`98024`.)" +"if :func:`os.pidfd_open` is available and functional instead of :class:" +"`asyncio.ThreadedChildWatcher`. (Contributed by Kumar Aditya in :gh:`98024`.)" msgstr "" #: ../../whatsnew/3.12.rst:660 msgid "" -"The event loop now uses the best available child watcher for each platform " -"(:class:`asyncio.PidfdChildWatcher` if supported " -"and :class:`asyncio.ThreadedChildWatcher` otherwise), so manually " -"configuring a child watcher is not recommended. (Contributed by Kumar Aditya " -"in :gh:`94597`.)" +"The event loop now uses the best available child watcher for each platform (:" +"class:`asyncio.PidfdChildWatcher` if supported and :class:`asyncio." +"ThreadedChildWatcher` otherwise), so manually configuring a child watcher is " +"not recommended. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" #: ../../whatsnew/3.12.rst:666 @@ -988,9 +981,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:673 msgid "" -":func:`asyncio.iscoroutine` now returns ``False`` for generators " -"as :mod:`asyncio` does not support legacy generator-based coroutines. " -"(Contributed by Kumar Aditya in :gh:`102748`.)" +":func:`asyncio.iscoroutine` now returns ``False`` for generators as :mod:" +"`asyncio` does not support legacy generator-based coroutines. (Contributed " +"by Kumar Aditya in :gh:`102748`.)" msgstr "" #: ../../whatsnew/3.12.rst:677 @@ -1006,8 +999,8 @@ msgstr "calendar" #: ../../whatsnew/3.12.rst:684 msgid "" "Add enums :data:`calendar.Month` and :data:`calendar.Day` defining months of " -"the year and days of the week. (Contributed by Prince Roshan " -"in :gh:`103636`.)" +"the year and days of the week. (Contributed by Prince Roshan in :gh:" +"`103636`.)" msgstr "" #: ../../whatsnew/3.12.rst:689 @@ -1017,8 +1010,8 @@ msgstr "csv" #: ../../whatsnew/3.12.rst:691 msgid "" "Add :const:`csv.QUOTE_NOTNULL` and :const:`csv.QUOTE_STRINGS` flags to " -"provide finer grained control of ``None`` and empty strings " -"by :class:`~csv.reader` and :class:`~csv.writer` objects." +"provide finer grained control of ``None`` and empty strings by :class:`~csv." +"reader` and :class:`~csv.writer` objects." msgstr "" #: ../../whatsnew/3.12.rst:696 @@ -1028,10 +1021,10 @@ msgstr "dis" #: ../../whatsnew/3.12.rst:698 msgid "" "Pseudo instruction opcodes (which are used by the compiler but do not appear " -"in executable bytecode) are now exposed in the :mod:`dis` " -"module. :opcode:`HAVE_ARGUMENT` is still relevant to real opcodes, but it is " -"not useful for pseudo instructions. Use the new :data:`dis.hasarg` " -"collection instead. (Contributed by Irit Katriel in :gh:`94216`.)" +"in executable bytecode) are now exposed in the :mod:`dis` module. :opcode:" +"`HAVE_ARGUMENT` is still relevant to real opcodes, but it is not useful for " +"pseudo instructions. Use the new :data:`dis.hasarg` collection instead. " +"(Contributed by Irit Katriel in :gh:`94216`.)" msgstr "" #: ../../whatsnew/3.12.rst:706 @@ -1125,8 +1118,8 @@ msgid "" "Add :func:`math.sumprod` for computing a sum of products. (Contributed by " "Raymond Hettinger in :gh:`100485`.)" msgstr "" -"新增 :func:`math.sumprod` 以計算乘積總和。(由 Raymond Hettinger " -"於 :gh:`100485` 中貢獻。)" +"新增 :func:`math.sumprod` 以計算乘積總和。(由 Raymond Hettinger 於 :gh:" +"`100485` 中貢獻。)" #: ../../whatsnew/3.12.rst:752 msgid "" @@ -1141,16 +1134,16 @@ msgstr "os" #: ../../whatsnew/3.12.rst:759 msgid "" -"Add :const:`os.PIDFD_NONBLOCK` to open a file descriptor for a process " -"with :func:`os.pidfd_open` in non-blocking mode. (Contributed by Kumar " -"Aditya in :gh:`93312`.)" +"Add :const:`os.PIDFD_NONBLOCK` to open a file descriptor for a process with :" +"func:`os.pidfd_open` in non-blocking mode. (Contributed by Kumar Aditya in :" +"gh:`93312`.)" msgstr "" #: ../../whatsnew/3.12.rst:763 msgid "" ":class:`os.DirEntry` now includes an :meth:`os.DirEntry.is_junction` method " -"to check if the entry is a junction. (Contributed by Charles Machalow " -"in :gh:`99547`.)" +"to check if the entry is a junction. (Contributed by Charles Machalow in :gh:" +"`99547`.)" msgstr "" #: ../../whatsnew/3.12.rst:767 @@ -1169,8 +1162,8 @@ msgid "" "with other platforms). ``st_dev`` may be up to 64 bits and ``st_ino`` up to " "128 bits depending on your file system, and ``st_rdev`` is always set to " "zero rather than incorrect values. Both functions may be significantly " -"faster on newer releases of Windows. (Contributed by Steve Dower " -"in :gh:`99726`.)" +"faster on newer releases of Windows. (Contributed by Steve Dower in :gh:" +"`99726`.)" msgstr "" #: ../../whatsnew/3.12.rst:782 @@ -1199,10 +1192,10 @@ msgstr "pathlib" #: ../../whatsnew/3.12.rst:793 msgid "" -"Add support for subclassing :class:`pathlib.PurePath` " -"and :class:`pathlib.Path`, plus their Posix- and Windows-specific variants. " -"Subclasses may override the :meth:`pathlib.PurePath.with_segments` method to " -"pass information between path instances." +"Add support for subclassing :class:`pathlib.PurePath` and :class:`pathlib." +"Path`, plus their Posix- and Windows-specific variants. Subclasses may " +"override the :meth:`pathlib.PurePath.with_segments` method to pass " +"information between path instances." msgstr "" #: ../../whatsnew/3.12.rst:798 @@ -1216,23 +1209,22 @@ msgstr "" msgid "" "Add *walk_up* optional parameter to :meth:`pathlib.PurePath.relative_to` to " "allow the insertion of ``..`` entries in the result; this behavior is more " -"consistent with :func:`os.path.relpath`. (Contributed by Domenico Ragusa " -"in :gh:`84538`.)" +"consistent with :func:`os.path.relpath`. (Contributed by Domenico Ragusa in :" +"gh:`84538`.)" msgstr "" #: ../../whatsnew/3.12.rst:807 msgid "" -"Add :meth:`pathlib.Path.is_junction` as a proxy " -"to :func:`os.path.isjunction`. (Contributed by Charles Machalow " -"in :gh:`99547`.)" +"Add :meth:`pathlib.Path.is_junction` as a proxy to :func:`os.path." +"isjunction`. (Contributed by Charles Machalow in :gh:`99547`.)" msgstr "" #: ../../whatsnew/3.12.rst:810 msgid "" -"Add *case_sensitive* optional parameter " -"to :meth:`pathlib.Path.glob`, :meth:`pathlib.Path.rglob` " -"and :meth:`pathlib.PurePath.match` for matching the path's case sensitivity, " -"allowing for more precise control over the matching process." +"Add *case_sensitive* optional parameter to :meth:`pathlib.Path.glob`, :meth:" +"`pathlib.Path.rglob` and :meth:`pathlib.PurePath.match` for matching the " +"path's case sensitivity, allowing for more precise control over the matching " +"process." msgstr "" #: ../../whatsnew/3.12.rst:815 @@ -1264,8 +1256,8 @@ msgstr "random" #: ../../whatsnew/3.12.rst:833 msgid "" -"Add :func:`random.binomialvariate`. (Contributed by Raymond Hettinger " -"in :gh:`81620`.)" +"Add :func:`random.binomialvariate`. (Contributed by Raymond Hettinger in :gh:" +"`81620`.)" msgstr "" "新增 :func:`random.binomialvariate`。(由 Raymond Hettinger 於 :gh:`81620` 中" "貢獻。)" @@ -1329,31 +1321,29 @@ msgid "" "Add a :ref:`command-line interface `. (Contributed by Erlend E. " "Aasland in :gh:`77617`.)" msgstr "" -"新增\\ :ref:`命令列介面 `。(由 Erlend E. Aasland " -"於 :gh:`77617` 中貢獻。)" +"新增\\ :ref:`命令列介面 `。(由 Erlend E. Aasland 於 :gh:" +"`77617` 中貢獻。)" #: ../../whatsnew/3.12.rst:874 msgid "" -"Add the :attr:`sqlite3.Connection.autocommit` attribute " -"to :class:`sqlite3.Connection` and the *autocommit* parameter " -"to :func:`sqlite3.connect` to control :pep:`249`-compliant :ref:`transaction " -"handling `. (Contributed by Erlend " -"E. Aasland in :gh:`83638`.)" +"Add the :attr:`sqlite3.Connection.autocommit` attribute to :class:`sqlite3." +"Connection` and the *autocommit* parameter to :func:`sqlite3.connect` to " +"control :pep:`249`-compliant :ref:`transaction handling `. (Contributed by Erlend E. Aasland in :gh:`83638`.)" msgstr "" #: ../../whatsnew/3.12.rst:881 msgid "" -"Add *entrypoint* keyword-only parameter " -"to :meth:`sqlite3.Connection.load_extension`, for overriding the SQLite " -"extension entry point. (Contributed by Erlend E. Aasland in :gh:`103015`.)" +"Add *entrypoint* keyword-only parameter to :meth:`sqlite3.Connection." +"load_extension`, for overriding the SQLite extension entry point. " +"(Contributed by Erlend E. Aasland in :gh:`103015`.)" msgstr "" #: ../../whatsnew/3.12.rst:886 msgid "" -"Add :meth:`sqlite3.Connection.getconfig` " -"and :meth:`sqlite3.Connection.setconfig` to :class:`sqlite3.Connection` to " -"make configuration changes to a database connection. (Contributed by Erlend " -"E. Aasland in :gh:`103489`.)" +"Add :meth:`sqlite3.Connection.getconfig` and :meth:`sqlite3.Connection." +"setconfig` to :class:`sqlite3.Connection` to make configuration changes to a " +"database connection. (Contributed by Erlend E. Aasland in :gh:`103489`.)" msgstr "" #: ../../whatsnew/3.12.rst:892 @@ -1374,28 +1364,27 @@ msgstr "sys" #: ../../whatsnew/3.12.rst:901 msgid "" "Add the :mod:`sys.monitoring` namespace to expose the new :ref:`PEP 669 " -"` monitoring API. (Contributed by Mark Shannon " -"in :gh:`103082`.)" +"` monitoring API. (Contributed by Mark Shannon in :gh:" +"`103082`.)" msgstr "" #: ../../whatsnew/3.12.rst:905 msgid "" -"Add :func:`sys.activate_stack_trampoline` " -"and :func:`sys.deactivate_stack_trampoline` for activating and deactivating " -"stack profiler trampolines, and :func:`sys.is_stack_trampoline_active` for " -"querying if stack profiler trampolines are active. (Contributed by Pablo " -"Galindo and Christian Heimes with contributions from Gregory P. Smith " -"[Google] and Mark Shannon in :gh:`96123`.)" +"Add :func:`sys.activate_stack_trampoline` and :func:`sys." +"deactivate_stack_trampoline` for activating and deactivating stack profiler " +"trampolines, and :func:`sys.is_stack_trampoline_active` for querying if " +"stack profiler trampolines are active. (Contributed by Pablo Galindo and " +"Christian Heimes with contributions from Gregory P. Smith [Google] and Mark " +"Shannon in :gh:`96123`.)" msgstr "" #: ../../whatsnew/3.12.rst:914 msgid "" "Add :data:`sys.last_exc` which holds the last unhandled exception that was " "raised (for post-mortem debugging use cases). Deprecate the three fields " -"that have the same information in its legacy " -"form: :data:`sys.last_type`, :data:`sys.last_value` " -"and :data:`sys.last_traceback`. (Contributed by Irit Katriel " -"in :gh:`102778`.)" +"that have the same information in its legacy form: :data:`sys.last_type`, :" +"data:`sys.last_value` and :data:`sys.last_traceback`. (Contributed by Irit " +"Katriel in :gh:`102778`.)" msgstr "" #: ../../whatsnew/3.12.rst:920 ../../whatsnew/3.12.rst:1739 @@ -1439,10 +1428,10 @@ msgstr "threading" #: ../../whatsnew/3.12.rst:940 msgid "" -"Add :func:`threading.settrace_all_threads` " -"and :func:`threading.setprofile_all_threads` that allow to set tracing and " -"profiling functions in all running threads in addition to the calling one. " -"(Contributed by Pablo Galindo in :gh:`93503`.)" +"Add :func:`threading.settrace_all_threads` and :func:`threading." +"setprofile_all_threads` that allow to set tracing and profiling functions in " +"all running threads in addition to the calling one. (Contributed by Pablo " +"Galindo in :gh:`93503`.)" msgstr "" #: ../../whatsnew/3.12.rst:946 @@ -1466,9 +1455,9 @@ msgstr "tokenize" #: ../../whatsnew/3.12.rst:959 msgid "" "The :mod:`tokenize` module includes the changes introduced in :pep:`701`. " -"(Contributed by Marta Gómez Macías and Pablo Galindo in :gh:`102856`.) " -"See :ref:`whatsnew312-porting-to-python312` for more information on the " -"changes to the :mod:`tokenize` module." +"(Contributed by Marta Gómez Macías and Pablo Galindo in :gh:`102856`.) See :" +"ref:`whatsnew312-porting-to-python312` for more information on the changes " +"to the :mod:`tokenize` module." msgstr "" #: ../../whatsnew/3.12.rst:965 @@ -1477,9 +1466,9 @@ msgstr "types" #: ../../whatsnew/3.12.rst:967 msgid "" -"Add :func:`types.get_original_bases` to allow for further introspection " -"of :ref:`user-defined-generics` when subclassed. (Contributed by James " -"Hilton-Balfe and Alex Waygood in :gh:`101827`.)" +"Add :func:`types.get_original_bases` to allow for further introspection of :" +"ref:`user-defined-generics` when subclassed. (Contributed by James Hilton-" +"Balfe and Alex Waygood in :gh:`101827`.)" msgstr "" #: ../../whatsnew/3.12.rst:974 @@ -1488,16 +1477,15 @@ msgstr "typing" #: ../../whatsnew/3.12.rst:976 msgid "" -":func:`isinstance` checks against :func:`runtime-checkable protocols " -"` now use :func:`inspect.getattr_static` rather " -"than :func:`hasattr` to lookup whether attributes exist. This means that " -"descriptors and :meth:`~object.__getattr__` methods are no longer " -"unexpectedly evaluated during ``isinstance()`` checks against runtime-" -"checkable protocols. However, it may also mean that some objects which used " -"to be considered instances of a runtime-checkable protocol may no longer be " -"considered instances of that protocol on Python 3.12+, and vice versa. Most " -"users are unlikely to be affected by this change. (Contributed by Alex " -"Waygood in :gh:`102433`.)" +":func:`isinstance` checks against :func:`runtime-checkable protocols ` now use :func:`inspect.getattr_static` rather than :func:" +"`hasattr` to lookup whether attributes exist. This means that descriptors " +"and :meth:`~object.__getattr__` methods are no longer unexpectedly evaluated " +"during ``isinstance()`` checks against runtime-checkable protocols. However, " +"it may also mean that some objects which used to be considered instances of " +"a runtime-checkable protocol may no longer be considered instances of that " +"protocol on Python 3.12+, and vice versa. Most users are unlikely to be " +"affected by this change. (Contributed by Alex Waygood in :gh:`102433`.)" msgstr "" #: ../../whatsnew/3.12.rst:987 @@ -1558,8 +1546,8 @@ msgid "" "Most ``isinstance()`` checks against protocols with only a few members " "should be at least 2x faster than in 3.11, and some may be 20x faster or " "more. However, ``isinstance()`` checks against protocols with many members " -"may be slower than in Python 3.11. (Contributed by Alex Waygood " -"in :gh:`74690` and :gh:`103193`.)" +"may be slower than in Python 3.11. (Contributed by Alex Waygood in :gh:" +"`74690` and :gh:`103193`.)" msgstr "" #: ../../whatsnew/3.12.rst:1020 @@ -1662,8 +1650,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:1072 msgid "" -"Speed up the regular expression substitution (functions :func:`re.sub` " -"and :func:`re.subn` and corresponding :class:`!re.Pattern` methods) for " +"Speed up the regular expression substitution (functions :func:`re.sub` and :" +"func:`re.subn` and corresponding :class:`!re.Pattern` methods) for " "replacement strings containing group references by 2--3 times. (Contributed " "by Serhiy Storchaka in :gh:`91524`.)" msgstr "" @@ -1679,16 +1667,16 @@ msgstr "" #: ../../whatsnew/3.12.rst:1080 msgid "" "The :func:`tokenize.tokenize` and :func:`tokenize.generate_tokens` functions " -"are up to 64% faster as a side effect of the changes required to " -"cover :pep:`701` in the :mod:`tokenize` module. (Contributed by Marta Gómez " -"Macías and Pablo Galindo in :gh:`102856`.)" +"are up to 64% faster as a side effect of the changes required to cover :pep:" +"`701` in the :mod:`tokenize` module. (Contributed by Marta Gómez Macías and " +"Pablo Galindo in :gh:`102856`.)" msgstr "" #: ../../whatsnew/3.12.rst:1085 msgid "" -"Speed up :func:`super` method calls and attribute loads via the " -"new :opcode:`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer and " -"Vladimir Matveev in :gh:`103497`.)" +"Speed up :func:`super` method calls and attribute loads via the new :opcode:" +"`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer and Vladimir " +"Matveev in :gh:`103497`.)" msgstr "" #: ../../whatsnew/3.12.rst:1091 @@ -1697,29 +1685,28 @@ msgstr "CPython 位元組碼變更" #: ../../whatsnew/3.12.rst:1093 msgid "" -"Remove the :opcode:`!LOAD_METHOD` instruction. It has been merged " -"into :opcode:`LOAD_ATTR`. :opcode:`LOAD_ATTR` will now behave like the " -"old :opcode:`!LOAD_METHOD` instruction if the low bit of its oparg is set. " -"(Contributed by Ken Jin in :gh:`93429`.)" +"Remove the :opcode:`!LOAD_METHOD` instruction. It has been merged into :" +"opcode:`LOAD_ATTR`. :opcode:`LOAD_ATTR` will now behave like the old :opcode:" +"`!LOAD_METHOD` instruction if the low bit of its oparg is set. (Contributed " +"by Ken Jin in :gh:`93429`.)" msgstr "" -"移除 :opcode:`!LOAD_METHOD` 指令。它已經合併" -"至 :opcode:`LOAD_ATTR`。:opcode:`LOAD_ATTR` 現在會像舊的 :opcode:`!" -"LOAD_METHOD` 指令一樣行為,如果其 oparg 的低位元 (low bit) 有被設定。(由 " -"Ken Jin 於 :gh:`93429` 中貢獻。)" +"移除 :opcode:`!LOAD_METHOD` 指令。它已經合併至 :opcode:`LOAD_ATTR`。:opcode:" +"`LOAD_ATTR` 現在會像舊的 :opcode:`!LOAD_METHOD` 指令一樣行為,如果其 oparg 的" +"低位元 (low bit) 有被設定。(由 Ken Jin 於 :gh:`93429` 中貢獻。)" #: ../../whatsnew/3.12.rst:1098 msgid "" "Remove the :opcode:`!JUMP_IF_FALSE_OR_POP` and :opcode:`!" -"JUMP_IF_TRUE_OR_POP` instructions. (Contributed by Irit Katriel " -"in :gh:`102859`.)" +"JUMP_IF_TRUE_OR_POP` instructions. (Contributed by Irit Katriel in :gh:" +"`102859`.)" msgstr "" "移除 :opcode:`!JUMP_IF_FALSE_OR_POP` 和 :opcode:`!JUMP_IF_TRUE_OR_POP` 指令。" "(由 Irit Katriel 於 :gh:`102859` 中貢獻。)" #: ../../whatsnew/3.12.rst:1101 msgid "" -"Remove the :opcode:`!PRECALL` instruction. (Contributed by Mark Shannon " -"in :gh:`92925`.)" +"Remove the :opcode:`!PRECALL` instruction. (Contributed by Mark Shannon in :" +"gh:`92925`.)" msgstr "" "移除 :opcode:`!PRECALL` 指令。(由 Mark Shannon 於 :gh:`92925` 中貢獻。)" @@ -1757,8 +1744,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:1116 msgid "" -"Add the :opcode:`!END_SEND` instruction. (Contributed by Mark Shannon " -"in :gh:`103082`.)" +"Add the :opcode:`!END_SEND` instruction. (Contributed by Mark Shannon in :gh:" +"`103082`.)" msgstr "" "新增 :opcode:`!END_SEND` 指令。(由 Mark Shannon 於 :gh:`103082` 中貢獻。)" @@ -1780,31 +1767,30 @@ msgstr "" #: ../../whatsnew/3.12.rst:1125 msgid "" -"Add " -"the :opcode:`LOAD_FROM_DICT_OR_DEREF`, :opcode:`LOAD_FROM_DICT_OR_GLOBALS`, " -"and :opcode:`LOAD_LOCALS` opcodes as part of the implementation " -"of :pep:`695`. Remove the :opcode:`!LOAD_CLASSDEREF` opcode, which can be " -"replaced with :opcode:`LOAD_LOCALS` plus :opcode:`LOAD_FROM_DICT_OR_DEREF`. " -"(Contributed by Jelle Zijlstra in :gh:`103764`.)" +"Add the :opcode:`LOAD_FROM_DICT_OR_DEREF`, :opcode:" +"`LOAD_FROM_DICT_OR_GLOBALS`, and :opcode:`LOAD_LOCALS` opcodes as part of " +"the implementation of :pep:`695`. Remove the :opcode:`!LOAD_CLASSDEREF` " +"opcode, which can be replaced with :opcode:`LOAD_LOCALS` plus :opcode:" +"`LOAD_FROM_DICT_OR_DEREF`. (Contributed by Jelle Zijlstra in :gh:`103764`.)" msgstr "" "新增 :opcode:`LOAD_FROM_DICT_OR_DEREF`、:opcode:`LOAD_FROM_DICT_OR_GLOBALS` " "和 :opcode:`LOAD_LOCALS` 操作碼作為 :pep:`695` 實作的一部分。移除 :opcode:`!" -"LOAD_CLASSDEREF` 操作碼,可以用 :opcode:`LOAD_LOCALS` 加" -"上 :opcode:`LOAD_FROM_DICT_OR_DEREF` 來取代。(由 Jelle Zijlstra " -"於 :gh:`103764` 中貢獻。)" +"LOAD_CLASSDEREF` 操作碼,可以用 :opcode:`LOAD_LOCALS` 加上 :opcode:" +"`LOAD_FROM_DICT_OR_DEREF` 來取代。(由 Jelle Zijlstra 於 :gh:`103764` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1131 msgid "" "Add the :opcode:`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer " "and Vladimir Matveev in :gh:`103497`.)" msgstr "" -"新增 :opcode:`LOAD_SUPER_ATTR` 指令。(由 Carl Meyer 和 Vladimir Matveev " -"於 :gh:`103497` 中貢獻。)" +"新增 :opcode:`LOAD_SUPER_ATTR` 指令。(由 Carl Meyer 和 Vladimir Matveev 於 :" +"gh:`103497` 中貢獻。)" #: ../../whatsnew/3.12.rst:1134 msgid "" -"Add the :opcode:`RETURN_CONST` instruction. (Contributed by Wenyang Wang " -"in :gh:`101632`.)" +"Add the :opcode:`RETURN_CONST` instruction. (Contributed by Wenyang Wang in :" +"gh:`101632`.)" msgstr "" "新增 :opcode:`RETURN_CONST` 指令。(由 Wenyang Wang 於 :gh:`101632` 中貢" "獻。)" @@ -1881,8 +1867,8 @@ msgstr ":class:`!ast.Ellipsis`" #: ../../whatsnew/3.12.rst:1168 #: ../../deprecations/pending-removal-in-3.14.rst:19 msgid "" -"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka " -"in :gh:`90953`.)" +"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka in :gh:" +"`90953`.)" msgstr "" "請改用 :class:`ast.Constant`。(由 Serhiy Storchaka 於 :gh:`90953` 貢獻。)" @@ -1894,23 +1880,24 @@ msgstr ":mod:`asyncio`:" #: ../../whatsnew/3.12.rst:1173 msgid "" -"The child watcher " -"classes :class:`asyncio.MultiLoopChildWatcher`, :class:`asyncio.FastChildWatcher`, :class:`asyncio.AbstractChildWatcher` " -"and :class:`asyncio.SafeChildWatcher` are deprecated and will be removed in " -"Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" +"The child watcher classes :class:`asyncio.MultiLoopChildWatcher`, :class:" +"`asyncio.FastChildWatcher`, :class:`asyncio.AbstractChildWatcher` and :class:" +"`asyncio.SafeChildWatcher` are deprecated and will be removed in Python " +"3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" #: ../../whatsnew/3.12.rst:1179 #: ../../deprecations/pending-removal-in-3.14.rst:30 msgid "" -":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " -"and :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated " -"and will be removed in Python 3.14. (Contributed by Kumar Aditya " -"in :gh:`94597`.)" +":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:" +"`asyncio.AbstractEventLoopPolicy.set_child_watcher` and :meth:`asyncio." +"AbstractEventLoopPolicy.get_child_watcher` are deprecated and will be " +"removed in Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" -":func:`asyncio.set_child_watcher`、:func:`asyncio.get_child_watcher`、:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " -"和 :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 " -"Python 3.14 中移除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" +":func:`asyncio.set_child_watcher`、:func:`asyncio.get_child_watcher`、:meth:" +"`asyncio.AbstractEventLoopPolicy.set_child_watcher` 和 :meth:`asyncio." +"AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 Python 3.14 中移" +"除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" #: ../../whatsnew/3.12.rst:1185 #: ../../deprecations/pending-removal-in-3.14.rst:36 @@ -1928,9 +1915,8 @@ msgstr "" #: ../../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.FEBRUARY`. (Contributed by Prince Roshan " -"in :gh:`103636`.)" +"are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." +"FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.)" msgstr "" ":mod:`calendar`:``calendar.January`` 和 ``calendar.February`` 常數已被棄用並" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " @@ -1940,27 +1926,24 @@ msgstr "" msgid "" ":mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`. " "Prefer :class:`Sequence` or :class:`collections.abc.Buffer`. For use in " -"typing, prefer a union, like ``bytes | bytearray``, " -"or :class:`collections.abc.Buffer`. (Contributed by Shantanu Jain " -"in :gh:`91896`.)" +"typing, prefer a union, like ``bytes | bytearray``, or :class:`collections." +"abc.Buffer`. (Contributed by Shantanu Jain in :gh:`91896`.)" msgstr "" #: ../../whatsnew/3.12.rst:1199 msgid "" -":mod:`datetime`: :class:`datetime.datetime`'s :meth:`~datetime.datetime.utcnow` " -"and :meth:`~datetime.datetime.utcfromtimestamp` are deprecated and will be " -"removed in a future version. Instead, use timezone-aware objects to " -"represent datetimes in UTC: respectively, " -"call :meth:`~datetime.datetime.now` " -"and :meth:`~datetime.datetime.fromtimestamp` with the *tz* parameter set " -"to :const:`datetime.UTC`. (Contributed by Paul Ganssle in :gh:`103857`.)" +":mod:`datetime`: :class:`datetime.datetime`'s :meth:`~datetime.datetime." +"utcnow` and :meth:`~datetime.datetime.utcfromtimestamp` are deprecated and " +"will be removed in a future version. Instead, use timezone-aware objects to " +"represent datetimes in UTC: respectively, call :meth:`~datetime.datetime." +"now` and :meth:`~datetime.datetime.fromtimestamp` with the *tz* parameter " +"set to :const:`datetime.UTC`. (Contributed by Paul Ganssle in :gh:`103857`.)" msgstr "" #: ../../whatsnew/3.12.rst:1207 msgid "" -":mod:`email`: Deprecate the *isdst* parameter " -"in :func:`email.utils.localtime`. (Contributed by Alan Williams " -"in :gh:`72346`.)" +":mod:`email`: Deprecate the *isdst* parameter in :func:`email.utils." +"localtime`. (Contributed by Alan Williams in :gh:`72346`.)" msgstr "" ":mod:`email`:棄用 :func:`email.utils.localtime` 中的 *isdst* 參數。(由 " "Alan Williams 於 :gh:`72346` 中貢獻。)" @@ -2011,8 +1994,8 @@ msgid "" ":mod:`itertools`: Deprecate the support for copy, deepcopy, and pickle " "operations, which is undocumented, inefficient, historically buggy, and " "inconsistent. This will be removed in 3.14 for a significant reduction in " -"code volume and maintenance burden. (Contributed by Raymond Hettinger " -"in :gh:`101588`.)" +"code volume and maintenance burden. (Contributed by Raymond Hettinger in :gh:" +"`101588`.)" msgstr "" #: ../../whatsnew/3.12.rst:1230 @@ -2021,19 +2004,17 @@ msgid "" "start method will change to a safer one on Linux, BSDs, and other non-macOS " "POSIX platforms where ``'fork'`` is currently the default (:gh:`84559`). " "Adding a runtime warning about this was deemed too disruptive as the " -"majority of code is not expected to care. Use " -"the :func:`~multiprocessing.get_context` " -"or :func:`~multiprocessing.set_start_method` APIs to explicitly specify when " -"your code *requires* ``'fork'``. See :ref:`contexts and start methods " -"`." +"majority of code is not expected to care. Use the :func:`~multiprocessing." +"get_context` or :func:`~multiprocessing.set_start_method` APIs to explicitly " +"specify when your code *requires* ``'fork'``. See :ref:`contexts and start " +"methods `." msgstr "" #: ../../whatsnew/3.12.rst:1240 msgid "" ":mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader` " -"are deprecated and will be removed in Python 3.14; " -"use :func:`importlib.util.find_spec` instead. (Contributed by Nikita Sobolev " -"in :gh:`97850`.)" +"are deprecated and will be removed in Python 3.14; use :func:`importlib.util." +"find_spec` instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" msgstr "" ":mod:`pkgutil`::func:`pkgutil.find_loader` 和 :func:`pkgutil.get_loader` 已" "被棄用並將在 Python 3.14 中移除;請改用 :func:`importlib.util.find_spec`。" @@ -2062,31 +2043,30 @@ msgstr "" #: ../../whatsnew/3.12.rst:1258 msgid "" -"On POSIX platforms, :func:`os.fork` can now raise " -"a :exc:`DeprecationWarning` when it can detect being called from a " -"multithreaded process. There has always been a fundamental incompatibility " -"with the POSIX platform when doing so. Even if such code *appeared* to work. " -"We added the warning to raise awareness as issues encountered by code doing " -"this are becoming more frequent. See the :func:`os.fork` documentation for " -"more details along with `this discussion on fork being incompatible with " -"threads `_ for *why* we're now surfacing this longstanding " +"On POSIX platforms, :func:`os.fork` can now raise a :exc:" +"`DeprecationWarning` when it can detect being called from a multithreaded " +"process. There has always been a fundamental incompatibility with the POSIX " +"platform when doing so. Even if such code *appeared* to work. We added the " +"warning to raise awareness as issues encountered by code doing this are " +"becoming more frequent. See the :func:`os.fork` documentation for more " +"details along with `this discussion on fork being incompatible with threads " +"`_ for *why* we're now surfacing this longstanding " "platform compatibility problem to developers." msgstr "" #: ../../whatsnew/3.12.rst:1268 msgid "" -"When this warning appears due to usage of :mod:`multiprocessing` " -"or :mod:`concurrent.futures` the fix is to use a " -"different :mod:`multiprocessing` start method such as ``\"spawn\"`` or " -"``\"forkserver\"``." +"When this warning appears due to usage of :mod:`multiprocessing` or :mod:" +"`concurrent.futures` the fix is to use a different :mod:`multiprocessing` " +"start method such as ``\"spawn\"`` or ``\"forkserver\"``." msgstr "" #: ../../whatsnew/3.12.rst:1272 msgid "" ":mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is " -"deprecated; use *onexc* instead. (Contributed by Irit Katriel " -"in :gh:`102828`.)" +"deprecated; use *onexc* instead. (Contributed by Irit Katriel in :gh:" +"`102828`.)" msgstr "" ":mod:`shutil`::func:`shutil.rmtree` 的 *onerror* 引數已被棄用,請改用 " "*onexc*。(由 Irit Katriel 於 :gh:`102828` 中貢獻。)" @@ -2115,14 +2095,13 @@ msgstr "" #: ../../whatsnew/3.12.rst:1290 msgid "" -":mod:`sys`: The :data:`sys.last_type`, :data:`sys.last_value` " -"and :data:`sys.last_traceback` fields are deprecated. " -"Use :data:`sys.last_exc` instead. (Contributed by Irit Katriel " -"in :gh:`102778`.)" +":mod:`sys`: The :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys." +"last_traceback` fields are deprecated. Use :data:`sys.last_exc` instead. " +"(Contributed by Irit Katriel in :gh:`102778`.)" msgstr "" -":mod:`sys`::data:`sys.last_type`、:data:`sys.last_value` " -"和 :data:`sys.last_traceback` 欄位已被棄用。請改用 :data:`sys.last_exc`。" -"(由 Irit Katriel 於 :gh:`102778` 中貢獻。)" +":mod:`sys`::data:`sys.last_type`、:data:`sys.last_value` 和 :data:`sys." +"last_traceback` 欄位已被棄用。請改用 :data:`sys.last_exc`。(由 Irit Katriel " +"於 :gh:`102778` 中貢獻。)" #: ../../whatsnew/3.12.rst:1294 msgid "" @@ -2138,16 +2117,16 @@ msgstr ":mod:`typing`:" #: ../../whatsnew/3.12.rst:1300 msgid "" -":class:`typing.Hashable` and :class:`typing.Sized`, aliases " -"for :class:`collections.abc.Hashable` and :class:`collections.abc.Sized` " -"respectively, are deprecated. (:gh:`94309`.)" +":class:`typing.Hashable` and :class:`typing.Sized`, aliases for :class:" +"`collections.abc.Hashable` and :class:`collections.abc.Sized` respectively, " +"are deprecated. (:gh:`94309`.)" msgstr "" #: ../../whatsnew/3.12.rst:1304 msgid "" -":class:`typing.ByteString`, deprecated since Python 3.9, now causes " -"a :exc:`DeprecationWarning` to be emitted when it is used. (Contributed by " -"Alex Waygood in :gh:`91896`.)" +":class:`typing.ByteString`, deprecated since Python 3.9, now causes a :exc:" +"`DeprecationWarning` to be emitted when it is used. (Contributed by Alex " +"Waygood in :gh:`91896`.)" msgstr "" #: ../../whatsnew/3.12.rst:1308 @@ -2161,26 +2140,26 @@ msgstr "" #: ../../whatsnew/3.12.rst:1314 msgid "" "The 3-arg signatures (type, value, traceback) of :meth:`coroutine throw() " -"`, :meth:`generator throw() ` " -"and :meth:`async generator throw() ` are deprecated and may be " -"removed in a future version of Python. Use the single-arg versions of these " -"functions instead. (Contributed by Ofey Chan in :gh:`89874`.)" +"`, :meth:`generator throw() ` and :meth:" +"`async generator throw() ` are deprecated and may be removed in " +"a future version of Python. Use the single-arg versions of these functions " +"instead. (Contributed by Ofey Chan in :gh:`89874`.)" msgstr "" #: ../../whatsnew/3.12.rst:1320 msgid "" ":exc:`DeprecationWarning` is now raised when :attr:`~module.__package__` on " -"a module differs from :attr:`__spec__.parent " -"` (previously it " -"was :exc:`ImportWarning`). (Contributed by Brett Cannon in :gh:`65961`.)" +"a module differs from :attr:`__spec__.parent ` (previously it was :exc:`ImportWarning`). (Contributed by Brett " +"Cannon in :gh:`65961`.)" msgstr "" #: ../../whatsnew/3.12.rst:1326 msgid "" "Setting :attr:`~module.__package__` or :attr:`~module.__cached__` on a " "module is deprecated, and will cease to be set or taken into consideration " -"by the import system in Python 3.14. (Contributed by Brett Cannon " -"in :gh:`65961`.)" +"by the import system in Python 3.14. (Contributed by Brett Cannon in :gh:" +"`65961`.)" msgstr "" #: ../../whatsnew/3.12.rst:1330 @@ -2195,13 +2174,13 @@ msgstr "" #: ../../whatsnew/3.12.rst:1336 msgid "" "Accessing :attr:`~codeobject.co_lnotab` on code objects was deprecated in " -"Python 3.10 via :pep:`626`, but it only got a " -"proper :exc:`DeprecationWarning` in 3.12. May be removed in 3.15. " -"(Contributed by Nikita Sobolev in :gh:`101866`.)" +"Python 3.10 via :pep:`626`, but it only got a proper :exc:" +"`DeprecationWarning` in 3.12. May be removed in 3.15. (Contributed by Nikita " +"Sobolev in :gh:`101866`.)" msgstr "" -"自 3.10 起,於程式碼物件存取 :attr:`~codeobject.co_lnotab` 的功能已" -"在 :pep:`626` 中被棄用,但只在 3.12 中於適時發出 :exc:`DeprecationWarning`。" -"可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:`101866` 貢獻。)" +"自 3.10 起,於程式碼物件存取 :attr:`~codeobject.co_lnotab` 的功能已在 :pep:" +"`626` 中被棄用,但只在 3.12 中於適時發出 :exc:`DeprecationWarning`。可能在 " +"3.15 中移除。(由 Nikita Sobolev 於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.13.rst:2 msgid "Pending Removal in Python 3.13" @@ -2393,35 +2372,32 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.14.rst:24 msgid "" -"The child watcher " -"classes :class:`~asyncio.MultiLoopChildWatcher`, :class:`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` " -"and :class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " +"The child watcher classes :class:`~asyncio.MultiLoopChildWatcher`, :class:" +"`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` and :" +"class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " "Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" -"已棄用並將在 Python 3.14 中移除的 child watcher 類" -"別::class:`~asyncio.MultiLoopChildWatcher`、:class:`~asyncio.FastChildWatcher`、:class:`~asyncio.AbstractChildWatcher` " -"和 :class:`~asyncio.SafeChildWatcher`。 (由 Kumar Aditya 於 :gh:`94597` 貢" -"獻。)" +"已棄用並將在 Python 3.14 中移除的 child watcher 類別::class:`~asyncio." +"MultiLoopChildWatcher`、:class:`~asyncio.FastChildWatcher`、:class:`~asyncio." +"AbstractChildWatcher` 和 :class:`~asyncio.SafeChildWatcher`。 (由 Kumar " +"Aditya 於 :gh:`94597` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:41 msgid "" ":mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`. " "Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " -"typing, prefer a union, like ``bytes | bytearray``, " -"or :class:`collections.abc.Buffer`. (Contributed by Shantanu Jain " -"in :gh:`91896`.)" -msgstr "" -":mod:`collections.abc`:已棄用 :class:`~collections.abc.ByteString`。請改" -"用 :class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使用" -"時,請改用聯集,如 ``bytes | bytearray``," -"或 :class:`collections.abc.Buffer`。(由 Shantanu Jain 於 :gh:`91896` 貢" -"獻。)" +"typing, prefer a union, like ``bytes | bytearray``, or :class:`collections." +"abc.Buffer`. (Contributed by Shantanu Jain in :gh:`91896`.)" +msgstr "" +":mod:`collections.abc`:已棄用 :class:`~collections.abc.ByteString`。請改用 :" +"class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使用時,請" +"改用聯集,如 ``bytes | bytearray``,或 :class:`collections.abc.Buffer`。(由 " +"Shantanu Jain 於 :gh:`91896` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:47 msgid "" -":mod:`email`: Deprecated the *isdst* parameter " -"in :func:`email.utils.localtime`. (Contributed by Alan Williams " -"in :gh:`72346`.)" +":mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils." +"localtime`. (Contributed by Alan Williams in :gh:`72346`.)" msgstr "" ":mod:`email`:已棄用 :func:`email.utils.localtime` 中的 *isdst* 參數。(由 " "Alan Williams 於 :gh:`72346` 貢獻。)" @@ -2447,25 +2423,24 @@ msgid "" "on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " "currently the default (:gh:`84559`). Adding a runtime warning about this was " "deemed too disruptive as the majority of code is not expected to care. Use " -"the :func:`~multiprocessing.get_context` " -"or :func:`~multiprocessing.set_start_method` APIs to explicitly specify when " -"your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`." +"the :func:`~multiprocessing.get_context` or :func:`~multiprocessing." +"set_start_method` APIs to explicitly specify when your code *requires* " +"``'fork'``. See :ref:`multiprocessing-start-methods`." msgstr "" ":mod:`multiprocessing`:預設的啟動方法將在 Linux、BSD 和其他非 macOS POSIX 平" "台上更改為更安全的 方法,目前 ``'fork'`` 是預設值 (:gh:`84559`)。對此增加一" -"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使" -"用 :func:`~multiprocessing.get_context` " -"或 :func:`~multiprocessing.set_start_method` API 來明確指定你的程式碼何時\\ *" -"需要* ``'fork'``。請參閱 :ref:`multiprocessing-start-methods`。" +"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用 :func:" +"`~multiprocessing.get_context` 或 :func:`~multiprocessing.set_start_method` " +"API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" +"`multiprocessing-start-methods`。" #: ../../deprecations/pending-removal-in-3.14.rst:77 msgid "" -":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` " -"and :meth:`~pathlib.PurePath.relative_to`: passing additional arguments is " -"deprecated." +":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` and :meth:`~pathlib." +"PurePath.relative_to`: passing additional arguments is deprecated." msgstr "" -":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` " -"和 :meth:`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" +":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" +"`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" #: ../../deprecations/pending-removal-in-3.14.rst:81 msgid "" @@ -2474,9 +2449,8 @@ msgid "" "instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" msgstr "" ":mod:`pkgutil`::func:`~pkgutil.find_loader` 和 :func:`~pkgutil.get_loader` " -"現在會引發 :exc:`DeprecationWarning`;請改" -"用 :func:`importlib.util.find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢" -"獻。)" +"現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." +"find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:86 msgid ":mod:`pty`:" @@ -2496,9 +2470,9 @@ msgstr ":data:`~sqlite3.version` 和 :data:`~sqlite3.version_info`。" #: ../../deprecations/pending-removal-in-3.14.rst:95 msgid "" -":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` " -"if :ref:`named placeholders ` are used and " -"*parameters* is a sequence instead of a :class:`dict`." +":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` if :" +"ref:`named placeholders ` are used and *parameters* is " +"a sequence instead of a :class:`dict`." msgstr "" ":meth:`~sqlite3.Cursor.execute` 和 :meth:`~sqlite3.Cursor.executemany`,如果" "使用 :ref:`named placeholders ` 且 *parameters* 是序列" @@ -2515,8 +2489,8 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.14.rst:102 msgid "" ":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " -"intended to be a public API. (Contributed by Gregory P. Smith " -"in :gh:`88168`.)" +"intended to be a public API. (Contributed by Gregory P. Smith in :gh:" +"`88168`.)" msgstr "" ":mod:`urllib`::class:`!urllib.parse.Quoter` 已被棄用:它並非預期的公開 API。" "(由 Gregory P. Smith 於 :gh:`88168` 貢獻。)" @@ -2533,10 +2507,10 @@ msgstr "引入系統 (import system):" #: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to " -"set :attr:`__spec__.cached ` is " -"deprecated. In Python 3.15, :attr:`!__cached__` will cease to be set or take " -"into consideration by the import system or standard library. (:gh:`97879`)" +"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +"`__spec__.cached ` is deprecated. In " +"Python 3.15, :attr:`!__cached__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" "在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " "` 的做法已被棄用。在 Python 3.15 中," @@ -2544,11 +2518,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" -"Setting :attr:`~module.__package__` on a module while failing to " -"set :attr:`__spec__.parent ` is " -"deprecated. In Python 3.15, :attr:`!__package__` will cease to be set or " -"take into consideration by the import system or standard library. " -"(:gh:`97879`)" +"Setting :attr:`~module.__package__` on a module while failing to set :attr:" +"`__spec__.parent ` is deprecated. In " +"Python 3.15, :attr:`!__package__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" msgstr "" "在模組上設定 :attr:`~module.__package__` 而沒有設定 :attr:`__spec__.parent " "` 的做法已被棄用。在 Python 3.15 中," @@ -2603,17 +2576,15 @@ msgstr ":class:`locale`:" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" "The :func:`~locale.getdefaultlocale` function has been deprecated since " -"Python 3.11. Its removal was originally planned for Python 3.13 " -"(:gh:`90817`), but has been postponed to Python 3.15. " -"Use :func:`~locale.getlocale`, :func:`~locale.setlocale`, " -"and :func:`~locale.getencoding` instead. (Contributed by Hugo van Kemenade " -"in :gh:`111187`.)" +"Python 3.11. Its removal was originally planned for Python 3.13 (:gh:" +"`90817`), but has been postponed to Python 3.15. Use :func:`~locale." +"getlocale`, :func:`~locale.setlocale`, and :func:`~locale.getencoding` " +"instead. (Contributed by Hugo van Kemenade in :gh:`111187`.)" msgstr "" ":func:`~locale.getdefaultlocale` 已在 Python 3.11 中被棄用,原本計劃在 " -"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改" -"用 :func:`~locale.getlocale`、:func:`~locale.setlocale` " -"和 :func:`~locale.getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢" -"獻。)" +"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :func:" +"`~locale.getlocale`、:func:`~locale.setlocale` 和 :func:`~locale." +"getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:46 msgid ":mod:`pathlib`:" @@ -2621,11 +2592,11 @@ msgstr ":mod:`pathlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:48 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. " -"Use :func:`os.path.isreserved` to detect reserved paths on Windows." +":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +"func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請" -"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" +":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." +"isreserved` 來偵測 Windows 上的保留路徑。" #: ../../deprecations/pending-removal-in-3.15.rst:52 msgid ":mod:`platform`:" @@ -2679,16 +2650,16 @@ msgid "" "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" ":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發" -"出 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " -"於 :gh:`101866` 貢獻。)" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" +"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" +"`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:82 msgid "" -"The undocumented keyword argument syntax for " -"creating :class:`~typing.NamedTuple` classes (e.g. ``Point = " -"NamedTuple(\"Point\", x=int, y=int)``) has been deprecated since Python " -"3.13. Use the class-based syntax or the functional syntax instead." +"The undocumented keyword argument syntax for creating :class:`~typing." +"NamedTuple` classes (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:`~typing.NamedTuple` 類別的未以文件記錄之關鍵字引數語法 " "(``Point = NamedTuple(\"Point\", x=int, y=int)``) 已自 Python 3.13 棄用。請改" @@ -2696,6 +2667,20 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:88 msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." +msgstr "" +"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* " +"參數 (``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = " +"TypedDict(\"TD\", None)``) 的做法自 Python 3.13 起已被棄用。請" +"使用 ``class TD(TypedDict): pass`` 或 ``TD = " +"TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#: ../../deprecations/pending-removal-in-3.15.rst: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." @@ -2704,20 +2689,19 @@ msgstr "" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" -#: ../../deprecations/pending-removal-in-3.15.rst:93 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:95 +#: ../../deprecations/pending-removal-in-3.15.rst:102 msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, " -"and :meth:`~wave.Wave_read.getmarkers` methods of " -"the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been " -"deprecated since Python 3.13." +"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." +"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" +"`~wave.Wave_write` classes have been deprecated since Python 3.13." msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別" -"的 :meth:`~wave.Wave_read.getmark`、:meth:`!setmark` " -"和 :meth:`~wave.Wave_read.getmarkers` 方法自 Python 3.13 被棄用。" +"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" +"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." +"getmarkers` 方法自 Python 3.13 被棄用。" #: ../../deprecations/pending-removal-in-3.16.rst:2 msgid "Pending removal in Python 3.16" @@ -2725,10 +2709,10 @@ msgstr "Python 3.16 中待移除的項目" #: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" -"Setting :attr:`~module.__loader__` on a module while failing to " -"set :attr:`__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." +"Setting :attr:`~module.__loader__` on a module while failing to set :attr:" +"`__spec__.loader ` is deprecated. In " +"Python 3.16, :attr:`!__loader__` will cease to be set or taken into " +"consideration by the import system or the standard library." msgstr "" "在模組上設定 :attr:`~module.__loader__` 而沒有設定 :attr:`__spec__.loader " "` 的做法將於 Python 3.16 被棄用。在 " @@ -2755,8 +2739,8 @@ msgid "" "by Jiahao Li and Kumar Aditya in :gh:`122875`.)" msgstr "" ":func:`!asyncio.iscoroutinefunction` 已被棄用並將在 Python 3.16 中移除,請改" -"用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya " -"於 :gh:`122875` 貢獻。)" +"用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya 於 :" +"gh:`122875` 貢獻。)" #: ../../deprecations/pending-removal-in-3.16.rst:26 #: ../../deprecations/pending-removal-in-future.rst:10 @@ -2862,17 +2846,17 @@ msgid "" "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " "ambiguous expressions like ``[0x1for x in y]`` (which can be interpreted as " "``[0x1 for x in y]`` or ``[0x1f or x in y]``). A syntax warning is raised " -"if the numeric literal is immediately followed by one of " -"keywords :keyword:`and`, :keyword:`else`, :keyword:`for`, :keyword:`if`, :keyword:`in`, :keyword:`is` " -"and :keyword:`or`. In a future release it will be changed to a syntax " -"error. (:gh:`87999`)" +"if the numeric literal is immediately followed by one of keywords :keyword:" +"`and`, :keyword:`else`, :keyword:`for`, :keyword:`if`, :keyword:`in`, :" +"keyword:`is` and :keyword:`or`. In a future release it will be changed to a " +"syntax error. (:gh:`87999`)" msgstr "" "目前 Python 接受數值字面值後面立即接關鍵字,例如 ``0in x``、``1or x``、``0if " "1else 2``。它讓表達式模糊且容易混淆,如 ``[0x1for x in y]``\\ (可以解釋為 " -"``[0x1 for x in y]`` 或 ``[0x1f or x in y]``)。如果數值字面值後立即" -"接 :keyword:`and`、:keyword:`else`、:keyword:`for`、:keyword:`if`、:keyword:`in`、:keyword:`is` " -"和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版本中,它將被更改為語" -"法錯誤。(:gh:`87999`)" +"``[0x1 for x in y]`` 或 ``[0x1f or x in y]``)。如果數值字面值後立即接 :" +"keyword:`and`、:keyword:`else`、:keyword:`for`、:keyword:`if`、:keyword:" +"`in`、:keyword:`is` 和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版" +"本中,它將被更改為語法錯誤。(:gh:`87999`)" #: ../../deprecations/pending-removal-in-future.rst:24 msgid "" @@ -2885,18 +2869,18 @@ msgstr "" #: ../../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:`float`." +"Support for ``__float__()`` method returning a strict subclass of :class:" +"`float`: these methods will be required to return an instance of :class:" +"`float`." msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" #: ../../deprecations/pending-removal-in-future.rst:30 msgid "" -"Support for ``__complex__()`` method returning a strict subclass " -"of :class:`complex`: these methods will be required to return an instance " -"of :class:`complex`." +"Support for ``__complex__()`` method returning a strict subclass of :class:" +"`complex`: these methods will be required to return an instance of :class:" +"`complex`." msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" @@ -2907,10 +2891,10 @@ msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" #: ../../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 single positional argument. (Contributed by Serhiy Storchaka " -"in :gh:`109218`.)" +"Passing a complex number as the *real* or *imag* argument in the :func:" +"`complex` constructor is now deprecated; it should only be passed as a " +"single positional argument. (Contributed by Serhiy Storchaka in :gh:" +"`109218`.)" msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" @@ -2928,19 +2912,19 @@ msgstr ":mod:`datetime`:" #: ../../deprecations/pending-removal-in-future.rst:49 msgid "" -":meth:`~datetime.datetime.utcnow`: use " -"``datetime.datetime.now(tz=datetime.UTC)``." +":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." +"UTC)``." msgstr "" -":meth:`~datetime.datetime.utcnow`:請改用 " -"``datetime.datetime.now(tz=datetime.UTC)``。" +":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." +"now(tz=datetime.UTC)``。" #: ../../deprecations/pending-removal-in-future.rst:51 msgid "" -":meth:`~datetime.datetime.utcfromtimestamp`: use " -"``datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)``." +":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." +"fromtimestamp(timestamp, tz=datetime.UTC)``." msgstr "" -":meth:`~datetime.datetime.utcfromtimestamp`:請改用 " -"``datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)``。" +":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." +"fromtimestamp(timestamp, tz=datetime.UTC)``。" #: ../../deprecations/pending-removal-in-future.rst:54 msgid ":mod:`gettext`: Plural value must be an integer." @@ -2971,8 +2955,8 @@ msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." msgstr "" -":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改" -"用 :meth:`~logging.warning`。" +":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改用 :meth:" +"`~logging.warning`。" #: ../../deprecations/pending-removal-in-future.rst:69 msgid "" @@ -3029,11 +3013,11 @@ msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" #: ../../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." +":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" +"`!selected_npn_protocol` are deprecated: use ALPN instead." msgstr "" -":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` " -"和 :meth:`!selected_npn_protocol` 已被棄用:請改用 ALPN。" +":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" +"`!selected_npn_protocol` 已被棄用:請改用 ALPN。" #: ../../deprecations/pending-removal-in-future.rst:95 msgid "``ssl.OP_NO_SSL*`` options" @@ -3081,11 +3065,11 @@ msgstr ":mod:`threading` 方法:" #: ../../deprecations/pending-removal-in-future.rst:108 msgid "" -":meth:`!threading.Condition.notifyAll`: " -"use :meth:`~threading.Condition.notify_all`." +":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." +"notify_all`." msgstr "" -":meth:`!threading.Condition.notifyAll`:請" -"用 :meth:`~threading.Condition.notify_all`。" +":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." +"notify_all`。" #: ../../deprecations/pending-removal-in-future.rst:109 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." @@ -3093,19 +3077,19 @@ msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set` #: ../../deprecations/pending-removal-in-future.rst:110 msgid "" -":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: " -"use :attr:`threading.Thread.daemon` attribute." +":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" +"attr:`threading.Thread.daemon` attribute." msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" #: ../../deprecations/pending-removal-in-future.rst:112 msgid "" -":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: " -"use :attr:`threading.Thread.name` attribute." +":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" +"attr:`threading.Thread.name` attribute." msgstr "" -":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請" -"用 :attr:`threading.Thread.name` 屬性。" +":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" +"attr:`threading.Thread.name` 屬性。" #: ../../deprecations/pending-removal-in-future.rst:114 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." @@ -3181,13 +3165,13 @@ msgstr "``to_bytes()``" #: ../../deprecations/pending-removal-in-future.rst:136 msgid "" -":mod:`urllib.request`: :class:`~urllib.request.URLopener` " -"and :class:`~urllib.request.FancyURLopener` style of invoking requests is " -"deprecated. Use newer :func:`~urllib.request.urlopen` functions and methods." +":mod:`urllib.request`: :class:`~urllib.request.URLopener` and :class:" +"`~urllib.request.FancyURLopener` style of invoking requests is deprecated. " +"Use newer :func:`~urllib.request.urlopen` functions and methods." msgstr "" -":mod:`urllib.request`:呼叫請求的 :class:`~urllib.request.URLopener` " -"和 :class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新" -"的 :func:`~urllib.request.urlopen` 函式和方法。" +":mod:`urllib.request`:呼叫請求的 :class:`~urllib.request.URLopener` 和 :" +"class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" +"`~urllib.request.urlopen` 函式和方法。" #: ../../deprecations/pending-removal-in-future.rst:140 msgid "" @@ -3197,22 +3181,22 @@ msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分 #: ../../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 return ``True``. Prefer explicit ``len(elem)`` or " -"``elem is not None`` tests instead." +":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." +"etree.ElementTree.Element` is deprecated. In a future release it will always " +"return ``True``. Prefer explicit ``len(elem)`` or ``elem is not None`` tests " +"instead." msgstr "" -":mod:`xml.etree.ElementTree`:已棄用" -"對 :class:`~xml.etree.ElementTree.Element` 的真值測試。在未來版本中,它將始終" -"回傳 ``True``。請改用明確的 ``len(elem)`` 或 ``elem is not None`` 測試。" +":mod:`xml.etree.ElementTree`:已棄用對 :class:`~xml.etree.ElementTree." +"Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " +"``len(elem)`` 或 ``elem is not None`` 測試。" #: ../../deprecations/pending-removal-in-future.rst:148 msgid "" -":meth:`zipimport.zipimporter.load_module` is deprecated: " -"use :meth:`~zipimport.zipimporter.exec_module` instead." +":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`。" +":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." +"zipimporter.exec_module`。" #: ../../whatsnew/3.12.rst:1355 ../../whatsnew/3.12.rst:2237 msgid "Removed" @@ -3253,16 +3237,16 @@ msgid "" ":mod:`configparser` no longer has a ``SafeConfigParser`` class. Use the " "shorter :class:`~configparser.ConfigParser` name instead." msgstr "" -":mod:`configparser` 不再具有 ``SafeConfigParser`` 類別。請改用較短" -"的 :class:`~configparser.ConfigParser` 名稱。" +":mod:`configparser` 不再具有 ``SafeConfigParser`` 類別。請改用較短的 :class:" +"`~configparser.ConfigParser` 名稱。" #: ../../whatsnew/3.12.rst:1376 msgid "" -":class:`configparser.ConfigParser` no longer has a ``readfp`` method. " -"Use :meth:`~configparser.ConfigParser.read_file` instead." +":class:`configparser.ConfigParser` no longer has a ``readfp`` method. Use :" +"meth:`~configparser.ConfigParser.read_file` instead." msgstr "" -":class:`configparser.ConfigParser` 不再具有 ``readfp`` 方法。請改" -"用 :meth:`~configparser.ConfigParser.read_file`。" +":class:`configparser.ConfigParser` 不再具有 ``readfp`` 方法。請改用 :meth:" +"`~configparser.ConfigParser.read_file`。" #: ../../whatsnew/3.12.rst:1382 msgid "distutils" @@ -3342,8 +3326,8 @@ msgid "" "Remove the ``filename`` attribute of :mod:`gzip`'s :class:`gzip.GzipFile`, " "deprecated since Python 2.6, use the :attr:`~gzip.GzipFile.name` attribute " "instead. In write mode, the ``filename`` attribute added ``'.gz'`` file " -"extension if it was not present. (Contributed by Victor Stinner " -"in :gh:`94196`.)" +"extension if it was not present. (Contributed by Victor Stinner in :gh:" +"`94196`.)" msgstr "" #: ../../whatsnew/3.12.rst:1435 @@ -3352,11 +3336,11 @@ msgstr "hashlib" #: ../../whatsnew/3.12.rst:1437 msgid "" -"Remove the pure Python implementation " -"of :mod:`hashlib`'s :func:`hashlib.pbkdf2_hmac`, deprecated in Python 3.10. " -"Python 3.10 and newer requires OpenSSL 1.1.1 (:pep:`644`): this OpenSSL " -"version provides a C implementation of :func:`~hashlib.pbkdf2_hmac` which is " -"faster. (Contributed by Victor Stinner in :gh:`94199`.)" +"Remove the pure Python implementation of :mod:`hashlib`'s :func:`hashlib." +"pbkdf2_hmac`, deprecated in Python 3.10. Python 3.10 and newer requires " +"OpenSSL 1.1.1 (:pep:`644`): this OpenSSL version provides a C implementation " +"of :func:`~hashlib.pbkdf2_hmac` which is faster. (Contributed by Victor " +"Stinner in :gh:`94199`.)" msgstr "" #: ../../whatsnew/3.12.rst:1444 ../../whatsnew/3.12.rst:1473 @@ -3402,8 +3386,8 @@ msgstr "imp" #: ../../whatsnew/3.12.rst:1467 msgid "" -"The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw " -"in :gh:`98040`.)" +"The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in :" +"gh:`98040`.)" msgstr ":mod:`!imp` 模組已被移除。(由 Barry Warsaw 在 :gh:`98040` 中貢獻。)" #: ../../whatsnew/3.12.rst:1470 @@ -3448,11 +3432,11 @@ msgstr "``imp.get_suffixes()``" #: ../../whatsnew/3.12.rst:1479 msgid "" -":const:`importlib.machinery.SOURCE_SUFFIXES`, :const:`importlib.machinery.EXTENSION_SUFFIXES`, " -"and :const:`importlib.machinery.BYTECODE_SUFFIXES`" +":const:`importlib.machinery.SOURCE_SUFFIXES`, :const:`importlib.machinery." +"EXTENSION_SUFFIXES`, and :const:`importlib.machinery.BYTECODE_SUFFIXES`" msgstr "" -":const:`importlib.machinery.SOURCE_SUFFIXES`、:const:`importlib.machinery.EXTENSION_SUFFIXES` " -"和 :const:`importlib.machinery.BYTECODE_SUFFIXES`" +":const:`importlib.machinery.SOURCE_SUFFIXES`、:const:`importlib.machinery." +"EXTENSION_SUFFIXES` 和 :const:`importlib.machinery.BYTECODE_SUFFIXES`" #: ../../whatsnew/3.12.rst:1480 msgid "``imp.get_tag()``" @@ -3583,10 +3567,10 @@ msgstr "io" #: ../../whatsnew/3.12.rst:1521 msgid "" "Remove :mod:`io`'s ``io.OpenWrapper`` and ``_pyio.OpenWrapper``, deprecated " -"in Python 3.10: just use :func:`open` instead. The :func:`open` " -"(:func:`io.open`) function is a built-in function. Since Python " -"3.10, :func:`!_pyio.open` is also a static method. (Contributed by Victor " -"Stinner in :gh:`94169`.)" +"in Python 3.10: just use :func:`open` instead. The :func:`open` (:func:`io." +"open`) function is a built-in function. Since Python 3.10, :func:`!_pyio." +"open` is also a static method. (Contributed by Victor Stinner in :gh:" +"`94169`.)" msgstr "" #: ../../whatsnew/3.12.rst:1528 @@ -3606,10 +3590,10 @@ msgstr "smtpd" #: ../../whatsnew/3.12.rst:1537 msgid "" -"The ``smtpd`` module has been removed according to the schedule " -"in :pep:`594`, having been deprecated in Python 3.4.7 and 3.5.4. Use " -"the :pypi:`aiosmtpd` PyPI module or any other :mod:`asyncio`-based server " -"instead. (Contributed by Oleg Iarygin in :gh:`93243`.)" +"The ``smtpd`` module has been removed according to the schedule in :pep:" +"`594`, having been deprecated in Python 3.4.7 and 3.5.4. Use the :pypi:" +"`aiosmtpd` PyPI module or any other :mod:`asyncio`-based server instead. " +"(Contributed by Oleg Iarygin in :gh:`93243`.)" msgstr "" "根據 :pep:`594` 的時間表移除 ``smtpd`` 模組,它在 Python 3.4.7 和 3.5.4 中已" "被棄用。請改用 PyPI 上的 :pypi:`aiosmtpd` 模組或任何其他基於 :mod:`asyncio` " @@ -3639,9 +3623,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:1555 msgid "" -"The ``sqlite3.OptimizedUnicode`` text factory has been an alias " -"for :class:`str` since Python 3.3. Code that previously set the text factory " -"to ``OptimizedUnicode`` can either use ``str`` explicitly, or rely on the " +"The ``sqlite3.OptimizedUnicode`` text factory has been an alias for :class:" +"`str` since Python 3.3. Code that previously set the text factory to " +"``OptimizedUnicode`` can either use ``str`` explicitly, or rely on the " "default value which is also ``str``." msgstr "" @@ -3671,12 +3655,12 @@ msgstr "" #: ../../whatsnew/3.12.rst:1575 msgid "" "Remove the :func:`!ssl.wrap_socket` function, deprecated in Python 3.7: " -"instead, create a :class:`ssl.SSLContext` object and call " -"its :class:`ssl.SSLContext.wrap_socket` method. Any package that still " -"uses :func:`!ssl.wrap_socket` is broken and insecure. The function neither " -"sends a SNI TLS extension nor validates the server hostname. Code is subject " -"to :cwe:`295` (Improper Certificate Validation). (Contributed by Victor " -"Stinner in :gh:`94199`.)" +"instead, create a :class:`ssl.SSLContext` object and call its :class:`ssl." +"SSLContext.wrap_socket` method. Any package that still uses :func:`!ssl." +"wrap_socket` is broken and insecure. The function neither sends a SNI TLS " +"extension nor validates the server hostname. Code is subject to :cwe:`295` " +"(Improper Certificate Validation). (Contributed by Victor Stinner in :gh:" +"`94199`.)" msgstr "" #: ../../whatsnew/3.12.rst:1586 @@ -3834,9 +3818,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:1618 msgid "" -"Undocumented :meth:`TestLoader.loadTestsFromModule " -"` parameter *use_load_tests* " -"(deprecated and ignored since Python 3.5)." +"Undocumented :meth:`TestLoader.loadTestsFromModule ` parameter *use_load_tests* (deprecated and ignored " +"since Python 3.5)." msgstr "" #: ../../whatsnew/3.12.rst:1622 @@ -3882,9 +3866,8 @@ msgstr "zipimport" #: ../../whatsnew/3.12.rst:1646 msgid "" "Remove :mod:`zipimport`'s ``find_loader()`` and ``find_module()`` methods, " -"deprecated in Python 3.10: use the ``find_spec()`` method instead. " -"See :pep:`451` for the rationale. (Contributed by Victor Stinner " -"in :gh:`94379`.)" +"deprecated in Python 3.10: use the ``find_spec()`` method instead. See :pep:" +"`451` for the rationale. (Contributed by Victor Stinner in :gh:`94379`.)" msgstr "" #: ../../whatsnew/3.12.rst:1652 @@ -3893,20 +3876,20 @@ msgstr "其他" #: ../../whatsnew/3.12.rst:1654 msgid "" -"Remove the ``suspicious`` rule from the documentation :file:`Makefile` " -"and :file:`Doc/tools/rstlint.py`, both in favor of `sphinx-lint `_. (Contributed by Julien Palard " -"in :gh:`98179`.)" +"Remove the ``suspicious`` rule from the documentation :file:`Makefile` and :" +"file:`Doc/tools/rstlint.py`, both in favor of `sphinx-lint `_. (Contributed by Julien Palard in :gh:" +"`98179`.)" msgstr "" #: ../../whatsnew/3.12.rst:1659 msgid "" -"Remove the *keyfile* and *certfile* parameters from " -"the :mod:`ftplib`, :mod:`imaplib`, :mod:`poplib` and :mod:`smtplib` modules, " -"and the *key_file*, *cert_file* and *check_hostname* parameters from " -"the :mod:`http.client` module, all deprecated since Python 3.6. Use the " -"*context* parameter (*ssl_context* in :mod:`imaplib`) instead. (Contributed " -"by Victor Stinner in :gh:`94172`.)" +"Remove the *keyfile* and *certfile* parameters from the :mod:`ftplib`, :mod:" +"`imaplib`, :mod:`poplib` and :mod:`smtplib` modules, and the *key_file*, " +"*cert_file* and *check_hostname* parameters from the :mod:`http.client` " +"module, all deprecated since Python 3.6. Use the *context* parameter " +"(*ssl_context* in :mod:`imaplib`) instead. (Contributed by Victor Stinner " +"in :gh:`94172`.)" msgstr "" #: ../../whatsnew/3.12.rst:1667 @@ -3919,8 +3902,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:1670 msgid "" -"Remove ``_use_broken_old_ctypes_structure_semantics_`` flag " -"from :mod:`ctypes` module. (Contributed by Nikita Sobolev in :gh:`99285`.)" +"Remove ``_use_broken_old_ctypes_structure_semantics_`` flag from :mod:" +"`ctypes` module. (Contributed by Nikita Sobolev in :gh:`99285`.)" msgstr "" "移除 :mod:`ctypes` 模組中的 ``_use_broken_old_ctypes_structure_semantics_`` " "旗標。(由 Nikita Sobolev 於 :gh:`99285` 中貢獻。)" @@ -3956,8 +3939,8 @@ msgid "" "integer values such as ``randrange(10.5)`` or ``randrange('10')`` has been " "changed from :exc:`ValueError` to :exc:`TypeError`. This also prevents bugs " "where ``randrange(1e25)`` would silently select from a larger range than " -"``randrange(10**25)``. (Originally suggested by Serhiy " -"Storchaka :gh:`86388`.)" +"``randrange(10**25)``. (Originally suggested by Serhiy Storchaka :gh:" +"`86388`.)" msgstr "" #: ../../whatsnew/3.12.rst:1701 @@ -3973,8 +3956,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:1707 msgid "" "Remove the ``asyncore``-based ``smtpd`` module deprecated in Python 3.4.7 " -"and 3.5.4. A recommended replacement is the :mod:`asyncio`-" -"based :pypi:`aiosmtpd` PyPI module." +"and 3.5.4. A recommended replacement is the :mod:`asyncio`-based :pypi:" +"`aiosmtpd` PyPI module." msgstr "" #: ../../whatsnew/3.12.rst:1711 @@ -3986,10 +3969,10 @@ msgstr "" #: ../../whatsnew/3.12.rst:1716 msgid "" -"The :mod:`os` module no longer accepts bytes-like paths, " -"like :class:`bytearray` and :class:`memoryview` types: only the " -"exact :class:`bytes` type is accepted for bytes strings. (Contributed by " -"Victor Stinner in :gh:`98393`.)" +"The :mod:`os` module no longer accepts bytes-like paths, like :class:" +"`bytearray` and :class:`memoryview` types: only the exact :class:`bytes` " +"type is accepted for bytes strings. (Contributed by Victor Stinner in :gh:" +"`98393`.)" msgstr "" #: ../../whatsnew/3.12.rst:1721 @@ -4018,23 +4001,21 @@ msgstr "" #: ../../whatsnew/3.12.rst:1743 msgid "" -"When extracting tar files using :mod:`tarfile` " -"or :func:`shutil.unpack_archive`, pass the *filter* argument to limit " -"features that may be surprising or dangerous. See :ref:`tarfile-extraction-" -"filter` for details." +"When extracting tar files using :mod:`tarfile` or :func:`shutil." +"unpack_archive`, pass the *filter* argument to limit features that may be " +"surprising or dangerous. See :ref:`tarfile-extraction-filter` for details." msgstr "" #: ../../whatsnew/3.12.rst:1748 msgid "" -"The output of the :func:`tokenize.tokenize` " -"and :func:`tokenize.generate_tokens` functions is now changed due to the " -"changes introduced in :pep:`701`. This means that ``STRING`` tokens are not " -"emitted any more for f-strings and the tokens described in :pep:`701` are " -"now produced instead: ``FSTRING_START``, ``FSTRING_MIDDLE`` and " -"``FSTRING_END`` are now emitted for f-string \"string\" parts in addition to " -"the appropriate tokens for the tokenization in the expression components. " -"For example for the f-string ``f\"start {1+1} end\"`` the old version of the " -"tokenizer emitted::" +"The output of the :func:`tokenize.tokenize` and :func:`tokenize." +"generate_tokens` functions is now changed due to the changes introduced in :" +"pep:`701`. This means that ``STRING`` tokens are not emitted any more for f-" +"strings and the tokens described in :pep:`701` are now produced instead: " +"``FSTRING_START``, ``FSTRING_MIDDLE`` and ``FSTRING_END`` are now emitted " +"for f-string \"string\" parts in addition to the appropriate tokens for the " +"tokenization in the expression components. For example for the f-string " +"``f\"start {1+1} end\"`` the old version of the tokenizer emitted::" msgstr "" #: ../../whatsnew/3.12.rst:1757 @@ -4139,11 +4120,11 @@ msgstr "" #: ../../whatsnew/3.12.rst:1813 msgid "" -"Add ``COMPILEALL_OPTS`` variable in :file:`Makefile` to " -"override :mod:`compileall` options (default: ``-j0``) in ``make install``. " -"Also merged the 3 ``compileall`` commands into a single command to " -"build .pyc files for all optimization levels (0, 1, 2) at once. (Contributed " -"by Victor Stinner in :gh:`99289`.)" +"Add ``COMPILEALL_OPTS`` variable in :file:`Makefile` to override :mod:" +"`compileall` options (default: ``-j0``) in ``make install``. Also merged the " +"3 ``compileall`` commands into a single command to build .pyc files for all " +"optimization levels (0, 1, 2) at once. (Contributed by Victor Stinner in :gh:" +"`99289`.)" msgstr "" #: ../../whatsnew/3.12.rst:1819 @@ -4262,8 +4243,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:1873 msgid "" ":c:macro:`Py_TPFLAGS_ITEMS_AT_END` and :c:func:`PyObject_GetItemData` added " -"to allow safely extending certain variable-sized types, " -"including :c:var:`PyType_Type`." +"to allow safely extending certain variable-sized types, including :c:var:" +"`PyType_Type`." msgstr "" #: ../../whatsnew/3.12.rst:1876 @@ -4278,10 +4259,10 @@ msgstr "(由 Petr Viktorin 於 :gh:`103509` 中貢獻。)" #: ../../whatsnew/3.12.rst:1881 msgid "" -"Add the new :ref:`limited C API ` " -"function :c:func:`PyType_FromMetaclass`, which generalizes the " -"existing :c:func:`PyType_FromModuleAndSpec` using an additional metaclass " -"argument. (Contributed by Wenzel Jakob in :gh:`93012`.)" +"Add the new :ref:`limited C API ` function :c:func:" +"`PyType_FromMetaclass`, which generalizes the existing :c:func:" +"`PyType_FromModuleAndSpec` using an additional metaclass argument. " +"(Contributed by Wenzel Jakob in :gh:`93012`.)" msgstr "" #: ../../whatsnew/3.12.rst:1886 @@ -4313,16 +4294,16 @@ msgid "" "makes vectorcall safe to use with mutable types (i.e. heap types without the " "immutable flag, :c:macro:`Py_TPFLAGS_IMMUTABLETYPE`). Mutable types that do " "not override :c:member:`~PyTypeObject.tp_call` now inherit the " -"``Py_TPFLAGS_HAVE_VECTORCALL`` flag. (Contributed by Petr Viktorin " -"in :gh:`93274`.)" +"``Py_TPFLAGS_HAVE_VECTORCALL`` flag. (Contributed by Petr Viktorin in :gh:" +"`93274`.)" msgstr "" #: ../../whatsnew/3.12.rst:1903 msgid "" -"The :c:macro:`Py_TPFLAGS_MANAGED_DICT` " -"and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` flags have been added. This allows " -"extensions classes to support object :attr:`~object.__dict__` and weakrefs " -"with less bookkeeping, using less memory and with faster access." +"The :c:macro:`Py_TPFLAGS_MANAGED_DICT` and :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` flags have been added. This allows extensions " +"classes to support object :attr:`~object.__dict__` and weakrefs with less " +"bookkeeping, using less memory and with faster access." msgstr "" #: ../../whatsnew/3.12.rst:1908 @@ -4352,9 +4333,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:1920 msgid "" -"Add two new public functions, :c:func:`PyEval_SetProfileAllThreads` " -"and :c:func:`PyEval_SetTraceAllThreads`, that allow to set tracing and " -"profiling functions in all running threads in addition to the calling one. " +"Add two new public functions, :c:func:`PyEval_SetProfileAllThreads` and :c:" +"func:`PyEval_SetTraceAllThreads`, that allow to set tracing and profiling " +"functions in all running threads in addition to the calling one. " "(Contributed by Pablo Galindo in :gh:`93503`.)" msgstr "" @@ -4367,11 +4348,11 @@ msgstr "" #: ../../whatsnew/3.12.rst:1930 msgid "" -"The C API now permits registering callbacks " -"via :c:func:`PyDict_AddWatcher`, :c:func:`PyDict_Watch` and related APIs to " -"be called whenever a dictionary is modified. This is intended for use by " -"optimizing interpreters, JIT compilers, or debuggers. (Contributed by Carl " -"Meyer in :gh:`91052`.)" +"The C API now permits registering callbacks via :c:func:" +"`PyDict_AddWatcher`, :c:func:`PyDict_Watch` and related APIs to be called " +"whenever a dictionary is modified. This is intended for use by optimizing " +"interpreters, JIT compilers, or debuggers. (Contributed by Carl Meyer in :gh:" +"`91052`.)" msgstr "" #: ../../whatsnew/3.12.rst:1936 @@ -4391,18 +4372,18 @@ msgstr "" #: ../../whatsnew/3.12.rst:1945 msgid "" "Add :c:func:`PyFrame_GetVar` and :c:func:`PyFrame_GetVarString` functions to " -"get a frame variable by its name. (Contributed by Victor Stinner " -"in :gh:`91248`.)" +"get a frame variable by its name. (Contributed by Victor Stinner in :gh:" +"`91248`.)" msgstr "" #: ../../whatsnew/3.12.rst:1949 msgid "" -"Add :c:func:`PyErr_GetRaisedException` " -"and :c:func:`PyErr_SetRaisedException` for saving and restoring the current " -"exception. These functions return and accept a single exception object, " -"rather than the triple arguments of the now-deprecated :c:func:`PyErr_Fetch` " -"and :c:func:`PyErr_Restore`. This is less error prone and a bit more " -"efficient. (Contributed by Mark Shannon in :gh:`101578`.)" +"Add :c:func:`PyErr_GetRaisedException` and :c:func:" +"`PyErr_SetRaisedException` for saving and restoring the current exception. " +"These functions return and accept a single exception object, rather than the " +"triple arguments of the now-deprecated :c:func:`PyErr_Fetch` and :c:func:" +"`PyErr_Restore`. This is less error prone and a bit more efficient. " +"(Contributed by Mark Shannon in :gh:`101578`.)" msgstr "" #: ../../whatsnew/3.12.rst:1957 @@ -4415,9 +4396,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:1961 msgid "" "Add :c:func:`PyException_GetArgs` and :c:func:`PyException_SetArgs` as " -"convenience functions for retrieving and modifying " -"the :attr:`~BaseException.args` passed to the exception's constructor. " -"(Contributed by Mark Shannon in :gh:`101578`.)" +"convenience functions for retrieving and modifying the :attr:`~BaseException." +"args` passed to the exception's constructor. (Contributed by Mark Shannon " +"in :gh:`101578`.)" msgstr "" #: ../../whatsnew/3.12.rst:1966 @@ -4486,18 +4467,17 @@ msgstr "(由 Eddie Elizondo 於 :gh:`84436` 中貢獻。)" #: ../../whatsnew/3.12.rst:1990 msgid "" -":pep:`684`: Add the new :c:func:`Py_NewInterpreterFromConfig` function " -"and :c:type:`PyInterpreterConfig`, which may be used to create sub-" -"interpreters with their own GILs. (See :ref:`whatsnew312-pep684` for more " -"info.) (Contributed by Eric Snow in :gh:`104110`.)" +":pep:`684`: Add the new :c:func:`Py_NewInterpreterFromConfig` function and :" +"c:type:`PyInterpreterConfig`, which may be used to create sub-interpreters " +"with their own GILs. (See :ref:`whatsnew312-pep684` for more info.) " +"(Contributed by Eric Snow in :gh:`104110`.)" msgstr "" #: ../../whatsnew/3.12.rst:1996 msgid "" -"In the limited C API version 3.12, :c:func:`Py_INCREF` " -"and :c:func:`Py_DECREF` functions are now implemented as opaque function " -"calls to hide implementation details. (Contributed by Victor Stinner " -"in :gh:`105387`.)" +"In the limited C API version 3.12, :c:func:`Py_INCREF` and :c:func:" +"`Py_DECREF` functions are now implemented as opaque function calls to hide " +"implementation details. (Contributed by Victor Stinner in :gh:`105387`.)" msgstr "" #: ../../whatsnew/3.12.rst:2004 @@ -4532,9 +4512,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:2023 msgid "" -"To get a list of subclasses, call the Python " -"method :py:meth:`~type.__subclasses__` (using :c:func:`PyObject_CallMethod`, " -"for example)." +"To get a list of subclasses, call the Python method :py:meth:`~type." +"__subclasses__` (using :c:func:`PyObject_CallMethod`, for example)." msgstr "" #: ../../whatsnew/3.12.rst:2027 @@ -4542,38 +4521,37 @@ msgid "" "Add support of more formatting options (left aligning, octals, uppercase " "hexadecimals, :c:type:`intmax_t`, :c:type:`ptrdiff_t`, :c:type:`wchar_t` C " "strings, variable width and precision) in :c:func:`PyUnicode_FromFormat` " -"and :c:func:`PyUnicode_FromFormatV`. (Contributed by Serhiy Storchaka " -"in :gh:`98836`.)" +"and :c:func:`PyUnicode_FromFormatV`. (Contributed by Serhiy Storchaka in :gh:" +"`98836`.)" msgstr "" #: ../../whatsnew/3.12.rst:2033 msgid "" -"An unrecognized format character in :c:func:`PyUnicode_FromFormat` " -"and :c:func:`PyUnicode_FromFormatV` 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. (Contributed " -"by Serhiy Storchaka in :gh:`95781`.)" +"An unrecognized format character in :c:func:`PyUnicode_FromFormat` and :c:" +"func:`PyUnicode_FromFormatV` 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. (Contributed by Serhiy " +"Storchaka in :gh:`95781`.)" msgstr "" #: ../../whatsnew/3.12.rst:2039 msgid "" -"Fix wrong sign placement in :c:func:`PyUnicode_FromFormat` " -"and :c:func:`PyUnicode_FromFormatV`. (Contributed by Philip Georgi " -"in :gh:`95504`.)" +"Fix wrong sign placement in :c:func:`PyUnicode_FromFormat` and :c:func:" +"`PyUnicode_FromFormatV`. (Contributed by Philip Georgi in :gh:`95504`.)" msgstr "" #: ../../whatsnew/3.12.rst:2043 msgid "" "Extension classes wanting to add a :attr:`~object.__dict__` or weak " -"reference slot should use :c:macro:`Py_TPFLAGS_MANAGED_DICT` " -"and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead of ``tp_dictoffset`` and " +"reference slot should use :c:macro:`Py_TPFLAGS_MANAGED_DICT` and :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` instead of ``tp_dictoffset`` and " "``tp_weaklistoffset``, respectively. The use of ``tp_dictoffset`` and " "``tp_weaklistoffset`` is still supported, but does not fully support " "multiple inheritance (:gh:`95589`), and performance may be worse. Classes " "declaring :c:macro:`Py_TPFLAGS_MANAGED_DICT` must call :c:func:`!" "_PyObject_VisitManagedDict` and :c:func:`!_PyObject_ClearManagedDict` to " -"traverse and clear their instance's dictionaries. To clear weakrefs, " -"call :c:func:`PyObject_ClearWeakRefs`, as before." +"traverse and clear their instance's dictionaries. To clear weakrefs, call :c:" +"func:`PyObject_ClearWeakRefs`, as before." msgstr "" #: ../../whatsnew/3.12.rst:2055 @@ -4594,10 +4572,10 @@ msgstr "" #: ../../whatsnew/3.12.rst:2065 msgid "" -"The interpreter's error indicator is now always normalized. This means " -"that :c:func:`PyErr_SetObject`, :c:func:`PyErr_SetString` and the other " -"functions that set the error indicator now normalize the exception before " -"storing it. (Contributed by Mark Shannon in :gh:`101578`.)" +"The interpreter's error indicator is now always normalized. This means that :" +"c:func:`PyErr_SetObject`, :c:func:`PyErr_SetString` and the other functions " +"that set the error indicator now normalize the exception before storing it. " +"(Contributed by Mark Shannon in :gh:`101578`.)" msgstr "" #: ../../whatsnew/3.12.rst:2070 @@ -4637,8 +4615,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:2087 msgid "" "Note that :c:func:`PyType_FromMetaclass` (added in Python 3.12) already " -"disallows creating classes whose metaclass overrides ``tp_new`` " -"(:meth:`~object.__new__` in Python)." +"disallows creating classes whose metaclass overrides ``tp_new`` (:meth:" +"`~object.__new__` in Python)." msgstr "" #: ../../whatsnew/3.12.rst:2091 @@ -4656,16 +4634,16 @@ msgstr "" #: ../../whatsnew/3.12.rst:2100 msgid "" -"If initialization can be skipped, it can be done " -"in :c:member:`~PyTypeObject.tp_init` instead." +"If initialization can be skipped, it can be done in :c:member:`~PyTypeObject." +"tp_init` instead." msgstr "" #: ../../whatsnew/3.12.rst:2102 msgid "" "If the metaclass doesn't need to be instantiated from Python, set its " -"``tp_new`` to ``NULL`` using " -"the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag. This makes it " -"acceptable for ``PyType_From*`` functions." +"``tp_new`` to ``NULL`` using the :c:macro:" +"`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag. This makes it acceptable for " +"``PyType_From*`` functions." msgstr "" #: ../../whatsnew/3.12.rst:2107 @@ -4701,10 +4679,10 @@ msgid "" ":c:struct:`PyLongObject` has had its internals changed for better " "performance. Although the internals of :c:struct:`PyLongObject` are private, " "they are used by some extension modules. The internal fields should no " -"longer be accessed directly, instead the API functions beginning " -"``PyLong_...`` should be used instead. Two new *unstable* API functions are " -"provided for efficient access to the value of :c:struct:`PyLongObject`\\s " -"which fit into a single machine word:" +"longer be accessed directly, instead the API functions beginning ``PyLong_..." +"`` should be used instead. Two new *unstable* API functions are provided for " +"efficient access to the value of :c:struct:`PyLongObject`\\s which fit into " +"a single machine word:" msgstr "" #: ../../whatsnew/3.12.rst:2131 @@ -4726,11 +4704,11 @@ msgstr "" #: ../../whatsnew/3.12.rst:2144 msgid "" -"In accordance with :pep:`699`, the ``ma_version_tag`` field " -"in :c:type:`PyDictObject` is deprecated for extension modules. Accessing " -"this field will generate a compiler warning at compile time. This field will " -"be removed in Python 3.14. (Contributed by Ramvikrams and Kumar Aditya " -"in :gh:`101193`. PEP by Ken Jin.)" +"In accordance with :pep:`699`, the ``ma_version_tag`` field in :c:type:" +"`PyDictObject` is deprecated for extension modules. Accessing this field " +"will generate a compiler warning at compile time. This field will be removed " +"in Python 3.14. (Contributed by Ramvikrams and Kumar Aditya in :gh:`101193`. " +"PEP by Ken Jin.)" msgstr "" #: ../../whatsnew/3.12.rst:2149 @@ -4780,8 +4758,8 @@ msgstr "" msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment`" msgstr "" -":c:var:`Py_IgnoreEnvironmentFlag`: 請改" -"用 :c:member:`PyConfig.use_environment`" +":c:var:`Py_IgnoreEnvironmentFlag`: 請改用 :c:member:`PyConfig." +"use_environment`" #: ../../whatsnew/3.12.rst:2161 msgid "" @@ -4793,8 +4771,8 @@ msgstr "" msgid "" ":c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory`" msgstr "" -":c:var:`Py_NoUserSiteDirectory`: 請改" -"用 :c:member:`PyConfig.user_site_directory`" +":c:var:`Py_NoUserSiteDirectory`: 請改用 :c:member:`PyConfig." +"user_site_directory`" #: ../../whatsnew/3.12.rst:2163 msgid "" @@ -4816,57 +4794,56 @@ msgstr ":c:var:`Py_IsolatedFlag`: 請改用 :c:member:`PyConfig.isolated`" #: ../../whatsnew/3.12.rst:2167 msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: " -"use :c:member:`PyPreConfig.legacy_windows_fs_encoding`" +":c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig." +"legacy_windows_fs_encoding`" msgstr "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: 請改" -"用 :c:member:`PyPreConfig.legacy_windows_fs_encoding`" +":c:var:`Py_LegacyWindowsFSEncodingFlag`: 請改用 :c:member:`PyPreConfig." +"legacy_windows_fs_encoding`" #: ../../whatsnew/3.12.rst:2168 msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: " -"use :c:member:`PyConfig.legacy_windows_stdio`" +":c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig." +"legacy_windows_stdio`" msgstr "" -":c:var:`Py_LegacyWindowsStdioFlag`: 請改" -"用 :c:member:`PyConfig.legacy_windows_stdio`" +":c:var:`Py_LegacyWindowsStdioFlag`: 請改用 :c:member:`PyConfig." +"legacy_windows_stdio`" #: ../../whatsnew/3.12.rst:2169 msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: " -"use :c:member:`PyConfig.filesystem_encoding`" +":c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig." +"filesystem_encoding`" msgstr "" -":c:var:`!Py_FileSystemDefaultEncoding`: 請改" -"用 :c:member:`PyConfig.filesystem_encoding`" +":c:var:`!Py_FileSystemDefaultEncoding`: 請改用 :c:member:`PyConfig." +"filesystem_encoding`" #: ../../whatsnew/3.12.rst:2170 msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: " -"use :c:member:`PyConfig.filesystem_encoding`" +":c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig." +"filesystem_encoding`" msgstr "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: 請改" -"用 :c:member:`PyConfig.filesystem_encoding`" +":c:var:`!Py_HasFileSystemDefaultEncoding`: 請改用 :c:member:`PyConfig." +"filesystem_encoding`" #: ../../whatsnew/3.12.rst:2171 msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: " -"use :c:member:`PyConfig.filesystem_errors`" +":c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig." +"filesystem_errors`" msgstr "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: 請改" -"用 :c:member:`PyConfig.filesystem_errors`" +":c:var:`!Py_FileSystemDefaultEncodeErrors`: 請改用 :c:member:`PyConfig." +"filesystem_errors`" #: ../../whatsnew/3.12.rst:2172 msgid "" -":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` " -"(see :c:func:`Py_PreInitialize`)" +":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:" +"`Py_PreInitialize`)" msgstr "" -":c:var:`!Py_UTF8Mode`: 請改用 :c:member:`PyPreConfig.utf8_mode`\\ (參" -"見 :c:func:`Py_PreInitialize`)" +":c:var:`!Py_UTF8Mode`: 請改用 :c:member:`PyPreConfig.utf8_mode`\\ (參見 :c:" +"func:`Py_PreInitialize`)" #: ../../whatsnew/3.12.rst:2174 msgid "" -"The :c:func:`Py_InitializeFromConfig` API should be used " -"with :c:type:`PyConfig` instead. (Contributed by Victor Stinner " -"in :gh:`77782`.)" +"The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" +"`PyConfig` instead. (Contributed by Victor Stinner in :gh:`77782`.)" msgstr "" ":c:func:`Py_InitializeFromConfig` API 應改為與 :c:type:`PyConfig` 一起使用。" "(由 Victor Stinner 於 :gh:`77782` 中貢獻。)" @@ -4891,11 +4868,11 @@ msgstr "" #: ../../whatsnew/3.12.rst:2187 msgid "" -":c:struct:`PyMemberDef`, :c:func:`PyMember_GetOne` " -"and :c:func:`PyMember_SetOne`" +":c:struct:`PyMemberDef`, :c:func:`PyMember_GetOne` and :c:func:" +"`PyMember_SetOne`" msgstr "" -":c:struct:`PyMemberDef`、:c:func:`PyMember_GetOne` " -"和 :c:func:`PyMember_SetOne`" +":c:struct:`PyMemberDef`、:c:func:`PyMember_GetOne` 和 :c:func:" +"`PyMember_SetOne`" #: ../../whatsnew/3.12.rst:2189 msgid "" @@ -4905,11 +4882,11 @@ msgstr "" #: ../../whatsnew/3.12.rst:2191 msgid "" -"The flags :c:macro:`Py_READONLY` (previously ``READONLY``) " -"and :c:macro:`Py_AUDIT_READ` (previously all uppercase)" +"The flags :c:macro:`Py_READONLY` (previously ``READONLY``) and :c:macro:" +"`Py_AUDIT_READ` (previously all uppercase)" msgstr "" -":c:macro:`Py_READONLY`\\ (先前為 ``READONLY``)" -"和 :c:macro:`Py_AUDIT_READ`\\ (先前全大寫)旗標" +":c:macro:`Py_READONLY`\\ (先前為 ``READONLY``)和 :c:macro:" +"`Py_AUDIT_READ`\\ (先前全大寫)旗標" #: ../../whatsnew/3.12.rst:2194 msgid "Several items are not exposed from :file:`Python.h`:" @@ -4929,17 +4906,16 @@ msgstr "不做任何事的巨集 ``WRITE_RESTRICTED``。" #: ../../whatsnew/3.12.rst:2199 msgid "" -"The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents " -"of :c:macro:`Py_AUDIT_READ`." +"The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of :c:macro:" +"`Py_AUDIT_READ`." msgstr "" -"``RESTRICTED`` 和 ``READ_RESTRICTED`` 這兩個巨集,相當" -"於 :c:macro:`Py_AUDIT_READ`。" +"``RESTRICTED`` 和 ``READ_RESTRICTED`` 這兩個巨集,相當於 :c:macro:" +"`Py_AUDIT_READ`。" #: ../../whatsnew/3.12.rst:2201 msgid "" -"In some configurations, ```` is not included " -"from :file:`Python.h`. It should be included manually when using " -"``offsetof()``." +"In some configurations, ```` is not included from :file:`Python." +"h`. It should be included manually when using ``offsetof()``." msgstr "" #: ../../whatsnew/3.12.rst:2204 @@ -4957,10 +4933,9 @@ msgstr "" #: ../../whatsnew/3.12.rst:2212 msgid "" -":c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` are deprecated. " -"Use :c:func:`PyErr_GetRaisedException` " -"and :c:func:`PyErr_SetRaisedException` instead. (Contributed by Mark Shannon " -"in :gh:`101578`.)" +":c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` are deprecated. Use :c:" +"func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException` " +"instead. (Contributed by Mark Shannon in :gh:`101578`.)" msgstr "" #: ../../whatsnew/3.12.rst:2217 @@ -4981,30 +4956,29 @@ msgstr "" #: ../../whatsnew/3.12.rst:2223 msgid "" -"Using :c:func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases` " -"or :c:func:`PyType_FromModuleAndSpec` to create a class whose metaclass " -"overrides :c:member:`~PyTypeObject.tp_new` is deprecated. Call the metaclass " -"instead." +"Using :c:func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases` or :c:" +"func:`PyType_FromModuleAndSpec` to create a class whose metaclass overrides :" +"c:member:`~PyTypeObject.tp_new` is deprecated. Call the metaclass instead." msgstr "" -"使用 :c:func:`PyType_FromSpec`、:c:func:`PyType_FromSpecWithBases` " -"或 :c:func:`PyType_FromModuleAndSpec` 建立一個其元類別覆" -"寫 :c:member:`~PyTypeObject.tp_new` 的類別已被棄用。請改為呼叫元類別。" +"使用 :c:func:`PyType_FromSpec`、:c:func:`PyType_FromSpecWithBases` 或 :c:" +"func:`PyType_FromModuleAndSpec` 建立一個其元類別覆寫 :c:member:" +"`~PyTypeObject.tp_new` 的類別已被棄用。請改為呼叫元類別。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:4 msgid "" "The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules " "(:pep:`699`; :gh:`101193`)." msgstr "" -":c:type:`PyDictObject` 中的 ``ma_version_tag`` 欄位,用於擴充模組 " -"(:pep:`699`;:gh:`101193`)。" +":c:type:`PyDictObject` 中的 ``ma_version_tag`` 欄位,用於擴充模組 (:pep:" +"`699`;:gh:`101193`)。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:7 msgid "" "Creating :c:data:`immutable types ` with mutable " "bases (:gh:`95388`)." msgstr "" -"使用可變基底建立\\ :c:data:`不可變型別 ` " -"(:gh:`95388`)。" +"使用可變基底建立\\ :c:data:`不可變型別 ` (:gh:" +"`95388`)。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:10 msgid "" @@ -5034,8 +5008,8 @@ msgstr ":c:func:`!Py_SetPythonHome()`:請改以 :c:member:`PyConfig.home` 設 #: ../../deprecations/c-api-pending-removal-in-3.14.rst:21 #: ../../deprecations/c-api-pending-removal-in-3.14.rst:71 msgid "" -"The :c:func:`Py_InitializeFromConfig` API should be used " -"with :c:type:`PyConfig` instead." +"The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" +"`PyConfig` instead." msgstr "" ":c:func:`Py_InitializeFromConfig` API 應該與 :c:type:`PyConfig` 一起使用。" @@ -5092,24 +5066,24 @@ msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "instead." msgstr "" -":c:var:`Py_IgnoreEnvironmentFlag`:請改" -"用 :c:member:`PyConfig.use_environment`。" +":c:var:`Py_IgnoreEnvironmentFlag`:請改用 :c:member:`PyConfig." +"use_environment`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "instead." msgstr "" -":c:var:`Py_DontWriteBytecodeFlag`:請改" -"用 :c:member:`PyConfig.write_bytecode`。" +":c:var:`Py_DontWriteBytecodeFlag`:請改用 :c:member:`PyConfig." +"write_bytecode`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 msgid "" -":c:var:`Py_NoUserSiteDirectory`: " -"Use :c:member:`PyConfig.user_site_directory` instead." +":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." +"user_site_directory` instead." msgstr "" -":c:var:`Py_NoUserSiteDirectory`:請改" -"用 :c:member:`PyConfig.user_site_directory`。" +":c:var:`Py_NoUserSiteDirectory`:請改用 :c:member:`PyConfig." +"user_site_directory`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 msgid "" @@ -5132,51 +5106,51 @@ msgstr ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: " -"Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead." +":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`。" +":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改用 :c:member:`PyPreConfig." +"legacy_windows_fs_encoding`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: " -"Use :c:member:`PyConfig.legacy_windows_stdio` instead." +":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." +"legacy_windows_stdio` instead." msgstr "" -":c:var:`Py_LegacyWindowsStdioFlag`:請改" -"用 :c:member:`PyConfig.legacy_windows_stdio`。" +":c:var:`Py_LegacyWindowsStdioFlag`:請改用 :c:member:`PyConfig." +"legacy_windows_stdio`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: " -"Use :c:member:`PyConfig.filesystem_encoding` instead." +":c:var:`!Py_FileSystemDefaultEncoding`: Use :c:member:`PyConfig." +"filesystem_encoding` instead." msgstr "" -":c:var:`!Py_FileSystemDefaultEncoding`:請改" -"用 :c:member:`PyConfig.filesystem_encoding`。" +":c:var:`!Py_FileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." +"filesystem_encoding`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: " -"Use :c:member:`PyConfig.filesystem_encoding` instead." +":c:var:`!Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." +"filesystem_encoding` instead." msgstr "" -":c:var:`!Py_HasFileSystemDefaultEncoding`:請改" -"用 :c:member:`PyConfig.filesystem_encoding`。" +":c:var:`!Py_HasFileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." +"filesystem_encoding`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: " -"Use :c:member:`PyConfig.filesystem_errors` instead." +":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." +"filesystem_errors` instead." msgstr "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改" -"用 :c:member:`PyConfig.filesystem_errors`。" +":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改用 :c:member:`PyConfig." +"filesystem_errors`。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 msgid "" -":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. " -"(see :c:func:`Py_PreInitialize`)" +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. (see :" +"c:func:`Py_PreInitialize`)" msgstr "" -":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請" -"見 :c:func:`Py_PreInitialize`)" +":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請見 :c:" +"func:`Py_PreInitialize`)" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "The bundled copy of ``libmpdecimal``." @@ -5184,27 +5158,27 @@ msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:5 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: " -"Use :c:func:`PyImport_ImportModule` instead." +"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"`PyImport_ImportModule` instead." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改" -"用 :c:func:`PyImport_ImportModule`。" +":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" +"`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:7 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: " -"Use :c:func:`PyWeakref_GetRef` instead." +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +"func:`PyWeakref_GetRef` instead." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改" -"用 :c:func:`PyWeakref_GetRef`。" +":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" +"func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:9 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: " -"Use :c:type:`wchar_t` instead." +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" +"type:`wchar_t` instead." msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改" -"用 :c:type:`wchar_t`。" +":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" +"`wchar_t`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:11 msgid "Python initialization functions:" @@ -5215,16 +5189,16 @@ msgid "" ":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " -"和 :data:`!warnings.filters`。" +":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" +"data:`!warnings.filters`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" -":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` " -"and :data:`sys.exec_prefix` instead." +":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." +"exec_prefix` instead." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.base_exec_prefix` " -"與 :data:`sys.exec_prefix`。" +":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.base_exec_prefix` 與 :data:" +"`sys.exec_prefix`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." @@ -5235,8 +5209,8 @@ msgid "" ":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " "instead." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :data:`sys.base_prefix` " -"與 :data:`sys.prefix`。" +":c:func:`Py_GetPrefix`:請改用 :data:`sys.base_prefix` 與 :data:`sys." +"prefix`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:21 msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." @@ -5248,11 +5222,11 @@ msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" -":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or " -"the :envvar:`PYTHONHOME` environment variable instead." +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" +"`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` " -"或 :envvar:`PYTHONHOME` 環境變數。" +":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" +"`PYTHONHOME` 環境變數。" #: ../../deprecations/c-api-pending-removal-in-future.rst:4 msgid "" @@ -5273,8 +5247,8 @@ msgid "" ":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" -":c:func:`PyErr_NormalizeException`:請改" -"用 :c:func:`PyErr_GetRaisedException`。" +":c:func:`PyErr_NormalizeException`:請改用 :c:func:" +"`PyErr_GetRaisedException`。" #: ../../deprecations/c-api-pending-removal-in-future.rst:13 msgid "" @@ -5294,11 +5268,11 @@ msgstr ":c:func:`PyOS_AfterFork`:請改用 :c:func:`PyOS_AfterFork_Child`。" #: ../../deprecations/c-api-pending-removal-in-future.rst:19 msgid "" -":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` " -"and :c:func:`PySlice_AdjustIndices` instead." +":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`。" +":c:func:`PySlice_GetIndicesEx`:請改用 :c:func:`PySlice_Unpack` 和 :c:func:" +"`PySlice_AdjustIndices`。" #: ../../deprecations/c-api-pending-removal-in-future.rst:21 msgid "" @@ -5344,8 +5318,8 @@ msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." msgstr "" -":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼" -"叫 :c:func:`PyObject_Hash`。" +":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼叫 :c:func:" +"`PyObject_Hash`。" #: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid ":c:member:`!PyDictObject.ma_version_tag` member." @@ -5391,9 +5365,9 @@ msgid "" "C API. The :file:`token.h` header file was only designed to be used by " "Python internals. (Contributed by Victor Stinner in :gh:`92651`.)" msgstr "" -"移除 :file:`token.h` 標頭檔案。從未有任何公開的 tokenizer C " -"API。:file:`token.h` 標頭檔案的設計是僅限用於 Python 內部。(由 Victor " -"Stinner 於 :gh:`92651` 中貢獻。)" +"移除 :file:`token.h` 標頭檔案。從未有任何公開的 tokenizer C API。:file:" +"`token.h` 標頭檔案的設計是僅限用於 Python 內部。(由 Victor Stinner 於 :gh:" +"`92651` 中貢獻。)" #: ../../whatsnew/3.12.rst:2244 msgid "Legacy Unicode APIs have been removed. See :pep:`623` for detail." @@ -5440,8 +5414,8 @@ msgid "" "Remove the ``PyUnicode_InternImmortal()`` function macro. (Contributed by " "Victor Stinner in :gh:`85858`.)" msgstr "" -"移除 ``PyUnicode_InternImmortal()`` 函式巨集。(由 Victor Stinner " -"於 :gh:`85858` 中貢獻。)" +"移除 ``PyUnicode_InternImmortal()`` 函式巨集。(由 Victor Stinner 於 :gh:" +"`85858` 中貢獻。)" #~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" #~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" diff --git a/whatsnew/3.13.po b/whatsnew/3.13.po index 00b971f26a..f41a44f35d 100644 --- a/whatsnew/3.13.po +++ b/whatsnew/3.13.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-07 00:15+0000\n" +"POT-Creation-Date: 2025-06-27 07:36+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-" @@ -346,7 +346,7 @@ msgid "" "years of security fixes." msgstr "" -#: ../../whatsnew/3.13.rst:208 ../../whatsnew/3.13.rst:2037 +#: ../../whatsnew/3.13.rst:208 ../../whatsnew/3.13.rst:2053 msgid "New Features" msgstr "新增功能" @@ -1150,38 +1150,57 @@ msgid "" "(Contributed by Arthur Tacca and Jason Zhang in :gh:`115957`.)" msgstr "" -#: ../../whatsnew/3.13.rst:744 +#: ../../whatsnew/3.13.rst:742 +msgid "" +"The function and methods named ``create_task`` have received a new " +"``**kwargs`` argument that is passed through to the task constructor. This " +"change was accidentally added in 3.13.3, and broke the API contract for " +"custom task factories. Several third-party task factories implemented " +"workarounds for this. In 3.13.4 and later releases the old factory contract " +"is honored once again (until 3.14). To keep the workarounds working, the " +"extra ``**kwargs`` argument still allows passing additional keyword " +"arguments to :class:`~asyncio.Task` and to custom task factories." +msgstr "" + +#: ../../whatsnew/3.13.rst:753 +msgid "" +"This affects the following function and methods: :meth:`asyncio." +"create_task`, :meth:`asyncio.loop.create_task`, :meth:`asyncio.TaskGroup." +"create_task`. (Contributed by Thomas Grainger in :gh:`128307`.)" +msgstr "" + +#: ../../whatsnew/3.13.rst:760 msgid "base64" msgstr "base64" -#: ../../whatsnew/3.13.rst:746 +#: ../../whatsnew/3.13.rst:762 msgid "" "Add :func:`~base64.z85encode` and :func:`~base64.z85decode` functions for " "encoding :class:`bytes` as `Z85 data`_ and decoding Z85-encoded data to :" "class:`!bytes`. (Contributed by Matan Perelman in :gh:`75299`.)" msgstr "" -#: ../../whatsnew/3.13.rst:755 +#: ../../whatsnew/3.13.rst:771 msgid "compileall" msgstr "compileall" -#: ../../whatsnew/3.13.rst:757 ../../whatsnew/3.13.rst:765 -#: ../../whatsnew/3.13.rst:1024 +#: ../../whatsnew/3.13.rst:773 ../../whatsnew/3.13.rst:781 +#: ../../whatsnew/3.13.rst:1040 msgid "" "The default number of worker threads and processes is now selected using :" "func:`os.process_cpu_count` instead of :func:`os.cpu_count`. (Contributed by " "Victor Stinner in :gh:`109649`.)" msgstr "" -#: ../../whatsnew/3.13.rst:763 +#: ../../whatsnew/3.13.rst:779 msgid "concurrent.futures" msgstr "concurrent.futures" -#: ../../whatsnew/3.13.rst:771 ../../whatsnew/3.13.rst:1673 +#: ../../whatsnew/3.13.rst:787 ../../whatsnew/3.13.rst:1689 msgid "configparser" msgstr "configparser" -#: ../../whatsnew/3.13.rst:773 +#: ../../whatsnew/3.13.rst:789 msgid "" ":class:`~configparser.ConfigParser` now has support for unnamed sections, " "which allows for top-level key-value pairs. This can be enabled with the new " @@ -1189,11 +1208,11 @@ msgid "" "gh:`66449`.)" msgstr "" -#: ../../whatsnew/3.13.rst:780 +#: ../../whatsnew/3.13.rst:796 msgid "copy" msgstr "copy" -#: ../../whatsnew/3.13.rst:782 +#: ../../whatsnew/3.13.rst:798 msgid "" "The new :func:`~copy.replace` function and the :meth:`replace protocol " "` make creating modified copies of objects much simpler. " @@ -1202,44 +1221,44 @@ msgid "" "protocol:" msgstr "" -#: ../../whatsnew/3.13.rst:788 +#: ../../whatsnew/3.13.rst:804 msgid ":func:`collections.namedtuple`" msgstr ":func:`collections.namedtuple`" -#: ../../whatsnew/3.13.rst:789 +#: ../../whatsnew/3.13.rst:805 msgid ":class:`dataclasses.dataclass`" msgstr ":class:`dataclasses.dataclass`" -#: ../../whatsnew/3.13.rst:790 +#: ../../whatsnew/3.13.rst:806 msgid "" ":class:`datetime.datetime`, :class:`datetime.date`, :class:`datetime.time`" msgstr "" ":class:`datetime.datetime`、:class:`datetime.date`、:class:`datetime.time`" -#: ../../whatsnew/3.13.rst:791 +#: ../../whatsnew/3.13.rst:807 msgid ":class:`inspect.Signature`, :class:`inspect.Parameter`" msgstr ":class:`inspect.Signature`、:class:`inspect.Parameter`" -#: ../../whatsnew/3.13.rst:792 +#: ../../whatsnew/3.13.rst:808 msgid ":class:`types.SimpleNamespace`" msgstr ":class:`types.SimpleNamespace`" -#: ../../whatsnew/3.13.rst:793 +#: ../../whatsnew/3.13.rst:809 msgid ":ref:`code objects `" msgstr ":ref:`程式碼物件 `" -#: ../../whatsnew/3.13.rst:795 +#: ../../whatsnew/3.13.rst:811 msgid "" "Any user-defined class can also support :func:`copy.replace` by defining " "the :meth:`~object.__replace__` method. (Contributed by Serhiy Storchaka in :" "gh:`108751`.)" msgstr "" -#: ../../whatsnew/3.13.rst:801 +#: ../../whatsnew/3.13.rst:817 msgid "ctypes" msgstr "ctypes" -#: ../../whatsnew/3.13.rst:803 +#: ../../whatsnew/3.13.rst:819 msgid "" "As a consequence of necessary internal refactoring, initialization of " "internal metaclasses now happens in ``__init__`` rather than in ``__new__``. " @@ -1247,25 +1266,25 @@ msgid "" "custom initialization. Generally:" msgstr "" -#: ../../whatsnew/3.13.rst:809 +#: ../../whatsnew/3.13.rst:825 msgid "" "Custom logic that was done in ``__new__`` after calling ``super().__new__`` " "should be moved to ``__init__``." msgstr "" -#: ../../whatsnew/3.13.rst:811 +#: ../../whatsnew/3.13.rst:827 msgid "" "To create a class, call the metaclass, not only the metaclass's ``__new__`` " "method." msgstr "" -#: ../../whatsnew/3.13.rst:814 +#: ../../whatsnew/3.13.rst:830 msgid "" "See :gh:`124520` for discussion and links to changes in some affected " "projects." msgstr "" -#: ../../whatsnew/3.13.rst:817 +#: ../../whatsnew/3.13.rst:833 msgid "" ":class:`ctypes.Structure` objects have a new :attr:`~ctypes.Structure." "_align_` attribute which allows the alignment of the structure being packed " @@ -1273,29 +1292,29 @@ msgid "" "in :gh:`112433`)" msgstr "" -#: ../../whatsnew/3.13.rst:823 +#: ../../whatsnew/3.13.rst:839 msgid "dbm" msgstr "dbm" -#: ../../whatsnew/3.13.rst:825 +#: ../../whatsnew/3.13.rst:841 msgid "" "Add :mod:`dbm.sqlite3`, a new module which implements an SQLite backend, and " "make it the default :mod:`!dbm` backend. (Contributed by Raymond Hettinger " "and Erlend E. Aasland in :gh:`100414`.)" msgstr "" -#: ../../whatsnew/3.13.rst:829 +#: ../../whatsnew/3.13.rst:845 msgid "" "Allow removing all items from the database through the new :meth:`.gdbm." "clear` and :meth:`.ndbm.clear` methods. (Contributed by Donghee Na in :gh:" "`107122`.)" msgstr "" -#: ../../whatsnew/3.13.rst:835 +#: ../../whatsnew/3.13.rst:851 msgid "dis" msgstr "dis" -#: ../../whatsnew/3.13.rst:837 +#: ../../whatsnew/3.13.rst:853 msgid "" "Change the output of :mod:`dis` module functions to show logical labels for " "jump targets and exception handlers, rather than offsets. The offsets can be " @@ -1303,7 +1322,7 @@ msgid "" "the *show_offsets* argument. (Contributed by Irit Katriel in :gh:`112137`.)" msgstr "" -#: ../../whatsnew/3.13.rst:844 +#: ../../whatsnew/3.13.rst:860 msgid "" ":meth:`~dis.get_instructions` no longer represents cache entries as separate " "instructions. Instead, it returns them as part of the :class:`~dis." @@ -1312,11 +1331,11 @@ msgid "" "(Contributed by Irit Katriel in :gh:`112962`.)" msgstr "" -#: ../../whatsnew/3.13.rst:856 +#: ../../whatsnew/3.13.rst:872 msgid "doctest" msgstr "doctest" -#: ../../whatsnew/3.13.rst:858 +#: ../../whatsnew/3.13.rst:874 msgid "" ":mod:`doctest` output is now colored by default. This can be controlled via " "the new :envvar:`PYTHON_COLORS` environment variable as well as the " @@ -1325,18 +1344,18 @@ msgid "" "`117225`.)" msgstr "" -#: ../../whatsnew/3.13.rst:865 +#: ../../whatsnew/3.13.rst:881 msgid "" "The :meth:`.DocTestRunner.run` method now counts the number of skipped " "tests. Add the :attr:`.DocTestRunner.skips` and :attr:`.TestResults.skipped` " "attributes. (Contributed by Victor Stinner in :gh:`108794`.)" msgstr "" -#: ../../whatsnew/3.13.rst:871 +#: ../../whatsnew/3.13.rst:887 msgid "email" msgstr "email" -#: ../../whatsnew/3.13.rst:873 +#: ../../whatsnew/3.13.rst:889 msgid "" "Headers with embedded newlines are now quoted on output. The :mod:`~email." "generator` will now refuse to serialize (write) headers that are improperly " @@ -1346,7 +1365,7 @@ msgid "" "Bloemsaat and Petr Viktorin in :gh:`121650`.)" msgstr "" -#: ../../whatsnew/3.13.rst:881 +#: ../../whatsnew/3.13.rst:897 msgid "" ":func:`~email.utils.getaddresses` and :func:`~email.utils.parseaddr` now " "return ``('', '')`` pairs in more situations where invalid email addresses " @@ -1358,22 +1377,22 @@ msgid "" "Stinner for :gh:`102988` to improve the :cve:`2023-27043` fix.)" msgstr "" -#: ../../whatsnew/3.13.rst:893 +#: ../../whatsnew/3.13.rst:909 msgid "enum" msgstr "enum" -#: ../../whatsnew/3.13.rst:895 +#: ../../whatsnew/3.13.rst:911 msgid "" ":class:`~enum.EnumDict` has been made public to better support subclassing :" "class:`~enum.EnumType`." msgstr "" "公開 :class:`~enum.EnumDict` 以更好地支援 :class:`~enum.EnumType` 的子類別。" -#: ../../whatsnew/3.13.rst:900 +#: ../../whatsnew/3.13.rst:916 msgid "fractions" msgstr "fractions" -#: ../../whatsnew/3.13.rst:902 +#: ../../whatsnew/3.13.rst:918 msgid "" ":class:`~fractions.Fraction` objects now support the standard :ref:`format " "specification mini-language ` rules for fill, alignment, sign " @@ -1381,22 +1400,22 @@ msgid "" "`111320`.)" msgstr "" -#: ../../whatsnew/3.13.rst:909 +#: ../../whatsnew/3.13.rst:925 msgid "glob" msgstr "glob" -#: ../../whatsnew/3.13.rst:911 +#: ../../whatsnew/3.13.rst:927 msgid "" "Add :func:`~glob.translate`, a function to convert a path specification with " "shell-style wildcards to a regular expression. (Contributed by Barney Gale " "in :gh:`72904`.)" msgstr "" -#: ../../whatsnew/3.13.rst:917 +#: ../../whatsnew/3.13.rst:933 msgid "importlib" msgstr "importlib" -#: ../../whatsnew/3.13.rst:919 +#: ../../whatsnew/3.13.rst:935 msgid "" "The following functions in :mod:`importlib.resources` now allow accessing a " "directory (or tree) of resources, using multiple positional arguments (the " @@ -1404,37 +1423,37 @@ msgid "" "keyword-only):" msgstr "" -#: ../../whatsnew/3.13.rst:924 +#: ../../whatsnew/3.13.rst:940 msgid ":func:`~importlib.resources.is_resource`" msgstr ":func:`~importlib.resources.is_resource`" -#: ../../whatsnew/3.13.rst:925 +#: ../../whatsnew/3.13.rst:941 msgid ":func:`~importlib.resources.open_binary`" msgstr ":func:`~importlib.resources.open_binary`" -#: ../../whatsnew/3.13.rst:926 +#: ../../whatsnew/3.13.rst:942 msgid ":func:`~importlib.resources.open_text`" msgstr ":func:`~importlib.resources.open_text`" -#: ../../whatsnew/3.13.rst:927 +#: ../../whatsnew/3.13.rst:943 msgid ":func:`~importlib.resources.path`" msgstr ":func:`~importlib.resources.path`" -#: ../../whatsnew/3.13.rst:928 +#: ../../whatsnew/3.13.rst:944 msgid ":func:`~importlib.resources.read_binary`" msgstr ":func:`~importlib.resources.read_binary`" -#: ../../whatsnew/3.13.rst:929 +#: ../../whatsnew/3.13.rst:945 msgid ":func:`~importlib.resources.read_text`" msgstr ":func:`~importlib.resources.read_text`" -#: ../../whatsnew/3.13.rst:931 +#: ../../whatsnew/3.13.rst:947 msgid "" "These functions are no longer deprecated and are not scheduled for removal. " "(Contributed by Petr Viktorin in :gh:`116608`.)" msgstr "" -#: ../../whatsnew/3.13.rst:934 +#: ../../whatsnew/3.13.rst:950 msgid "" ":func:`~importlib.resources.contents` remains deprecated in favor of the " "fully-featured :class:`~importlib.resources.abc.Traversable` API. However, " @@ -1442,11 +1461,11 @@ msgid "" "`116608`.)" msgstr "" -#: ../../whatsnew/3.13.rst:941 +#: ../../whatsnew/3.13.rst:957 msgid "io" msgstr "io" -#: ../../whatsnew/3.13.rst:943 +#: ../../whatsnew/3.13.rst:959 msgid "" "The :class:`~io.IOBase` finalizer now logs any errors raised by the :meth:" "`~io.IOBase.close` method with :data:`sys.unraisablehook`. Previously, " @@ -1455,17 +1474,17 @@ msgid "" "build>`. (Contributed by Victor Stinner in :gh:`62948`.)" msgstr "" -#: ../../whatsnew/3.13.rst:952 +#: ../../whatsnew/3.13.rst:968 msgid "ipaddress" msgstr "ipaddress" -#: ../../whatsnew/3.13.rst:954 +#: ../../whatsnew/3.13.rst:970 msgid "" "Add the :attr:`.IPv4Address.ipv6_mapped` property, which returns the IPv4-" "mapped IPv6 address. (Contributed by Charles Machalow in :gh:`109466`.)" msgstr "" -#: ../../whatsnew/3.13.rst:958 +#: ../../whatsnew/3.13.rst:974 msgid "" "Fix ``is_global`` and ``is_private`` behavior in :class:`~ipaddress." "IPv4Address`, :class:`~ipaddress.IPv6Address`, :class:`~ipaddress." @@ -1473,22 +1492,22 @@ msgid "" "Stasiak in :gh:`113171`.)" msgstr "" -#: ../../whatsnew/3.13.rst:965 +#: ../../whatsnew/3.13.rst:981 msgid "itertools" msgstr "itertools" -#: ../../whatsnew/3.13.rst:967 +#: ../../whatsnew/3.13.rst:983 msgid "" ":func:`~itertools.batched` has a new *strict* parameter, which raises a :exc:" "`ValueError` if the final batch is shorter than the specified batch size. " "(Contributed by Raymond Hettinger in :gh:`113202`.)" msgstr "" -#: ../../whatsnew/3.13.rst:974 +#: ../../whatsnew/3.13.rst:990 msgid "marshal" msgstr "marshal" -#: ../../whatsnew/3.13.rst:976 +#: ../../whatsnew/3.13.rst:992 msgid "" "Add the *allow_code* parameter in module functions. Passing " "``allow_code=False`` prevents serialization and de-serialization of code " @@ -1496,11 +1515,11 @@ msgid "" "Serhiy Storchaka in :gh:`113626`.)" msgstr "" -#: ../../whatsnew/3.13.rst:983 +#: ../../whatsnew/3.13.rst:999 msgid "math" msgstr "math" -#: ../../whatsnew/3.13.rst:985 +#: ../../whatsnew/3.13.rst:1001 msgid "" "The new function :func:`~math.fma` performs fused multiply-add operations. " "This computes ``x * y + z`` with only a single round, and so avoids any " @@ -1510,11 +1529,11 @@ msgid "" "Stinner in :gh:`73468`.)" msgstr "" -#: ../../whatsnew/3.13.rst:995 +#: ../../whatsnew/3.13.rst:1011 msgid "mimetypes" msgstr "mimetypes" -#: ../../whatsnew/3.13.rst:997 +#: ../../whatsnew/3.13.rst:1013 msgid "" "Add the :func:`~mimetypes.guess_file_type` function to guess a MIME type " "from a filesystem path. Using paths with :func:`~mimetypes.guess_type` is " @@ -1522,18 +1541,18 @@ msgid "" "`66543`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1004 +#: ../../whatsnew/3.13.rst:1020 msgid "mmap" msgstr "mmap" -#: ../../whatsnew/3.13.rst:1006 +#: ../../whatsnew/3.13.rst:1022 msgid "" ":class:`~mmap.mmap` is now protected from crashing on Windows when the " "mapped memory is inaccessible due to file system errors or access " "violations. (Contributed by Jannis Weigend in :gh:`118209`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1010 +#: ../../whatsnew/3.13.rst:1026 msgid "" ":class:`~mmap.mmap` has a new :meth:`~mmap.mmap.seekable` method that can be " "used when a seekable file-like object is required. The :meth:`~mmap.mmap." @@ -1541,7 +1560,7 @@ msgid "" "Na and Sylvie Liberman in :gh:`111835`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1015 +#: ../../whatsnew/3.13.rst:1031 msgid "" "The new UNIX-only *trackfd* parameter for :class:`~mmap.mmap` controls file " "descriptor duplication; if false, the file descriptor specified by *fileno* " @@ -1549,22 +1568,22 @@ msgid "" "gh:`78502`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1022 +#: ../../whatsnew/3.13.rst:1038 msgid "multiprocessing" msgstr "multiprocessing" -#: ../../whatsnew/3.13.rst:1030 +#: ../../whatsnew/3.13.rst:1046 msgid "os" msgstr "os" -#: ../../whatsnew/3.13.rst:1032 +#: ../../whatsnew/3.13.rst:1048 msgid "" "Add :func:`~os.process_cpu_count` function to get the number of logical CPU " "cores usable by the calling thread of the current process. (Contributed by " "Victor Stinner in :gh:`109649`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1036 +#: ../../whatsnew/3.13.rst:1052 msgid "" ":func:`~os.cpu_count` and :func:`~os.process_cpu_count` can be overridden " "through the new environment variable :envvar:`PYTHON_CPU_COUNT` or the new " @@ -1574,7 +1593,7 @@ msgid "" "Na in :gh:`109595`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1044 +#: ../../whatsnew/3.13.rst:1060 msgid "" "Add a :ref:`low level interface ` to Linux's :manpage:`timer " "file descriptors ` via :func:`~os.timerfd_create`, :func:" @@ -1585,7 +1604,7 @@ msgid "" "in :gh:`108277`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1053 +#: ../../whatsnew/3.13.rst:1069 msgid "" ":func:`~os.lchmod` and the *follow_symlinks* argument of :func:`~os.chmod` " "are both now available on Windows. Note that the default value of " @@ -1593,14 +1612,14 @@ msgid "" "by Serhiy Storchaka in :gh:`59616`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1059 +#: ../../whatsnew/3.13.rst:1075 msgid "" ":func:`~os.fchmod` and support for file descriptors in :func:`~os.chmod` are " "both now available on Windows. (Contributed by Serhiy Storchaka in :gh:" "`113191`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1063 +#: ../../whatsnew/3.13.rst:1079 msgid "" "On Windows, :func:`~os.mkdir` and :func:`~os.makedirs` now support passing a " "*mode* value of ``0o700`` to apply access control to the new directory. This " @@ -1609,14 +1628,14 @@ msgid "" "Steve Dower in :gh:`118486`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1070 +#: ../../whatsnew/3.13.rst:1086 msgid "" ":func:`~os.posix_spawn` now accepts ``None`` for the *env* argument, which " "makes the newly spawned process use the current process environment. " "(Contributed by Jakub Kulik in :gh:`113119`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1074 +#: ../../whatsnew/3.13.rst:1090 msgid "" ":func:`~os.posix_spawn` can now use the :const:`~os.POSIX_SPAWN_CLOSEFROM` " "attribute in the *file_actions* parameter on platforms that support :c:func:" @@ -1624,76 +1643,76 @@ msgid "" "gh:`113117`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1081 +#: ../../whatsnew/3.13.rst:1097 ../../whatsnew/3.13.rst:2837 msgid "os.path" msgstr "os.path" -#: ../../whatsnew/3.13.rst:1083 +#: ../../whatsnew/3.13.rst:1099 msgid "" "Add :func:`~os.path.isreserved` to check if a path is reserved on the " "current system. This function is only available on Windows. (Contributed by " "Barney Gale in :gh:`88569`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1088 +#: ../../whatsnew/3.13.rst:1104 msgid "" "On Windows, :func:`~os.path.isabs` no longer considers paths starting with " "exactly one slash (``\\`` or ``/``) to be absolute. (Contributed by Barney " "Gale and Jon Foster in :gh:`44626`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1092 +#: ../../whatsnew/3.13.rst:1108 msgid "" ":func:`~os.path.realpath` now resolves MS-DOS style file names even if the " "file is not accessible. (Contributed by Moonsik Park in :gh:`82367`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1098 ../../whatsnew/3.13.rst:1729 +#: ../../whatsnew/3.13.rst:1114 ../../whatsnew/3.13.rst:1745 msgid "pathlib" msgstr "pathlib" -#: ../../whatsnew/3.13.rst:1100 +#: ../../whatsnew/3.13.rst:1116 msgid "" "Add :exc:`~pathlib.UnsupportedOperation`, which is raised instead of :exc:" "`NotImplementedError` when a path operation isn't supported. (Contributed by " "Barney Gale in :gh:`89812`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1104 +#: ../../whatsnew/3.13.rst:1120 msgid "" "Add a new constructor for creating :class:`~pathlib.Path` objects from " "'file' URIs (``file:///``), :meth:`.Path.from_uri`. (Contributed by Barney " "Gale in :gh:`107465`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1108 +#: ../../whatsnew/3.13.rst:1124 msgid "" "Add :meth:`.PurePath.full_match` for matching paths with shell-style " "wildcards, including the recursive wildcard \"``**``\". (Contributed by " "Barney Gale in :gh:`73435`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1112 +#: ../../whatsnew/3.13.rst:1128 msgid "" "Add the :attr:`.PurePath.parser` class attribute to store the implementation " "of :mod:`os.path` used for low-level path parsing and joining. This will be " "either :mod:`!posixpath` or :mod:`!ntpath`." msgstr "" -#: ../../whatsnew/3.13.rst:1117 +#: ../../whatsnew/3.13.rst:1133 msgid "" "Add *recurse_symlinks* keyword-only argument to :meth:`.Path.glob` and :meth:" "`~pathlib.Path.rglob`. (Contributed by Barney Gale in :gh:`77609`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1121 +#: ../../whatsnew/3.13.rst:1137 msgid "" ":meth:`.Path.glob` and :meth:`~pathlib.Path.rglob` now return files and " "directories when given a pattern that ends with \"``**``\". Previously, only " "directories were returned. (Contributed by Barney Gale in :gh:`70303`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1126 +#: ../../whatsnew/3.13.rst:1142 msgid "" "Add the *follow_symlinks* keyword-only argument to :meth:`Path.is_file " "`, :meth:`Path.is_dir `, :meth:`." @@ -1701,11 +1720,11 @@ msgid "" "`105793` and Kamil Turek in :gh:`107962`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1134 +#: ../../whatsnew/3.13.rst:1150 msgid "pdb" msgstr "pdb" -#: ../../whatsnew/3.13.rst:1136 +#: ../../whatsnew/3.13.rst:1152 msgid "" ":func:`breakpoint` and :func:`~pdb.set_trace` now enter the debugger " "immediately rather than on the next line of code to be executed. This change " @@ -1714,20 +1733,20 @@ msgid "" "Gao in :gh:`118579`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1142 +#: ../../whatsnew/3.13.rst:1158 msgid "" "``sys.path[0]`` is no longer replaced by the directory of the script being " "debugged when :attr:`sys.flags.safe_path` is set. (Contributed by Tian Gao " "and Christian Walther in :gh:`111762`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1146 +#: ../../whatsnew/3.13.rst:1162 msgid "" ":mod:`zipapp` is now supported as a debugging target. (Contributed by Tian " "Gao in :gh:`118501`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1149 +#: ../../whatsnew/3.13.rst:1165 msgid "" "Add ability to move between chained exceptions during post-mortem debugging " "in :func:`~pdb.pm` using the new :pdbcmd:`exceptions [exc_number] " @@ -1735,101 +1754,101 @@ msgid "" "`106676`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1154 +#: ../../whatsnew/3.13.rst:1170 msgid "" "Expressions and statements whose prefix is a pdb command are now correctly " "identified and executed. (Contributed by Tian Gao in :gh:`108464`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1160 +#: ../../whatsnew/3.13.rst:1176 msgid "queue" msgstr "queue" -#: ../../whatsnew/3.13.rst:1162 +#: ../../whatsnew/3.13.rst:1178 msgid "" "Add :meth:`Queue.shutdown ` and :exc:`~queue.ShutDown` " "to manage queue termination. (Contributed by Laurie Opperman and Yves Duprat " "in :gh:`104750`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1168 +#: ../../whatsnew/3.13.rst:1184 msgid "random" msgstr "random" -#: ../../whatsnew/3.13.rst:1170 +#: ../../whatsnew/3.13.rst:1186 msgid "" "Add a :ref:`command-line interface `. (Contributed by Hugo van " "Kemenade in :gh:`118131`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1175 ../../whatsnew/3.13.rst:1737 +#: ../../whatsnew/3.13.rst:1191 ../../whatsnew/3.13.rst:1753 msgid "re" msgstr "re" -#: ../../whatsnew/3.13.rst:1177 +#: ../../whatsnew/3.13.rst:1193 msgid "" "Rename :exc:`!re.error` to :exc:`~re.PatternError` for improved clarity. :" "exc:`!re.error` is kept for backward compatibility." msgstr "" -#: ../../whatsnew/3.13.rst:1182 +#: ../../whatsnew/3.13.rst:1198 msgid "shutil" msgstr "shutil" -#: ../../whatsnew/3.13.rst:1184 +#: ../../whatsnew/3.13.rst:1200 msgid "" "Support the *dir_fd* and *follow_symlinks* keyword arguments in :func:" "`~shutil.chown`. (Contributed by Berker Peksag and Tahia K in :gh:`62308`)" msgstr "" -#: ../../whatsnew/3.13.rst:1190 +#: ../../whatsnew/3.13.rst:1206 msgid "site" msgstr "site" -#: ../../whatsnew/3.13.rst:1192 +#: ../../whatsnew/3.13.rst:1208 msgid "" ":file:`.pth` files are now decoded using UTF-8 first, and then with the :" "term:`locale encoding` if UTF-8 decoding fails. (Contributed by Inada Naoki " "in :gh:`117802`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1198 +#: ../../whatsnew/3.13.rst:1214 msgid "sqlite3" msgstr "sqlite3" -#: ../../whatsnew/3.13.rst:1200 +#: ../../whatsnew/3.13.rst:1216 msgid "" "A :exc:`ResourceWarning` is now emitted if a :class:`~sqlite3.Connection` " "object is not :meth:`closed ` explicitly. " "(Contributed by Erlend E. Aasland in :gh:`105539`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1204 +#: ../../whatsnew/3.13.rst:1220 msgid "" "Add the *filter* keyword-only parameter to :meth:`.Connection.iterdump` for " "filtering database objects to dump. (Contributed by Mariusz Felisiak in :gh:" "`91602`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1210 +#: ../../whatsnew/3.13.rst:1226 msgid "ssl" msgstr "ssl" -#: ../../whatsnew/3.13.rst:1212 +#: ../../whatsnew/3.13.rst:1228 msgid "" "The :func:`~ssl.create_default_context` API now includes :data:`~ssl." "VERIFY_X509_PARTIAL_CHAIN` and :data:`~ssl.VERIFY_X509_STRICT` in its " "default flags." msgstr "" -#: ../../whatsnew/3.13.rst:1218 +#: ../../whatsnew/3.13.rst:1234 msgid "" ":data:`~ssl.VERIFY_X509_STRICT` may reject pre-:rfc:`5280` or malformed " "certificates that the underlying OpenSSL implementation might otherwise " "accept. Whilst disabling this is not recommended, you can do so using:" msgstr "" -#: ../../whatsnew/3.13.rst:1223 +#: ../../whatsnew/3.13.rst:1239 msgid "" "import ssl\n" "\n" @@ -1841,15 +1860,15 @@ msgstr "" "ctx = ssl.create_default_context()\n" "ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT" -#: ../../whatsnew/3.13.rst:1230 +#: ../../whatsnew/3.13.rst:1246 msgid "(Contributed by William Woodruff in :gh:`112389`.)" msgstr "(由 William Woodruff 在 :gh:`112389` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1234 +#: ../../whatsnew/3.13.rst:1250 msgid "statistics" msgstr "statistics" -#: ../../whatsnew/3.13.rst:1236 +#: ../../whatsnew/3.13.rst:1252 msgid "" "Add :func:`~statistics.kde` for kernel density estimation. This makes it " "possible to estimate a continuous probability density function from a fixed " @@ -1857,24 +1876,24 @@ msgid "" "`115863`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1241 +#: ../../whatsnew/3.13.rst:1257 msgid "" "Add :func:`~statistics.kde_random` for sampling from an estimated " "probability density function created by :func:`~statistics.kde`. " "(Contributed by Raymond Hettinger in :gh:`115863`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1249 +#: ../../whatsnew/3.13.rst:1265 msgid "subprocess" msgstr "subprocess" -#: ../../whatsnew/3.13.rst:1251 +#: ../../whatsnew/3.13.rst:1267 msgid "" "The :mod:`subprocess` module now uses the :func:`~os.posix_spawn` function " "in more situations." msgstr "" -#: ../../whatsnew/3.13.rst:1254 +#: ../../whatsnew/3.13.rst:1270 msgid "" "Notably, when *close_fds* is ``True`` (the default), :func:`~os.posix_spawn` " "will be used when the C library provides :c:func:`!" @@ -1883,7 +1902,7 @@ msgid "" "existing Linux :c:func:`!vfork` based code." msgstr "" -#: ../../whatsnew/3.13.rst:1261 +#: ../../whatsnew/3.13.rst:1277 msgid "" "A private control knob :attr:`!subprocess._USE_POSIX_SPAWN` can be set to " "``False`` if you need to force :mod:`subprocess` to never use :func:`~os." @@ -1893,22 +1912,22 @@ msgid "" "`113117`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1271 ../../whatsnew/3.13.rst:2811 +#: ../../whatsnew/3.13.rst:1287 ../../whatsnew/3.13.rst:2827 msgid "sys" msgstr "sys" -#: ../../whatsnew/3.13.rst:1273 +#: ../../whatsnew/3.13.rst:1289 msgid "" "Add the :func:`~sys._is_interned` function to test if a string was interned. " "This function is not guaranteed to exist in all implementations of Python. " "(Contributed by Serhiy Storchaka in :gh:`78573`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1279 +#: ../../whatsnew/3.13.rst:1295 msgid "tempfile" msgstr "tempfile" -#: ../../whatsnew/3.13.rst:1281 +#: ../../whatsnew/3.13.rst:1297 msgid "" "On Windows, the default mode ``0o700`` used by :func:`tempfile.mkdtemp` now " "limits access to the new directory due to changes to :func:`os.mkdir`. This " @@ -1916,11 +1935,11 @@ msgid "" "`118486`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1288 +#: ../../whatsnew/3.13.rst:1304 msgid "time" msgstr "time" -#: ../../whatsnew/3.13.rst:1290 +#: ../../whatsnew/3.13.rst:1306 msgid "" "On Windows, :func:`~time.monotonic` now uses the " "``QueryPerformanceCounter()`` clock for a resolution of 1 microsecond, " @@ -1928,7 +1947,7 @@ msgid "" "milliseconds. (Contributed by Victor Stinner in :gh:`88494`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1296 +#: ../../whatsnew/3.13.rst:1312 msgid "" "On Windows, :func:`~time.time` now uses the " "``GetSystemTimePreciseAsFileTime()`` clock for a resolution of 1 " @@ -1937,11 +1956,11 @@ msgid "" "`63207`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1304 +#: ../../whatsnew/3.13.rst:1320 msgid "tkinter" msgstr "tkinter" -#: ../../whatsnew/3.13.rst:1306 +#: ../../whatsnew/3.13.rst:1322 msgid "" "Add :mod:`tkinter` widget methods: :meth:`!tk_busy_hold`, :meth:`!" "tk_busy_configure`, :meth:`!tk_busy_cget`, :meth:`!tk_busy_forget`, :meth:`!" @@ -1949,7 +1968,7 @@ msgid "" "klappnase and Serhiy Storchaka in :gh:`72684`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1312 +#: ../../whatsnew/3.13.rst:1328 msgid "" "The :mod:`tkinter` widget method :meth:`!wm_attributes` now accepts the " "attribute name without the minus prefix to get window attributes, for " @@ -1958,14 +1977,14 @@ msgid "" "wm_attributes(alpha=0.5)``. (Contributed by Serhiy Storchaka in :gh:`43457`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1319 +#: ../../whatsnew/3.13.rst:1335 msgid "" ":meth:`!wm_attributes` can now return attributes as a :class:`dict`, by " "using the new optional keyword-only parameter *return_python_dict*. " "(Contributed by Serhiy Storchaka in :gh:`43457`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1323 +#: ../../whatsnew/3.13.rst:1339 msgid "" ":meth:`!Text.count` can now return a simple :class:`int` when the new " "optional keyword-only parameter *return_ints* is used. Otherwise, the single " @@ -1973,27 +1992,27 @@ msgid "" "in :gh:`97928`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1328 +#: ../../whatsnew/3.13.rst:1344 msgid "" "Support the \"vsapi\" element type in the :meth:`~tkinter.ttk.Style." "element_create` method of :class:`tkinter.ttk.Style`. (Contributed by Serhiy " "Storchaka in :gh:`68166`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1333 +#: ../../whatsnew/3.13.rst:1349 msgid "" "Add the :meth:`!after_info` method for Tkinter widgets. (Contributed by " "Cheryl Sabella in :gh:`77020`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1336 +#: ../../whatsnew/3.13.rst:1352 msgid "" "Add a new :meth:`!copy_replace` method to :class:`!PhotoImage` to copy a " "region from one image to another, possibly with pixel zooming, subsampling, " "or both. (Contributed by Serhiy Storchaka in :gh:`118225`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1341 +#: ../../whatsnew/3.13.rst:1357 msgid "" "Add *from_coords* parameter to the :class:`!PhotoImage` methods :meth:`!" "copy`, :meth:`!zoom` and :meth:`!subsample`. Add *zoom* and *subsample* " @@ -2001,7 +2020,7 @@ msgid "" "Serhiy Storchaka in :gh:`118225`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1347 +#: ../../whatsnew/3.13.rst:1363 msgid "" "Add the :class:`!PhotoImage` methods :meth:`!read` to read an image from a " "file and :meth:`!data` to get the image data. Add *background* and " @@ -2009,11 +2028,11 @@ msgid "" "Storchaka in :gh:`118271`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1355 +#: ../../whatsnew/3.13.rst:1371 msgid "traceback" msgstr "traceback" -#: ../../whatsnew/3.13.rst:1357 +#: ../../whatsnew/3.13.rst:1373 msgid "" "Add the :attr:`~traceback.TracebackException.exc_type_str` attribute to :" "class:`~traceback.TracebackException`, which holds a string display of the " @@ -2023,7 +2042,7 @@ msgid "" "(Contributed by Irit Katriel in :gh:`112332`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1366 +#: ../../whatsnew/3.13.rst:1382 msgid "" "Add a new *show_group* keyword-only parameter to :meth:`.TracebackException." "format_exception_only` to (recursively) format the nested exceptions of a :" @@ -2031,11 +2050,11 @@ msgid "" "`105292`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1373 +#: ../../whatsnew/3.13.rst:1389 msgid "types" msgstr "types" -#: ../../whatsnew/3.13.rst:1375 +#: ../../whatsnew/3.13.rst:1391 msgid "" ":class:`~types.SimpleNamespace` can now take a single positional argument to " "initialise the namespace's arguments. This argument must either be a mapping " @@ -2043,63 +2062,63 @@ msgid "" "`108191`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1382 ../../whatsnew/3.13.rst:1762 +#: ../../whatsnew/3.13.rst:1398 ../../whatsnew/3.13.rst:1778 msgid "typing" msgstr "typing" -#: ../../whatsnew/3.13.rst:1384 +#: ../../whatsnew/3.13.rst:1400 msgid "" ":pep:`705`: Add :data:`~typing.ReadOnly`, a special typing construct to mark " "a :class:`~typing.TypedDict` item as read-only for type checkers." msgstr "" -#: ../../whatsnew/3.13.rst:1387 +#: ../../whatsnew/3.13.rst:1403 msgid "" ":pep:`742`: Add :data:`~typing.TypeIs`, a typing construct that can be used " "to instruct a type checker how to narrow a type." msgstr "" -#: ../../whatsnew/3.13.rst:1390 +#: ../../whatsnew/3.13.rst:1406 msgid "" "Add :data:`~typing.NoDefault`, a sentinel object used to represent the " "defaults of some parameters in the :mod:`typing` module. (Contributed by " "Jelle Zijlstra in :gh:`116126`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1394 +#: ../../whatsnew/3.13.rst:1410 msgid "" "Add :func:`~typing.get_protocol_members` to return the set of members " "defining a :class:`typing.Protocol`. (Contributed by Jelle Zijlstra in :gh:" "`104873`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1398 +#: ../../whatsnew/3.13.rst:1414 msgid "" "Add :func:`~typing.is_protocol` to check whether a class is a :class:" "`~typing.Protocol`. (Contributed by Jelle Zijlstra in :gh:`104873`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1402 +#: ../../whatsnew/3.13.rst:1418 msgid "" ":data:`~typing.ClassVar` can now be nested in :data:`~typing.Final`, and " "vice versa. (Contributed by Mehdi Drissi in :gh:`89547`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1408 +#: ../../whatsnew/3.13.rst:1424 msgid "unicodedata" msgstr "unicodedata" -#: ../../whatsnew/3.13.rst:1410 +#: ../../whatsnew/3.13.rst:1426 msgid "" "Update the Unicode database to `version 15.1.0`__. (Contributed by James " "Gerity in :gh:`109559`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1417 +#: ../../whatsnew/3.13.rst:1433 msgid "venv" msgstr "venv" -#: ../../whatsnew/3.13.rst:1419 +#: ../../whatsnew/3.13.rst:1435 msgid "" "Add support for creating source control management (SCM) ignore files in a " "virtual environment's directory. By default, Git is supported. This is " @@ -2109,11 +2128,11 @@ msgid "" "Cannon in :gh:`108125`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1430 +#: ../../whatsnew/3.13.rst:1446 msgid "warnings" msgstr "warnings" -#: ../../whatsnew/3.13.rst:1432 +#: ../../whatsnew/3.13.rst:1448 msgid "" ":pep:`702`: The new :func:`warnings.deprecated` decorator provides a way to " "communicate deprecations to a :term:`static type checker` and to warn on " @@ -2122,62 +2141,62 @@ msgid "" "(Contributed by Jelle Zijlstra in :gh:`104003`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1441 +#: ../../whatsnew/3.13.rst:1457 msgid "xml" msgstr "xml" -#: ../../whatsnew/3.13.rst:1443 +#: ../../whatsnew/3.13.rst:1459 msgid "" "Allow controlling Expat >=2.6.0 reparse deferral (:cve:`2023-52425`) by " "adding five new methods:" msgstr "" -#: ../../whatsnew/3.13.rst:1446 +#: ../../whatsnew/3.13.rst:1462 msgid ":meth:`xml.etree.ElementTree.XMLParser.flush`" msgstr ":meth:`xml.etree.ElementTree.XMLParser.flush`" -#: ../../whatsnew/3.13.rst:1447 +#: ../../whatsnew/3.13.rst:1463 msgid ":meth:`xml.etree.ElementTree.XMLPullParser.flush`" msgstr ":meth:`xml.etree.ElementTree.XMLPullParser.flush`" -#: ../../whatsnew/3.13.rst:1448 +#: ../../whatsnew/3.13.rst:1464 msgid ":meth:`xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`" msgstr ":meth:`xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`" -#: ../../whatsnew/3.13.rst:1449 +#: ../../whatsnew/3.13.rst:1465 msgid ":meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`" msgstr ":meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`" -#: ../../whatsnew/3.13.rst:1450 +#: ../../whatsnew/3.13.rst:1466 msgid ":meth:`!xml.sax.expatreader.ExpatParser.flush`" msgstr ":meth:`!xml.sax.expatreader.ExpatParser.flush`" -#: ../../whatsnew/3.13.rst:1452 +#: ../../whatsnew/3.13.rst:1468 msgid "(Contributed by Sebastian Pipping in :gh:`115623`.)" msgstr "(由 Sebastian Pipping 在 :gh:`115623` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1454 +#: ../../whatsnew/3.13.rst:1470 msgid "" "Add the :meth:`!close` method for the iterator returned by :func:`~xml.etree." "ElementTree.iterparse` for explicit cleanup. (Contributed by Serhiy " "Storchaka in :gh:`69893`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1460 +#: ../../whatsnew/3.13.rst:1476 msgid "zipimport" msgstr "zipimport" -#: ../../whatsnew/3.13.rst:1462 +#: ../../whatsnew/3.13.rst:1478 msgid "" "Add support for ZIP64_ format files. Everybody loves huge data, right? " "(Contributed by Tim Hatch in :gh:`94146`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1470 +#: ../../whatsnew/3.13.rst:1486 msgid "Optimizations" msgstr "最佳化" -#: ../../whatsnew/3.13.rst:1472 +#: ../../whatsnew/3.13.rst:1488 msgid "" "Several standard library modules have had their import times significantly " "improved. For example, the import time of the :mod:`typing` module has been " @@ -2188,13 +2207,13 @@ msgid "" "Turner, Daniel Hollas, and others in :gh:`109653`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1483 +#: ../../whatsnew/3.13.rst:1499 msgid "" ":func:`textwrap.indent` is now around 30% faster than before for large " "input. (Contributed by Inada Naoki in :gh:`107369`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1486 +#: ../../whatsnew/3.13.rst:1502 msgid "" "The :mod:`subprocess` module now uses the :func:`~os.posix_spawn` function " "in more situations, including when *close_fds* is ``True`` (the default) on " @@ -2204,15 +2223,15 @@ msgid "" "Kulik in :gh:`113117`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1496 +#: ../../whatsnew/3.13.rst:1512 msgid "Removed Modules And APIs" msgstr "被移除的模組和 API" -#: ../../whatsnew/3.13.rst:1502 +#: ../../whatsnew/3.13.rst:1518 msgid "PEP 594: Remove \"dead batteries\" from the standard library" msgstr "PEP 594:從標準函式庫中移除「用完的電池」" -#: ../../whatsnew/3.13.rst:1504 +#: ../../whatsnew/3.13.rst:1520 msgid "" ":pep:`594` proposed removing 19 modules from the standard library, " "colloquially referred to as 'dead batteries' due to their historic, " @@ -2223,38 +2242,38 @@ msgstr "" "池 (dead batteries)」的 19 個模組。以下所有模組在 Python 3.11 中已被棄用,現" "在已被移除:" -#: ../../whatsnew/3.13.rst:1510 +#: ../../whatsnew/3.13.rst:1526 msgid ":mod:`!aifc`" msgstr ":mod:`!aifc`" -#: ../../whatsnew/3.13.rst:1512 +#: ../../whatsnew/3.13.rst:1528 msgid "" ":pypi:`standard-aifc`: Use the redistribution of ``aifc`` library from PyPI." msgstr ":pypi:`standard-aifc`:PyPI 上的 ``aifc`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1515 +#: ../../whatsnew/3.13.rst:1531 msgid ":mod:`!audioop`" msgstr ":mod:`!audioop`" -#: ../../whatsnew/3.13.rst:1517 +#: ../../whatsnew/3.13.rst:1533 msgid ":pypi:`audioop-lts`: Use ``audioop-lts`` library from PyPI." msgstr ":pypi:`audioop-lts`:PyPI 上的 ``audioop-lts`` 函式庫。" -#: ../../whatsnew/3.13.rst:1520 +#: ../../whatsnew/3.13.rst:1536 msgid ":mod:`!chunk`" msgstr ":mod:`!chunk`" -#: ../../whatsnew/3.13.rst:1522 +#: ../../whatsnew/3.13.rst:1538 msgid "" ":pypi:`standard-chunk`: Use the redistribution of ``chunk`` library from " "PyPI." msgstr ":pypi:`standard-chunk`:PyPI 上的 ``chunk`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1525 +#: ../../whatsnew/3.13.rst:1541 msgid ":mod:`!cgi` and :mod:`!cgitb`" msgstr ":mod:`!cgi` 和 :mod:`!cgitb`" -#: ../../whatsnew/3.13.rst:1527 +#: ../../whatsnew/3.13.rst:1543 msgid "" ":class:`!cgi.FieldStorage` can typically be replaced with :func:`urllib." "parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and the :mod:`email." @@ -2265,7 +2284,7 @@ msgstr "" "`urllib.parse.parse_qsl` 取代,而在於 ``POST`` 和 ``PUT`` 請求中可以被 :mod:" "`email.message` 模組或 :pypi:`multipart` 函式庫取代。" -#: ../../whatsnew/3.13.rst:1532 +#: ../../whatsnew/3.13.rst:1548 msgid "" ":func:`!cgi.parse` can be replaced by calling :func:`urllib.parse.parse_qs` " "directly on the desired query string, unless the input is ``multipart/form-" @@ -2276,14 +2295,14 @@ msgstr "" "parse_qs` 來取代,除非輸入為 ``multipart/form-data``,而這種情況則應該如下所" "述地將 :func:`!cgi.parse_multipart` 給替換掉。" -#: ../../whatsnew/3.13.rst:1537 +#: ../../whatsnew/3.13.rst:1553 msgid "" ":func:`!cgi.parse_header` can be replaced with the functionality in the :mod:" "`email` package, which implements the same MIME RFCs. For example, with :" "class:`email.message.EmailMessage`:" msgstr "" -#: ../../whatsnew/3.13.rst:1541 +#: ../../whatsnew/3.13.rst:1557 msgid "" "from email.message import EmailMessage\n" "\n" @@ -2297,7 +2316,7 @@ msgstr "" "msg['content-type'] = 'application/json; charset=\"utf8\"'\n" "main, params = msg.get_content_type(), msg['content-type'].params" -#: ../../whatsnew/3.13.rst:1549 +#: ../../whatsnew/3.13.rst:1565 msgid "" ":func:`!cgi.parse_multipart` can be replaced with the functionality in the :" "mod:`email` package, which implements the same MIME RFCs, or with the :pypi:" @@ -2308,7 +2327,7 @@ msgstr "" "的功能取代,或者可以被 :pypi:`multipart` 函式庫取代,例如 :class:`email." "message.EmailMessage` 和 :class:`email.message.Message` 類別。" -#: ../../whatsnew/3.13.rst:1555 +#: ../../whatsnew/3.13.rst:1571 msgid "" ":pypi:`standard-cgi`: and :pypi:`standard-cgitb`: Use the redistribution of " "``cgi`` and ``cgitb`` library from PyPI." @@ -2316,29 +2335,29 @@ msgstr "" ":pypi:`standard-cgi` 和 :pypi:`standard-cgitb`:PyPI 上的 ``cgi`` 和 " "``cgitb`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1558 +#: ../../whatsnew/3.13.rst:1574 msgid "" ":mod:`!crypt` and the private :mod:`!_crypt` extension. The :mod:`hashlib` " "module may be an appropriate replacement when simply hashing a value is " "required. Otherwise, various third-party libraries on PyPI are available:" msgstr "" -#: ../../whatsnew/3.13.rst:1563 +#: ../../whatsnew/3.13.rst:1579 msgid "" ":pypi:`bcrypt`: Modern password hashing for your software and your servers." msgstr ":pypi:`bcrypt`:適用於你的軟體與伺服器的現代密碼雜湊演算法。" -#: ../../whatsnew/3.13.rst:1565 +#: ../../whatsnew/3.13.rst:1581 msgid "" ":pypi:`passlib`: Comprehensive password hashing framework supporting over 30 " "schemes." msgstr ":pypi:`passlib`:支援超過 30 種方案的廣泛密碼雜湊框架。" -#: ../../whatsnew/3.13.rst:1567 +#: ../../whatsnew/3.13.rst:1583 msgid ":pypi:`argon2-cffi`: The secure Argon2 password hashing algorithm." msgstr ":pypi:`argon2-cffi`:安全的 Argon2 密碼雜湊演算法。" -#: ../../whatsnew/3.13.rst:1569 +#: ../../whatsnew/3.13.rst:1585 msgid "" ":pypi:`legacycrypt`: :mod:`ctypes` wrapper to the POSIX crypt library call " "and associated functionality." @@ -2346,7 +2365,7 @@ msgstr "" ":pypi:`legacycrypt`:對 POSIX crypt 函式庫呼叫及相關功能的 :mod:`ctypes` 包" "裝。" -#: ../../whatsnew/3.13.rst:1572 +#: ../../whatsnew/3.13.rst:1588 msgid "" ":pypi:`crypt_r`: Fork of the :mod:`!crypt` module, wrapper to the :manpage:" "`crypt_r(3)` library call and associated functionality." @@ -2354,7 +2373,7 @@ msgstr "" ":pypi:`crypt_r`:對 :mod:`!crypt` 模組的分支 (fork),對 :manpage:" "`crypt_r(3)` 函式庫呼叫及相關功能的包裝。" -#: ../../whatsnew/3.13.rst:1576 +#: ../../whatsnew/3.13.rst:1592 msgid "" ":pypi:`standard-crypt` and :pypi:`deprecated-crypt-alternative`: Use the " "redistribution of ``crypt`` and reimplementation of ``_crypt`` libraries " @@ -2363,7 +2382,7 @@ msgstr "" ":pypi:`standard-crypt` 和 :pypi:`deprecated-crypt-alternative`:PyPI 上的 " "``crypt`` 函式庫重新發布版和 ``_crypt`` 函式庫的重新實作。" -#: ../../whatsnew/3.13.rst:1579 +#: ../../whatsnew/3.13.rst:1595 msgid "" ":mod:`!imghdr`: The :pypi:`filetype`, :pypi:`puremagic`, or :pypi:`python-" "magic` libraries should be used as replacements. For example, the :func:`!" @@ -2374,48 +2393,48 @@ msgstr "" "magic` 函式庫。例如 :func:`!puremagic.what` 函式可以取代 :mod:`!imghdr` 過去" "所支援所有文件格式的 :func:`!imghdr.what` 函式。" -#: ../../whatsnew/3.13.rst:1586 +#: ../../whatsnew/3.13.rst:1602 msgid "" ":pypi:`standard-imghdr`: Use the redistribution of ``imghdr`` library from " "PyPI." msgstr ":pypi:`standard-imghdr`:PyPI 上的 ``imghdr`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1589 +#: ../../whatsnew/3.13.rst:1605 msgid ":mod:`!mailcap`: Use the :mod:`mimetypes` module instead." msgstr ":mod:`!mailcap`:請改用 :mod:`mimetypes` 模組。" -#: ../../whatsnew/3.13.rst:1592 +#: ../../whatsnew/3.13.rst:1608 msgid "" ":pypi:`standard-mailcap`: Use the redistribution of ``mailcap`` library from " "PyPI." msgstr ":pypi:`standard-mailcap`:PyPI 上的 ``mailcap`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1595 +#: ../../whatsnew/3.13.rst:1611 msgid ":mod:`!msilib`" msgstr ":mod:`!msilib`" -#: ../../whatsnew/3.13.rst:1596 +#: ../../whatsnew/3.13.rst:1612 msgid ":mod:`!nis`" msgstr ":mod:`!nis`" -#: ../../whatsnew/3.13.rst:1597 +#: ../../whatsnew/3.13.rst:1613 msgid ":mod:`!nntplib`: Use the :pypi:`pynntp` library from PyPI instead." msgstr ":mod:`!nntplib`:請改用 PyPI 上的 :pypi:`pynntp` 函式庫。" -#: ../../whatsnew/3.13.rst:1600 +#: ../../whatsnew/3.13.rst:1616 msgid "" ":pypi:`standard-nntplib`: Use the redistribution of ``nntplib`` library from " "PyPI." msgstr ":pypi:`standard-nntplib`:PyPI 上的 ``nntplib`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1603 +#: ../../whatsnew/3.13.rst:1619 msgid "" ":mod:`!ossaudiodev`: For audio playback, use the :pypi:`pygame` library from " "PyPI instead." msgstr "" ":mod:`!ossaudiodev`:音訊播放方面,請改用 PyPI 上的 :pypi:`pygame` 函式庫。" -#: ../../whatsnew/3.13.rst:1605 +#: ../../whatsnew/3.13.rst:1621 msgid "" ":mod:`!pipes`: Use the :mod:`subprocess` module instead. Use :func:`shlex." "quote` to replace the undocumented ``pipes.quote`` function." @@ -2423,13 +2442,13 @@ msgstr "" ":mod:`!pipes`:請改用 :mod:`subprocess` 模組。使用 :func:`shlex.quote` 來取代" "未以文件紀錄的 ``pipes.quote`` 函式。" -#: ../../whatsnew/3.13.rst:1610 +#: ../../whatsnew/3.13.rst:1626 msgid "" ":pypi:`standard-pipes`: Use the redistribution of ``pipes`` library from " "PyPI." msgstr ":pypi:`standard-pipes`:PyPI 上的 ``pipes`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1613 +#: ../../whatsnew/3.13.rst:1629 msgid "" ":mod:`!sndhdr`: The :pypi:`filetype`, :pypi:`puremagic`, or :pypi:`python-" "magic` libraries should be used as replacements." @@ -2437,27 +2456,27 @@ msgstr "" ":mod:`!sndhdr`:請改用 :pypi:`filetype`、:pypi:`puremagic` 或 :pypi:`python-" "magic` 函式庫。" -#: ../../whatsnew/3.13.rst:1617 +#: ../../whatsnew/3.13.rst:1633 msgid "" ":pypi:`standard-sndhdr`: Use the redistribution of ``sndhdr`` library from " "PyPI." msgstr ":pypi:`standard-sndhdr`:PyPI 上的 ``sndhdr`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1620 +#: ../../whatsnew/3.13.rst:1636 msgid ":mod:`!spwd`: Use the :pypi:`python-pam` library from PyPI instead." msgstr ":mod:`!spwd`:請改用 PyPI 上的 :pypi:`python-pam` 函式庫。" -#: ../../whatsnew/3.13.rst:1622 +#: ../../whatsnew/3.13.rst:1638 msgid ":mod:`!sunau`" msgstr ":mod:`!sunau`" -#: ../../whatsnew/3.13.rst:1624 +#: ../../whatsnew/3.13.rst:1640 msgid "" ":pypi:`standard-sunau`: Use the redistribution of ``sunau`` library from " "PyPI." msgstr ":pypi:`standard-sunau`:PyPI 上的 ``sunau`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1627 +#: ../../whatsnew/3.13.rst:1643 msgid "" ":mod:`!telnetlib`, Use the :pypi:`telnetlib3` or :pypi:`Exscript` libraries " "from PyPI instead." @@ -2465,33 +2484,33 @@ msgstr "" ":mod:`!telnetlib`:請改用 PyPI 上的 :pypi:`telnetlib3` 或 :pypi:`Exscript` 函" "式庫。" -#: ../../whatsnew/3.13.rst:1630 +#: ../../whatsnew/3.13.rst:1646 msgid "" ":pypi:`standard-telnetlib`: Use the redistribution of ``telnetlib`` library " "from PyPI." msgstr ":pypi:`standard-telnetlib`:PyPI 上的 ``telnetlib`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1633 +#: ../../whatsnew/3.13.rst:1649 msgid "" ":mod:`!uu`: Use the :mod:`base64` module instead, as a modern alternative." msgstr ":mod:`!uu`:請改用 :mod:`base64` 模組來作為當代的替代方案。" -#: ../../whatsnew/3.13.rst:1636 +#: ../../whatsnew/3.13.rst:1652 msgid "" ":pypi:`standard-uu`: Use the redistribution of ``uu`` library from PyPI." msgstr ":pypi:`standard-uu`:PyPI 上的 ``uu`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1639 +#: ../../whatsnew/3.13.rst:1655 msgid ":mod:`!xdrlib`" msgstr ":mod:`!xdrlib`" -#: ../../whatsnew/3.13.rst:1641 +#: ../../whatsnew/3.13.rst:1657 msgid "" ":pypi:`standard-xdrlib`: Use the redistribution of ``xdrlib`` library from " "PyPI." msgstr ":pypi:`standard-xdrlib`:PyPI 上的 ``xdrlib`` 函式庫重新發布版。" -#: ../../whatsnew/3.13.rst:1644 +#: ../../whatsnew/3.13.rst:1660 msgid "" "(Contributed by Victor Stinner and Zachary Ware in :gh:`104773` and :gh:" "`104780`.)" @@ -2499,22 +2518,22 @@ msgstr "" "(由 Victor Stinner 和 Zachary Ware 在 :gh:`104773` 和 :gh:`104780` 中貢" "獻。)" -#: ../../whatsnew/3.13.rst:1648 +#: ../../whatsnew/3.13.rst:1664 msgid "2to3" msgstr "2to3" -#: ../../whatsnew/3.13.rst:1650 +#: ../../whatsnew/3.13.rst:1666 msgid "" "Remove the :program:`2to3` program and the :mod:`!lib2to3` module, " "previously deprecated in Python 3.11. (Contributed by Victor Stinner in :gh:" "`104780`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1656 +#: ../../whatsnew/3.13.rst:1672 msgid "builtins" msgstr "builtins" -#: ../../whatsnew/3.13.rst:1658 +#: ../../whatsnew/3.13.rst:1674 msgid "" "Remove support for chained :class:`classmethod` descriptors (introduced in :" "gh:`63272`). These can no longer be used to wrap other descriptors, such as :" @@ -2524,47 +2543,47 @@ msgid "" "(Contributed by Raymond Hettinger in :gh:`89519`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1667 +#: ../../whatsnew/3.13.rst:1683 msgid "" "Raise a :exc:`RuntimeError` when calling :meth:`frame.clear` on a suspended " "frame (as has always been the case for an executing frame). (Contributed by " "Irit Katriel in :gh:`79932`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1675 +#: ../../whatsnew/3.13.rst:1691 msgid "" "Remove the undocumented :class:`!LegacyInterpolation` class, deprecated in " "the docstring since Python 3.2, and at runtime since Python 3.11. " "(Contributed by Hugo van Kemenade in :gh:`104886`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1682 +#: ../../whatsnew/3.13.rst:1698 msgid "importlib.metadata" msgstr "importlib.metadata" -#: ../../whatsnew/3.13.rst:1684 +#: ../../whatsnew/3.13.rst:1700 msgid "" "Remove deprecated subscript (:meth:`~object.__getitem__`) access for :ref:" "`EntryPoint ` objects. (Contributed by Jason R. Coombs in :gh:" "`113175`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1690 +#: ../../whatsnew/3.13.rst:1706 msgid "locale" msgstr "locale" -#: ../../whatsnew/3.13.rst:1692 +#: ../../whatsnew/3.13.rst:1708 msgid "" "Remove the :func:`!locale.resetlocale` function, deprecated in Python 3.11. " "Use ``locale.setlocale(locale.LC_ALL, \"\")`` instead. (Contributed by " "Victor Stinner in :gh:`104783`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1698 +#: ../../whatsnew/3.13.rst:1714 msgid "opcode" msgstr "opcode" -#: ../../whatsnew/3.13.rst:1700 +#: ../../whatsnew/3.13.rst:1716 msgid "" "Move :attr:`!opcode.ENABLE_SPECIALIZATION` to :attr:`!_opcode." "ENABLE_SPECIALIZATION`. This field was added in 3.12, it was never " @@ -2572,7 +2591,7 @@ msgid "" "Katriel in :gh:`105481`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1705 +#: ../../whatsnew/3.13.rst:1721 msgid "" "Remove :func:`!opcode.is_pseudo`, :attr:`!opcode.MIN_PSEUDO_OPCODE`, and :" "attr:`!opcode.MAX_PSEUDO_OPCODE`, which were added in Python 3.12, but were " @@ -2580,11 +2599,11 @@ msgid "" "be used externally. (Contributed by Irit Katriel in :gh:`105481`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1713 +#: ../../whatsnew/3.13.rst:1729 msgid "optparse" msgstr "optparse" -#: ../../whatsnew/3.13.rst:1715 +#: ../../whatsnew/3.13.rst:1731 msgid "" "This module is no longer considered :term:`soft deprecated`. While :mod:" "`argparse` remains preferred for new projects that aren't using a third " @@ -2597,43 +2616,43 @@ msgid "" "(Contributed by Alyssa Coghlan and Serhiy Storchaka in :gh:`126180`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1731 +#: ../../whatsnew/3.13.rst:1747 msgid "" "Remove the ability to use :class:`~pathlib.Path` objects as context " "managers. This functionality was deprecated and has had no effect since " "Python 3.9. (Contributed by Barney Gale in :gh:`83863`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1739 +#: ../../whatsnew/3.13.rst:1755 msgid "" "Remove the undocumented, deprecated, and broken :func:`!re.template` " "function and :attr:`!re.TEMPLATE` / :attr:`!re.T` flag. (Contributed by " "Serhiy Storchaka and Nikita Sobolev in :gh:`105687`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1745 +#: ../../whatsnew/3.13.rst:1761 msgid "tkinter.tix" msgstr "tkinter.tix" -#: ../../whatsnew/3.13.rst:1747 +#: ../../whatsnew/3.13.rst:1763 msgid "" "Remove the :mod:`!tkinter.tix` module, deprecated in Python 3.6. The third-" "party Tix library which the module wrapped is unmaintained. (Contributed by " "Zachary Ware in :gh:`75552`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1753 +#: ../../whatsnew/3.13.rst:1769 msgid "turtle" msgstr "turtle" -#: ../../whatsnew/3.13.rst:1755 +#: ../../whatsnew/3.13.rst:1771 msgid "" "Remove the :meth:`!RawTurtle.settiltangle` method, deprecated in the " "documentation since Python 3.1 and at runtime since Python 3.11. " "(Contributed by Hugo van Kemenade in :gh:`104876`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1764 +#: ../../whatsnew/3.13.rst:1780 msgid "" "Remove the :mod:`!typing.io` and :mod:`!typing.re` namespaces, deprecated " "since Python 3.8. The items in those namespaces can be imported directly " @@ -2641,66 +2660,66 @@ msgid "" "`92871`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1770 +#: ../../whatsnew/3.13.rst:1786 msgid "" "Remove the keyword-argument method of creating :class:`~typing.TypedDict` " "types, deprecated in Python 3.11. (Contributed by Tomas Roun in :gh:" "`104786`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1776 +#: ../../whatsnew/3.13.rst:1792 msgid "unittest" msgstr "unittest" -#: ../../whatsnew/3.13.rst:1778 +#: ../../whatsnew/3.13.rst:1794 msgid "" "Remove the following :mod:`unittest` functions, deprecated in Python 3.11:" msgstr "移除以下在 Python 3.11 中已被棄用的 :mod:`unittest` 函式:" -#: ../../whatsnew/3.13.rst:1780 +#: ../../whatsnew/3.13.rst:1796 msgid ":func:`!unittest.findTestCases`" msgstr ":func:`!unittest.findTestCases`" -#: ../../whatsnew/3.13.rst:1781 +#: ../../whatsnew/3.13.rst:1797 msgid ":func:`!unittest.makeSuite`" msgstr ":func:`!unittest.makeSuite`" -#: ../../whatsnew/3.13.rst:1782 +#: ../../whatsnew/3.13.rst:1798 msgid ":func:`!unittest.getTestCaseNames`" msgstr ":func:`!unittest.getTestCaseNames`" -#: ../../whatsnew/3.13.rst:1784 +#: ../../whatsnew/3.13.rst:1800 msgid "Use :class:`~unittest.TestLoader` methods instead:" msgstr "" -#: ../../whatsnew/3.13.rst:1786 +#: ../../whatsnew/3.13.rst:1802 msgid ":meth:`~unittest.TestLoader.loadTestsFromModule`" msgstr ":meth:`~unittest.TestLoader.loadTestsFromModule`" -#: ../../whatsnew/3.13.rst:1787 +#: ../../whatsnew/3.13.rst:1803 msgid ":meth:`~unittest.TestLoader.loadTestsFromTestCase`" msgstr ":meth:`~unittest.TestLoader.loadTestsFromTestCase`" -#: ../../whatsnew/3.13.rst:1788 +#: ../../whatsnew/3.13.rst:1804 msgid ":meth:`~unittest.TestLoader.getTestCaseNames`" msgstr ":meth:`~unittest.TestLoader.getTestCaseNames`" -#: ../../whatsnew/3.13.rst:1790 +#: ../../whatsnew/3.13.rst:1806 msgid "(Contributed by Hugo van Kemenade in :gh:`104835`.)" msgstr "(由 Hugo van Kemenade 在 :gh:`104835` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1792 +#: ../../whatsnew/3.13.rst:1808 msgid "" "Remove the untested and undocumented :meth:`!TestProgram.usageExit` method, " "deprecated in Python 3.11. (Contributed by Hugo van Kemenade in :gh:" "`104992`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1798 +#: ../../whatsnew/3.13.rst:1814 msgid "urllib" msgstr "urllib" -#: ../../whatsnew/3.13.rst:1800 +#: ../../whatsnew/3.13.rst:1816 msgid "" "Remove the *cafile*, *capath*, and *cadefault* parameters of the :func:" "`urllib.request.urlopen` function, deprecated in Python 3.6. Use the " @@ -2711,33 +2730,33 @@ msgid "" "Victor Stinner in :gh:`105382`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1811 +#: ../../whatsnew/3.13.rst:1827 msgid "webbrowser" msgstr "webbrowser" -#: ../../whatsnew/3.13.rst:1813 +#: ../../whatsnew/3.13.rst:1829 msgid "" "Remove the untested and undocumented :class:`!MacOSX` class, deprecated in " "Python 3.11. Use the :class:`!MacOSXOSAScript` class (introduced in Python " "3.2) instead. (Contributed by Hugo van Kemenade in :gh:`104804`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1818 +#: ../../whatsnew/3.13.rst:1834 msgid "" "Remove the deprecated :attr:`!MacOSXOSAScript._name` attribute. Use the :" "attr:`MacOSXOSAScript.name ` attribute instead. " "(Contributed by Nikita Sobolev in :gh:`105546`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1825 +#: ../../whatsnew/3.13.rst:1841 msgid "New Deprecations" msgstr "" -#: ../../whatsnew/3.13.rst:1827 +#: ../../whatsnew/3.13.rst:1843 msgid ":ref:`User-defined functions `:" msgstr "" -#: ../../whatsnew/3.13.rst:1829 +#: ../../whatsnew/3.13.rst:1845 msgid "" "Deprecate assignment to a function's :attr:`~function.__code__` attribute, " "where the new code object's type does not match the function's type. The " @@ -2745,12 +2764,12 @@ msgid "" "coroutine. (Contributed by Irit Katriel in :gh:`81137`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1835 +#: ../../whatsnew/3.13.rst:1851 #: ../../deprecations/pending-removal-in-3.16.rst:11 msgid ":mod:`array`:" msgstr ":mod:`array`:" -#: ../../whatsnew/3.13.rst:1837 +#: ../../whatsnew/3.13.rst:1853 msgid "" "Deprecate the ``'u'`` format code (:c:type:`wchar_t`) at runtime. This " "format code has been deprecated in documentation since Python 3.3, and will " @@ -2759,61 +2778,61 @@ msgid "" "`80480`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1844 +#: ../../whatsnew/3.13.rst:1860 #: ../../deprecations/pending-removal-in-3.15.rst:16 msgid ":mod:`ctypes`:" msgstr ":mod:`ctypes`:" -#: ../../whatsnew/3.13.rst:1846 +#: ../../whatsnew/3.13.rst:1862 msgid "" "Deprecate the undocumented :func:`!SetPointerType` function, to be removed " "in Python 3.15. (Contributed by Victor Stinner in :gh:`105733`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1850 +#: ../../whatsnew/3.13.rst:1866 msgid "" ":term:`Soft-deprecate ` the :func:`~ctypes.ARRAY` function " "in favour of ``type * length`` multiplication. (Contributed by Victor " "Stinner in :gh:`105733`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1854 +#: ../../whatsnew/3.13.rst:1870 msgid ":mod:`decimal`:" msgstr ":mod:`decimal`:" -#: ../../whatsnew/3.13.rst:1856 +#: ../../whatsnew/3.13.rst:1872 msgid "" "Deprecate the non-standard and undocumented :class:`~decimal.Decimal` format " "specifier ``'N'``, which is only supported in the :mod:`!decimal` module's C " "implementation. (Contributed by Serhiy Storchaka in :gh:`89902`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1861 +#: ../../whatsnew/3.13.rst:1877 msgid ":mod:`dis`:" msgstr ":mod:`dis`:" -#: ../../whatsnew/3.13.rst:1863 +#: ../../whatsnew/3.13.rst:1879 msgid "" "Deprecate the :attr:`!HAVE_ARGUMENT` separator. Check membership in :data:" "`~dis.hasarg` instead. (Contributed by Irit Katriel in :gh:`109319`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1867 +#: ../../whatsnew/3.13.rst:1883 msgid ":mod:`gettext`:" msgstr ":mod:`gettext`:" -#: ../../whatsnew/3.13.rst:1869 +#: ../../whatsnew/3.13.rst:1885 msgid "" "Deprecate non-integer numbers as arguments to functions and methods that " "consider plural forms in the :mod:`!gettext` module, even if no translation " "was found. (Contributed by Serhiy Storchaka in :gh:`88434`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1874 +#: ../../whatsnew/3.13.rst:1890 msgid ":mod:`glob`:" msgstr ":mod:`glob`:" -#: ../../whatsnew/3.13.rst:1876 +#: ../../whatsnew/3.13.rst:1892 msgid "" "Deprecate the undocumented :func:`!glob0` and :func:`!glob1` functions. Use :" "func:`~glob.glob` and pass a :term:`path-like object` specifying the root " @@ -2821,12 +2840,12 @@ msgid "" "in :gh:`117337`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1881 +#: ../../whatsnew/3.13.rst:1897 #: ../../deprecations/pending-removal-in-3.15.rst:21 msgid ":mod:`http.server`:" msgstr ":mod:`http.server`:" -#: ../../whatsnew/3.13.rst:1883 +#: ../../whatsnew/3.13.rst:1899 msgid "" "Deprecate :class:`~http.server.CGIHTTPRequestHandler`, to be removed in " "Python 3.15. Process-based CGI HTTP servers have been out of favor for a " @@ -2835,29 +2854,29 @@ msgid "" "by Gregory P. Smith in :gh:`109096`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1890 +#: ../../whatsnew/3.13.rst:1906 msgid "" "Deprecate the :option:`!--cgi` flag to the :program:`python -m http.server` " "command-line interface, to be removed in Python 3.15. (Contributed by " "Gregory P. Smith in :gh:`109096`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1895 +#: ../../whatsnew/3.13.rst:1911 msgid ":mod:`mimetypes`:" msgstr ":mod:`mimetypes`:" -#: ../../whatsnew/3.13.rst:1897 +#: ../../whatsnew/3.13.rst:1913 msgid "" ":term:`Soft-deprecate ` file path arguments to :func:" "`~mimetypes.guess_type`, use :func:`~mimetypes.guess_file_type` instead. " "(Contributed by Serhiy Storchaka in :gh:`66543`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1902 +#: ../../whatsnew/3.13.rst:1918 msgid ":mod:`re`:" msgstr ":mod:`re`:" -#: ../../whatsnew/3.13.rst:1904 +#: ../../whatsnew/3.13.rst:1920 msgid "" "Deprecate passing the optional *maxsplit*, *count*, or *flags* arguments as " "positional arguments to the module-level :func:`~re.split`, :func:`~re.sub`, " @@ -2866,46 +2885,46 @@ msgid "" "by Serhiy Storchaka in :gh:`56166`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1911 +#: ../../whatsnew/3.13.rst:1927 #: ../../deprecations/pending-removal-in-3.15.rst:46 msgid ":mod:`pathlib`:" msgstr ":mod:`pathlib`:" -#: ../../whatsnew/3.13.rst:1913 +#: ../../whatsnew/3.13.rst:1929 msgid "" "Deprecate :meth:`.PurePath.is_reserved`, to be removed in Python 3.15. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows. (Contributed " "by Barney Gale in :gh:`88569`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1918 +#: ../../whatsnew/3.13.rst:1934 #: ../../deprecations/pending-removal-in-3.15.rst:52 msgid ":mod:`platform`:" msgstr ":mod:`platform`:" -#: ../../whatsnew/3.13.rst:1920 +#: ../../whatsnew/3.13.rst:1936 msgid "" "Deprecate :func:`~platform.java_ver`, to be removed in Python 3.15. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested. (Contributed by Nikita Sobolev in :gh:`116349`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1926 +#: ../../whatsnew/3.13.rst:1942 msgid ":mod:`pydoc`:" msgstr ":mod:`pydoc`:" -#: ../../whatsnew/3.13.rst:1928 +#: ../../whatsnew/3.13.rst:1944 msgid "" "Deprecate the undocumented :func:`!ispackage` function. (Contributed by " "Zackery Spytz in :gh:`64020`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1931 +#: ../../whatsnew/3.13.rst:1947 #: ../../deprecations/pending-removal-in-3.14.rst:91 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../whatsnew/3.13.rst:1933 +#: ../../whatsnew/3.13.rst:1949 msgid "" "Deprecate passing more than one positional argument to the :func:`~sqlite3." "connect` function and the :class:`~sqlite3.Connection` constructor. The " @@ -2913,7 +2932,7 @@ msgid "" "by Erlend E. Aasland in :gh:`107948`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1939 +#: ../../whatsnew/3.13.rst:1955 msgid "" "Deprecate passing name, number of arguments, and the callable as keyword " "arguments for :meth:`.Connection.create_function` and :meth:`.Connection." @@ -2921,7 +2940,7 @@ msgid "" "3.15. (Contributed by Erlend E. Aasland in :gh:`108278`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1945 +#: ../../whatsnew/3.13.rst:1961 msgid "" "Deprecate passing the callback callable by keyword for the :meth:`~sqlite3." "Connection.set_authorizer`, :meth:`~sqlite3.Connection." @@ -2931,46 +2950,46 @@ msgid "" "`108278`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1953 +#: ../../whatsnew/3.13.rst:1969 #: ../../deprecations/pending-removal-in-3.16.rst:47 msgid ":mod:`sys`:" msgstr ":mod:`sys`:" -#: ../../whatsnew/3.13.rst:1955 +#: ../../whatsnew/3.13.rst:1971 msgid "" "Deprecate the :func:`~sys._enablelegacywindowsfsencoding` function, to be " "removed in Python 3.16. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " "environment variable instead. (Contributed by Inada Naoki in :gh:`73427`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1960 +#: ../../whatsnew/3.13.rst:1976 #: ../../deprecations/pending-removal-in-3.16.rst:53 msgid ":mod:`tarfile`:" msgstr ":mod:`tarfile`:" -#: ../../whatsnew/3.13.rst:1962 +#: ../../whatsnew/3.13.rst:1978 msgid "" "Deprecate the undocumented and unused :attr:`!TarFile.tarfile` attribute, to " "be removed in Python 3.16. (Contributed in :gh:`115256`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1966 +#: ../../whatsnew/3.13.rst:1982 msgid ":mod:`traceback`:" msgstr ":mod:`traceback`:" -#: ../../whatsnew/3.13.rst:1968 +#: ../../whatsnew/3.13.rst:1984 msgid "" "Deprecate the :attr:`.TracebackException.exc_type` attribute. Use :attr:`." "TracebackException.exc_type_str` instead. (Contributed by Irit Katriel in :" "gh:`112332`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1972 +#: ../../whatsnew/3.13.rst:1988 #: ../../deprecations/pending-removal-in-3.15.rst:80 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" -#: ../../whatsnew/3.13.rst:1974 +#: ../../whatsnew/3.13.rst:1990 msgid "" "Deprecate the undocumented keyword argument syntax for creating :class:" "`~typing.NamedTuple` classes (e.g. ``Point = NamedTuple(\"Point\", x=int, " @@ -2978,7 +2997,7 @@ msgid "" "functional syntax instead. (Contributed by Alex Waygood in :gh:`105566`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1981 +#: ../../whatsnew/3.13.rst:1997 msgid "" "Deprecate omitting the *fields* parameter when creating a :class:`~typing." "NamedTuple` or :class:`typing.TypedDict` class, and deprecate passing " @@ -2990,15 +3009,18 @@ msgid "" "Alex Waygood in :gh:`105566` and :gh:`105570`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1991 +#: ../../whatsnew/3.13.rst:2007 msgid "" "Deprecate the :func:`typing.no_type_check_decorator` decorator function, to " -"be removed in in Python 3.15. After eight years in the :mod:`typing` module, " -"it has yet to be supported by any major type checker. (Contributed by Alex " +"be removed in Python 3.15. After eight years in the :mod:`typing` module, it " +"has yet to be supported by any major type checker. (Contributed by Alex " "Waygood in :gh:`106309`.)" msgstr "" +"棄用 :func:`typing.no_type_check_decorator` 裝飾器函式。" +"將在 Python 3.15 中移除。在 :mod:`typing` 模組中經過八年後," +"它至今仍未被任何主要的型別檢查器所支援。(由 Alex Waygood 在 :gh:`106309` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1997 +#: ../../whatsnew/3.13.rst:2013 msgid "" "Deprecate :data:`typing.AnyStr`. In Python 3.16, it will be removed from " "``typing.__all__``, and a :exc:`DeprecationWarning` will be emitted at " @@ -3007,12 +3029,12 @@ msgid "" "(Contributed by Michael The in :gh:`107116`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2005 -#: ../../deprecations/pending-removal-in-3.15.rst:93 +#: ../../whatsnew/3.13.rst:2021 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../whatsnew/3.13.rst:2007 +#: ../../whatsnew/3.13.rst:2023 msgid "" "Deprecate the :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:" "`~wave.Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :" @@ -3408,6 +3430,20 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:88 msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." +msgstr "" +"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* " +"參數 (``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = " +"TypedDict(\"TD\", None)``) 的做法自 Python 3.13 起已被棄用。請" +"使用 ``class TD(TypedDict): pass`` 或 ``TD = " +"TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#: ../../deprecations/pending-removal-in-3.15.rst: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." @@ -3416,7 +3452,7 @@ msgstr "" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" -#: ../../deprecations/pending-removal-in-3.15.rst:95 +#: ../../deprecations/pending-removal-in-3.15.rst:102 msgid "" "The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." "Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" @@ -3919,11 +3955,11 @@ msgstr "" ":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." "zipimporter.exec_module`。" -#: ../../whatsnew/3.13.rst:2024 +#: ../../whatsnew/3.13.rst:2040 msgid "CPython Bytecode Changes" msgstr "" -#: ../../whatsnew/3.13.rst:2026 +#: ../../whatsnew/3.13.rst:2042 msgid "" "The oparg of :opcode:`YIELD_VALUE` is now ``1`` if the yield is part of a " "yield-from or await, and ``0`` otherwise. The oparg of :opcode:`RESUME` was " @@ -3932,97 +3968,97 @@ msgid "" "`111354`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2034 +#: ../../whatsnew/3.13.rst:2050 msgid "C API Changes" msgstr "C API 變更" -#: ../../whatsnew/3.13.rst:2039 +#: ../../whatsnew/3.13.rst:2055 msgid "" "Add the :ref:`PyMonitoring C API ` for generating :pep:" "`669` monitoring events:" msgstr "" -#: ../../whatsnew/3.13.rst:2042 +#: ../../whatsnew/3.13.rst:2058 msgid ":c:type:`PyMonitoringState`" msgstr ":c:type:`PyMonitoringState`" -#: ../../whatsnew/3.13.rst:2043 +#: ../../whatsnew/3.13.rst:2059 msgid ":c:func:`PyMonitoring_FirePyStartEvent`" msgstr ":c:func:`PyMonitoring_FirePyStartEvent`" -#: ../../whatsnew/3.13.rst:2044 +#: ../../whatsnew/3.13.rst:2060 msgid ":c:func:`PyMonitoring_FirePyResumeEvent`" msgstr ":c:func:`PyMonitoring_FirePyResumeEvent`" -#: ../../whatsnew/3.13.rst:2045 +#: ../../whatsnew/3.13.rst:2061 msgid ":c:func:`PyMonitoring_FirePyReturnEvent`" msgstr ":c:func:`PyMonitoring_FirePyReturnEvent`" -#: ../../whatsnew/3.13.rst:2046 +#: ../../whatsnew/3.13.rst:2062 msgid ":c:func:`PyMonitoring_FirePyYieldEvent`" msgstr ":c:func:`PyMonitoring_FirePyYieldEvent`" -#: ../../whatsnew/3.13.rst:2047 +#: ../../whatsnew/3.13.rst:2063 msgid ":c:func:`PyMonitoring_FireCallEvent`" msgstr ":c:func:`PyMonitoring_FireCallEvent`" -#: ../../whatsnew/3.13.rst:2048 +#: ../../whatsnew/3.13.rst:2064 msgid ":c:func:`PyMonitoring_FireLineEvent`" msgstr ":c:func:`PyMonitoring_FireLineEvent`" -#: ../../whatsnew/3.13.rst:2049 +#: ../../whatsnew/3.13.rst:2065 msgid ":c:func:`PyMonitoring_FireJumpEvent`" msgstr ":c:func:`PyMonitoring_FireJumpEvent`" -#: ../../whatsnew/3.13.rst:2050 +#: ../../whatsnew/3.13.rst:2066 msgid ":c:func:`PyMonitoring_FireBranchEvent`" msgstr ":c:func:`PyMonitoring_FireBranchEvent`" -#: ../../whatsnew/3.13.rst:2051 +#: ../../whatsnew/3.13.rst:2067 msgid ":c:func:`PyMonitoring_FireCReturnEvent`" msgstr ":c:func:`PyMonitoring_FireCReturnEvent`" -#: ../../whatsnew/3.13.rst:2052 +#: ../../whatsnew/3.13.rst:2068 msgid ":c:func:`PyMonitoring_FirePyThrowEvent`" msgstr ":c:func:`PyMonitoring_FirePyThrowEvent`" -#: ../../whatsnew/3.13.rst:2053 +#: ../../whatsnew/3.13.rst:2069 msgid ":c:func:`PyMonitoring_FireRaiseEvent`" msgstr ":c:func:`PyMonitoring_FireRaiseEvent`" -#: ../../whatsnew/3.13.rst:2054 +#: ../../whatsnew/3.13.rst:2070 msgid ":c:func:`PyMonitoring_FireCRaiseEvent`" msgstr ":c:func:`PyMonitoring_FireCRaiseEvent`" -#: ../../whatsnew/3.13.rst:2055 +#: ../../whatsnew/3.13.rst:2071 msgid ":c:func:`PyMonitoring_FireReraiseEvent`" msgstr ":c:func:`PyMonitoring_FireReraiseEvent`" -#: ../../whatsnew/3.13.rst:2056 +#: ../../whatsnew/3.13.rst:2072 msgid ":c:func:`PyMonitoring_FireExceptionHandledEvent`" msgstr ":c:func:`PyMonitoring_FireExceptionHandledEvent`" -#: ../../whatsnew/3.13.rst:2057 +#: ../../whatsnew/3.13.rst:2073 msgid ":c:func:`PyMonitoring_FirePyUnwindEvent`" msgstr ":c:func:`PyMonitoring_FirePyUnwindEvent`" -#: ../../whatsnew/3.13.rst:2058 +#: ../../whatsnew/3.13.rst:2074 msgid ":c:func:`PyMonitoring_FireStopIterationEvent`" msgstr ":c:func:`PyMonitoring_FireStopIterationEvent`" -#: ../../whatsnew/3.13.rst:2059 +#: ../../whatsnew/3.13.rst:2075 msgid ":c:func:`PyMonitoring_EnterScope`" msgstr ":c:func:`PyMonitoring_EnterScope`" -#: ../../whatsnew/3.13.rst:2060 +#: ../../whatsnew/3.13.rst:2076 msgid ":c:func:`PyMonitoring_ExitScope`" msgstr ":c:func:`PyMonitoring_ExitScope`" -#: ../../whatsnew/3.13.rst:2062 +#: ../../whatsnew/3.13.rst:2078 msgid "(Contributed by Irit Katriel in :gh:`111997`)." msgstr "(由 Irit Katriel 在 :gh:`111997` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2064 +#: ../../whatsnew/3.13.rst:2080 msgid "" "Add :c:type:`PyMutex`, a lightweight mutex that occupies a single byte, and " "the new :c:func:`PyMutex_Lock` and :c:func:`PyMutex_Unlock` functions. :c:" @@ -4030,52 +4066,52 @@ msgid "" "operation needs to block. (Contributed by Sam Gross in :gh:`108724`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2070 +#: ../../whatsnew/3.13.rst:2086 msgid "" "Add the :ref:`PyTime C API ` to provide access to system clocks:" msgstr "" -#: ../../whatsnew/3.13.rst:2072 +#: ../../whatsnew/3.13.rst:2088 msgid ":c:type:`PyTime_t`." msgstr ":c:type:`PyTime_t`。" -#: ../../whatsnew/3.13.rst:2073 +#: ../../whatsnew/3.13.rst:2089 msgid ":c:var:`PyTime_MIN` and :c:var:`PyTime_MAX`." msgstr "" -#: ../../whatsnew/3.13.rst:2074 +#: ../../whatsnew/3.13.rst:2090 msgid ":c:func:`PyTime_AsSecondsDouble`." msgstr ":c:func:`PyTime_AsSecondsDouble`。" -#: ../../whatsnew/3.13.rst:2075 +#: ../../whatsnew/3.13.rst:2091 msgid ":c:func:`PyTime_Monotonic`." msgstr ":c:func:`PyTime_Monotonic`。" -#: ../../whatsnew/3.13.rst:2076 +#: ../../whatsnew/3.13.rst:2092 msgid ":c:func:`PyTime_MonotonicRaw`." msgstr ":c:func:`PyTime_MonotonicRaw`。" -#: ../../whatsnew/3.13.rst:2077 +#: ../../whatsnew/3.13.rst:2093 msgid ":c:func:`PyTime_PerfCounter`." msgstr ":c:func:`PyTime_PerfCounter`。" -#: ../../whatsnew/3.13.rst:2078 +#: ../../whatsnew/3.13.rst:2094 msgid ":c:func:`PyTime_PerfCounterRaw`." msgstr ":c:func:`PyTime_PerfCounterRaw`。" -#: ../../whatsnew/3.13.rst:2079 +#: ../../whatsnew/3.13.rst:2095 msgid ":c:func:`PyTime_Time`." msgstr ":c:func:`PyTime_Time`。" -#: ../../whatsnew/3.13.rst:2080 +#: ../../whatsnew/3.13.rst:2096 msgid ":c:func:`PyTime_TimeRaw`." msgstr ":c:func:`PyTime_TimeRaw`。" -#: ../../whatsnew/3.13.rst:2082 +#: ../../whatsnew/3.13.rst:2098 msgid "(Contributed by Victor Stinner and Petr Viktorin in :gh:`110850`.)" msgstr "(由 Victor Stinner 和 Petr Viktorin 在 :gh:`110850` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2084 +#: ../../whatsnew/3.13.rst:2100 msgid "" "Add the :c:func:`PyDict_ContainsString` function with the same behavior as :" "c:func:`PyDict_Contains`, but *key* is specified as a :c:expr:`const char*` " @@ -4083,7 +4119,7 @@ msgid "" "by Victor Stinner in :gh:`108314`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2090 +#: ../../whatsnew/3.13.rst:2106 msgid "" "Add the :c:func:`PyDict_GetItemRef` and :c:func:`PyDict_GetItemStringRef` " "functions, which behave similarly to :c:func:`PyDict_GetItemWithError`, but " @@ -4093,7 +4129,7 @@ msgid "" "`106004`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2098 +#: ../../whatsnew/3.13.rst:2114 msgid "" "Add the :c:func:`PyDict_SetDefaultRef` function, which behaves similarly to :" "c:func:`PyDict_SetDefault`, but returns a :term:`strong reference` instead " @@ -4102,7 +4138,7 @@ msgid "" "dictionary. (Contributed by Sam Gross in :gh:`112066`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2106 +#: ../../whatsnew/3.13.rst:2122 msgid "" "Add the :c:func:`PyDict_Pop` and :c:func:`PyDict_PopString` functions to " "remove a key from a dictionary and optionally return the removed value. This " @@ -4111,7 +4147,7 @@ msgid "" "Victor Stinner in :gh:`111262`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2113 +#: ../../whatsnew/3.13.rst:2129 msgid "" "Add the :c:func:`PyMapping_GetOptionalItem` and :c:func:" "`PyMapping_GetOptionalItemString` functions as alternatives to :c:func:" @@ -4122,7 +4158,7 @@ msgid "" "gh:`106307`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2123 +#: ../../whatsnew/3.13.rst:2139 msgid "" "Add the :c:func:`PyObject_GetOptionalAttr` and :c:func:" "`PyObject_GetOptionalAttrString` functions as alternatives to :c:func:" @@ -4133,37 +4169,37 @@ msgid "" "Serhiy Storchaka in :gh:`106521`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2133 +#: ../../whatsnew/3.13.rst:2149 msgid "" "Add the :c:func:`PyErr_FormatUnraisable` function as an extension to :c:func:" "`PyErr_WriteUnraisable` that allows customizing the warning message. " "(Contributed by Serhiy Storchaka in :gh:`108082`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2138 +#: ../../whatsnew/3.13.rst:2154 msgid "" "Add new functions that return a :term:`strong reference` instead of a :term:" "`borrowed reference` for frame locals, globals, and builtins, as part of :" "ref:`PEP 667 `:" msgstr "" -#: ../../whatsnew/3.13.rst:2142 +#: ../../whatsnew/3.13.rst:2158 msgid ":c:func:`PyEval_GetFrameBuiltins` replaces :c:func:`PyEval_GetBuiltins`" msgstr ":c:func:`PyEval_GetFrameBuiltins` 取代 :c:func:`PyEval_GetBuiltins`" -#: ../../whatsnew/3.13.rst:2143 +#: ../../whatsnew/3.13.rst:2159 msgid ":c:func:`PyEval_GetFrameGlobals` replaces :c:func:`PyEval_GetGlobals`" msgstr ":c:func:`PyEval_GetFrameGlobals` 取代 :c:func:`PyEval_GetGlobals`" -#: ../../whatsnew/3.13.rst:2144 +#: ../../whatsnew/3.13.rst:2160 msgid ":c:func:`PyEval_GetFrameLocals` replaces :c:func:`PyEval_GetLocals`" msgstr ":c:func:`PyEval_GetFrameLocals` 取代 :c:func:`PyEval_GetLocals`" -#: ../../whatsnew/3.13.rst:2146 +#: ../../whatsnew/3.13.rst:2162 msgid "(Contributed by Mark Shannon and Tian Gao in :gh:`74929`.)" msgstr "(由 Mark Shannon 和 Tian Gao 在 :gh:`74929` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2148 +#: ../../whatsnew/3.13.rst:2164 msgid "" "Add the :c:func:`Py_GetConstant` and :c:func:`Py_GetConstantBorrowed` " "functions to get :term:`strong ` or :term:`borrowed " @@ -4172,7 +4208,7 @@ msgid "" "constant zero. (Contributed by Victor Stinner in :gh:`115754`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2155 +#: ../../whatsnew/3.13.rst:2171 msgid "" "Add the :c:func:`PyImport_AddModuleRef` function as a replacement for :c:" "func:`PyImport_AddModule` that returns a :term:`strong reference` instead of " @@ -4180,35 +4216,35 @@ msgid "" "`105922`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2160 +#: ../../whatsnew/3.13.rst:2176 msgid "" "Add the :c:func:`Py_IsFinalizing` function to check whether the main Python " "interpreter is :term:`shutting down `. (Contributed by " "Victor Stinner in :gh:`108014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2165 +#: ../../whatsnew/3.13.rst:2181 msgid "" "Add the :c:func:`PyList_GetItemRef` function as a replacement for :c:func:" "`PyList_GetItem` that returns a :term:`strong reference` instead of a :term:" "`borrowed reference`. (Contributed by Sam Gross in :gh:`114329`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2170 +#: ../../whatsnew/3.13.rst:2186 msgid "" "Add the :c:func:`PyList_Extend` and :c:func:`PyList_Clear` functions, " "mirroring the Python :meth:`!list.extend` and :meth:`!list.clear` methods. " "(Contributed by Victor Stinner in :gh:`111138`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2174 +#: ../../whatsnew/3.13.rst:2190 msgid "" "Add the :c:func:`PyLong_AsInt` function. It behaves similarly to :c:func:" "`PyLong_AsLong`, but stores the result in a C :c:expr:`int` instead of a C :" "c:expr:`long`. (Contributed by Victor Stinner in :gh:`108014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2179 +#: ../../whatsnew/3.13.rst:2195 msgid "" "Add the :c:func:`PyLong_AsNativeBytes`, :c:func:`PyLong_FromNativeBytes`, " "and :c:func:`PyLong_FromUnsignedNativeBytes` functions to simplify " @@ -4216,27 +4252,27 @@ msgid "" "(Contributed by Steve Dower in :gh:`111140`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2185 +#: ../../whatsnew/3.13.rst:2201 msgid "" "Add :c:func:`PyModule_Add` function, which is similar to :c:func:" "`PyModule_AddObjectRef` and :c:func:`PyModule_AddObject`, but always steals " "a reference to the value. (Contributed by Serhiy Storchaka in :gh:`86493`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2190 +#: ../../whatsnew/3.13.rst:2206 msgid "" "Add the :c:func:`PyObject_GenericHash` function that implements the default " "hashing function of a Python object. (Contributed by Serhiy Storchaka in :gh:" "`113024`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2194 +#: ../../whatsnew/3.13.rst:2210 msgid "" "Add the :c:func:`Py_HashPointer` function to hash a raw pointer. " "(Contributed by Victor Stinner in :gh:`111545`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2197 +#: ../../whatsnew/3.13.rst:2213 msgid "" "Add the :c:func:`PyObject_VisitManagedDict` and :c:func:" "`PyObject_ClearManagedDict` functions. which must be called by the traverse " @@ -4245,7 +4281,7 @@ msgid "" "with Python 3.11 and 3.12. (Contributed by Victor Stinner in :gh:`107073`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2205 +#: ../../whatsnew/3.13.rst:2221 msgid "" "Add the :c:func:`PyRefTracer_SetTracer` and :c:func:`PyRefTracer_GetTracer` " "functions, which enable tracking object creation and destruction in the same " @@ -4253,14 +4289,14 @@ msgid "" "in :gh:`93502`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2211 +#: ../../whatsnew/3.13.rst:2227 msgid "" "Add the :c:func:`PySys_AuditTuple` function as an alternative to :c:func:" "`PySys_Audit` that takes event arguments as a Python :class:`tuple` object. " "(Contributed by Victor Stinner in :gh:`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2216 +#: ../../whatsnew/3.13.rst:2232 msgid "" "Add the :c:func:`PyThreadState_GetUnchecked()` function as an alternative " "to :c:func:`PyThreadState_Get()` that doesn't kill the process with a fatal " @@ -4268,7 +4304,7 @@ msgid "" "result is ``NULL``. (Contributed by Victor Stinner in :gh:`108867`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2222 +#: ../../whatsnew/3.13.rst:2238 msgid "" "Add the :c:func:`PyType_GetFullyQualifiedName` function to get the type's " "fully qualified name. The module name is prepended if :attr:`type." @@ -4276,14 +4312,14 @@ msgid "" "``'__main__'``. (Contributed by Victor Stinner in :gh:`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2228 +#: ../../whatsnew/3.13.rst:2244 msgid "" "Add the :c:func:`PyType_GetModuleName` function to get the type's module " "name. This is equivalent to getting the :attr:`type.__module__` attribute. " "(Contributed by Eric Snow and Victor Stinner in :gh:`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2233 +#: ../../whatsnew/3.13.rst:2249 msgid "" "Add the :c:func:`PyUnicode_EqualToUTF8AndSize` and :c:func:" "`PyUnicode_EqualToUTF8` functions to compare a Unicode object with a :c:expr:" @@ -4292,7 +4328,7 @@ msgid "" "Storchaka in :gh:`110289`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2240 +#: ../../whatsnew/3.13.rst:2256 msgid "" "Add the :c:func:`PyWeakref_GetRef` function as an alternative to :c:func:" "`PyWeakref_GetObject` that returns a :term:`strong reference` or ``NULL`` if " @@ -4300,16 +4336,16 @@ msgid "" "`105927`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2246 +#: ../../whatsnew/3.13.rst:2262 msgid "Add fixed variants of functions which silently ignore errors:" msgstr "" -#: ../../whatsnew/3.13.rst:2248 +#: ../../whatsnew/3.13.rst:2264 msgid "" ":c:func:`PyObject_HasAttrWithError` replaces :c:func:`PyObject_HasAttr`." msgstr ":c:func:`PyObject_HasAttrWithError` 取代 :c:func:`PyObject_HasAttr`。" -#: ../../whatsnew/3.13.rst:2249 +#: ../../whatsnew/3.13.rst:2265 msgid "" ":c:func:`PyObject_HasAttrStringWithError` replaces :c:func:" "`PyObject_HasAttrString`." @@ -4317,12 +4353,12 @@ msgstr "" ":c:func:`PyObject_HasAttrStringWithError` 取代 :c:func:" "`PyObject_HasAttrString`。" -#: ../../whatsnew/3.13.rst:2251 +#: ../../whatsnew/3.13.rst:2267 msgid "" ":c:func:`PyMapping_HasKeyWithError` replaces :c:func:`PyMapping_HasKey`." msgstr ":c:func:`PyMapping_HasKeyWithError` 取代 :c:func:`PyMapping_HasKey`。" -#: ../../whatsnew/3.13.rst:2252 +#: ../../whatsnew/3.13.rst:2268 msgid "" ":c:func:`PyMapping_HasKeyStringWithError` replaces :c:func:" "`PyMapping_HasKeyString`." @@ -4330,21 +4366,21 @@ msgstr "" ":c:func:`PyMapping_HasKeyStringWithError` 取代 :c:func:" "`PyMapping_HasKeyString`。" -#: ../../whatsnew/3.13.rst:2255 +#: ../../whatsnew/3.13.rst:2271 msgid "" "The new functions return ``-1`` for errors and the standard ``1`` for true " "and ``0`` for false." msgstr "" -#: ../../whatsnew/3.13.rst:2258 +#: ../../whatsnew/3.13.rst:2274 msgid "(Contributed by Serhiy Storchaka in :gh:`108511`.)" msgstr "(由 Serhiy Storchaka 在 :gh:`108511` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2262 +#: ../../whatsnew/3.13.rst:2278 msgid "Changed C APIs" msgstr "" -#: ../../whatsnew/3.13.rst:2264 +#: ../../whatsnew/3.13.rst:2280 msgid "" "The *keywords* parameter of :c:func:`PyArg_ParseTupleAndKeywords` and :c:" "func:`PyArg_VaParseTupleAndKeywords` now has type :c:expr:`char * const *` " @@ -4357,20 +4393,20 @@ msgid "" "`65210`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2276 +#: ../../whatsnew/3.13.rst:2292 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` now supports non-ASCII keyword " "parameter names. (Contributed by Serhiy Storchaka in :gh:`110815`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2280 +#: ../../whatsnew/3.13.rst:2296 msgid "" "The :c:func:`!PyCode_GetFirstFree` function is now unstable API and is now " "named :c:func:`PyUnstable_Code_GetFirstFree`. (Contributed by Bogdan " "Romanyuk in :gh:`115781`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2284 +#: ../../whatsnew/3.13.rst:2300 msgid "" "The :c:func:`PyDict_GetItem`, :c:func:`PyDict_GetItemString`, :c:func:" "`PyMapping_HasKey`, :c:func:`PyMapping_HasKeyString`, :c:func:" @@ -4381,35 +4417,35 @@ msgid "" "documentation. (Contributed by Serhiy Storchaka in :gh:`106672`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2293 +#: ../../whatsnew/3.13.rst:2309 msgid "" "Add support for the ``%T``, ``%#T``, ``%N`` and ``%#N`` formats to :c:func:" "`PyUnicode_FromFormat`:" msgstr "" -#: ../../whatsnew/3.13.rst:2296 +#: ../../whatsnew/3.13.rst:2312 msgid "``%T``: Get the fully qualified name of an object type" msgstr "" -#: ../../whatsnew/3.13.rst:2297 +#: ../../whatsnew/3.13.rst:2313 msgid "``%#T``: As above, but use a colon as the separator" msgstr "" -#: ../../whatsnew/3.13.rst:2298 +#: ../../whatsnew/3.13.rst:2314 msgid "``%N``: Get the fully qualified name of a type" msgstr "" -#: ../../whatsnew/3.13.rst:2299 +#: ../../whatsnew/3.13.rst:2315 msgid "``%#N``: As above, but use a colon as the separator" msgstr "" -#: ../../whatsnew/3.13.rst:2301 +#: ../../whatsnew/3.13.rst:2317 msgid "" "See :pep:`737` for more information. (Contributed by Victor Stinner in :gh:" "`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2304 +#: ../../whatsnew/3.13.rst:2320 msgid "" "You no longer have to define the ``PY_SSIZE_T_CLEAN`` macro before " "including :file:`Python.h` when using ``#`` formats in :ref:`format codes " @@ -4418,7 +4454,7 @@ msgid "" "`104922`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2310 +#: ../../whatsnew/3.13.rst:2326 msgid "" "If Python is built in :ref:`debug mode ` or :option:`with " "assertions <--with-assertions>`, :c:func:`PyTuple_SET_ITEM` and :c:func:" @@ -4426,61 +4462,61 @@ msgid "" "(Contributed by Victor Stinner in :gh:`106168`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2318 +#: ../../whatsnew/3.13.rst:2334 msgid "Limited C API Changes" msgstr "" -#: ../../whatsnew/3.13.rst:2320 +#: ../../whatsnew/3.13.rst:2336 msgid "The following functions are now included in the Limited C API:" msgstr "" -#: ../../whatsnew/3.13.rst:2322 +#: ../../whatsnew/3.13.rst:2338 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../whatsnew/3.13.rst:2323 +#: ../../whatsnew/3.13.rst:2339 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../whatsnew/3.13.rst:2324 +#: ../../whatsnew/3.13.rst:2340 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../whatsnew/3.13.rst:2325 +#: ../../whatsnew/3.13.rst:2341 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../whatsnew/3.13.rst:2326 +#: ../../whatsnew/3.13.rst:2342 msgid ":c:func:`PySys_Audit`" msgstr ":c:func:`PySys_Audit`" -#: ../../whatsnew/3.13.rst:2327 +#: ../../whatsnew/3.13.rst:2343 msgid ":c:func:`PySys_AuditTuple`" msgstr ":c:func:`PySys_AuditTuple`" -#: ../../whatsnew/3.13.rst:2328 +#: ../../whatsnew/3.13.rst:2344 msgid ":c:func:`PyType_GetModuleByDef`" msgstr ":c:func:`PyType_GetModuleByDef`" -#: ../../whatsnew/3.13.rst:2330 +#: ../../whatsnew/3.13.rst:2346 msgid "" "(Contributed by Victor Stinner in :gh:`85283`, :gh:`85283`, and :gh:" "`116936`.)" msgstr "" "(由 Victor Stinner 貢獻於 :gh:`85283`、:gh:`85283` 和 :gh:`116936`。)" -#: ../../whatsnew/3.13.rst:2332 +#: ../../whatsnew/3.13.rst:2348 msgid "" "Python built with :option:`--with-trace-refs` (tracing references) now " "supports the :ref:`Limited API `. (Contributed by Victor " "Stinner in :gh:`108634`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2338 +#: ../../whatsnew/3.13.rst:2354 msgid "Removed C APIs" msgstr "移除的 C API" -#: ../../whatsnew/3.13.rst:2340 +#: ../../whatsnew/3.13.rst:2356 msgid "" "Remove several functions, macros, variables, etc with names prefixed by " "``_Py`` or ``_PY`` (which are considered private). If your project is " @@ -4490,13 +4526,13 @@ msgid "" "Victor Stinner. (Contributed by Victor Stinner in :gh:`106320`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2348 +#: ../../whatsnew/3.13.rst:2364 msgid "" "Remove old buffer protocols deprecated in Python 3.0. Use :ref:" "`bufferobjects` instead." msgstr "" -#: ../../whatsnew/3.13.rst:2351 +#: ../../whatsnew/3.13.rst:2367 msgid "" ":c:func:`!PyObject_CheckReadBuffer`: Use :c:func:`PyObject_CheckBuffer` to " "test whether the object supports the buffer protocol. Note that :c:func:" @@ -4505,7 +4541,7 @@ msgid "" "example of :c:func:`PyObject_GetBuffer`." msgstr "" -#: ../../whatsnew/3.13.rst:2359 +#: ../../whatsnew/3.13.rst:2375 msgid "" ":c:func:`!PyObject_AsCharBuffer`, :c:func:`!PyObject_AsReadBuffer`: Use :c:" "func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release` instead:" @@ -4513,7 +4549,7 @@ msgstr "" ":c:func:`!PyObject_AsCharBuffer`、:c:func:`!PyObject_AsReadBuffer`:請改用 :" "c:func:`PyObject_GetBuffer` 和 :c:func:`PyBuffer_Release`。" -#: ../../whatsnew/3.13.rst:2362 +#: ../../whatsnew/3.13.rst:2378 msgid "" "Py_buffer view;\n" "if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0) {\n" @@ -4524,7 +4560,7 @@ msgid "" "PyBuffer_Release(&view);" msgstr "" -#: ../../whatsnew/3.13.rst:2372 +#: ../../whatsnew/3.13.rst:2388 msgid "" ":c:func:`!PyObject_AsWriteBuffer`: Use :c:func:`PyObject_GetBuffer` and :c:" "func:`PyBuffer_Release` instead:" @@ -4532,7 +4568,7 @@ msgstr "" ":c:func:`!PyObject_AsWriteBuffer`:請改用 :c:func:`PyObject_GetBuffer` 和 :c:" "func:`PyBuffer_Release`。" -#: ../../whatsnew/3.13.rst:2375 +#: ../../whatsnew/3.13.rst:2391 msgid "" "Py_buffer view;\n" "if (PyObject_GetBuffer(obj, &view, PyBUF_WRITABLE) < 0) {\n" @@ -4542,15 +4578,15 @@ msgid "" "PyBuffer_Release(&view);" msgstr "" -#: ../../whatsnew/3.13.rst:2384 +#: ../../whatsnew/3.13.rst:2400 msgid "(Contributed by Inada Naoki in :gh:`85275`.)" msgstr "(由 Inada Naoki 貢獻於 :gh:`85275`。)" -#: ../../whatsnew/3.13.rst:2386 +#: ../../whatsnew/3.13.rst:2402 msgid "Remove various functions deprecated in Python 3.9:" msgstr "" -#: ../../whatsnew/3.13.rst:2388 +#: ../../whatsnew/3.13.rst:2404 msgid "" ":c:func:`!PyEval_CallObject`, :c:func:`!PyEval_CallObjectWithKeywords`: Use :" "c:func:`PyObject_CallNoArgs` or :c:func:`PyObject_Call` instead." @@ -4558,7 +4594,7 @@ msgstr "" ":c:func:`!PyEval_CallObject`、:c:func:`!PyEval_CallObjectWithKeywords`:請改" "用 :c:func:`PyObject_CallNoArgs` 或 :c:func:`PyObject_Call`。" -#: ../../whatsnew/3.13.rst:2393 +#: ../../whatsnew/3.13.rst:2409 msgid "" "In :c:func:`PyObject_Call`, positional arguments must be a :class:`tuple` " "and must not be ``NULL``, and keyword arguments must be a :class:`dict` or " @@ -4569,33 +4605,33 @@ msgid "" "`PyTuple_New(0) `." msgstr "" -#: ../../whatsnew/3.13.rst:2403 +#: ../../whatsnew/3.13.rst:2419 msgid "" ":c:func:`!PyEval_CallFunction`: Use :c:func:`PyObject_CallFunction` instead." msgstr "" ":c:func:`!PyEval_CallFunction`:請改用 :c:func:`PyObject_CallFunction`。" -#: ../../whatsnew/3.13.rst:2405 +#: ../../whatsnew/3.13.rst:2421 msgid "" ":c:func:`!PyEval_CallMethod`: Use :c:func:`PyObject_CallMethod` instead." msgstr ":c:func:`!PyEval_CallMethod`:請改用 :c:func:`PyObject_CallMethod`。" -#: ../../whatsnew/3.13.rst:2407 +#: ../../whatsnew/3.13.rst:2423 msgid ":c:func:`!PyCFunction_Call`: Use :c:func:`PyObject_Call` instead." msgstr ":c:func:`!PyCFunction_Call`:請改用 :c:func:`PyCFunction_Call`。" -#: ../../whatsnew/3.13.rst:2410 +#: ../../whatsnew/3.13.rst:2426 msgid "(Contributed by Victor Stinner in :gh:`105107`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`105107`。)" -#: ../../whatsnew/3.13.rst:2412 +#: ../../whatsnew/3.13.rst:2428 msgid "" "Remove the following old functions to configure the Python initialization, " "deprecated in Python 3.11:" msgstr "" "移除以下設定 Python 初始化的舊函式,這些函式在 Python 3.11 中已被棄用:" -#: ../../whatsnew/3.13.rst:2415 +#: ../../whatsnew/3.13.rst:2431 msgid "" ":c:func:`!PySys_AddWarnOptionUnicode`: Use :c:member:`PyConfig.warnoptions` " "instead." @@ -4603,36 +4639,36 @@ msgstr "" ":c:func:`!PySys_AddWarnOptionUnicode`:請改用 :c:member:`PyConfig." "warnoptions`。" -#: ../../whatsnew/3.13.rst:2417 +#: ../../whatsnew/3.13.rst:2433 msgid "" ":c:func:`!PySys_AddWarnOption`: Use :c:member:`PyConfig.warnoptions` instead." msgstr "" ":c:func:`!PySys_AddWarnOption`:請改用 :c:member:`PyConfig.warnoptions`。" -#: ../../whatsnew/3.13.rst:2419 +#: ../../whatsnew/3.13.rst:2435 msgid ":c:func:`!PySys_AddXOption`: Use :c:member:`PyConfig.xoptions` instead." msgstr ":c:func:`!PySys_AddXOption`:請改用 :c:member:`PyConfig.xoptions`。" -#: ../../whatsnew/3.13.rst:2421 +#: ../../whatsnew/3.13.rst:2437 msgid "" ":c:func:`!PySys_HasWarnOptions`: Use :c:member:`PyConfig.xoptions` instead." msgstr "" ":c:func:`!PySys_HasWarnOptions`:請改用 :c:member:`PyConfig.xoptions`。" -#: ../../whatsnew/3.13.rst:2423 +#: ../../whatsnew/3.13.rst:2439 msgid "" ":c:func:`!PySys_SetPath`: Set :c:member:`PyConfig.module_search_paths` " "instead." msgstr "" ":c:func:`!PySys_SetPath`:請改用 :c:member:`PyConfig.module_search_paths`。" -#: ../../whatsnew/3.13.rst:2425 +#: ../../whatsnew/3.13.rst:2441 msgid "" ":c:func:`!Py_SetPath`: Set :c:member:`PyConfig.module_search_paths` instead." msgstr "" ":c:func:`!Py_SetPath`:請改用 :c:member:`PyConfig.module_search_paths`。" -#: ../../whatsnew/3.13.rst:2427 +#: ../../whatsnew/3.13.rst:2443 msgid "" ":c:func:`!Py_SetStandardStreamEncoding`: Set :c:member:`PyConfig." "stdio_encoding` instead, and set also maybe :c:member:`PyConfig." @@ -4642,14 +4678,14 @@ msgstr "" "stdio_encoding` 並設定可能的 :c:member:`PyConfig.legacy_windows_stdio`\\ " "(在 Windows 上)。" -#: ../../whatsnew/3.13.rst:2430 +#: ../../whatsnew/3.13.rst:2446 msgid "" ":c:func:`!_Py_SetProgramFullPath`: Set :c:member:`PyConfig.executable` " "instead." msgstr "" ":c:func:`!_Py_SetProgramFullPath`:請改用 :c:member:`PyConfig.executable`。" -#: ../../whatsnew/3.13.rst:2433 +#: ../../whatsnew/3.13.rst:2449 msgid "" "Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization " "Configuration ` instead (:pep:`587`), added to Python 3.8. " @@ -4659,7 +4695,7 @@ msgstr "" "(:pep:`587`),這是在 Python 3.8 中新增的。(由 Victor Stinner 於 :gh:" "`105145` 貢獻。)" -#: ../../whatsnew/3.13.rst:2437 +#: ../../whatsnew/3.13.rst:2453 msgid "" "Remove :c:func:`!PyEval_AcquireLock` and :c:func:`!PyEval_ReleaseLock` " "functions, deprecated in Python 3.2. They didn't update the current thread " @@ -4669,25 +4705,25 @@ msgstr "" "些函式在 Python 3.2 中已被廢棄。它們不會更新目前的執行緒狀態。可以用以下函式" "取代:" -#: ../../whatsnew/3.13.rst:2442 +#: ../../whatsnew/3.13.rst:2458 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`;" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`;" -#: ../../whatsnew/3.13.rst:2443 +#: ../../whatsnew/3.13.rst:2459 msgid "" "low-level :c:func:`PyEval_AcquireThread` and :c:func:`PyEval_RestoreThread`;" msgstr "" "低階的 :c:func:`PyEval_AcquireThread` 和 :c:func:`PyEval_RestoreThread`;" -#: ../../whatsnew/3.13.rst:2444 +#: ../../whatsnew/3.13.rst:2460 msgid "or :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`." msgstr "或 :c:func:`PyGILState_Ensure` 與 :c:func:`PyGILState_Release`。" -#: ../../whatsnew/3.13.rst:2446 +#: ../../whatsnew/3.13.rst:2462 msgid "(Contributed by Victor Stinner in :gh:`105182`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`105182`。)" -#: ../../whatsnew/3.13.rst:2448 +#: ../../whatsnew/3.13.rst:2464 msgid "" "Remove the :c:func:`!PyEval_ThreadsInitialized` function, deprecated in " "Python 3.9. Since Python 3.7, :c:func:`!Py_Initialize` always creates the " @@ -4700,7 +4736,7 @@ msgstr "" "PyEval_InitThreads` 不會有任何作用,而 :c:func:`!PyEval_ThreadsInitialized` " "總是會回傳非零值。(由 Victor Stinner 於 :gh:`105182` 貢獻。)" -#: ../../whatsnew/3.13.rst:2455 +#: ../../whatsnew/3.13.rst:2471 msgid "" "Remove the :c:func:`!_PyInterpreterState_Get` alias to :c:func:" "`PyInterpreterState_Get()` which was kept for backward compatibility with " @@ -4714,7 +4750,7 @@ msgstr "" "得 :c:func:`PyInterpreterState_Get()`。(由 Victor Stinner 於 :gh:`106320` 貢" "獻。)" -#: ../../whatsnew/3.13.rst:2462 +#: ../../whatsnew/3.13.rst:2478 msgid "" "Remove the private :c:func:`!_PyObject_FastCall` function: use :c:func:`!" "PyObject_Vectorcall` which is available since Python 3.8 (:pep:`590`). " @@ -4724,7 +4760,7 @@ msgstr "" "c:func:`!PyObject_Vectorcall` 函式(:pep:`590`)。(由 Victor Stinner 於 :gh:" "`106023` 貢獻。)" -#: ../../whatsnew/3.13.rst:2467 +#: ../../whatsnew/3.13.rst:2483 msgid "" "Remove the ``cpython/pytime.h`` header file, which only contained private " "functions. (Contributed by Victor Stinner in :gh:`106316`.)" @@ -4732,13 +4768,13 @@ msgstr "" "移除只包含私有函式的 ``cpython/pytime.h`` 標頭檔。(由 Victor Stinner 於 :gh:" "`106316` 貢獻。)" -#: ../../whatsnew/3.13.rst:2471 +#: ../../whatsnew/3.13.rst:2487 msgid "" "Remove the undocumented ``PY_TIMEOUT_MAX`` constant from the limited C API. " "(Contributed by Victor Stinner in :gh:`110014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2474 +#: ../../whatsnew/3.13.rst:2490 msgid "" "Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and " "``Py_TRASHCAN_SAFE_END``. Replace both with the new macros " @@ -4749,15 +4785,15 @@ msgstr "" "將兩者都替換為新的巨集 ``Py_TRASHCAN_BEGIN`` 和 ``Py_TRASHCAN_END``。(由 " "Irit Katriel 在 :gh:`105111` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2481 +#: ../../whatsnew/3.13.rst:2497 msgid "Deprecated C APIs" msgstr "器用的 C API" -#: ../../whatsnew/3.13.rst:2483 +#: ../../whatsnew/3.13.rst:2499 msgid "Deprecate old Python initialization functions:" msgstr "棄用舊的 Python 初始化函式:" -#: ../../whatsnew/3.13.rst:2485 +#: ../../whatsnew/3.13.rst:2501 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:13 msgid "" ":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" @@ -4766,30 +4802,30 @@ msgstr "" ":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" "data:`!warnings.filters`。" -#: ../../whatsnew/3.13.rst:2487 +#: ../../whatsnew/3.13.rst:2503 msgid ":c:func:`Py_GetExecPrefix`: Get :data:`sys.exec_prefix` instead." msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" -#: ../../whatsnew/3.13.rst:2489 +#: ../../whatsnew/3.13.rst:2505 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" -#: ../../whatsnew/3.13.rst:2491 +#: ../../whatsnew/3.13.rst:2507 msgid ":c:func:`Py_GetPrefix`: Get :data:`sys.prefix` instead." msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" -#: ../../whatsnew/3.13.rst:2493 +#: ../../whatsnew/3.13.rst:2509 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:21 msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" -#: ../../whatsnew/3.13.rst:2495 +#: ../../whatsnew/3.13.rst:2511 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:23 msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" -#: ../../whatsnew/3.13.rst:2497 +#: ../../whatsnew/3.13.rst:2513 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" ":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" @@ -4798,11 +4834,11 @@ msgstr "" ":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" "`PYTHONHOME` 環境變數。" -#: ../../whatsnew/3.13.rst:2501 +#: ../../whatsnew/3.13.rst:2517 msgid "(Contributed by Victor Stinner in :gh:`105145`.)" msgstr "(由 Victor Stinner 在 :gh:`105145` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2503 +#: ../../whatsnew/3.13.rst:2519 msgid "" ":term:`Soft deprecate ` the :c:func:`PyEval_GetBuiltins`, :" "c:func:`PyEval_GetGlobals`, and :c:func:`PyEval_GetLocals` functions, which " @@ -4813,7 +4849,7 @@ msgstr "" "\\ :term:`借用參照 `。(作為 :pep:`667` 一部分的軟性棄" "用。)" -#: ../../whatsnew/3.13.rst:2509 +#: ../../whatsnew/3.13.rst:2525 msgid "" "Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function, which is just " "an alias to :c:func:`PyImport_ImportModule` since Python 3.3. (Contributed " @@ -4823,7 +4859,7 @@ msgstr "" "c:func:`PyImport_ImportModule` 的別名。(由 Victor Stinner 在 :gh:`105396` 中" "貢獻。)" -#: ../../whatsnew/3.13.rst:2513 +#: ../../whatsnew/3.13.rst:2529 msgid "" ":term:`Soft deprecate ` the :c:func:`PyModule_AddObject` " "function. It should be replaced with :c:func:`PyModule_Add` or :c:func:" @@ -4833,7 +4869,7 @@ msgstr "" "用 :c:func:`PyModule_Add` 或 :c:func:`PyModule_AddObjectRef`。(由 Serhiy " "Storchaka 在 :gh:`86493` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2519 +#: ../../whatsnew/3.13.rst:2535 msgid "" "Deprecate the old ``Py_UNICODE`` and ``PY_UNICODE_TYPE`` types and the :c:" "macro:`!Py_UNICODE_WIDE` define. Use the :c:type:`wchar_t` type directly " @@ -4846,7 +4882,7 @@ msgstr "" "``Py_UNICODE`` 和 ``PY_UNICODE_TYPE`` 只是 :c:type:`!wchar_t` 的別名。(由 " "Victor Stinner 在 :gh:`105156` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2526 +#: ../../whatsnew/3.13.rst:2542 msgid "" "Deprecate the :c:func:`PyWeakref_GetObject` and :c:func:" "`PyWeakref_GET_OBJECT` functions, which return a :term:`borrowed reference`. " @@ -5229,56 +5265,56 @@ msgstr "" msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" -#: ../../whatsnew/3.13.rst:2546 +#: ../../whatsnew/3.13.rst:2562 msgid "Build Changes" msgstr "建置變更" -#: ../../whatsnew/3.13.rst:2548 +#: ../../whatsnew/3.13.rst:2564 msgid "" "``arm64-apple-ios`` and ``arm64-apple-ios-simulator`` are both now :pep:`11` " "tier 3 platforms. (:ref:`PEP 730 ` written and " "implementation contributed by Russell Keith-Magee in :gh:`114099`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2553 +#: ../../whatsnew/3.13.rst:2569 msgid "" "``aarch64-linux-android`` and ``x86_64-linux-android`` are both now :pep:" "`11` tier 3 platforms. (:ref:`PEP 738 ` " "written and implementation contributed by Malcolm Smith in :gh:`116622`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2558 +#: ../../whatsnew/3.13.rst:2574 msgid "" "``wasm32-wasi`` is now a :pep:`11` tier 2 platform. (Contributed by Brett " "Cannon in :gh:`115192`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2561 +#: ../../whatsnew/3.13.rst:2577 msgid "" "``wasm32-emscripten`` is no longer a :pep:`11` supported platform. " "(Contributed by Brett Cannon in :gh:`115192`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2564 +#: ../../whatsnew/3.13.rst:2580 msgid "" "Building CPython now requires a compiler with support for the C11 atomic " "library, GCC built-in atomic functions, or MSVC interlocked intrinsics." msgstr "" -#: ../../whatsnew/3.13.rst:2567 +#: ../../whatsnew/3.13.rst:2583 msgid "" "Autoconf 2.71 and aclocal 1.16.5 are now required to regenerate the :file:" "`configure` script. (Contributed by Christian Heimes in :gh:`89886` and by " "Victor Stinner in :gh:`112090`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2571 +#: ../../whatsnew/3.13.rst:2587 msgid "" "SQLite 3.15.2 or newer is required to build the :mod:`sqlite3` extension " "module. (Contributed by Erlend Aasland in :gh:`105875`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2575 +#: ../../whatsnew/3.13.rst:2591 msgid "" "CPython now bundles the `mimalloc library`_ by default. It is licensed under " "the MIT license; see :ref:`mimalloc license `. The bundled " @@ -5286,28 +5322,28 @@ msgid "" "Dino Viehland in :gh:`109914`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2583 +#: ../../whatsnew/3.13.rst:2599 msgid "" "The :file:`configure` option :option:`--with-system-libmpdec` now defaults " "to ``yes``. The bundled copy of ``libmpdecimal`` will be removed in Python " "3.15." msgstr "" -#: ../../whatsnew/3.13.rst:2587 +#: ../../whatsnew/3.13.rst:2603 msgid "" "Python built with :file:`configure` :option:`--with-trace-refs` (tracing " "references) is now ABI compatible with the Python release build and :ref:" "`debug build `. (Contributed by Victor Stinner in :gh:`108634`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2592 +#: ../../whatsnew/3.13.rst:2608 msgid "" "On POSIX systems, the pkg-config (``.pc``) filenames now include the ABI " "flags. For example, the free-threaded build generates ``python-3.13t.pc`` " "and the debug build generates ``python-3.13d.pc``." msgstr "" -#: ../../whatsnew/3.13.rst:2596 +#: ../../whatsnew/3.13.rst:2612 msgid "" "The ``errno``, ``fcntl``, ``grp``, ``md5``, ``pwd``, ``resource``, " "``termios``, ``winsound``, ``_ctypes_test``, ``_multiprocessing." @@ -5317,27 +5353,27 @@ msgid "" "`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2605 +#: ../../whatsnew/3.13.rst:2621 msgid "Porting to Python 3.13" msgstr "移植至 Python 3.13" -#: ../../whatsnew/3.13.rst:2607 +#: ../../whatsnew/3.13.rst:2623 msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." msgstr "" -#: ../../whatsnew/3.13.rst:2611 +#: ../../whatsnew/3.13.rst:2627 msgid "Changes in the Python API" msgstr "Python API 的變更" -#: ../../whatsnew/3.13.rst:2615 +#: ../../whatsnew/3.13.rst:2631 msgid "" ":ref:`PEP 667 ` introduces several changes to " "the semantics of :func:`locals` and :attr:`f_locals `:" msgstr "" -#: ../../whatsnew/3.13.rst:2618 +#: ../../whatsnew/3.13.rst:2634 msgid "" "Calling :func:`locals` in an :term:`optimized scope` now produces an " "independent snapshot on each call, and hence no longer implicitly updates " @@ -5349,7 +5385,7 @@ msgid "" "scope. (Changed as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2627 +#: ../../whatsnew/3.13.rst:2643 msgid "" "Calling :func:`locals` from a comprehension at module or class scope " "(including via ``exec`` or ``eval``) once more behaves as if the " @@ -5359,7 +5395,7 @@ msgid "" "implementing :pep:`709`. (Changed as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2634 +#: ../../whatsnew/3.13.rst:2650 msgid "" "Accessing :attr:`FrameType.f_locals ` in an :term:`optimized " "scope` now returns a write-through proxy rather than a snapshot that gets " @@ -5368,7 +5404,7 @@ msgid "" "of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2640 +#: ../../whatsnew/3.13.rst:2656 msgid "" ":class:`functools.partial` now emits a :exc:`FutureWarning` when used as a " "method. The behavior will change in future Python versions. Wrap it in :func:" @@ -5376,14 +5412,14 @@ msgid "" "Serhiy Storchaka in :gh:`121027`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2646 +#: ../../whatsnew/3.13.rst:2662 msgid "" "An :exc:`OSError` is now raised by :func:`getpass.getuser` for any failure " "to retrieve a username, instead of :exc:`ImportError` on non-Unix platforms " "or :exc:`KeyError` on Unix platforms where the password database is empty." msgstr "" -#: ../../whatsnew/3.13.rst:2651 +#: ../../whatsnew/3.13.rst:2667 msgid "" "The value of the :attr:`!mode` attribute of :class:`gzip.GzipFile` is now a " "string (``'rb'`` or ``'wb'``) instead of an integer (``1`` or ``2``). The " @@ -5392,13 +5428,13 @@ msgid "" "(Contributed by Serhiy Storchaka in :gh:`115961`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2657 +#: ../../whatsnew/3.13.rst:2673 msgid "" ":class:`mailbox.Maildir` now ignores files with a leading dot (``.``). " "(Contributed by Zackery Spytz in :gh:`65559`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2660 +#: ../../whatsnew/3.13.rst:2676 msgid "" ":meth:`pathlib.Path.glob` and :meth:`~pathlib.Path.rglob` now return both " "files and directories if a pattern that ends with \"``**``\" is given, " @@ -5406,25 +5442,25 @@ msgid "" "behavior and only match directories." msgstr "" -#: ../../whatsnew/3.13.rst:2665 +#: ../../whatsnew/3.13.rst:2681 msgid "" "The :mod:`threading` module now expects the :mod:`!_thread` module to have " "an :func:`!_is_main_interpreter` function. This function takes no arguments " "and returns ``True`` if the current interpreter is the main interpreter." msgstr "" -#: ../../whatsnew/3.13.rst:2670 +#: ../../whatsnew/3.13.rst:2686 msgid "" "Any library or application that provides a custom :mod:`!_thread` module " "must provide :func:`!_is_main_interpreter`, just like the module's other " "\"private\" attributes. (:gh:`112826`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2677 +#: ../../whatsnew/3.13.rst:2693 msgid "Changes in the C API" msgstr "C API 中的改動" -#: ../../whatsnew/3.13.rst:2679 +#: ../../whatsnew/3.13.rst:2695 msgid "" "``Python.h`` no longer includes the ```` standard header. It was " "included for the :c:func:`!finite` function which is now provided by the " @@ -5433,7 +5469,7 @@ msgid "" "`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2685 +#: ../../whatsnew/3.13.rst:2701 msgid "" "``Python.h`` no longer includes these standard header files: ````, " "```` and ````. If needed, they should now be " @@ -5444,7 +5480,7 @@ msgid "" "Victor Stinner in :gh:`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2693 +#: ../../whatsnew/3.13.rst:2709 msgid "" "On Windows, ``Python.h`` no longer includes the ```` standard " "header file. If needed, it should now be included explicitly. For example, " @@ -5454,7 +5490,7 @@ msgid "" "(Contributed by Victor Stinner in :gh:`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2700 +#: ../../whatsnew/3.13.rst:2716 msgid "" "If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!" "Py_BUILD_CORE`, :c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!" @@ -5462,18 +5498,18 @@ msgid "" "(Contributed by Victor Stinner in :gh:`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2705 +#: ../../whatsnew/3.13.rst:2721 msgid "" "The old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and " "``Py_TRASHCAN_SAFE_END`` were removed. They should be replaced by the new " "macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``." msgstr "" -#: ../../whatsnew/3.13.rst:2709 +#: ../../whatsnew/3.13.rst:2725 msgid "A ``tp_dealloc`` function that has the old macros, such as::" msgstr "有舊巨集的 ``tp_dealloc`` 函式,例如: ::" -#: ../../whatsnew/3.13.rst:2711 +#: ../../whatsnew/3.13.rst:2727 msgid "" "static void\n" "mytype_dealloc(mytype *p)\n" @@ -5493,11 +5529,11 @@ msgstr "" " Py_TRASHCAN_SAFE_END\n" "}" -#: ../../whatsnew/3.13.rst:2720 +#: ../../whatsnew/3.13.rst:2736 msgid "should migrate to the new macros as follows::" msgstr "應該改為使用新的巨集,如下所示: ::" -#: ../../whatsnew/3.13.rst:2722 +#: ../../whatsnew/3.13.rst:2738 msgid "" "static void\n" "mytype_dealloc(mytype *p)\n" @@ -5517,7 +5553,7 @@ msgstr "" " Py_TRASHCAN_END\n" "}" -#: ../../whatsnew/3.13.rst:2731 +#: ../../whatsnew/3.13.rst:2747 msgid "" "Note that ``Py_TRASHCAN_BEGIN`` has a second argument which should be the " "deallocation function it is in. The new macros were added in Python 3.8 and " @@ -5525,13 +5561,13 @@ msgid "" "in :gh:`105111`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2738 +#: ../../whatsnew/3.13.rst:2754 msgid "" ":ref:`PEP 667 ` introduces several changes to " "frame-related functions:" msgstr "" -#: ../../whatsnew/3.13.rst:2741 +#: ../../whatsnew/3.13.rst:2757 msgid "" "The effects of mutating the dictionary returned from :c:func:" "`PyEval_GetLocals` in an :term:`optimized scope` have changed. New dict " @@ -5545,7 +5581,7 @@ msgid "" "being used, so refer to the deprecation notice on the function for details." msgstr "" -#: ../../whatsnew/3.13.rst:2754 +#: ../../whatsnew/3.13.rst:2770 msgid "" "Calling :c:func:`PyFrame_GetLocals` in an :term:`optimized scope` now " "returns a write-through proxy rather than a snapshot that gets updated at " @@ -5554,40 +5590,40 @@ msgid "" "`PyEval_GetFrameLocals` API." msgstr "" -#: ../../whatsnew/3.13.rst:2761 +#: ../../whatsnew/3.13.rst:2777 msgid "" ":c:func:`!PyFrame_FastToLocals` and :c:func:`!PyFrame_FastToLocalsWithError` " "no longer have any effect. Calling these functions has been redundant since " "Python 3.11, when :c:func:`PyFrame_GetLocals` was first introduced." msgstr "" -#: ../../whatsnew/3.13.rst:2766 +#: ../../whatsnew/3.13.rst:2782 msgid "" ":c:func:`!PyFrame_LocalsToFast` no longer has any effect. Calling this " "function is redundant now that :c:func:`PyFrame_GetLocals` returns a write-" "through proxy for :term:`optimized scopes `." msgstr "" -#: ../../whatsnew/3.13.rst:2770 +#: ../../whatsnew/3.13.rst:2786 msgid "" "Python 3.13 removed many private functions. Some of them can be replaced " "using these alternatives:" msgstr "" -#: ../../whatsnew/3.13.rst:2773 +#: ../../whatsnew/3.13.rst:2789 msgid "``_PyDict_Pop()``: :c:func:`PyDict_Pop` or :c:func:`PyDict_PopString`;" msgstr "" "``_PyDict_Pop()``::c:func:`PyDict_Pop` 或 :c:func:`PyDict_PopString`;" -#: ../../whatsnew/3.13.rst:2774 +#: ../../whatsnew/3.13.rst:2790 msgid "``_PyDict_GetItemWithError()``: :c:func:`PyDict_GetItemRef`;" msgstr "``_PyDict_GetItemWithError()``::c:func:`PyDict_GetItemRef`;" -#: ../../whatsnew/3.13.rst:2775 +#: ../../whatsnew/3.13.rst:2791 msgid "``_PyErr_WriteUnraisableMsg()``: :c:func:`PyErr_FormatUnraisable`;" msgstr "``_PyErr_WriteUnraisableMsg()``::c:func:`PyErr_FormatUnraisable`;" -#: ../../whatsnew/3.13.rst:2776 +#: ../../whatsnew/3.13.rst:2792 msgid "" "``_PyEval_SetTrace()``: :c:func:`PyEval_SetTrace` or :c:func:" "`PyEval_SetTraceAllThreads`;" @@ -5595,43 +5631,43 @@ msgstr "" "``_PyEval_SetTrace()``::c:func:`PyEval_SetTrace` 或 :c:func:" "`PyEval_SetTraceAllThreads`;" -#: ../../whatsnew/3.13.rst:2777 +#: ../../whatsnew/3.13.rst:2793 msgid "``_PyList_Extend()``: :c:func:`PyList_Extend`;" msgstr "``_PyList_Extend()``::c:func:`PyList_Extend`;" -#: ../../whatsnew/3.13.rst:2778 +#: ../../whatsnew/3.13.rst:2794 msgid "``_PyLong_AsInt()``: :c:func:`PyLong_AsInt`;" msgstr "``_PyLong_AsInt()``::c:func:`PyLong_AsInt`;" -#: ../../whatsnew/3.13.rst:2779 +#: ../../whatsnew/3.13.rst:2795 msgid "``_PyMem_RawStrdup()``: ``strdup()``;" msgstr "``_PyMem_RawStrdup()``:``strdup()``;" -#: ../../whatsnew/3.13.rst:2780 +#: ../../whatsnew/3.13.rst:2796 msgid "``_PyMem_Strdup()``: ``strdup()``;" msgstr "``_PyMem_Strdup()``:``strdup()``;" -#: ../../whatsnew/3.13.rst:2781 +#: ../../whatsnew/3.13.rst:2797 msgid "``_PyObject_ClearManagedDict()``: :c:func:`PyObject_ClearManagedDict`;" msgstr "" "``_PyObject_ClearManagedDict()``::c:func:`PyObject_ClearManagedDict`;" -#: ../../whatsnew/3.13.rst:2782 +#: ../../whatsnew/3.13.rst:2798 msgid "``_PyObject_VisitManagedDict()``: :c:func:`PyObject_VisitManagedDict`;" msgstr "" "``_PyObject_VisitManagedDict()``::c:func:`PyObject_VisitManagedDict`;" -#: ../../whatsnew/3.13.rst:2783 +#: ../../whatsnew/3.13.rst:2799 msgid "" "``_PyThreadState_UncheckedGet()``: :c:func:`PyThreadState_GetUnchecked()`;" msgstr "" "``_PyThreadState_UncheckedGet()``::c:func:`PyThreadState_GetUnchecked()`;" -#: ../../whatsnew/3.13.rst:2784 +#: ../../whatsnew/3.13.rst:2800 msgid "``_PyTime_AsSecondsDouble()``: :c:func:`PyTime_AsSecondsDouble`;" msgstr "``_PyTime_AsSecondsDouble()``::c:func:`PyTime_AsSecondsDouble`;" -#: ../../whatsnew/3.13.rst:2785 +#: ../../whatsnew/3.13.rst:2801 msgid "" "``_PyTime_GetMonotonicClock()``: :c:func:`PyTime_Monotonic` or :c:func:" "`PyTime_MonotonicRaw`;" @@ -5639,7 +5675,7 @@ msgstr "" "``_PyTime_GetMonotonicClock()``::c:func:`PyTime_Monotonic` 或 :c:func:" "`PyTime_MonotonicRaw`;" -#: ../../whatsnew/3.13.rst:2786 +#: ../../whatsnew/3.13.rst:2802 msgid "" "``_PyTime_GetPerfCounter()``: :c:func:`PyTime_PerfCounter` or :c:func:" "`PyTime_PerfCounterRaw`;" @@ -5647,7 +5683,7 @@ msgstr "" "``_PyTime_GetPerfCounter()``::c:func:`PyTime_PerfCounter` 或 :c:func:" "`PyTime_PerfCounterRaw`;" -#: ../../whatsnew/3.13.rst:2787 +#: ../../whatsnew/3.13.rst:2803 msgid "" "``_PyTime_GetSystemClock()``: :c:func:`PyTime_Time` or :c:func:" "`PyTime_TimeRaw`;" @@ -5655,27 +5691,27 @@ msgstr "" "``_PyTime_GetSystemClock()``::c:func:`PyTime_Time` 或 :c:func:" "`PyTime_TimeRaw`;" -#: ../../whatsnew/3.13.rst:2788 +#: ../../whatsnew/3.13.rst:2804 msgid "``_PyTime_MAX``: :c:var:`PyTime_MAX`;" msgstr "``_PyTime_MAX``::c:var:`PyTime_MAX`;" -#: ../../whatsnew/3.13.rst:2789 +#: ../../whatsnew/3.13.rst:2805 msgid "``_PyTime_MIN``: :c:var:`PyTime_MIN`;" msgstr "``_PyTime_MIN``::c:var:`PyTime_MIN`;" -#: ../../whatsnew/3.13.rst:2790 +#: ../../whatsnew/3.13.rst:2806 msgid "``_PyTime_t``: :c:type:`PyTime_t`;" msgstr "``_PyTime_t``::c:type:`PyTime_t`;" -#: ../../whatsnew/3.13.rst:2791 +#: ../../whatsnew/3.13.rst:2807 msgid "``_Py_HashPointer()``: :c:func:`Py_HashPointer`;" msgstr "``_Py_HashPointer()``::c:func:`Py_HashPointer`;" -#: ../../whatsnew/3.13.rst:2792 +#: ../../whatsnew/3.13.rst:2808 msgid "``_Py_IsFinalizing()``: :c:func:`Py_IsFinalizing`." msgstr "``_Py_IsFinalizing()``::c:func:`Py_IsFinalizing`。" -#: ../../whatsnew/3.13.rst:2794 +#: ../../whatsnew/3.13.rst:2810 msgid "" "The `pythoncapi-compat project`_ can be used to get most of these new " "functions on Python 3.12 and older." @@ -5683,11 +5719,11 @@ msgstr "" "可以使用 `pythoncapi-compat 專案`_\\ 來在 Python 3.12 及更舊的版本中取用大部" "分的這些新函式。" -#: ../../whatsnew/3.13.rst:2798 +#: ../../whatsnew/3.13.rst:2814 msgid "Regression Test Changes" msgstr "迴歸測試的變更" -#: ../../whatsnew/3.13.rst:2800 +#: ../../whatsnew/3.13.rst:2816 msgid "" "Python built with :file:`configure` :option:`--with-pydebug` now supports a :" "option:`-X presite=package.module <-X>` command-line option. If used, it " @@ -5700,11 +5736,11 @@ msgstr "" "該在解譯器生命週期的早期階段、在執行 ``site.py`` 之前被引入的模組。(由 " "Łukasz Langa 在 :gh:`110769` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2808 +#: ../../whatsnew/3.13.rst:2824 msgid "Notable changes in 3.13.1" msgstr "Python 3.13.1 中顯著的變更" -#: ../../whatsnew/3.13.rst:2813 +#: ../../whatsnew/3.13.rst:2829 msgid "" "The previously undocumented special function :func:`sys.getobjects`, which " "only exists in specialized builds of Python, may now return objects from " @@ -5713,6 +5749,55 @@ msgstr "" "先前未以文件記錄的特殊函式 :func:`sys.getobjects`,只存在於 Python 的特殊建置" "中,現在可能會回傳來自於呼叫它的直譯器之外的物件。" +#: ../../whatsnew/3.13.rst:2834 +msgid "Notable changes in 3.13.4" +msgstr "Python 3.13.4 中顯著的變更" + +#: ../../whatsnew/3.13.rst:2839 +msgid "" +"The *strict* parameter to :func:`os.path.realpath` accepts a new value, :" +"data:`os.path.ALLOW_MISSING`. If used, errors other than :exc:" +"`FileNotFoundError` will be re-raised; the resulting path can be missing but " +"it will be free of symlinks. (Contributed by Petr Viktorin for :cve:" +"`2025-4517`.)" +msgstr "" + +#: ../../whatsnew/3.13.rst:2846 +msgid "tarfile" +msgstr "tarfile" + +#: ../../whatsnew/3.13.rst:2848 +msgid "" +":func:`~tarfile.data_filter` now normalizes symbolic link targets in order " +"to avoid path traversal attacks.Add commentMore actions (Contributed by Petr " +"Viktorin in :gh:`127987` and :cve:`2025-4138`.)" +msgstr "" + +#: ../../whatsnew/3.13.rst:2851 +msgid "" +":func:`~tarfile.TarFile.extractall` now skips fixing up directory attributes " +"when a directory was removed or replaced by another kind of file. " +"(Contributed by Petr Viktorin in :gh:`127987` and :cve:`2024-12718`.)" +msgstr "" + +#: ../../whatsnew/3.13.rst:2854 +msgid "" +":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` now " +"(re-)apply the extraction filter when substituting a link (hard or symbolic) " +"with a copy of another archive member, and when fixing up directory " +"attributes. The former raises a new exception, :exc:`~tarfile." +"LinkFallbackError`. (Contributed by Petr Viktorin for :cve:`2025-4330` and :" +"cve:`2024-12718`.)" +msgstr "" + +#: ../../whatsnew/3.13.rst:2860 +msgid "" +":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` no " +"longer extract rejected members when :func:`~tarfile.TarFile.errorlevel` is " +"zero. (Contributed by Matt Prodani and Petr Viktorin in :gh:`112887` and :" +"cve:`2025-4435`.)" +msgstr "" + #~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" #~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy