diff --git a/c-api/memory.po b/c-api/memory.po index e3b9669a9d..0b7ee268d0 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"POT-Creation-Date: 2025-07-21 00:18+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-" @@ -587,19 +587,19 @@ msgid "" "following fields:" msgstr "" -#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:670 +#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 msgid "Field" msgstr "欄位" -#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:670 +#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 msgid "Meaning" msgstr "意義" -#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:672 +#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 msgid "``void *ctx``" msgstr "``void *ctx``" -#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:672 +#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 msgid "user context passed as first argument" msgstr "" @@ -1003,45 +1003,52 @@ msgid "" "envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``)." msgstr "" -#: ../../c-api/memory.rst:660 +#: ../../c-api/memory.rst:659 +msgid "" +"Typically, it makes sense to disable the pymalloc allocator when building " +"Python with AddressSanitizer (:option:`--with-address-sanitizer`) which " +"helps uncover low level bugs within the C code." +msgstr "" + +#: ../../c-api/memory.rst:664 msgid "Customize pymalloc Arena Allocator" msgstr "" -#: ../../c-api/memory.rst:666 +#: ../../c-api/memory.rst:670 msgid "" "Structure used to describe an arena allocator. The structure has three " "fields:" msgstr "" -#: ../../c-api/memory.rst:674 +#: ../../c-api/memory.rst:678 msgid "``void* alloc(void *ctx, size_t size)``" msgstr "``void* alloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:674 +#: ../../c-api/memory.rst:678 msgid "allocate an arena of size bytes" msgstr "" -#: ../../c-api/memory.rst:676 +#: ../../c-api/memory.rst:680 msgid "``void free(void *ctx, void *ptr, size_t size)``" msgstr "``void free(void *ctx, void *ptr, size_t size)``" -#: ../../c-api/memory.rst:676 +#: ../../c-api/memory.rst:680 msgid "free an arena" msgstr "" -#: ../../c-api/memory.rst:681 +#: ../../c-api/memory.rst:685 msgid "Get the arena allocator." msgstr "" -#: ../../c-api/memory.rst:685 +#: ../../c-api/memory.rst:689 msgid "Set the arena allocator." msgstr "" -#: ../../c-api/memory.rst:690 +#: ../../c-api/memory.rst:694 msgid "The mimalloc allocator" msgstr "" -#: ../../c-api/memory.rst:694 +#: ../../c-api/memory.rst:698 msgid "" "Python supports the mimalloc allocator when the underlying platform support " "is available. mimalloc \"is a general purpose allocator with excellent " @@ -1049,46 +1056,46 @@ msgid "" "runtime systems of the Koka and Lean languages.\"" msgstr "" -#: ../../c-api/memory.rst:699 +#: ../../c-api/memory.rst:703 msgid "tracemalloc C API" msgstr "" -#: ../../c-api/memory.rst:705 +#: ../../c-api/memory.rst:709 msgid "Track an allocated memory block in the :mod:`tracemalloc` module." msgstr "" -#: ../../c-api/memory.rst:707 +#: ../../c-api/memory.rst:711 msgid "" "Return ``0`` on success, return ``-1`` on error (failed to allocate memory " "to store the trace). Return ``-2`` if tracemalloc is disabled." msgstr "" -#: ../../c-api/memory.rst:710 +#: ../../c-api/memory.rst:714 msgid "If memory block is already tracked, update the existing trace." msgstr "" -#: ../../c-api/memory.rst:714 +#: ../../c-api/memory.rst:718 msgid "" "Untrack an allocated memory block in the :mod:`tracemalloc` module. Do " "nothing if the block was not tracked." msgstr "" -#: ../../c-api/memory.rst:717 +#: ../../c-api/memory.rst:721 msgid "Return ``-2`` if tracemalloc is disabled, otherwise return ``0``." msgstr "" -#: ../../c-api/memory.rst:723 +#: ../../c-api/memory.rst:727 msgid "Examples" msgstr "範例" -#: ../../c-api/memory.rst:725 +#: ../../c-api/memory.rst:729 msgid "" "Here is the example from section :ref:`memoryoverview`, rewritten so that " "the I/O buffer is allocated from the Python heap by using the first function " "set::" msgstr "" -#: ../../c-api/memory.rst:728 +#: ../../c-api/memory.rst:732 msgid "" "PyObject *res;\n" "char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" @@ -1101,11 +1108,11 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:738 +#: ../../c-api/memory.rst:742 msgid "The same code using the type-oriented function set::" msgstr "" -#: ../../c-api/memory.rst:740 +#: ../../c-api/memory.rst:744 msgid "" "PyObject *res;\n" "char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" @@ -1118,7 +1125,7 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:750 +#: ../../c-api/memory.rst:754 msgid "" "Note that in the two examples above, the buffer is always manipulated via " "functions belonging to the same set. Indeed, it is required to use the same " @@ -1128,7 +1135,7 @@ msgid "" "different allocators operating on different heaps. ::" msgstr "" -#: ../../c-api/memory.rst:757 +#: ../../c-api/memory.rst:761 msgid "" "char *buf1 = PyMem_New(char, BUFSIZ);\n" "char *buf2 = (char *) malloc(BUFSIZ);\n" @@ -1139,14 +1146,14 @@ msgid "" "free(buf1); /* Fatal -- should be PyMem_Del() */" msgstr "" -#: ../../c-api/memory.rst:765 +#: ../../c-api/memory.rst:769 msgid "" "In addition to the functions aimed at handling raw memory blocks from the " "Python heap, objects in Python are allocated and released with :c:macro:" "`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Del`." msgstr "" -#: ../../c-api/memory.rst:769 +#: ../../c-api/memory.rst:773 msgid "" "These will be explained in the next chapter on defining and implementing new " "object types in C." diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po index 5ce4f89173..42af41a8d9 100644 --- a/howto/free-threading-extensions.po +++ b/howto/free-threading-extensions.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-07-24 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -57,7 +57,7 @@ msgstr "" #: ../../howto/free-threading-extensions.rst:35 msgid "Module Initialization" -msgstr "" +msgstr "模組初始化" #: ../../howto/free-threading-extensions.rst:37 msgid "" @@ -268,68 +268,73 @@ msgid ":c:func:`PyList_GetItem`" msgstr ":c:func:`PyList_GetItem`" #: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:162 msgid ":c:func:`PyList_GetItemRef`" msgstr ":c:func:`PyList_GetItemRef`" #: ../../howto/free-threading-extensions.rst:162 +msgid ":c:func:`PyList_GET_ITEM`" +msgstr ":c:func:`PyList_GET_ITEM`" + +#: ../../howto/free-threading-extensions.rst:164 msgid ":c:func:`PyDict_GetItem`" msgstr ":c:func:`PyDict_GetItem`" -#: ../../howto/free-threading-extensions.rst:162 #: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:166 msgid ":c:func:`PyDict_GetItemRef`" msgstr ":c:func:`PyDict_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:166 msgid ":c:func:`PyDict_GetItemWithError`" msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:168 msgid ":c:func:`PyDict_GetItemString`" msgstr ":c:func:`PyDict_GetItemString`" -#: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:168 msgid ":c:func:`PyDict_GetItemStringRef`" msgstr ":c:func:`PyDict_GetItemStringRef`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:170 msgid ":c:func:`PyDict_SetDefault`" msgstr ":c:func:`PyDict_SetDefault`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:170 msgid ":c:func:`PyDict_SetDefaultRef`" msgstr ":c:func:`PyDict_SetDefaultRef`" -#: ../../howto/free-threading-extensions.rst:170 +#: ../../howto/free-threading-extensions.rst:172 msgid ":c:func:`PyDict_Next`" msgstr ":c:func:`PyDict_Next`" -#: ../../howto/free-threading-extensions.rst:170 +#: ../../howto/free-threading-extensions.rst:172 msgid "none (see :ref:`PyDict_Next`)" msgstr "" -#: ../../howto/free-threading-extensions.rst:172 +#: ../../howto/free-threading-extensions.rst:174 msgid ":c:func:`PyWeakref_GetObject`" msgstr ":c:func:`PyWeakref_GetObject`" -#: ../../howto/free-threading-extensions.rst:172 #: ../../howto/free-threading-extensions.rst:174 +#: ../../howto/free-threading-extensions.rst:176 msgid ":c:func:`PyWeakref_GetRef`" msgstr ":c:func:`PyWeakref_GetRef`" -#: ../../howto/free-threading-extensions.rst:174 +#: ../../howto/free-threading-extensions.rst:176 msgid ":c:func:`PyWeakref_GET_OBJECT`" msgstr ":c:func:`PyWeakref_GET_OBJECT`" -#: ../../howto/free-threading-extensions.rst:176 +#: ../../howto/free-threading-extensions.rst:178 msgid ":c:func:`PyImport_AddModule`" msgstr ":c:func:`PyImport_AddModule`" -#: ../../howto/free-threading-extensions.rst:176 +#: ../../howto/free-threading-extensions.rst:178 msgid ":c:func:`PyImport_AddModuleRef`" msgstr ":c:func:`PyImport_AddModuleRef`" -#: ../../howto/free-threading-extensions.rst:179 +#: ../../howto/free-threading-extensions.rst:181 msgid "" "Not all APIs that return borrowed references are problematic. For example, :" "c:func:`PyTuple_GetItem` is safe because tuples are immutable. Similarly, " @@ -340,18 +345,18 @@ msgid "" "context is safe." msgstr "" -#: ../../howto/free-threading-extensions.rst:187 +#: ../../howto/free-threading-extensions.rst:189 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:195 +#: ../../howto/free-threading-extensions.rst:197 msgid "Memory Allocation APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:197 +#: ../../howto/free-threading-extensions.rst:199 msgid "" "Python's memory management C API provides functions in three different :ref:" "`allocation domains `: \"raw\", \"mem\", and \"object\". " @@ -361,36 +366,36 @@ msgid "" "where this was only a best practice and not a hard requirement." msgstr "" -#: ../../howto/free-threading-extensions.rst:206 +#: ../../howto/free-threading-extensions.rst:208 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:213 +#: ../../howto/free-threading-extensions.rst:215 msgid "Thread State and GIL APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:215 +#: ../../howto/free-threading-extensions.rst:217 msgid "" "Python provides a set of functions and macros to manage thread state and the " "GIL, such as:" msgstr "" -#: ../../howto/free-threading-extensions.rst:218 +#: ../../howto/free-threading-extensions.rst:220 msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" msgstr ":c:func:`PyGILState_Ensure` 和 :c:func:`PyGILState_Release`" -#: ../../howto/free-threading-extensions.rst:219 +#: ../../howto/free-threading-extensions.rst:221 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`" -#: ../../howto/free-threading-extensions.rst:220 +#: ../../howto/free-threading-extensions.rst:222 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:222 +#: ../../howto/free-threading-extensions.rst:224 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 " @@ -399,7 +404,7 @@ msgid "" "Python thread state." msgstr "" -#: ../../howto/free-threading-extensions.rst:228 +#: ../../howto/free-threading-extensions.rst:230 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 " @@ -407,25 +412,25 @@ msgid "" "collector `." msgstr "" -#: ../../howto/free-threading-extensions.rst:235 +#: ../../howto/free-threading-extensions.rst:237 msgid "Protecting Internal Extension State" msgstr "" -#: ../../howto/free-threading-extensions.rst:237 +#: ../../howto/free-threading-extensions.rst:239 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:241 +#: ../../howto/free-threading-extensions.rst:243 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:244 +#: ../../howto/free-threading-extensions.rst:246 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 " @@ -433,34 +438,34 @@ msgid "" "language/storage_duration>`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:251 +#: ../../howto/free-threading-extensions.rst:253 msgid "Building Extensions for the Free-Threaded Build" msgstr "" -#: ../../howto/free-threading-extensions.rst:253 +#: ../../howto/free-threading-extensions.rst:255 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:256 +#: ../../howto/free-threading-extensions.rst:258 msgid "" "`pypa/manylinux `_ supports the free-" "threaded build, with the ``t`` suffix, such as ``python3.13t``." msgstr "" -#: ../../howto/free-threading-extensions.rst:258 +#: ../../howto/free-threading-extensions.rst:260 msgid "" "`pypa/cibuildwheel `_ supports the " "free-threaded build if you set `CIBW_ENABLE to cpython-freethreading " "`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:263 +#: ../../howto/free-threading-extensions.rst:265 msgid "Limited C API and Stable ABI" msgstr "" -#: ../../howto/free-threading-extensions.rst:265 +#: ../../howto/free-threading-extensions.rst:267 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/logging.po b/howto/logging.po index 4a1f511a6c..42a56983bc 100644 --- a/howto/logging.po +++ b/howto/logging.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-07-22 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -528,8 +528,8 @@ msgstr "" msgid "" "If your logging needs are simple, then use the above examples to incorporate " "logging into your own scripts, and if you run into problems or don't " -"understand something, please post a question on the comp.lang.python Usenet " -"group (available at https://groups.google.com/g/comp.lang.python) and you " +"understand something, please post a question in the Help category of the " +"`Python discussion forum `_ and you " "should receive help before too long." msgstr "" diff --git a/library/argparse.po b/library/argparse.po index 0cf492ac45..7c9a382be0 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-09 00:17+0000\n" +"POT-Creation-Date: 2025-07-20 00:19+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-" @@ -217,7 +217,7 @@ msgstr "" msgid "*exit_on_error* parameter was added." msgstr "新增 *exit_on_error* 參數。" -#: ../../library/argparse.rst:128 ../../library/argparse.rst:610 +#: ../../library/argparse.rst:128 ../../library/argparse.rst:616 msgid "The following sections describe how each of these are used." msgstr "" @@ -717,7 +717,7 @@ msgstr "" #: ../../library/argparse.rst:418 msgid "" -"Arguments read from a file must by default be one per line (but see also :" +"Arguments read from a file must be one per line by default (but see also :" "meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " "were in the same place as the original file referencing argument on the " "command line. So in the example above, the expression ``['-f', 'foo', " @@ -725,19 +725,26 @@ msgid "" "f', 'bar']``." msgstr "" -#: ../../library/argparse.rst:424 +#: ../../library/argparse.rst:426 +msgid "" +"Empty lines are treated as empty strings (``''``), which are allowed as " +"values but not as arguments. Empty lines that are read as arguments will " +"result in an \"unrecognized arguments\" error." +msgstr "" + +#: ../../library/argparse.rst:430 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" -#: ../../library/argparse.rst:427 +#: ../../library/argparse.rst:433 msgid "" "The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that " "arguments will never be treated as file references." msgstr "" -#: ../../library/argparse.rst:430 +#: ../../library/argparse.rst:436 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " "from default (e.g. :func:`locale.getpreferredencoding(False) >> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" ">>> parser.add_argument('--foo')\n" @@ -780,22 +787,22 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace()" -#: ../../library/argparse.rst:460 +#: ../../library/argparse.rst:466 msgid "allow_abbrev" msgstr "allow_abbrev" -#: ../../library/argparse.rst:462 +#: ../../library/argparse.rst:468 msgid "" "Normally, when you pass an argument list to the :meth:`~ArgumentParser." "parse_args` method of an :class:`ArgumentParser`, it :ref:`recognizes " "abbreviations ` of long options." msgstr "" -#: ../../library/argparse.rst:466 +#: ../../library/argparse.rst:472 msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:468 +#: ../../library/argparse.rst:474 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" ">>> parser.add_argument('--foobar', action='store_true')\n" @@ -811,11 +818,11 @@ msgstr "" "usage: PROG [-h] [--foobar] [--foonley]\n" "PROG: error: unrecognized arguments: --foon" -#: ../../library/argparse.rst:479 +#: ../../library/argparse.rst:485 msgid "conflict_handler" msgstr "conflict_handler" -#: ../../library/argparse.rst:481 +#: ../../library/argparse.rst:487 msgid "" ":class:`ArgumentParser` objects do not allow two actions with the same " "option string. By default, :class:`ArgumentParser` objects raise an " @@ -823,7 +830,7 @@ msgid "" "that is already in use::" msgstr "" -#: ../../library/argparse.rst:486 +#: ../../library/argparse.rst:492 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo', help='old foo help')\n" @@ -839,7 +846,7 @@ msgstr "" " ..\n" "ArgumentError: argument --foo: conflicting option string(s): --foo" -#: ../../library/argparse.rst:493 +#: ../../library/argparse.rst:499 msgid "" "Sometimes (e.g. when using parents_) it may be useful to simply override any " "older arguments with the same option string. To get this behavior, the " @@ -847,7 +854,7 @@ msgid "" "of :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:498 +#: ../../library/argparse.rst:504 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', " "conflict_handler='resolve')\n" @@ -873,7 +880,7 @@ msgstr "" " -f FOO old foo help\n" " --foo FOO new foo help" -#: ../../library/argparse.rst:509 +#: ../../library/argparse.rst:515 msgid "" "Note that :class:`ArgumentParser` objects only remove an action if all of " "its option strings are overridden. So, in the example above, the old ``-f/--" @@ -881,25 +888,25 @@ msgid "" "option string was overridden." msgstr "" -#: ../../library/argparse.rst:516 +#: ../../library/argparse.rst:522 msgid "add_help" msgstr "add_help" -#: ../../library/argparse.rst:518 +#: ../../library/argparse.rst:524 msgid "" "By default, :class:`ArgumentParser` objects add an option which simply " "displays the parser's help message. If ``-h`` or ``--help`` is supplied at " "the command line, the :class:`!ArgumentParser` help will be printed." msgstr "" -#: ../../library/argparse.rst:522 +#: ../../library/argparse.rst:528 msgid "" "Occasionally, it may be useful to disable the addition of this help option. " "This can be achieved by passing ``False`` as the ``add_help=`` argument to :" "class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:526 +#: ../../library/argparse.rst:532 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> parser.add_argument('--foo', help='foo help')\n" @@ -917,7 +924,7 @@ msgstr "" "options:\n" " --foo FOO foo help" -#: ../../library/argparse.rst:534 +#: ../../library/argparse.rst:540 msgid "" "The help option is typically ``-h/--help``. The exception to this is if the " "``prefix_chars=`` is specified and does not include ``-``, in which case ``-" @@ -925,7 +932,7 @@ msgid "" "in ``prefix_chars`` is used to prefix the help options::" msgstr "" -#: ../../library/argparse.rst:540 +#: ../../library/argparse.rst:546 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" ">>> parser.print_help()\n" @@ -941,24 +948,24 @@ msgstr "" "options:\n" " +h, ++help show this help message and exit" -#: ../../library/argparse.rst:549 +#: ../../library/argparse.rst:555 msgid "exit_on_error" msgstr "exit_on_error" -#: ../../library/argparse.rst:551 +#: ../../library/argparse.rst:557 msgid "" "Normally, when you pass an invalid argument list to the :meth:" "`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " "print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" -#: ../../library/argparse.rst:555 +#: ../../library/argparse.rst:561 msgid "" "If the user would like to catch errors manually, the feature can be enabled " "by setting ``exit_on_error`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:558 +#: ../../library/argparse.rst:564 msgid "" ">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" ">>> parser.add_argument('--integers', type=int)\n" @@ -984,81 +991,81 @@ msgstr "" "...\n" "Catching an argumentError" -#: ../../library/argparse.rst:572 +#: ../../library/argparse.rst:578 msgid "The add_argument() method" msgstr "add_argument() 方法" -#: ../../library/argparse.rst:578 +#: ../../library/argparse.rst:584 msgid "" "Define how a single command-line argument should be parsed. Each parameter " "has its own more detailed description below, but in short they are:" msgstr "" -#: ../../library/argparse.rst:581 +#: ../../library/argparse.rst:587 msgid "" "`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " "or ``'-f', '--foo'``." msgstr "" -#: ../../library/argparse.rst:584 +#: ../../library/argparse.rst:590 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "" -#: ../../library/argparse.rst:587 +#: ../../library/argparse.rst:593 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "" -#: ../../library/argparse.rst:589 +#: ../../library/argparse.rst:595 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "" -#: ../../library/argparse.rst:591 +#: ../../library/argparse.rst:597 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "" -#: ../../library/argparse.rst:594 +#: ../../library/argparse.rst:600 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "" -#: ../../library/argparse.rst:596 +#: ../../library/argparse.rst:602 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "" -#: ../../library/argparse.rst:598 +#: ../../library/argparse.rst:604 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "" -#: ../../library/argparse.rst:601 +#: ../../library/argparse.rst:607 msgid "help_ - A brief description of what the argument does." msgstr "" -#: ../../library/argparse.rst:603 +#: ../../library/argparse.rst:609 msgid "metavar_ - A name for the argument in usage messages." msgstr "" -#: ../../library/argparse.rst:605 +#: ../../library/argparse.rst:611 msgid "" "dest_ - The name of the attribute to be added to the object returned by :" "meth:`parse_args`." msgstr "" -#: ../../library/argparse.rst:608 +#: ../../library/argparse.rst:614 msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "" -#: ../../library/argparse.rst:616 +#: ../../library/argparse.rst:622 msgid "name or flags" msgstr "name or flags" -#: ../../library/argparse.rst:618 +#: ../../library/argparse.rst:624 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1067,30 +1074,30 @@ msgid "" "or a simple argument name." msgstr "" -#: ../../library/argparse.rst:624 +#: ../../library/argparse.rst:630 msgid "For example, an optional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:626 +#: ../../library/argparse.rst:632 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:628 +#: ../../library/argparse.rst:634 msgid "while a positional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:630 +#: ../../library/argparse.rst:636 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:632 +#: ../../library/argparse.rst:638 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " "assumed to be positional::" msgstr "" -#: ../../library/argparse.rst:636 +#: ../../library/argparse.rst:642 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1114,11 +1121,11 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:651 +#: ../../library/argparse.rst:657 msgid "action" msgstr "action" -#: ../../library/argparse.rst:653 +#: ../../library/argparse.rst:659 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1128,13 +1135,13 @@ msgid "" "be handled. The supplied actions are:" msgstr "" -#: ../../library/argparse.rst:659 +#: ../../library/argparse.rst:665 msgid "" "``'store'`` - This just stores the argument's value. This is the default " "action." msgstr "" -#: ../../library/argparse.rst:662 +#: ../../library/argparse.rst:668 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1142,7 +1149,7 @@ msgid "" "specify some sort of flag. For example::" msgstr "" -#: ../../library/argparse.rst:667 +#: ../../library/argparse.rst:673 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1154,7 +1161,7 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:672 +#: ../../library/argparse.rst:678 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " "``'store_const'`` used for storing the values ``True`` and ``False`` " @@ -1162,7 +1169,7 @@ msgid "" "``True`` respectively::" msgstr "" -#: ../../library/argparse.rst:677 +#: ../../library/argparse.rst:683 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1178,7 +1185,7 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:684 +#: ../../library/argparse.rst:690 msgid "" "``'append'`` - This stores a list, and appends each argument value to the " "list. It is useful to allow an option to be specified multiple times. If the " @@ -1187,7 +1194,7 @@ msgid "" "after those default values. Example usage::" msgstr "" -#: ../../library/argparse.rst:690 +#: ../../library/argparse.rst:696 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append')\n" @@ -1199,7 +1206,7 @@ msgstr "" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['1', '2'])" -#: ../../library/argparse.rst:695 +#: ../../library/argparse.rst:701 msgid "" "``'append_const'`` - This stores a list, and appends the value specified by " "the const_ keyword argument to the list; note that the const_ keyword " @@ -1208,7 +1215,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:701 +#: ../../library/argparse.rst:707 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1226,7 +1233,7 @@ msgstr "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" -#: ../../library/argparse.rst:707 +#: ../../library/argparse.rst:713 msgid "" "``'extend'`` - This stores a list and appends each item from the multi-value " "argument list to it. The ``'extend'`` action is typically used with the " @@ -1235,7 +1242,7 @@ msgid "" "will be appended to the list. Example usage::" msgstr "" -#: ../../library/argparse.rst:715 +#: ../../library/argparse.rst:721 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " @@ -1251,13 +1258,13 @@ msgstr "" "\"f4\"])\n" "Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -#: ../../library/argparse.rst:722 +#: ../../library/argparse.rst:728 msgid "" "``'count'`` - This counts the number of times a keyword argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" -#: ../../library/argparse.rst:725 +#: ../../library/argparse.rst:731 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" @@ -1265,11 +1272,11 @@ msgid "" "Namespace(verbose=3)" msgstr "" -#: ../../library/argparse.rst:730 +#: ../../library/argparse.rst:736 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "" -#: ../../library/argparse.rst:732 +#: ../../library/argparse.rst:738 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " @@ -1277,14 +1284,14 @@ msgid "" "output is created." msgstr "" -#: ../../library/argparse.rst:737 +#: ../../library/argparse.rst:743 msgid "" "``'version'`` - This expects a ``version=`` keyword argument in the :meth:" "`~ArgumentParser.add_argument` call, and prints version information and " "exits when invoked::" msgstr "" -#: ../../library/argparse.rst:741 +#: ../../library/argparse.rst:747 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1300,7 +1307,7 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:747 +#: ../../library/argparse.rst:753 msgid "" "You may also specify an arbitrary action by passing an :class:`Action` " "subclass (e.g. :class:`BooleanOptionalAction`) or other object that " @@ -1308,11 +1315,12 @@ msgid "" "arguments (e.g. ``'store'``, ``'append'``, ``'extend'``, or custom actions " "with non-zero ``nargs``) can be used with positional arguments." msgstr "" -"你也可以傳遞一個 :class:`Action` 子類別(例如 :class:`BooleanOptionalAction`)" -"或實作相同介面的其他物件。只有會消耗命令列引數的 action(例如 ``'store'``、" -"``'append'``、``'extend'`` 或 ``nargs`` 不為零的自定義 action)可以被用於位置引數。" +"你也可以傳遞一個 :class:`Action` 子類別(例如 :class:" +"`BooleanOptionalAction`)或實作相同介面的其他物件。只有會消耗命令列引數的 " +"action(例如 ``'store'``、``'append'``、``'extend'`` 或 ``nargs`` 不為零的自" +"定義 action)可以被用於位置引數。" -#: ../../library/argparse.rst:753 +#: ../../library/argparse.rst:759 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " "overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " @@ -1321,11 +1329,11 @@ msgid "" "their registered name." msgstr "" -#: ../../library/argparse.rst:758 +#: ../../library/argparse.rst:764 msgid "An example of a custom action::" msgstr "" -#: ../../library/argparse.rst:760 +#: ../../library/argparse.rst:766 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1346,15 +1354,15 @@ msgid "" "Namespace(bar='1', foo='2')" msgstr "" -#: ../../library/argparse.rst:778 +#: ../../library/argparse.rst:784 msgid "For more details, see :class:`Action`." msgstr "更多詳情請見 :class:`Action`。" -#: ../../library/argparse.rst:784 +#: ../../library/argparse.rst:790 msgid "nargs" msgstr "nargs" -#: ../../library/argparse.rst:786 +#: ../../library/argparse.rst:792 msgid "" ":class:`ArgumentParser` objects usually associate a single command-line " "argument with a single action to be taken. The ``nargs`` keyword argument " @@ -1363,13 +1371,13 @@ msgid "" "are:" msgstr "" -#: ../../library/argparse.rst:791 +#: ../../library/argparse.rst:797 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" -#: ../../library/argparse.rst:794 +#: ../../library/argparse.rst:800 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1383,13 +1391,13 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:800 +#: ../../library/argparse.rst:806 msgid "" "Note that ``nargs=1`` produces a list of one item. This is different from " "the default, in which the item is produced by itself." msgstr "" -#: ../../library/argparse.rst:805 +#: ../../library/argparse.rst:811 msgid "" "``'?'``. One argument will be consumed from the command line if possible, " "and produced as a single item. If no command-line argument is present, the " @@ -1399,7 +1407,7 @@ msgid "" "produced. Some examples to illustrate this::" msgstr "" -#: ../../library/argparse.rst:812 +#: ../../library/argparse.rst:818 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1421,13 +1429,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:822 +#: ../../library/argparse.rst:828 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "" -#: ../../library/argparse.rst:825 +#: ../../library/argparse.rst:831 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" @@ -1453,7 +1461,7 @@ msgstr "" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" " outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:839 +#: ../../library/argparse.rst:845 msgid "" "``'*'``. All command-line arguments present are gathered into a list. Note " "that it generally doesn't make much sense to have more than one positional " @@ -1461,7 +1469,7 @@ msgid "" "``nargs='*'`` is possible. For example::" msgstr "" -#: ../../library/argparse.rst:844 +#: ../../library/argparse.rst:850 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1477,14 +1485,14 @@ msgstr "" ">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" "Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" -#: ../../library/argparse.rst:853 +#: ../../library/argparse.rst:859 msgid "" "``'+'``. Just like ``'*'``, all command-line arguments present are gathered " "into a list. Additionally, an error message will be generated if there " "wasn't at least one command-line argument present. For example::" msgstr "" -#: ../../library/argparse.rst:857 +#: ../../library/argparse.rst:863 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1502,7 +1510,7 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:865 +#: ../../library/argparse.rst:871 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " @@ -1511,11 +1519,11 @@ msgid "" "``'store_const'``) set ``nargs=0``." msgstr "" -#: ../../library/argparse.rst:875 +#: ../../library/argparse.rst:881 msgid "const" msgstr "const" -#: ../../library/argparse.rst:877 +#: ../../library/argparse.rst:883 msgid "" "The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to " "hold constant values that are not read from the command line but are " @@ -1523,7 +1531,7 @@ msgid "" "common uses of it are:" msgstr "" -#: ../../library/argparse.rst:881 +#: ../../library/argparse.rst:887 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1533,7 +1541,7 @@ msgid "" "receive a default value of ``None``." msgstr "" -#: ../../library/argparse.rst:889 +#: ../../library/argparse.rst:895 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1543,17 +1551,17 @@ msgid "" "to be ``None`` instead. See the nargs_ description for examples." msgstr "" -#: ../../library/argparse.rst:896 +#: ../../library/argparse.rst:902 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." msgstr "" -#: ../../library/argparse.rst:903 +#: ../../library/argparse.rst:909 msgid "default" msgstr "default" -#: ../../library/argparse.rst:905 +#: ../../library/argparse.rst:911 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -1563,7 +1571,7 @@ msgid "" "command line::" msgstr "" -#: ../../library/argparse.rst:912 +#: ../../library/argparse.rst:918 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1579,13 +1587,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:919 +#: ../../library/argparse.rst:925 msgid "" "If the target namespace already has an attribute set, the action *default* " "will not overwrite it::" msgstr "" -#: ../../library/argparse.rst:922 +#: ../../library/argparse.rst:928 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1597,7 +1605,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:927 +#: ../../library/argparse.rst:933 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_ " @@ -1605,7 +1613,7 @@ msgid "" "`Namespace` return value. Otherwise, the parser uses the value as is::" msgstr "" -#: ../../library/argparse.rst:932 +#: ../../library/argparse.rst:938 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -1619,13 +1627,13 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:938 +#: ../../library/argparse.rst:944 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" msgstr "" -#: ../../library/argparse.rst:941 +#: ../../library/argparse.rst:947 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -1641,20 +1649,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:948 +#: ../../library/argparse.rst:954 msgid "" "For required_ arguments, the ``default`` value is ignored. For example, this " "applies to positional arguments with nargs_ values other than ``?`` or " "``*``, or optional arguments marked as ``required=True``." msgstr "" -#: ../../library/argparse.rst:952 +#: ../../library/argparse.rst:958 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" msgstr "" -#: ../../library/argparse.rst:955 +#: ../../library/argparse.rst:961 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -1670,11 +1678,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:966 +#: ../../library/argparse.rst:972 msgid "type" msgstr "type" -#: ../../library/argparse.rst:968 +#: ../../library/argparse.rst:974 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -1683,13 +1691,13 @@ msgid "" "checking and type conversions to be performed." msgstr "" -#: ../../library/argparse.rst:974 +#: ../../library/argparse.rst:980 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." msgstr "" -#: ../../library/argparse.rst:977 +#: ../../library/argparse.rst:983 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 " @@ -1698,11 +1706,11 @@ msgid "" "is displayed. Other exception types are not handled." msgstr "" -#: ../../library/argparse.rst:983 +#: ../../library/argparse.rst:989 msgid "Common built-in types and functions can be used as type converters:" msgstr "" -#: ../../library/argparse.rst:985 +#: ../../library/argparse.rst:991 msgid "" "import argparse\n" "import pathlib\n" @@ -1728,11 +1736,11 @@ msgstr "" "encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:998 +#: ../../library/argparse.rst:1004 msgid "User defined functions can be used as well:" msgstr "" -#: ../../library/argparse.rst:1000 +#: ../../library/argparse.rst:1006 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -1750,14 +1758,14 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1010 +#: ../../library/argparse.rst:1016 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " "``True``. This is usually not what is desired." msgstr "" -#: ../../library/argparse.rst:1014 +#: ../../library/argparse.rst:1020 msgid "" "In general, the ``type`` keyword is a convenience that should only be used " "for simple conversions that can only raise one of the three supported " @@ -1765,7 +1773,7 @@ msgid "" "management should be done downstream after the arguments are parsed." msgstr "" -#: ../../library/argparse.rst:1019 +#: ../../library/argparse.rst:1025 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." @@ -1773,7 +1781,7 @@ msgid "" "exception would not be handled at all." msgstr "" -#: ../../library/argparse.rst:1024 +#: ../../library/argparse.rst:1030 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " "``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " @@ -1783,17 +1791,17 @@ msgid "" "files." msgstr "" -#: ../../library/argparse.rst:1031 +#: ../../library/argparse.rst:1037 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "" -#: ../../library/argparse.rst:1038 +#: ../../library/argparse.rst:1044 msgid "choices" msgstr "choices" -#: ../../library/argparse.rst:1040 +#: ../../library/argparse.rst:1046 msgid "" "Some command-line arguments should be selected from a restricted set of " "values. These can be handled by passing a sequence object as the *choices* " @@ -1802,7 +1810,7 @@ msgid "" "be displayed if the argument was not one of the acceptable values::" msgstr "" -#: ../../library/argparse.rst:1046 +#: ../../library/argparse.rst:1052 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -1822,26 +1830,26 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1055 +#: ../../library/argparse.rst:1061 msgid "" "Note that inclusion in the *choices* sequence is checked after any type_ " "conversions have been performed, so the type of the objects in the *choices* " "sequence should match the type_ specified." msgstr "" -#: ../../library/argparse.rst:1059 +#: ../../library/argparse.rst:1065 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." msgstr "" -#: ../../library/argparse.rst:1062 +#: ../../library/argparse.rst:1068 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" -#: ../../library/argparse.rst:1065 +#: ../../library/argparse.rst:1071 msgid "" "Formatted choices override the default *metavar* which is normally derived " "from *dest*. This is usually what you want because the user never sees the " @@ -1849,11 +1857,11 @@ msgid "" "are many choices), just specify an explicit metavar_." msgstr "" -#: ../../library/argparse.rst:1074 +#: ../../library/argparse.rst:1080 msgid "required" msgstr "required" -#: ../../library/argparse.rst:1076 +#: ../../library/argparse.rst:1082 msgid "" "In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " @@ -1861,7 +1869,7 @@ msgid "" "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" -#: ../../library/argparse.rst:1081 +#: ../../library/argparse.rst:1087 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -1879,24 +1887,24 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1089 +#: ../../library/argparse.rst:1095 msgid "" "As the example shows, if an option is marked as ``required``, :meth:" "`~ArgumentParser.parse_args` will report an error if that option is not " "present at the command line." msgstr "" -#: ../../library/argparse.rst:1095 +#: ../../library/argparse.rst:1101 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." msgstr "" -#: ../../library/argparse.rst:1102 +#: ../../library/argparse.rst:1108 msgid "help" msgstr "help" -#: ../../library/argparse.rst:1104 +#: ../../library/argparse.rst:1110 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " @@ -1904,7 +1912,7 @@ msgid "" "each argument." msgstr "" -#: ../../library/argparse.rst:1109 +#: ../../library/argparse.rst:1115 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -1913,7 +1921,7 @@ msgid "" "``%(type)s``, etc.::" msgstr "" -#: ../../library/argparse.rst:1114 +#: ../../library/argparse.rst:1120 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -1939,19 +1947,19 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1126 +#: ../../library/argparse.rst:1132 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." msgstr "" -#: ../../library/argparse.rst:1129 +#: ../../library/argparse.rst:1135 msgid "" ":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:1132 +#: ../../library/argparse.rst:1138 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -1969,11 +1977,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1144 +#: ../../library/argparse.rst:1150 msgid "metavar" msgstr "metavar" -#: ../../library/argparse.rst:1146 +#: ../../library/argparse.rst:1152 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " "refer to each expected argument. By default, :class:`!ArgumentParser` " @@ -1985,7 +1993,7 @@ msgid "" "command-line argument will be referred to as ``FOO``. An example::" msgstr "" -#: ../../library/argparse.rst:1155 +#: ../../library/argparse.rst:1161 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2017,11 +2025,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1170 +#: ../../library/argparse.rst:1176 msgid "An alternative name can be specified with ``metavar``::" msgstr "" -#: ../../library/argparse.rst:1172 +#: ../../library/argparse.rst:1178 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2053,21 +2061,21 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1187 +#: ../../library/argparse.rst:1193 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " "determined by the dest_ value." msgstr "" -#: ../../library/argparse.rst:1191 +#: ../../library/argparse.rst:1197 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " "each of the arguments::" msgstr "" -#: ../../library/argparse.rst:1195 +#: ../../library/argparse.rst:1201 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2091,11 +2099,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1210 +#: ../../library/argparse.rst:1216 msgid "dest" msgstr "dest" -#: ../../library/argparse.rst:1212 +#: ../../library/argparse.rst:1218 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2105,7 +2113,7 @@ msgid "" "add_argument`::" msgstr "" -#: ../../library/argparse.rst:1219 +#: ../../library/argparse.rst:1225 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2117,7 +2125,7 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1224 +#: ../../library/argparse.rst:1230 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2129,7 +2137,7 @@ msgid "" "below illustrate this behavior::" msgstr "" -#: ../../library/argparse.rst:1233 +#: ../../library/argparse.rst:1239 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" @@ -2147,11 +2155,11 @@ msgstr "" ">>> parser.parse_args('--foo 1 -y 2'.split())\n" "Namespace(foo_bar='1', x='2')" -#: ../../library/argparse.rst:1241 +#: ../../library/argparse.rst:1247 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "" -#: ../../library/argparse.rst:1243 +#: ../../library/argparse.rst:1249 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2163,11 +2171,11 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1252 +#: ../../library/argparse.rst:1258 msgid "deprecated" msgstr "deprecated" -#: ../../library/argparse.rst:1254 +#: ../../library/argparse.rst:1260 msgid "" "During a project's lifetime, some arguments may need to be removed from the " "command line. Before removing them, you should inform your users that the " @@ -2178,7 +2186,7 @@ msgid "" "will be printed to :data:`sys.stderr` when the argument is used::" msgstr "" -#: ../../library/argparse.rst:1264 +#: ../../library/argparse.rst:1270 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='snake.py')\n" @@ -2198,11 +2206,11 @@ msgstr "" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" -#: ../../library/argparse.rst:1277 +#: ../../library/argparse.rst:1283 msgid "Action classes" msgstr "Action 類別" -#: ../../library/argparse.rst:1279 +#: ../../library/argparse.rst:1285 msgid "" ":class:`!Action` classes implement the Action API, a callable which returns " "a callable which processes arguments from the command-line. Any object which " @@ -2210,7 +2218,7 @@ msgid "" "`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1288 +#: ../../library/argparse.rst:1294 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 " @@ -2219,7 +2227,7 @@ msgid "" "`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" -#: ../../library/argparse.rst:1294 +#: ../../library/argparse.rst:1300 msgid "" "Instances of :class:`!Action` (or return value of any callable to the " "``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" @@ -2228,46 +2236,46 @@ msgid "" "is to call :meth:`!Action.__init__`." msgstr "" -#: ../../library/argparse.rst:1302 +#: ../../library/argparse.rst:1308 msgid "" ":class:`!Action` instances should be callable, so subclasses must override " "the :meth:`!__call__` method, which should accept four parameters:" msgstr "" -#: ../../library/argparse.rst:1305 +#: ../../library/argparse.rst:1311 msgid "" "*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "" -#: ../../library/argparse.rst:1307 +#: ../../library/argparse.rst:1313 msgid "" "*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " "using :func:`setattr`." msgstr "" -#: ../../library/argparse.rst:1311 +#: ../../library/argparse.rst:1317 msgid "" "*values* - The associated command-line arguments, with any type conversions " "applied. Type conversions are specified with the type_ keyword argument to :" "meth:`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1315 +#: ../../library/argparse.rst:1321 msgid "" "*option_string* - The option string that was used to invoke this action. The " "``option_string`` argument is optional, and will be absent if the action is " "associated with a positional argument." msgstr "" -#: ../../library/argparse.rst:1319 +#: ../../library/argparse.rst:1325 msgid "" "The :meth:`!__call__` method may perform arbitrary actions, but will " "typically set attributes on the ``namespace`` based on ``dest`` and " "``values``." msgstr "" -#: ../../library/argparse.rst:1324 +#: ../../library/argparse.rst:1330 msgid "" ":class:`!Action` subclasses can define a :meth:`!format_usage` method that " "takes no argument and return a string which will be used when printing the " @@ -2275,7 +2283,7 @@ msgid "" "will be used." msgstr "" -#: ../../library/argparse.rst:1330 +#: ../../library/argparse.rst:1336 msgid "" "A subclass of :class:`Action` for handling boolean flags with positive and " "negative options. Adding a single argument such as ``--foo`` automatically " @@ -2283,7 +2291,7 @@ msgid "" "``False`` respectively::" msgstr "" -#: ../../library/argparse.rst:1335 +#: ../../library/argparse.rst:1341 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -2297,47 +2305,47 @@ msgstr "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" -#: ../../library/argparse.rst:1345 +#: ../../library/argparse.rst:1351 msgid "The parse_args() method" msgstr "parse_args() 方法" -#: ../../library/argparse.rst:1349 +#: ../../library/argparse.rst:1355 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" -#: ../../library/argparse.rst:1352 +#: ../../library/argparse.rst:1358 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " "created and how they are assigned. See the documentation for :meth:`!" "add_argument` for details." msgstr "" -#: ../../library/argparse.rst:1356 +#: ../../library/argparse.rst:1362 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "" -#: ../../library/argparse.rst:1359 +#: ../../library/argparse.rst:1365 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" -#: ../../library/argparse.rst:1364 +#: ../../library/argparse.rst:1370 msgid "Option value syntax" msgstr "" -#: ../../library/argparse.rst:1366 +#: ../../library/argparse.rst:1372 msgid "" "The :meth:`~ArgumentParser.parse_args` method supports several ways of " "specifying the value of an option (if it takes one). In the simplest case, " "the option and its value are passed as two separate arguments::" msgstr "" -#: ../../library/argparse.rst:1370 +#: ../../library/argparse.rst:1376 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2355,14 +2363,14 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1378 +#: ../../library/argparse.rst:1384 msgid "" "For long options (options with names longer than a single character), the " "option and value can also be passed as a single command-line argument, using " "``=`` to separate them::" msgstr "" -#: ../../library/argparse.rst:1382 +#: ../../library/argparse.rst:1388 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2370,13 +2378,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1385 +#: ../../library/argparse.rst:1391 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "" -#: ../../library/argparse.rst:1388 +#: ../../library/argparse.rst:1394 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2384,13 +2392,13 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1391 +#: ../../library/argparse.rst:1397 msgid "" "Several short options can be joined together, using only a single ``-`` " "prefix, as long as only the last option (or none of them) requires a value::" msgstr "" -#: ../../library/argparse.rst:1394 +#: ../../library/argparse.rst:1400 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2406,11 +2414,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1403 +#: ../../library/argparse.rst:1409 msgid "Invalid arguments" msgstr "無效引數" -#: ../../library/argparse.rst:1405 +#: ../../library/argparse.rst:1411 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -2418,7 +2426,7 @@ msgid "" "an error, it exits and prints the error along with a usage message::" msgstr "" -#: ../../library/argparse.rst:1410 +#: ../../library/argparse.rst:1416 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -2458,11 +2466,11 @@ msgstr "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: extra arguments found: badger" -#: ../../library/argparse.rst:1431 +#: ../../library/argparse.rst:1437 msgid "Arguments containing ``-``" msgstr "包含 ``-`` 的引數" -#: ../../library/argparse.rst:1433 +#: ../../library/argparse.rst:1439 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -2474,7 +2482,7 @@ msgid "" "negative numbers::" msgstr "" -#: ../../library/argparse.rst:1441 +#: ../../library/argparse.rst:1447 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2507,7 +2515,7 @@ msgid "" "PROG: error: argument -1: expected one argument" msgstr "" -#: ../../library/argparse.rst:1471 +#: ../../library/argparse.rst:1477 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -2515,7 +2523,7 @@ msgid "" "positional argument::" msgstr "" -#: ../../library/argparse.rst:1476 +#: ../../library/argparse.rst:1482 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -2523,24 +2531,24 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1479 +#: ../../library/argparse.rst:1485 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" -#: ../../library/argparse.rst:1485 +#: ../../library/argparse.rst:1491 msgid "Argument abbreviations (prefix matching)" msgstr "引數縮寫 (前綴匹配)" -#: ../../library/argparse.rst:1487 +#: ../../library/argparse.rst:1493 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " "abbreviation is unambiguous (the prefix matches a unique option)::" msgstr "" -#: ../../library/argparse.rst:1491 +#: ../../library/argparse.rst:1497 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -2564,17 +2572,17 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1502 +#: ../../library/argparse.rst:1508 msgid "" "An error is produced for arguments that could produce more than one options. " "This feature can be disabled by setting :ref:`allow_abbrev` to ``False``." msgstr "" -#: ../../library/argparse.rst:1508 +#: ../../library/argparse.rst:1514 msgid "Beyond ``sys.argv``" msgstr "" -#: ../../library/argparse.rst:1510 +#: ../../library/argparse.rst:1516 msgid "" "Sometimes it may be useful to have an :class:`ArgumentParser` parse " "arguments other than those of :data:`sys.argv`. This can be accomplished by " @@ -2582,7 +2590,7 @@ msgid "" "useful for testing at the interactive prompt::" msgstr "" -#: ../../library/argparse.rst:1515 +#: ../../library/argparse.rst:1521 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -2608,24 +2616,24 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1530 +#: ../../library/argparse.rst:1536 msgid "The Namespace object" msgstr "命名空間物件" -#: ../../library/argparse.rst:1534 +#: ../../library/argparse.rst:1540 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." msgstr "" -#: ../../library/argparse.rst:1537 +#: ../../library/argparse.rst:1543 msgid "" "This class is deliberately simple, just an :class:`object` subclass with a " "readable string representation. If you prefer to have dict-like view of the " "attributes, you can use the standard Python idiom, :func:`vars`::" msgstr "" -#: ../../library/argparse.rst:1541 +#: ../../library/argparse.rst:1547 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2639,14 +2647,14 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1547 +#: ../../library/argparse.rst:1553 msgid "" "It may also be useful to have an :class:`ArgumentParser` assign attributes " "to an already existing object, rather than a new :class:`Namespace` object. " "This can be achieved by specifying the ``namespace=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:1551 +#: ../../library/argparse.rst:1557 msgid "" ">>> class C:\n" "... pass\n" @@ -2668,15 +2676,15 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1563 +#: ../../library/argparse.rst:1569 msgid "Other utilities" msgstr "" -#: ../../library/argparse.rst:1566 +#: ../../library/argparse.rst:1572 msgid "Sub-commands" msgstr "子命令" -#: ../../library/argparse.rst:1573 +#: ../../library/argparse.rst:1579 msgid "" "Many programs split up their functionality into a number of subcommands, for " "example, the ``svn`` program can invoke subcommands like ``svn checkout``, " @@ -2691,69 +2699,69 @@ msgid "" "returns an :class:`!ArgumentParser` object that can be modified as usual." msgstr "" -#: ../../library/argparse.rst:1585 +#: ../../library/argparse.rst:1591 msgid "Description of parameters:" msgstr "參數的解釋:" -#: ../../library/argparse.rst:1587 +#: ../../library/argparse.rst:1593 msgid "" "*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " "positional arguments" msgstr "" -#: ../../library/argparse.rst:1591 +#: ../../library/argparse.rst:1597 msgid "" "*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" -#: ../../library/argparse.rst:1594 +#: ../../library/argparse.rst:1600 msgid "" "*prog* - usage information that will be displayed with sub-command help, by " "default the name of the program and any positional arguments before the " "subparser argument" msgstr "" -#: ../../library/argparse.rst:1598 +#: ../../library/argparse.rst:1604 msgid "" "*parser_class* - class which will be used to create sub-parser instances, by " "default the class of the current parser (e.g. :class:`ArgumentParser`)" msgstr "" -#: ../../library/argparse.rst:1601 +#: ../../library/argparse.rst:1607 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "" -#: ../../library/argparse.rst:1604 +#: ../../library/argparse.rst:1610 msgid "" "dest_ - name of the attribute under which sub-command name will be stored; " "by default ``None`` and no value is stored" msgstr "" -#: ../../library/argparse.rst:1607 +#: ../../library/argparse.rst:1613 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "" -#: ../../library/argparse.rst:1610 +#: ../../library/argparse.rst:1616 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "" -#: ../../library/argparse.rst:1612 +#: ../../library/argparse.rst:1618 msgid "" "metavar_ - string presenting available subcommands in help; by default it is " "``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" -#: ../../library/argparse.rst:1615 +#: ../../library/argparse.rst:1621 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1617 +#: ../../library/argparse.rst:1623 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -2776,7 +2784,7 @@ msgid "" "Namespace(baz='Z', foo=True)" msgstr "" -#: ../../library/argparse.rst:1636 +#: ../../library/argparse.rst:1642 msgid "" "Note that the object returned by :meth:`parse_args` will only contain " "attributes for the main parser and the subparser that was selected by the " @@ -2786,7 +2794,7 @@ msgid "" "``baz`` attributes are present." msgstr "" -#: ../../library/argparse.rst:1643 +#: ../../library/argparse.rst:1649 msgid "" "Similarly, when a help message is requested from a subparser, only the help " "for that particular parser will be printed. The help message will not " @@ -2795,7 +2803,7 @@ msgid "" "to :meth:`~_SubParsersAction.add_parser` as above.)" msgstr "" -#: ../../library/argparse.rst:1651 +#: ../../library/argparse.rst:1657 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" @@ -2853,14 +2861,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1679 +#: ../../library/argparse.rst:1685 msgid "" "The :meth:`add_subparsers` method also supports ``title`` and " "``description`` keyword arguments. When either is present, the subparser's " "commands will appear in their own group in the help output. For example::" msgstr "" -#: ../../library/argparse.rst:1683 +#: ../../library/argparse.rst:1689 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -2896,7 +2904,7 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1700 +#: ../../library/argparse.rst:1706 msgid "" "Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " "*aliases* argument, which allows multiple strings to refer to the same " @@ -2904,7 +2912,7 @@ msgid "" "``checkout``::" msgstr "" -#: ../../library/argparse.rst:1705 +#: ../../library/argparse.rst:1711 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -2920,13 +2928,13 @@ msgstr "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" -#: ../../library/argparse.rst:1712 +#: ../../library/argparse.rst:1718 msgid "" ":meth:`~_SubParsersAction.add_parser` supports also an additional " "*deprecated* argument, which allows to deprecate the subparser." msgstr "" -#: ../../library/argparse.rst:1726 +#: ../../library/argparse.rst:1732 msgid "" "One particularly effective way of handling subcommands is to combine the use " "of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so " @@ -2934,7 +2942,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:1731 +#: ../../library/argparse.rst:1737 msgid "" ">>> # subcommand functions\n" ">>> def foo(args):\n" @@ -2969,7 +2977,7 @@ msgid "" "((XYZYX))" msgstr "" -#: ../../library/argparse.rst:1763 +#: ../../library/argparse.rst:1769 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -2979,7 +2987,7 @@ msgid "" "argument to the :meth:`add_subparsers` call will work::" msgstr "" -#: ../../library/argparse.rst:1770 +#: ../../library/argparse.rst:1776 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -2999,15 +3007,15 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1779 +#: ../../library/argparse.rst:1785 msgid "New *required* keyword-only parameter." msgstr "" -#: ../../library/argparse.rst:1784 +#: ../../library/argparse.rst:1790 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1788 +#: ../../library/argparse.rst:1794 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -3016,7 +3024,7 @@ msgid "" "the :func:`open` function for more details)::" msgstr "" -#: ../../library/argparse.rst:1794 +#: ../../library/argparse.rst:1800 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3034,14 +3042,14 @@ msgstr "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" -#: ../../library/argparse.rst:1800 +#: ../../library/argparse.rst:1806 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " "and :data:`sys.stdout` for writable :class:`FileType` objects::" msgstr "" -#: ../../library/argparse.rst:1804 +#: ../../library/argparse.rst:1810 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -3053,15 +3061,15 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1809 +#: ../../library/argparse.rst:1815 msgid "Added the *encodings* and *errors* parameters." msgstr "" -#: ../../library/argparse.rst:1814 +#: ../../library/argparse.rst:1820 msgid "Argument groups" msgstr "" -#: ../../library/argparse.rst:1819 +#: ../../library/argparse.rst:1825 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " @@ -3070,7 +3078,7 @@ msgid "" "method::" msgstr "" -#: ../../library/argparse.rst:1825 +#: ../../library/argparse.rst:1831 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3094,7 +3102,7 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:1836 +#: ../../library/argparse.rst:1842 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" @@ -3105,7 +3113,7 @@ msgid "" "this display::" msgstr "" -#: ../../library/argparse.rst:1844 +#: ../../library/argparse.rst:1850 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3143,7 +3151,7 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1862 +#: ../../library/argparse.rst:1868 msgid "" "The optional, keyword-only parameters argument_default_ and " "conflict_handler_ allow for finer-grained control of the behavior of the " @@ -3152,13 +3160,13 @@ msgid "" "rather than the entire parser." msgstr "" -#: ../../library/argparse.rst:1867 +#: ../../library/argparse.rst:1873 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." msgstr "" -#: ../../library/argparse.rst:1870 +#: ../../library/argparse.rst:1876 msgid "" "Calling :meth:`add_argument_group` on an argument group is deprecated. This " "feature was never supported and does not always work correctly. The function " @@ -3166,18 +3174,18 @@ msgid "" "future." msgstr "" -#: ../../library/argparse.rst:1878 +#: ../../library/argparse.rst:1884 msgid "Mutual exclusion" msgstr "" -#: ../../library/argparse.rst:1882 +#: ../../library/argparse.rst:1888 msgid "" "Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " "command line::" msgstr "" -#: ../../library/argparse.rst:1886 +#: ../../library/argparse.rst:1892 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3203,14 +3211,14 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:1898 +#: ../../library/argparse.rst:1904 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " "is required::" msgstr "" -#: ../../library/argparse.rst:1902 +#: ../../library/argparse.rst:1908 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3228,7 +3236,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:1910 +#: ../../library/argparse.rst:1916 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -3236,7 +3244,7 @@ msgid "" "argument group that has a title and description. For example::" msgstr "" -#: ../../library/argparse.rst:1916 +#: ../../library/argparse.rst:1922 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -3272,7 +3280,7 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1933 +#: ../../library/argparse.rst:1939 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group is deprecated. These features were never " @@ -3280,11 +3288,11 @@ msgid "" "by accident through inheritance and will be removed in the future." msgstr "" -#: ../../library/argparse.rst:1941 +#: ../../library/argparse.rst:1947 msgid "Parser defaults" msgstr "" -#: ../../library/argparse.rst:1945 +#: ../../library/argparse.rst:1951 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -3293,7 +3301,7 @@ msgid "" "command line to be added::" msgstr "" -#: ../../library/argparse.rst:1951 +#: ../../library/argparse.rst:1957 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -3307,12 +3315,12 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:1957 +#: ../../library/argparse.rst:1963 msgid "" "Note that parser-level defaults always override argument-level defaults::" msgstr "" -#: ../../library/argparse.rst:1959 +#: ../../library/argparse.rst:1965 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -3326,20 +3334,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:1965 +#: ../../library/argparse.rst:1971 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " "example of this type." msgstr "" -#: ../../library/argparse.rst:1971 +#: ../../library/argparse.rst:1977 msgid "" "Get the default value for a namespace attribute, as set by either :meth:" "`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" msgstr "" -#: ../../library/argparse.rst:1975 +#: ../../library/argparse.rst:1981 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -3351,54 +3359,54 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:1982 +#: ../../library/argparse.rst:1988 msgid "Printing help" msgstr "印出幫助訊息" -#: ../../library/argparse.rst:1984 +#: ../../library/argparse.rst:1990 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " "several formatting methods are available:" msgstr "" -#: ../../library/argparse.rst:1990 +#: ../../library/argparse.rst:1996 msgid "" "Print a brief description of how the :class:`ArgumentParser` should be " "invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is " "assumed." msgstr "" -#: ../../library/argparse.rst:1996 +#: ../../library/argparse.rst:2002 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " "``None``, :data:`sys.stdout` is assumed." msgstr "" -#: ../../library/argparse.rst:2000 +#: ../../library/argparse.rst:2006 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "" -#: ../../library/argparse.rst:2005 +#: ../../library/argparse.rst:2011 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" -#: ../../library/argparse.rst:2010 +#: ../../library/argparse.rst:2016 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:2015 +#: ../../library/argparse.rst:2021 msgid "Partial parsing" msgstr "" -#: ../../library/argparse.rst:2019 +#: ../../library/argparse.rst:2025 msgid "" "Sometimes a script only needs to handle a specific set of command-line " "arguments, leaving any unrecognized arguments for another script or program. " @@ -3406,7 +3414,7 @@ msgid "" "useful." msgstr "" -#: ../../library/argparse.rst:2024 +#: ../../library/argparse.rst:2030 msgid "" "This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " "does not raise an error for extra, unrecognized arguments. Instead, it " @@ -3414,7 +3422,7 @@ msgid "" "populated namespace and the list of any unrecognized arguments." msgstr "" -#: ../../library/argparse.rst:2031 +#: ../../library/argparse.rst:2037 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3428,7 +3436,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2038 +#: ../../library/argparse.rst:2044 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -3436,11 +3444,11 @@ msgid "" "remaining arguments list." msgstr "" -#: ../../library/argparse.rst:2045 +#: ../../library/argparse.rst:2051 msgid "Customizing file parsing" msgstr "" -#: ../../library/argparse.rst:2049 +#: ../../library/argparse.rst:2055 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -3448,20 +3456,20 @@ msgid "" "reading." msgstr "" -#: ../../library/argparse.rst:2054 +#: ../../library/argparse.rst:2060 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:2058 +#: ../../library/argparse.rst:2064 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:2061 +#: ../../library/argparse.rst:2067 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -3471,18 +3479,18 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2067 +#: ../../library/argparse.rst:2073 msgid "Exiting methods" msgstr "" -#: ../../library/argparse.rst:2071 +#: ../../library/argparse.rst:2077 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:2075 +#: ../../library/argparse.rst:2081 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3496,17 +3504,17 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2083 +#: ../../library/argparse.rst:2089 msgid "" "This method prints a usage message, including the *message*, to :data:`sys." "stderr` and terminates the program with a status code of 2." msgstr "" -#: ../../library/argparse.rst:2088 +#: ../../library/argparse.rst:2094 msgid "Intermixed parsing" msgstr "" -#: ../../library/argparse.rst:2093 +#: ../../library/argparse.rst:2099 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -3514,7 +3522,7 @@ msgid "" "parsing style." msgstr "" -#: ../../library/argparse.rst:2098 +#: ../../library/argparse.rst:2104 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " @@ -3522,7 +3530,7 @@ msgid "" "positionals are not supported." msgstr "" -#: ../../library/argparse.rst:2103 +#: ../../library/argparse.rst:2109 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -3530,7 +3538,7 @@ msgid "" "collects all the positionals into ``rest``. ::" msgstr "" -#: ../../library/argparse.rst:2109 +#: ../../library/argparse.rst:2115 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3550,7 +3558,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:2118 +#: ../../library/argparse.rst:2124 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -3558,11 +3566,11 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: ../../library/argparse.rst:2127 +#: ../../library/argparse.rst:2133 msgid "Registering custom types or actions" msgstr "" -#: ../../library/argparse.rst:2131 +#: ../../library/argparse.rst:2137 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 " @@ -3570,7 +3578,7 @@ msgid "" "the type by their registered name instead of their callable name." msgstr "" -#: ../../library/argparse.rst:2136 +#: ../../library/argparse.rst:2142 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " @@ -3578,12 +3586,12 @@ msgid "" "be registered, and object, the callable to be registered." msgstr "" -#: ../../library/argparse.rst:2141 +#: ../../library/argparse.rst:2147 msgid "" "The following example shows how to register a custom type with a parser::" msgstr "" -#: ../../library/argparse.rst:2143 +#: ../../library/argparse.rst:2149 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -3599,42 +3607,42 @@ msgid "" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" -#: ../../library/argparse.rst:2155 +#: ../../library/argparse.rst:2161 msgid "Exceptions" msgstr "例外" -#: ../../library/argparse.rst:2159 +#: ../../library/argparse.rst:2165 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: ../../library/argparse.rst:2161 +#: ../../library/argparse.rst:2167 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: ../../library/argparse.rst:2166 +#: ../../library/argparse.rst:2172 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: ../../library/argparse.rst:2170 +#: ../../library/argparse.rst:2176 msgid "Guides and Tutorials" msgstr "" -#: ../../library/argparse.rst:803 +#: ../../library/argparse.rst:809 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:803 ../../library/argparse.rst:837 -#: ../../library/argparse.rst:851 +#: ../../library/argparse.rst:809 ../../library/argparse.rst:843 +#: ../../library/argparse.rst:857 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:837 +#: ../../library/argparse.rst:843 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:851 +#: ../../library/argparse.rst:857 msgid "+ (plus)" msgstr "+ (加號)" diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index 90bb2b684a..c12c90e6e0 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-23 00:15+0000\n" +"POT-Creation-Date: 2025-07-26 00:17+0000\n" "PO-Revision-Date: 2022-02-20 18:34+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -162,31 +162,56 @@ msgid "Return the number of items in the queue." msgstr "回傳佇列中的元素數量。" #: ../../library/asyncio-queue.rst:105 -msgid "" -"Shut down the queue, making :meth:`~Queue.get` and :meth:`~Queue.put` raise :" -"exc:`QueueShutDown`." +msgid "Put a :class:`Queue` instance into a shutdown mode." msgstr "" -#: ../../library/asyncio-queue.rst:108 +#: ../../library/asyncio-queue.rst:107 msgid "" -"By default, :meth:`~Queue.get` on a shut down queue will only raise once the " -"queue is empty. Set *immediate* to true to make :meth:`~Queue.get` raise " -"immediately instead." +"The queue can no longer grow. Future calls to :meth:`~Queue.put` raise :exc:" +"`QueueShutDown`. Currently blocked callers of :meth:`~Queue.put` will be " +"unblocked and will raise :exc:`QueueShutDown` in the formerly blocked thread." msgstr "" #: ../../library/asyncio-queue.rst:112 msgid "" -"All blocked callers of :meth:`~Queue.put` and :meth:`~Queue.get` will be " -"unblocked. If *immediate* is true, a task will be marked as done for each " -"remaining item in the queue, which may unblock callers of :meth:`~Queue." -"join`." +"If *immediate* is false (the default), the queue can be wound down normally " +"with :meth:`~Queue.get` calls to extract tasks that have already been loaded." +msgstr "" + +#: ../../library/asyncio-queue.rst:116 +msgid "" +"And if :meth:`~Queue.task_done` is called for each remaining task, a " +"pending :meth:`~Queue.join` will be unblocked normally." +msgstr "" + +#: ../../library/asyncio-queue.rst:119 +msgid "" +"Once the queue is empty, future calls to :meth:`~Queue.get` will raise :exc:" +"`QueueShutDown`." +msgstr "" + +#: ../../library/asyncio-queue.rst:122 +msgid "" +"If *immediate* is true, the queue is terminated immediately. The queue is " +"drained to be completely empty and the count of unfinished tasks is reduced " +"by the number of tasks drained. If unfinished tasks is zero, callers of :" +"meth:`~Queue.join` are unblocked. Also, blocked callers of :meth:`~Queue." +"get` are unblocked and will raise :exc:`QueueShutDown` because the queue is " +"empty." +msgstr "" + +#: ../../library/asyncio-queue.rst:130 +msgid "" +"Use caution when using :meth:`~Queue.join` with *immediate* set to true. " +"This unblocks the join even when no work has been done on the tasks, " +"violating the usual invariant for joining a queue." msgstr "" -#: ../../library/asyncio-queue.rst:121 +#: ../../library/asyncio-queue.rst:138 msgid "Indicate that a formerly enqueued work item is complete." msgstr "表示前面一個排隊的工作項目已經完成。" -#: ../../library/asyncio-queue.rst:123 +#: ../../library/asyncio-queue.rst:140 msgid "" "Used by queue consumers. For each :meth:`~Queue.get` used to fetch a work " "item, a subsequent call to :meth:`task_done` tells the queue that the " @@ -195,7 +220,7 @@ msgstr "" "由佇列消耗者使用。對於每個用於取得一個工作項目的 :meth:`~Queue.get`,接續的 :" "meth:`task_done` 呼叫會告訴佇列這個工作項目的處理已經完成。" -#: ../../library/asyncio-queue.rst:127 +#: ../../library/asyncio-queue.rst:144 msgid "" "If a :meth:`join` is currently blocking, it will resume when all items have " "been processed (meaning that a :meth:`task_done` call was received for every " @@ -204,53 +229,47 @@ msgstr "" "如果 :meth:`join` 目前正在阻塞,在所有項目都被處理後會解除阻塞(意味著每個" "以 :meth:`~Queue.put` 放進佇列的條目都會收到一個 :meth:`task_done`)。" -#: ../../library/asyncio-queue.rst:132 -msgid "" -"``shutdown(immediate=True)`` calls :meth:`task_done` for each remaining item " -"in the queue." -msgstr "" - -#: ../../library/asyncio-queue.rst:135 +#: ../../library/asyncio-queue.rst:149 msgid "" "Raises :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "如果被呼叫的次數多於放入佇列中的項目數量,將引發 :exc:`ValueError`。" -#: ../../library/asyncio-queue.rst:140 +#: ../../library/asyncio-queue.rst:154 msgid "Priority Queue" msgstr "Priority Queue(優先佇列)" -#: ../../library/asyncio-queue.rst:144 +#: ../../library/asyncio-queue.rst:158 msgid "" "A variant of :class:`Queue`; retrieves entries in priority order (lowest " "first)." msgstr ":class:`Queue` 的變形;按優先順序取出條目 (最小的先取出)。" -#: ../../library/asyncio-queue.rst:147 +#: ../../library/asyncio-queue.rst:161 msgid "Entries are typically tuples of the form ``(priority_number, data)``." msgstr "條目通常是 ``(priority_number, data)`` 形式的 tuple(元組)。" -#: ../../library/asyncio-queue.rst:152 +#: ../../library/asyncio-queue.rst:166 msgid "LIFO Queue" msgstr "LIFO Queue" -#: ../../library/asyncio-queue.rst:156 +#: ../../library/asyncio-queue.rst:170 msgid "" "A variant of :class:`Queue` that retrieves most recently added entries first " "(last in, first out)." msgstr ":class:`Queue` 的變形,先取出最近新增的條目(後進先出)。" -#: ../../library/asyncio-queue.rst:161 +#: ../../library/asyncio-queue.rst:175 msgid "Exceptions" msgstr "例外" -#: ../../library/asyncio-queue.rst:165 +#: ../../library/asyncio-queue.rst:179 msgid "" "This exception is raised when the :meth:`~Queue.get_nowait` method is called " "on an empty queue." msgstr "當佇列為空的時候,呼叫 :meth:`~Queue.get_nowait` 方法會引發這個例外。" -#: ../../library/asyncio-queue.rst:171 +#: ../../library/asyncio-queue.rst:185 msgid "" "Exception raised when the :meth:`~Queue.put_nowait` method is called on a " "queue that has reached its *maxsize*." @@ -258,22 +277,22 @@ msgstr "" "當佇列中條目數量已經達到它的 *maxsize* 時,呼叫 :meth:`~Queue.put_nowait` 方" "法會引發這個例外。" -#: ../../library/asyncio-queue.rst:177 +#: ../../library/asyncio-queue.rst:191 msgid "" "Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is called on " "a queue which has been shut down." msgstr "" -#: ../../library/asyncio-queue.rst:184 +#: ../../library/asyncio-queue.rst:198 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-queue.rst:188 +#: ../../library/asyncio-queue.rst:202 msgid "" "Queues can be used to distribute workload between several concurrent tasks::" msgstr "佇列能被用於多個並行任務的工作分配:" -#: ../../library/asyncio-queue.rst:191 +#: ../../library/asyncio-queue.rst:205 msgid "" "import asyncio\n" "import random\n" diff --git a/library/codecs.po b/library/codecs.po index 119ea7ec55..fdd1bfcb7c 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-14 00:18+0000\n" +"POT-Creation-Date: 2025-07-28 00:20+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-" @@ -397,7 +397,7 @@ msgstr "" #: ../../library/codecs.rst:352 ../../library/codecs.rst:395 #: ../../library/codecs.rst:415 ../../library/codecs.rst:1360 -#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1487 +#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 msgid "Meaning" msgstr "含義" @@ -1404,12 +1404,12 @@ msgid "an IBM PC code page, which is ASCII compatible" msgstr "" #: ../../library/codecs.rst:1104 ../../library/codecs.rst:1360 -#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1487 +#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 msgid "Codec" msgstr "" #: ../../library/codecs.rst:1104 ../../library/codecs.rst:1360 -#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1487 +#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 msgid "Aliases" msgstr "" @@ -2569,49 +2569,86 @@ msgid "Restoration of the aliases for the binary transforms." msgstr "" #: ../../library/codecs.rst:1478 -msgid "Text Transforms" +msgid "Standalone Codec Functions" msgstr "" #: ../../library/codecs.rst:1480 msgid "" +"The following functions provide encoding and decoding functionality similar " +"to codecs, but are not available as named codecs through :func:`codecs." +"encode` or :func:`codecs.decode`. They are used internally (for example, by :" +"mod:`pickle`) and behave similarly to the ``string_escape`` codec that was " +"removed in Python 3." +msgstr "" + +#: ../../library/codecs.rst:1487 +msgid "" +"Encode *input* using escape sequences. Similar to how :func:`repr` on bytes " +"produces escaped byte values." +msgstr "" + +#: ../../library/codecs.rst:1490 +msgid "*input* must be a :class:`bytes` object." +msgstr "*input* 必須是 :class:`bytes` 物件。" + +#: ../../library/codecs.rst:1492 ../../library/codecs.rst:1501 +msgid "" +"Returns a tuple ``(output, length)`` where *output* is a :class:`bytes` " +"object and *length* is the number of bytes consumed." +msgstr "" + +#: ../../library/codecs.rst:1497 +msgid "Decode *input* from escape sequences back to the original bytes." +msgstr "" + +#: ../../library/codecs.rst:1499 +msgid "*input* must be a :term:`bytes-like object`." +msgstr "*input* 必須是 :term:`bytes-like object`。" + +#: ../../library/codecs.rst:1508 +msgid "Text Transforms" +msgstr "" + +#: ../../library/codecs.rst:1510 +msgid "" "The following codec provides a text transform: a :class:`str` to :class:" "`str` mapping. It is not supported by :meth:`str.encode` (which only " "produces :class:`bytes` output)." msgstr "" -#: ../../library/codecs.rst:1489 +#: ../../library/codecs.rst:1519 msgid "rot_13" msgstr "rot_13" -#: ../../library/codecs.rst:1489 +#: ../../library/codecs.rst:1519 msgid "rot13" msgstr "" -#: ../../library/codecs.rst:1489 +#: ../../library/codecs.rst:1519 msgid "Return the Caesar-cypher encryption of the operand." msgstr "" -#: ../../library/codecs.rst:1494 +#: ../../library/codecs.rst:1524 msgid "Restoration of the ``rot_13`` text transform." msgstr "" -#: ../../library/codecs.rst:1497 +#: ../../library/codecs.rst:1527 msgid "Restoration of the ``rot13`` alias." msgstr "" -#: ../../library/codecs.rst:1502 +#: ../../library/codecs.rst:1532 msgid ":mod:`encodings` --- Encodings package" msgstr "" -#: ../../library/codecs.rst:1507 +#: ../../library/codecs.rst:1537 msgid "This module implements the following functions:" msgstr "" -#: ../../library/codecs.rst:1511 +#: ../../library/codecs.rst:1541 msgid "Normalize encoding name *encoding*." msgstr "" -#: ../../library/codecs.rst:1513 +#: ../../library/codecs.rst:1543 msgid "" "Normalization works as follows: all non-alphanumeric characters except the " "dot used for Python package names are collapsed and replaced with a single " @@ -2619,23 +2656,23 @@ msgid "" "-;#'`` becomes ``'_'``." msgstr "" -#: ../../library/codecs.rst:1518 +#: ../../library/codecs.rst:1548 msgid "Note that *encoding* should be ASCII only." msgstr "" -#: ../../library/codecs.rst:1522 +#: ../../library/codecs.rst:1552 msgid "" "The following function should not be used directly, except for testing " "purposes; :func:`codecs.lookup` should be used instead." msgstr "" -#: ../../library/codecs.rst:1528 +#: ../../library/codecs.rst:1558 msgid "" "Search for the codec module corresponding to the given encoding name " "*encoding*." msgstr "" -#: ../../library/codecs.rst:1531 +#: ../../library/codecs.rst:1561 msgid "" "This function first normalizes the *encoding* using :func:" "`normalize_encoding`, then looks for a corresponding alias. It attempts to " @@ -2645,26 +2682,26 @@ msgid "" "the codec is cached and returned." msgstr "" -#: ../../library/codecs.rst:1538 +#: ../../library/codecs.rst:1568 msgid "" "If the codec module defines a ``getaliases()`` function any returned aliases " "are registered for future use." msgstr "" -#: ../../library/codecs.rst:1542 +#: ../../library/codecs.rst:1572 msgid "This module implements the following exception:" msgstr "" -#: ../../library/codecs.rst:1546 +#: ../../library/codecs.rst:1576 msgid "Raised when a codec is invalid or incompatible." msgstr "" -#: ../../library/codecs.rst:1550 +#: ../../library/codecs.rst:1580 msgid "" ":mod:`encodings.idna` --- Internationalized Domain Names in Applications" msgstr "" -#: ../../library/codecs.rst:1556 +#: ../../library/codecs.rst:1586 msgid "" "This module implements :rfc:`3490` (Internationalized Domain Names in " "Applications) and :rfc:`3492` (Nameprep: A Stringprep Profile for " @@ -2672,13 +2709,13 @@ msgid "" "encoding and :mod:`stringprep`." msgstr "" -#: ../../library/codecs.rst:1561 +#: ../../library/codecs.rst:1591 msgid "" "If you need the IDNA 2008 standard from :rfc:`5891` and :rfc:`5895`, use the " "third-party :pypi:`idna` module." msgstr "" -#: ../../library/codecs.rst:1564 +#: ../../library/codecs.rst:1594 msgid "" "These RFCs together define a protocol to support non-ASCII characters in " "domain names. A domain name containing non-ASCII characters (such as ``www." @@ -2692,7 +2729,7 @@ msgid "" "presenting them to the user." msgstr "" -#: ../../library/codecs.rst:1575 +#: ../../library/codecs.rst:1605 msgid "" "Python supports this conversion in several ways: the ``idna`` codec " "performs conversion between Unicode and ACE, separating an input string into " @@ -2709,14 +2746,14 @@ msgid "" "sends that field at all)." msgstr "" -#: ../../library/codecs.rst:1588 +#: ../../library/codecs.rst:1618 msgid "" "When receiving host names from the wire (such as in reverse name lookup), no " "automatic conversion to Unicode is performed: applications wishing to " "present such host names to the user should decode them to Unicode." msgstr "" -#: ../../library/codecs.rst:1592 +#: ../../library/codecs.rst:1622 msgid "" "The module :mod:`encodings.idna` also implements the nameprep procedure, " "which performs certain normalizations on host names, to achieve case-" @@ -2724,49 +2761,49 @@ msgid "" "characters. The nameprep functions can be used directly if desired." msgstr "" -#: ../../library/codecs.rst:1600 +#: ../../library/codecs.rst:1630 msgid "" "Return the nameprepped version of *label*. The implementation currently " "assumes query strings, so ``AllowUnassigned`` is true." msgstr "" -#: ../../library/codecs.rst:1606 +#: ../../library/codecs.rst:1636 msgid "" "Convert a label to ASCII, as specified in :rfc:`3490`. ``UseSTD3ASCIIRules`` " "is assumed to be false." msgstr "" -#: ../../library/codecs.rst:1612 +#: ../../library/codecs.rst:1642 msgid "Convert a label to Unicode, as specified in :rfc:`3490`." msgstr "" -#: ../../library/codecs.rst:1616 +#: ../../library/codecs.rst:1646 msgid ":mod:`encodings.mbcs` --- Windows ANSI codepage" msgstr ":mod:`encodings.mbcs` --- Windows ANSI 碼頁" -#: ../../library/codecs.rst:1621 +#: ../../library/codecs.rst:1651 msgid "This module implements the ANSI codepage (CP_ACP)." msgstr "這個模組實作了 ANSI 碼頁 (CP_ACP)。" -#: ../../library/codecs.rst:1623 +#: ../../library/codecs.rst:1653 msgid "Availability" msgstr "可用性" -#: ../../library/codecs.rst:1625 +#: ../../library/codecs.rst:1655 msgid "" "Before 3.2, the *errors* argument was ignored; ``'replace'`` was always used " "to encode, and ``'ignore'`` to decode." msgstr "" -#: ../../library/codecs.rst:1629 +#: ../../library/codecs.rst:1659 msgid "Support any error handler." msgstr "" -#: ../../library/codecs.rst:1634 +#: ../../library/codecs.rst:1664 msgid ":mod:`encodings.utf_8_sig` --- UTF-8 codec with BOM signature" msgstr "" -#: ../../library/codecs.rst:1640 +#: ../../library/codecs.rst:1670 msgid "" "This module implements a variant of the UTF-8 codec. On encoding, a UTF-8 " "encoded BOM will be prepended to the UTF-8 encoded bytes. For the stateful " diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 6fefd66842..37d9b928e7 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-22 00:13+0000\n" +"POT-Creation-Date: 2025-07-28 00:20+0000\n" "PO-Revision-Date: 2023-01-24 03:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -41,10 +41,10 @@ msgstr "" #: ../../library/concurrent.futures.rst:17 msgid "" -"The asynchronous execution can be performed with threads, " -"using :class:`ThreadPoolExecutor`, or separate processes, " -"using :class:`ProcessPoolExecutor`. Both implement the same interface, " -"which is defined by the abstract :class:`Executor` class." +"The asynchronous execution can be performed with threads, using :class:" +"`ThreadPoolExecutor`, or separate processes, using :class:" +"`ProcessPoolExecutor`. Both implement the same interface, which is defined " +"by the abstract :class:`Executor` class." msgstr "" "非同步執行可以透過 :class:`ThreadPoolExecutor` 來使用執行緒 (thread) 執行,或" "透過 :class:`ProcessPoolExecutor` 來使用單獨行程 (process) 執行。兩者都實作了" @@ -109,11 +109,11 @@ msgstr "*fn* 是非同步執行的,並且對 *fn* 的多次呼叫可以並行 #: ../../library/concurrent.futures.rst:51 msgid "" -"The returned iterator raises a :exc:`TimeoutError` " -"if :meth:`~iterator.__next__` is called and the result isn't available after " -"*timeout* seconds from the original call to :meth:`Executor.map`. *timeout* " -"can be an int or a float. If *timeout* is not specified or ``None``, there " -"is no limit to the wait time." +"The returned iterator raises a :exc:`TimeoutError` if :meth:`~iterator." +"__next__` is called and the result isn't available after *timeout* seconds " +"from the original call to :meth:`Executor.map`. *timeout* can be an int or a " +"float. If *timeout* is not specified or ``None``, there is no limit to the " +"wait time." msgstr "" "如果 :meth:`~iterator.__next__` 被呼叫,且在原先呼叫 :meth:`Executor.map` 的 " "*timeout* 秒後結果仍不可用,回傳的疊代器就會引發 :exc:`TimeoutError`。" @@ -138,8 +138,8 @@ msgstr "" "使用 :class:`ProcessPoolExecutor` 時,此方法將 *iterables* 分成許多分塊 " "(chunks),並將其作為獨立的任務來提交給池 (pool)。可以透過將 *chunksize* 設定" "為正整數來指定這些分塊的(約略)大小。對於非常長的可疊代物件,*chunksize* 使" -"用較大的值(與預設大小 1 相比)可以顯著提高性能。對" -"於 :class:`ThreadPoolExecutor`,*chunksize* 無效。" +"用較大的值(與預設大小 1 相比)可以顯著提高性能。對於 :class:" +"`ThreadPoolExecutor`,*chunksize* 無效。" #: ../../library/concurrent.futures.rst:68 msgid "Added the *chunksize* argument." @@ -148,13 +148,13 @@ msgstr "新增 *chunksize* 引數。" #: ../../library/concurrent.futures.rst:73 msgid "" "Signal the executor that it should free any resources that it is using when " -"the currently pending futures are done executing. Calls " -"to :meth:`Executor.submit` and :meth:`Executor.map` made after shutdown will " -"raise :exc:`RuntimeError`." +"the currently pending futures are done executing. Calls to :meth:`Executor." +"submit` and :meth:`Executor.map` made after shutdown will raise :exc:" +"`RuntimeError`." msgstr "" "向 executor 發出訊號 (signal),表明它應該在目前未定 (pending) 的 future 完成" -"執行時釋放它正在使用的任何資源。在關閉後呼叫 :meth:`Executor.submit` " -"和 :meth:`Executor.map` 將引發 :exc:`RuntimeError`。" +"執行時釋放它正在使用的任何資源。在關閉後呼叫 :meth:`Executor.submit` 和 :" +"meth:`Executor.map` 將引發 :exc:`RuntimeError`。" #: ../../library/concurrent.futures.rst:78 msgid "" @@ -193,10 +193,9 @@ msgstr "" #: ../../library/concurrent.futures.rst:95 msgid "" -"You can avoid having to call this method explicitly if you use " -"the :keyword:`with` statement, which will shutdown the :class:`Executor` " -"(waiting as if :meth:`Executor.shutdown` were called with *wait* set to " -"``True``)::" +"You can avoid having to call this method explicitly if you use the :keyword:" +"`with` statement, which will shutdown the :class:`Executor` (waiting as if :" +"meth:`Executor.shutdown` were called with *wait* set to ``True``)::" msgstr "" "如果使用 :keyword:`with` 陳述句,你就可以不用明確地呼叫此方法,這將會自己關" "閉 :class:`Executor`\\(如同呼叫 :meth:`Executor.shutdown` 時 *wait* 被設定" @@ -260,6 +259,21 @@ msgid "" "a = executor.submit(wait_on_b)\n" "b = executor.submit(wait_on_a)" msgstr "" +"import time\n" +"def wait_on_b():\n" +" time.sleep(5)\n" +" print(b.result()) # b 永遠不會完成,因為它正在等待 a。\n" +" return 5\n" +"\n" +"def wait_on_a():\n" +" time.sleep(5)\n" +" print(a.result()) # a 永遠不會完成,因為它正在等待 b。\n" +" return 6\n" +"\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=2)\n" +"a = executor.submit(wait_on_b)\n" +"b = executor.submit(wait_on_a)" #: ../../library/concurrent.futures.rst:136 msgid "And::" @@ -276,6 +290,14 @@ msgid "" "executor = ThreadPoolExecutor(max_workers=1)\n" "executor.submit(wait_on_future)" msgstr "" +"def wait_on_future():\n" +" f = executor.submit(pow, 5, 2)\n" +" # 這將永遠不會完成,因為只有一個工作執行緒且\n" +" # 它正在執行這個函式。\n" +" print(f.result())\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=1)\n" +"executor.submit(wait_on_future)" #: ../../library/concurrent.futures.rst:150 msgid "" @@ -310,16 +332,16 @@ msgid "" msgstr "" "*initializer* 是一個可選的可呼叫物件,在每個工作執行緒開始時呼叫; " "*initargs* 是傳遞給 initializer 的引數元組 (tuple)。如果 *initializer* 引發例" -"外,所有目前未定的作業以及任何向池中提交 (submit) 更多作業的嘗試都將引" -"發 :exc:`~concurrent.futures.thread.BrokenThreadPool`。" +"外,所有目前未定的作業以及任何向池中提交 (submit) 更多作業的嘗試都將引發 :" +"exc:`~concurrent.futures.thread.BrokenThreadPool`。" #: ../../library/concurrent.futures.rst:166 msgid "" "If *max_workers* is ``None`` or not given, it will default to the number of " -"processors on the machine, multiplied by ``5``, assuming " -"that :class:`ThreadPoolExecutor` is often used to overlap I/O instead of CPU " -"work and the number of workers should be higher than the number of workers " -"for :class:`ProcessPoolExecutor`." +"processors on the machine, multiplied by ``5``, assuming that :class:" +"`ThreadPoolExecutor` is often used to overlap I/O instead of CPU work and " +"the number of workers should be higher than the number of workers for :class:" +"`ProcessPoolExecutor`." msgstr "" "如果 *max_workers* 為 ``None`` 或未給定,它將預設為機器上的處理器數量乘以 " "``5``,這假定了 :class:`ThreadPoolExecutor` 通常用於 I/O 重疊而非 CPU 密集的" @@ -328,15 +350,15 @@ msgstr "" #: ../../library/concurrent.futures.rst:174 msgid "" -"Added the *thread_name_prefix* parameter to allow users to control " -"the :class:`threading.Thread` names for worker threads created by the pool " -"for easier debugging." +"Added the *thread_name_prefix* parameter to allow users to control the :" +"class:`threading.Thread` names for worker threads created by the pool for " +"easier debugging." msgstr "" "新增 *thread_name_prefix* 參數以允許使用者控制由池所建立的工作執行緒 (worker " "thread) 的 :class:`threading.Thread` 名稱,以便於除錯。" #: ../../library/concurrent.futures.rst:179 -#: ../../library/concurrent.futures.rst:287 +#: ../../library/concurrent.futures.rst:292 msgid "Added the *initializer* and *initargs* arguments." msgstr "新增 *initializer* 與 *initargs* 引數。" @@ -361,9 +383,10 @@ msgstr "" #: ../../library/concurrent.futures.rst:191 msgid "" -"Default value of *max_workers* is changed to ``min(32, " -"(os.process_cpu_count() or 1) + 4)``." +"Default value of *max_workers* is changed to ``min(32, (os." +"process_cpu_count() or 1) + 4)``." msgstr "" +"*max_workers* 的預設值被改為 ``min(32, (os.process_cpu_count() or 1) + 4)``。" #: ../../library/concurrent.futures.rst:199 msgid "ThreadPoolExecutor Example" @@ -407,15 +430,15 @@ msgstr "ProcessPoolExecutor" #: ../../library/concurrent.futures.rst:233 msgid "" "The :class:`ProcessPoolExecutor` class is an :class:`Executor` subclass that " -"uses a pool of processes to execute calls " -"asynchronously. :class:`ProcessPoolExecutor` uses the :mod:`multiprocessing` " -"module, which allows it to side-step the :term:`Global Interpreter Lock " -"` but also means that only picklable objects can be " -"executed and returned." +"uses a pool of processes to execute calls asynchronously. :class:" +"`ProcessPoolExecutor` uses the :mod:`multiprocessing` module, which allows " +"it to side-step the :term:`Global Interpreter Lock ` but also means that only picklable objects can be executed and " +"returned." msgstr "" ":class:`ProcessPoolExecutor` 類別是一個 :class:`Executor` 的子類別,它使用行" -"程池來非同步地執行呼叫。:class:`ProcessPoolExecutor` 使用" -"了 :mod:`multiprocessing` 模組,這允許它避開\\ :term:`全域直譯器鎖 (Global " +"程池來非同步地執行呼叫。:class:`ProcessPoolExecutor` 使用了 :mod:" +"`multiprocessing` 模組,這允許它避開\\ :term:`全域直譯器鎖 (Global " "Interpreter Lock) `,但也意味著只能執行和回傳可被 " "pickle 的 (picklable) 物件。" @@ -425,9 +448,9 @@ msgid "" "means that :class:`ProcessPoolExecutor` will not work in the interactive " "interpreter." msgstr "" -"``__main__`` 模組必須可以被工作子行程 (worker subprocess) 引入。這意味" -"著 :class:`ProcessPoolExecutor` 將無法在交互式直譯器 (interactive " -"interpreter) 中工作。" +"``__main__`` 模組必須可以被工作子行程 (worker subprocess) 引入。這意味著 :" +"class:`ProcessPoolExecutor` 將無法在交互式直譯器 (interactive interpreter) 中" +"工作。" #: ../../library/concurrent.futures.rst:243 msgid "" @@ -437,7 +460,15 @@ msgstr "" "從提交給 :class:`ProcessPoolExecutor` 的可呼叫物件中呼叫 :class:`Executor` " "或 :class:`Future` 方法將導致死鎖。" -#: ../../library/concurrent.futures.rst:248 +#: ../../library/concurrent.futures.rst:246 +msgid "" +"Note that the restrictions on functions and arguments needing to picklable " +"as per :class:`multiprocessing.Process` apply when using :meth:`~Executor." +"submit` and :meth:`~Executor.map` on a :class:`ProcessPoolExecutor`. A " +"function defined in a REPL or a lambda should not be expected to work." +msgstr "" + +#: ../../library/concurrent.futures.rst:253 msgid "" "An :class:`Executor` subclass that executes calls asynchronously using a " "pool of at most *max_workers* processes. If *max_workers* is ``None`` or " @@ -448,20 +479,20 @@ msgid "" "the default chosen will be at most ``61``, even if more processors are " "available. *mp_context* can be a :mod:`multiprocessing` context or ``None``. " "It will be used to launch the workers. If *mp_context* is ``None`` or not " -"given, the default :mod:`multiprocessing` context is used. " -"See :ref:`multiprocessing-start-methods`." +"given, the default :mod:`multiprocessing` context is used. See :ref:" +"`multiprocessing-start-methods`." msgstr "" "一個 :class:`Executor` 子類別,它使用了最多有 *max_workers* 個行程的池來非同" -"步地執行呼叫。如果 *max_workers* 為 ``None`` 或未給定,它將被預設" -"為 :func:`os.process_cpu_count`。如果 *max_workers* 小於或等於 ``0``,則會引" -"發 :exc:`ValueError`。在 Windows 上,*max_workers* 必須小於或等於 ``61``。如" -"果不是,則會引發 :exc:`ValueError`。如果 *max_workers* 為 ``None``,則預設選" -"擇最多為 ``61``,即便有更多處理器可用。*mp_context* 可以" -"是 :mod:`multiprocessing` 情境 (context) 或 ``None``。它將用於啟動 worker。如" -"果 *mp_context* 為 ``None`` 或未給定,則使用預設的 :mod:`multiprocessing` 情" -"境。請見 :ref:`multiprocessing-start-methods`。" +"步地執行呼叫。如果 *max_workers* 為 ``None`` 或未給定,它將被預設為 :func:" +"`os.process_cpu_count`。如果 *max_workers* 小於或等於 ``0``,則會引發 :exc:" +"`ValueError`。在 Windows 上,*max_workers* 必須小於或等於 ``61``。如果不是," +"則會引發 :exc:`ValueError`。如果 *max_workers* 為 ``None``,則預設選擇最多為 " +"``61``,即便有更多處理器可用。*mp_context* 可以是 :mod:`multiprocessing` 情" +"境 (context) 或 ``None``。它將用於啟動 worker。如果 *mp_context* 為 ``None`` " +"或未給定,則使用預設的 :mod:`multiprocessing` 情境。請見 :ref:" +"`multiprocessing-start-methods`。" -#: ../../library/concurrent.futures.rst:262 +#: ../../library/concurrent.futures.rst:267 msgid "" "*initializer* is an optional callable that is called at the start of each " "worker process; *initargs* is a tuple of arguments passed to the " @@ -471,10 +502,10 @@ msgid "" msgstr "" "*initializer* 是一個可選的可呼叫物件,在每個工作行程 (worker process) 開始時" "呼叫;*initargs* 是傳遞給 initializer 的引數元組。如果 *initializer* 引發例" -"外,所有目前未定的作業以及任何向池中提交更多作業的嘗試都將引" -"發 :exc:`~concurrent.futures.process.BrokenProcessPool`。" +"外,所有目前未定的作業以及任何向池中提交更多作業的嘗試都將引發 :exc:" +"`~concurrent.futures.process.BrokenProcessPool`。" -#: ../../library/concurrent.futures.rst:268 +#: ../../library/concurrent.futures.rst:273 msgid "" "*max_tasks_per_child* is an optional argument that specifies the maximum " "number of tasks a single process can execute before it will exit and be " @@ -490,70 +521,68 @@ msgstr "" "數的情況下,將預設使用 \"spawn\" 做為 multiprocessing 啟動方法。此功能與 " "\"fork\" 啟動方法不相容。" -#: ../../library/concurrent.futures.rst:276 +#: ../../library/concurrent.futures.rst:281 msgid "" -"When one of the worker processes terminates abruptly, " -"a :exc:`~concurrent.futures.process.BrokenProcessPool` error is now raised. " -"Previously, behaviour was undefined but operations on the executor or its " -"futures would often freeze or deadlock." +"When one of the worker processes terminates abruptly, a :exc:`~concurrent." +"futures.process.BrokenProcessPool` error is now raised. Previously, " +"behaviour was undefined but operations on the executor or its futures would " +"often freeze or deadlock." msgstr "" -"當其中一個工作行程突然終止時,現在會引" -"發 :exc:`~concurrent.futures.process.BrokenProcessPool` 錯誤。在過去,此行為" -"是未定義的 (undefined),但對 executor 或其 future 的操作經常會發生凍結或死" -"鎖。" +"當其中一個工作行程突然終止時,現在會引發 :exc:`~concurrent.futures.process." +"BrokenProcessPool` 錯誤。在過去,此行為是未定義的 (undefined),但對 executor " +"或其 future 的操作經常會發生凍結或死鎖。" -#: ../../library/concurrent.futures.rst:283 +#: ../../library/concurrent.futures.rst:288 msgid "" "The *mp_context* argument was added to allow users to control the " "start_method for worker processes created by the pool." msgstr "" "新增了 *mp_context* 引數以允許使用者控制由池所建立的工作行程的 start_method。" -#: ../../library/concurrent.futures.rst:290 +#: ../../library/concurrent.futures.rst:295 msgid "" "The default :mod:`multiprocessing` start method (see :ref:`multiprocessing-" "start-methods`) will change away from *fork* in Python 3.14. Code that " "requires *fork* be used for their :class:`ProcessPoolExecutor` should " -"explicitly specify that by passing a " -"``mp_context=multiprocessing.get_context(\"fork\")`` parameter." +"explicitly specify that by passing a ``mp_context=multiprocessing." +"get_context(\"fork\")`` parameter." msgstr "" "預設的 :mod:`multiprocessing` 啟動方法(請參閱 :ref:`multiprocessing-start-" -"methods`\\ )將不再是 Python 3.14 中的 *fork*。需要 *fork* 用於" -"其 :class:`ProcessPoolExecutor` 的程式碼應透過傳遞 " -"``mp_context=multiprocessing.get_context(\"fork\")`` 參數來明確指定。" +"methods`\\ )將不再是 Python 3.14 中的 *fork*。需要 *fork* 用於其 :class:" +"`ProcessPoolExecutor` 的程式碼應透過傳遞 ``mp_context=multiprocessing." +"get_context(\"fork\")`` 參數來明確指定。" -#: ../../library/concurrent.futures.rst:297 +#: ../../library/concurrent.futures.rst:302 msgid "" "The *max_tasks_per_child* argument was added to allow users to control the " "lifetime of workers in the pool." msgstr "" "新增了 *max_tasks_per_child* 引數以允許使用者控制池中 worker 的生命週期。" -#: ../../library/concurrent.futures.rst:301 +#: ../../library/concurrent.futures.rst:306 msgid "" -"On POSIX systems, if your application has multiple threads and " -"the :mod:`multiprocessing` context uses the ``\"fork\"`` start method: " -"The :func:`os.fork` function called internally to spawn workers may raise " -"a :exc:`DeprecationWarning`. Pass a *mp_context* configured to use a " -"different start method. See the :func:`os.fork` documentation for further " -"explanation." +"On POSIX systems, if your application has multiple threads and the :mod:" +"`multiprocessing` context uses the ``\"fork\"`` start method: The :func:`os." +"fork` function called internally to spawn workers may raise a :exc:" +"`DeprecationWarning`. Pass a *mp_context* configured to use a different " +"start method. See the :func:`os.fork` documentation for further explanation." msgstr "" "在 POSIX 系統上,如果你的應用程式有多個執行緒並且 :mod:`multiprocessing` 情境" "使用了 ``\"fork\"`` 啟動方法:內部呼叫以產生 worker 的 :func:`os.fork` 函式可" "能會引發 :exc:`DeprecationWarning`。傳遞一個 *mp_context* 以配置為使用不同的" "啟動方法。更多說明請參閱 :func:`os.fork` 文件。" -#: ../../library/concurrent.futures.rst:309 +#: ../../library/concurrent.futures.rst:314 msgid "" -"*max_workers* uses :func:`os.process_cpu_count` by default, instead " -"of :func:`os.cpu_count`." +"*max_workers* uses :func:`os.process_cpu_count` by default, instead of :func:" +"`os.cpu_count`." msgstr "" -#: ../../library/concurrent.futures.rst:316 +#: ../../library/concurrent.futures.rst:321 msgid "ProcessPoolExecutor Example" msgstr "ProcessPoolExecutor 範例" -#: ../../library/concurrent.futures.rst:319 +#: ../../library/concurrent.futures.rst:324 msgid "" "import concurrent.futures\n" "import math\n" @@ -621,19 +650,19 @@ msgstr "" "if __name__ == '__main__':\n" " main()" -#: ../../library/concurrent.futures.rst:354 +#: ../../library/concurrent.futures.rst:359 msgid "Future Objects" msgstr "Future 物件" -#: ../../library/concurrent.futures.rst:356 +#: ../../library/concurrent.futures.rst:361 msgid "" "The :class:`Future` class encapsulates the asynchronous execution of a " "callable. :class:`Future` instances are created by :meth:`Executor.submit`." msgstr "" -":class:`Future` 類別封裝了可呼叫物件的非同步執行。:class:`Future` 實例" -"由 :meth:`Executor.submit` 建立。" +":class:`Future` 類別封裝了可呼叫物件的非同步執行。:class:`Future` 實例由 :" +"meth:`Executor.submit` 建立。" -#: ../../library/concurrent.futures.rst:361 +#: ../../library/concurrent.futures.rst:366 msgid "" "Encapsulates the asynchronous execution of a callable. :class:`Future` " "instances are created by :meth:`Executor.submit` and should not be created " @@ -642,7 +671,7 @@ msgstr "" "封裝可呼叫物件的非同步執行。:class:`Future` 實例由 :meth:`Executor.submit` 建" "立,且除測試外不應直接建立。" -#: ../../library/concurrent.futures.rst:367 +#: ../../library/concurrent.futures.rst:372 msgid "" "Attempt to cancel the call. If the call is currently being executed or " "finished running and cannot be cancelled then the method will return " @@ -652,22 +681,22 @@ msgstr "" "嘗試取消呼叫。如果呼叫目前正在執行或已完成運行且無法取消,則該方法將回傳 " "``False``,否則呼叫將被取消並且該方法將回傳 ``True``。" -#: ../../library/concurrent.futures.rst:374 +#: ../../library/concurrent.futures.rst:379 msgid "Return ``True`` if the call was successfully cancelled." msgstr "如果該呼叫成功被取消,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:378 +#: ../../library/concurrent.futures.rst:383 msgid "" "Return ``True`` if the call is currently being executed and cannot be " "cancelled." msgstr "如果呼叫正在執行且無法取消,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:383 +#: ../../library/concurrent.futures.rst:388 msgid "" "Return ``True`` if the call was successfully cancelled or finished running." msgstr "如果呼叫成功被取消或結束運行,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:388 +#: ../../library/concurrent.futures.rst:393 msgid "" "Return the value returned by the call. If the call hasn't yet completed then " "this method will wait up to *timeout* seconds. If the call hasn't completed " @@ -679,19 +708,19 @@ msgstr "" "叫在 *timeout* 秒內未完成,則會引發 :exc:`TimeoutError`。*timeout* 可以是整數" "或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間就不會有限制。" -#: ../../library/concurrent.futures.rst:395 -#: ../../library/concurrent.futures.rst:409 +#: ../../library/concurrent.futures.rst:400 +#: ../../library/concurrent.futures.rst:414 msgid "" "If the future is cancelled before completing then :exc:`.CancelledError` " "will be raised." msgstr "如果 future 在完成之前被取消,那麼 :exc:`.CancelledError` 將被引發。" -#: ../../library/concurrent.futures.rst:398 +#: ../../library/concurrent.futures.rst:403 msgid "" "If the call raised an exception, this method will raise the same exception." msgstr "如果該呼叫引發了例外,此方法將引發相同的例外。" -#: ../../library/concurrent.futures.rst:402 +#: ../../library/concurrent.futures.rst:407 msgid "" "Return the exception raised by the call. If the call hasn't yet completed " "then this method will wait up to *timeout* seconds. If the call hasn't " @@ -703,11 +732,11 @@ msgstr "" "呼叫在 *timeout* 秒內未完成,則會引發 :exc:`TimeoutError`。 *timeout* 可以是" "整數或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間就不會有限制。" -#: ../../library/concurrent.futures.rst:412 +#: ../../library/concurrent.futures.rst:417 msgid "If the call completed without raising, ``None`` is returned." msgstr "如果呼叫在沒有引發的情況下完成,則回傳 ``None``。" -#: ../../library/concurrent.futures.rst:416 +#: ../../library/concurrent.futures.rst:421 msgid "" "Attaches the callable *fn* to the future. *fn* will be called, with the " "future as its only argument, when the future is cancelled or finishes " @@ -716,7 +745,7 @@ msgstr "" "將可呼叫的 *fn* 附加到 future 上。當 future 被取消或完成運行時,*fn* 將被以 " "future 作為其唯一引數來呼叫。" -#: ../../library/concurrent.futures.rst:420 +#: ../../library/concurrent.futures.rst:425 msgid "" "Added callables are called in the order that they were added and are always " "called in a thread belonging to the process that added them. If the " @@ -728,19 +757,19 @@ msgstr "" "如果可呼叫物件引發 :exc:`Exception` 子類別,它將被記錄 (log) 並忽略。如果可呼" "叫物件引發 :exc:`BaseException` 子類別,該行為未定義。" -#: ../../library/concurrent.futures.rst:426 +#: ../../library/concurrent.futures.rst:431 msgid "" "If the future has already completed or been cancelled, *fn* will be called " "immediately." msgstr "如果 future 已經完成或被取消,*fn* 將立即被呼叫。" -#: ../../library/concurrent.futures.rst:429 +#: ../../library/concurrent.futures.rst:434 msgid "" -"The following :class:`Future` methods are meant for use in unit tests " -"and :class:`Executor` implementations." +"The following :class:`Future` methods are meant for use in unit tests and :" +"class:`Executor` implementations." msgstr "以下 :class:`Future` 方法旨在用於單元測試和 :class:`Executor` 實作。" -#: ../../library/concurrent.futures.rst:434 +#: ../../library/concurrent.futures.rst:439 msgid "" "This method should only be called by :class:`Executor` implementations " "before executing the work associated with the :class:`Future` and by unit " @@ -749,18 +778,18 @@ msgstr "" "此方法只能在與 :class:`Future` 關聯的工作被執行之前於 :class:`Executor` 實作" "中呼叫,或者在單元測試中呼叫。" -#: ../../library/concurrent.futures.rst:438 +#: ../../library/concurrent.futures.rst:443 msgid "" -"If the method returns ``False`` then the :class:`Future` was cancelled, " -"i.e. :meth:`Future.cancel` was called and returned ``True``. Any threads " +"If the method returns ``False`` then the :class:`Future` was cancelled, i." +"e. :meth:`Future.cancel` was called and returned ``True``. Any threads " "waiting on the :class:`Future` completing (i.e. through :func:`as_completed` " "or :func:`wait`) will be woken up." msgstr "" -"如果該方法回傳 ``False`` 則 :class:`Future` 已被取消," -"即 :meth:`Future.cancel` 被呼叫並回傳 ``True``。任何等待 :class:`Future` 完成" -"的執行緒(即透過 :func:`as_completed` 或 :func:`wait`)將被喚醒。" +"如果該方法回傳 ``False`` 則 :class:`Future` 已被取消,即 :meth:`Future." +"cancel` 被呼叫並回傳 ``True``。任何等待 :class:`Future` 完成的執行緒(即透" +"過 :func:`as_completed` 或 :func:`wait`)將被喚醒。" -#: ../../library/concurrent.futures.rst:443 +#: ../../library/concurrent.futures.rst:448 msgid "" "If the method returns ``True`` then the :class:`Future` was not cancelled " "and has been put in the running state, i.e. calls to :meth:`Future.running` " @@ -769,56 +798,55 @@ msgstr "" "如果該方法回傳 ``True`` 則代表 :class:`Future` 未被取消並已進入運行狀態,意即" "呼叫 :meth:`Future.running` 將回傳 ``True``。" -#: ../../library/concurrent.futures.rst:447 +#: ../../library/concurrent.futures.rst:452 msgid "" -"This method can only be called once and cannot be called " -"after :meth:`Future.set_result` or :meth:`Future.set_exception` have been " -"called." +"This method can only be called once and cannot be called after :meth:`Future." +"set_result` or :meth:`Future.set_exception` have been called." msgstr "" -"此方法只能呼叫一次,且不能在呼叫 :meth:`Future.set_result` " -"或 :meth:`Future.set_exception` 之後呼叫。" +"此方法只能呼叫一次,且不能在呼叫 :meth:`Future.set_result` 或 :meth:`Future." +"set_exception` 之後呼叫。" -#: ../../library/concurrent.futures.rst:453 +#: ../../library/concurrent.futures.rst:458 msgid "" "Sets the result of the work associated with the :class:`Future` to *result*." msgstr "將與 :class:`Future` 關聯的工作結果設定為 *result*。" -#: ../../library/concurrent.futures.rst:456 -#: ../../library/concurrent.futures.rst:469 +#: ../../library/concurrent.futures.rst:461 +#: ../../library/concurrent.futures.rst:474 msgid "" "This method should only be used by :class:`Executor` implementations and " "unit tests." msgstr "此方法只能在 :class:`Executor` 實作中和單元測試中使用。" -#: ../../library/concurrent.futures.rst:459 -#: ../../library/concurrent.futures.rst:472 +#: ../../library/concurrent.futures.rst:464 +#: ../../library/concurrent.futures.rst:477 msgid "" -"This method raises :exc:`concurrent.futures.InvalidStateError` if " -"the :class:`Future` is already done." +"This method raises :exc:`concurrent.futures.InvalidStateError` if the :class:" +"`Future` is already done." msgstr "" -"如果 :class:`Future` 已經完成,此方法會引" -"發 :exc:`concurrent.futures.InvalidStateError`。" +"如果 :class:`Future` 已經完成,此方法會引發 :exc:`concurrent.futures." +"InvalidStateError`。" -#: ../../library/concurrent.futures.rst:466 +#: ../../library/concurrent.futures.rst:471 msgid "" -"Sets the result of the work associated with the :class:`Future` to " -"the :class:`Exception` *exception*." +"Sets the result of the work associated with the :class:`Future` to the :" +"class:`Exception` *exception*." msgstr "" "將與 :class:`Future` 關聯的工作結果設定為 :class:`Exception` *exception*。" -#: ../../library/concurrent.futures.rst:478 +#: ../../library/concurrent.futures.rst:483 msgid "Module Functions" msgstr "模組函式" -#: ../../library/concurrent.futures.rst:482 +#: ../../library/concurrent.futures.rst:487 msgid "" -"Wait for the :class:`Future` instances (possibly created by " -"different :class:`Executor` instances) given by *fs* to complete. Duplicate " -"futures given to *fs* are removed and will be returned only once. Returns a " -"named 2-tuple of sets. The first set, named ``done``, contains the futures " -"that completed (finished or cancelled futures) before the wait completed. " -"The second set, named ``not_done``, contains the futures that did not " -"complete (pending or running futures)." +"Wait for the :class:`Future` instances (possibly created by different :class:" +"`Executor` instances) given by *fs* to complete. Duplicate futures given to " +"*fs* are removed and will be returned only once. Returns a named 2-tuple of " +"sets. The first set, named ``done``, contains the futures that completed " +"(finished or cancelled futures) before the wait completed. The second set, " +"named ``not_done``, contains the futures that did not complete (pending or " +"running futures)." msgstr "" "等待 *fs* 給定的 :class:`Future` 實例(可能由不同的 :class:`Executor` 實例建" "立)完成。提供給 *fs* 的重複 future 將被刪除,並且只會回傳一次。回傳一個集合" @@ -826,7 +854,7 @@ msgstr "" "完成的 future(已完成或被取消的 future)。第二組名為 ``not_done``,包含未完成" "的 future(未定或運行中的 future)。" -#: ../../library/concurrent.futures.rst:490 +#: ../../library/concurrent.futures.rst:495 msgid "" "*timeout* can be used to control the maximum number of seconds to wait " "before returning. *timeout* can be an int or float. If *timeout* is not " @@ -835,38 +863,38 @@ msgstr "" "*timeout* 可用於控制回傳前等待的最大秒數。*timeout* 可以是整數或浮點數。如果" "未指定 *timeout* 或為 ``None``,則等待時間就沒有限制。" -#: ../../library/concurrent.futures.rst:494 +#: ../../library/concurrent.futures.rst:499 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "*return_when* 表示此函式應回傳的時間。它必須是以下常數之一:" -#: ../../library/concurrent.futures.rst:500 +#: ../../library/concurrent.futures.rst:505 msgid "Constant" msgstr "常數" -#: ../../library/concurrent.futures.rst:501 +#: ../../library/concurrent.futures.rst:506 msgid "Description" msgstr "描述" -#: ../../library/concurrent.futures.rst:504 +#: ../../library/concurrent.futures.rst:509 msgid "The function will return when any future finishes or is cancelled." msgstr "當任何 future 完成或被取消時,該函式就會回傳。" -#: ../../library/concurrent.futures.rst:507 +#: ../../library/concurrent.futures.rst:512 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent " -"to :const:`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent to :const:" +"`ALL_COMPLETED`." msgstr "" "該函式會在任何 future 透過引發例外而完結時回傳。如果 future 沒有引發例外,那" "麼它等同於 :const:`ALL_COMPLETED`。" -#: ../../library/concurrent.futures.rst:512 +#: ../../library/concurrent.futures.rst:517 msgid "The function will return when all futures finish or are cancelled." msgstr "當所有 future 都完成或被取消時,該函式才會回傳。" -#: ../../library/concurrent.futures.rst:516 +#: ../../library/concurrent.futures.rst:521 msgid "" "Returns an iterator over the :class:`Future` instances (possibly created by " "different :class:`Executor` instances) given by *fs* that yields futures as " @@ -881,41 +909,41 @@ msgstr "" "回傳由 *fs* 給定的 :class:`Future` 實例(可能由不同的 :class:`Executor` 實例" "建立)的疊代器,它在完成時產生 future(已完成或被取消的 future)。*fs* 給定的" "任何重複的 future 將只被回傳一次。呼叫 :func:`as_completed` 之前完成的任何 " -"future 將首先產生。如果 :meth:`~iterator.__next__` 被呼叫,並且在原先呼" -"叫 :func:`as_completed` 的 *timeout* 秒後結果仍不可用,則回傳的疊代器會引" -"發 :exc:`TimeoutError`。*timeout* 可以是整數或浮點數。如果未指定 *timeout* 或" -"為 ``None``,則等待時間就沒有限制。" +"future 將首先產生。如果 :meth:`~iterator.__next__` 被呼叫,並且在原先呼叫 :" +"func:`as_completed` 的 *timeout* 秒後結果仍不可用,則回傳的疊代器會引發 :exc:" +"`TimeoutError`。*timeout* 可以是整數或浮點數。如果未指定 *timeout* 或為 " +"``None``,則等待時間就沒有限制。" -#: ../../library/concurrent.futures.rst:529 +#: ../../library/concurrent.futures.rst:534 msgid ":pep:`3148` -- futures - execute computations asynchronously" msgstr ":pep:`3148` -- futures - 非同步地執行運算" -#: ../../library/concurrent.futures.rst:530 +#: ../../library/concurrent.futures.rst:535 msgid "" "The proposal which described this feature for inclusion in the Python " "standard library." msgstr "描述此功能並提出被包含於 Python 標準函式庫中的提案。" -#: ../../library/concurrent.futures.rst:535 +#: ../../library/concurrent.futures.rst:540 msgid "Exception classes" msgstr "例外類別" -#: ../../library/concurrent.futures.rst:541 +#: ../../library/concurrent.futures.rst:546 msgid "Raised when a future is cancelled." msgstr "當 future 被取消時引發。" -#: ../../library/concurrent.futures.rst:545 +#: ../../library/concurrent.futures.rst:550 msgid "" "A deprecated alias of :exc:`TimeoutError`, raised when a future operation " "exceeds the given timeout." msgstr "" ":exc:`TimeoutError` 的棄用別名,在 future 操作超過給定超時 (timeout) 時引發。" -#: ../../library/concurrent.futures.rst:550 +#: ../../library/concurrent.futures.rst:555 msgid "This class was made an alias of :exc:`TimeoutError`." msgstr "這個類別是 :exc:`TimeoutError` 的別名。" -#: ../../library/concurrent.futures.rst:555 +#: ../../library/concurrent.futures.rst:560 msgid "" "Derived from :exc:`RuntimeError`, this exception class is raised when an " "executor is broken for some reason, and cannot be used to submit or execute " @@ -924,31 +952,29 @@ msgstr "" "衍生自 :exc:`RuntimeError`,當執行器因某種原因損壞時會引發此例外類別,並且不" "能用於提交或執行新任務。" -#: ../../library/concurrent.futures.rst:563 +#: ../../library/concurrent.futures.rst:568 msgid "" "Raised when an operation is performed on a future that is not allowed in the " "current state." msgstr "目前狀態下不允許的 future 操作被執行時而引發。" -#: ../../library/concurrent.futures.rst:572 +#: ../../library/concurrent.futures.rst:577 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception class " -"is raised when one of the workers of " -"a :class:`~concurrent.futures.ThreadPoolExecutor` has failed initializing." +"is raised when one of the workers of a :class:`~concurrent.futures." +"ThreadPoolExecutor` has failed initializing." msgstr "" -"衍生自 :exc:`~concurrent.futures.BrokenExecutor`," -"當 :class:`~concurrent.futures.ThreadPoolExecutor` 的其中一個 worker 初始化失" -"敗時會引發此例外類別。" +"衍生自 :exc:`~concurrent.futures.BrokenExecutor`,當 :class:`~concurrent." +"futures.ThreadPoolExecutor` 的其中一個 worker 初始化失敗時會引發此例外類別。" -#: ../../library/concurrent.futures.rst:583 +#: ../../library/concurrent.futures.rst:588 msgid "" -"Derived from :exc:`~concurrent.futures.BrokenExecutor` " -"(formerly :exc:`RuntimeError`), this exception class is raised when one of " -"the workers of a :class:`~concurrent.futures.ProcessPoolExecutor` has " -"terminated in a non-clean fashion (for example, if it was killed from the " -"outside)." +"Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly :exc:" +"`RuntimeError`), this exception class is raised when one of the workers of " +"a :class:`~concurrent.futures.ProcessPoolExecutor` has terminated in a non-" +"clean fashion (for example, if it was killed from the outside)." msgstr "" -"衍生自 :exc:`~concurrent.futures.BrokenExecutor`\\(以前" -"為 :exc:`RuntimeError`)," -"當 :class:`~concurrent.futures.ProcessPoolExecutor` 的其中一個 worker 以不乾" -"淨的方式終止時將引發此例外類別(例如它是從外面被 kill 掉的)。" +"衍生自 :exc:`~concurrent.futures.BrokenExecutor`\\(以前為 :exc:" +"`RuntimeError`),當 :class:`~concurrent.futures.ProcessPoolExecutor` 的其中" +"一個 worker 以不乾淨的方式終止時將引發此例外類別(例如它是從外面被 kill 掉" +"的)。" diff --git a/library/ctypes.po b/library/ctypes.po index 7125493c1f..484f953dee 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-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-07-20 00:19+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-" @@ -375,7 +375,7 @@ msgid "" "learn more about :mod:`ctypes` data types." msgstr "" -#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2262 +#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2278 msgid "Fundamental data types" msgstr "" @@ -440,8 +440,12 @@ msgstr ":class:`c_byte`" #: ../../library/ctypes.rst:233 ../../library/ctypes.rst:235 #: ../../library/ctypes.rst:237 ../../library/ctypes.rst:239 #: ../../library/ctypes.rst:241 ../../library/ctypes.rst:243 -#: ../../library/ctypes.rst:246 ../../library/ctypes.rst:248 -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:245 ../../library/ctypes.rst:247 +#: ../../library/ctypes.rst:249 ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:253 ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:257 ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:262 ../../library/ctypes.rst:264 +#: ../../library/ctypes.rst:267 msgid "int" msgstr "int" @@ -478,145 +482,209 @@ msgid ":c:expr:`int`" msgstr ":c:expr:`int`" #: ../../library/ctypes.rst:235 +msgid ":class:`c_int8`" +msgstr ":class:`c_int8`" + +#: ../../library/ctypes.rst:235 +msgid ":c:type:`int8_t`" +msgstr ":c:type:`int8_t`" + +#: ../../library/ctypes.rst:237 +msgid ":class:`c_int16`" +msgstr ":class:`c_int16`" + +#: ../../library/ctypes.rst:237 +msgid ":c:type:`int16_t`" +msgstr ":c:type:`int16_t`" + +#: ../../library/ctypes.rst:239 +msgid ":class:`c_int32`" +msgstr ":class:`c_int32`" + +#: ../../library/ctypes.rst:239 +msgid ":c:type:`int32_t`" +msgstr ":c:type:`int32_t`" + +#: ../../library/ctypes.rst:241 +msgid ":class:`c_int64`" +msgstr ":class:`c_int64`" + +#: ../../library/ctypes.rst:241 +msgid ":c:type:`int64_t`" +msgstr ":c:type:`int64_t`" + +#: ../../library/ctypes.rst:243 msgid ":class:`c_uint`" msgstr ":class:`c_uint`" -#: ../../library/ctypes.rst:235 +#: ../../library/ctypes.rst:243 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:245 +msgid ":class:`c_uint8`" +msgstr ":class:`c_uint8`" + +#: ../../library/ctypes.rst:245 +msgid ":c:type:`uint8_t`" +msgstr ":c:type:`uint8_t`" + +#: ../../library/ctypes.rst:247 +msgid ":class:`c_uint16`" +msgstr ":class:`c_uint16`" + +#: ../../library/ctypes.rst:247 +msgid ":c:type:`uint16_t`" +msgstr ":c:type:`uint16_t`" + +#: ../../library/ctypes.rst:249 +msgid ":class:`c_uint32`" +msgstr ":class:`c_uint32`" + +#: ../../library/ctypes.rst:249 +msgid ":c:type:`uint32_t`" +msgstr ":c:type:`uint32_t`" + +#: ../../library/ctypes.rst:251 +msgid ":class:`c_uint64`" +msgstr ":class:`c_uint64`" + +#: ../../library/ctypes.rst:251 +msgid ":c:type:`uint64_t`" +msgstr ":c:type:`uint64_t`" + +#: ../../library/ctypes.rst:253 msgid ":class:`c_long`" msgstr ":class:`c_long`" -#: ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:253 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:255 msgid ":class:`c_ulong`" msgstr ":class:`c_ulong`" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:255 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:257 msgid ":class:`c_longlong`" msgstr ":class:`c_longlong`" -#: ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:257 msgid ":c:expr:`__int64` or :c:expr:`long long`" msgstr ":c:expr:`__int64` 或 :c:expr:`long long`" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:259 msgid ":class:`c_ulonglong`" msgstr ":class:`c_ulonglong`" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:259 msgid ":c:expr:`unsigned __int64` or :c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned __int64` 或 :c:expr:`unsigned long long`" -#: ../../library/ctypes.rst:246 +#: ../../library/ctypes.rst:262 msgid ":class:`c_size_t`" msgstr ":class:`c_size_t`" -#: ../../library/ctypes.rst:246 +#: ../../library/ctypes.rst:262 msgid ":c:type:`size_t`" msgstr ":c:type:`size_t`" -#: ../../library/ctypes.rst:248 +#: ../../library/ctypes.rst:264 msgid ":class:`c_ssize_t`" msgstr ":class:`c_ssize_t`" -#: ../../library/ctypes.rst:248 +#: ../../library/ctypes.rst:264 msgid ":c:type:`ssize_t` or :c:expr:`Py_ssize_t`" msgstr ":c:type:`ssize_t` 或 :c:expr:`Py_ssize_t`" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:267 msgid ":class:`c_time_t`" msgstr ":class:`c_time_t`" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:267 msgid ":c:type:`time_t`" msgstr ":c:type:`time_t`" -#: ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:269 msgid ":class:`c_float`" msgstr ":class:`c_float`" -#: ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:269 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../library/ctypes.rst:253 ../../library/ctypes.rst:255 -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:269 ../../library/ctypes.rst:271 +#: ../../library/ctypes.rst:273 msgid "float" msgstr "float" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:271 msgid ":class:`c_double`" msgstr ":class:`c_double`" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:271 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:273 msgid ":class:`c_longdouble`" msgstr ":class:`c_longdouble`" -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:273 msgid ":c:expr:`long double`" msgstr ":c:expr:`long double`" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:275 msgid ":class:`c_char_p`" msgstr ":class:`c_char_p`" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:275 msgid ":c:expr:`char *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:275 msgid "bytes object or ``None``" -msgstr "" +msgstr "位元組物件或 ``None``" -#: ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:277 msgid ":class:`c_wchar_p`" msgstr ":class:`c_wchar_p`" -#: ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:277 msgid ":c:expr:`wchar_t *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:277 msgid "string or ``None``" msgstr "字串或 ``None``" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:279 msgid ":class:`c_void_p`" msgstr ":class:`c_void_p`" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:279 msgid ":c:expr:`void *`" msgstr ":c:expr:`void *`" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:279 msgid "int or ``None``" msgstr "" -#: ../../library/ctypes.rst:267 +#: ../../library/ctypes.rst:283 msgid "The constructor accepts any object with a truth value." msgstr "" -#: ../../library/ctypes.rst:269 +#: ../../library/ctypes.rst:285 msgid "" "All these types can be created by calling them with an optional initializer " "of the correct type and value::" msgstr "" -#: ../../library/ctypes.rst:272 +#: ../../library/ctypes.rst:288 msgid "" ">>> c_int()\n" "c_long(0)\n" @@ -634,12 +702,12 @@ msgstr "" "c_ushort(65533)\n" ">>>" -#: ../../library/ctypes.rst:280 +#: ../../library/ctypes.rst:296 msgid "" "Since these types are mutable, their value can also be changed afterwards::" msgstr "" -#: ../../library/ctypes.rst:282 +#: ../../library/ctypes.rst:298 msgid "" ">>> i = c_int(42)\n" ">>> print(i)\n" @@ -661,7 +729,7 @@ msgstr "" "-99\n" ">>>" -#: ../../library/ctypes.rst:292 +#: ../../library/ctypes.rst:308 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 " @@ -669,7 +737,7 @@ msgid "" "Python string objects are immutable)::" msgstr "" -#: ../../library/ctypes.rst:297 +#: ../../library/ctypes.rst:313 msgid "" ">>> s = \"Hello, World\"\n" ">>> c_s = c_wchar_p(s)\n" @@ -686,8 +754,22 @@ msgid "" "Hello, World\n" ">>>" msgstr "" +">>> s = \"Hello, World\"\n" +">>> c_s = c_wchar_p(s)\n" +">>> print(c_s)\n" +"c_wchar_p(139966785747344)\n" +">>> print(c_s.value)\n" +"Hello World\n" +">>> c_s.value = \"Hi, there\"\n" +">>> print(c_s) # 記憶體位置已改變\n" +"c_wchar_p(139966783348904)\n" +">>> print(c_s.value)\n" +"Hi, there\n" +">>> print(s) # 第一個物件未改變\n" +"Hello, World\n" +">>>" -#: ../../library/ctypes.rst:312 +#: ../../library/ctypes.rst:328 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 :" @@ -697,7 +779,7 @@ msgid "" "``value`` property::" msgstr "" -#: ../../library/ctypes.rst:319 +#: ../../library/ctypes.rst:335 msgid "" ">>> from ctypes import *\n" ">>> p = create_string_buffer(3) # create a 3 byte buffer, " @@ -719,7 +801,7 @@ msgid "" ">>>" msgstr "" -#: ../../library/ctypes.rst:336 +#: ../../library/ctypes.rst:352 msgid "" "The :func:`create_string_buffer` function replaces the old :func:`!c_buffer` " "function (which is still available as an alias). To create a mutable memory " @@ -727,18 +809,18 @@ msgid "" "the :func:`create_unicode_buffer` function." msgstr "" -#: ../../library/ctypes.rst:345 +#: ../../library/ctypes.rst:361 msgid "Calling functions, continued" msgstr "" -#: ../../library/ctypes.rst:347 +#: ../../library/ctypes.rst:363 msgid "" "Note that printf prints to the real standard output channel, *not* to :data:" "`sys.stdout`, so these examples will only work at the console prompt, not " "from within *IDLE* or *PythonWin*::" msgstr "" -#: ../../library/ctypes.rst:351 +#: ../../library/ctypes.rst:367 msgid "" ">>> printf = libc.printf\n" ">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" @@ -774,14 +856,14 @@ msgstr "" "parameter 2\n" ">>>" -#: ../../library/ctypes.rst:367 +#: ../../library/ctypes.rst:383 msgid "" "As has been mentioned before, all Python types except integers, strings, and " "bytes objects have to be wrapped in their corresponding :mod:`ctypes` type, " "so that they can be converted to the required C data type::" msgstr "" -#: ../../library/ctypes.rst:371 +#: ../../library/ctypes.rst:387 msgid "" ">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" "An int 1234, a double 3.140000\n" @@ -793,11 +875,11 @@ msgstr "" "31\n" ">>>" -#: ../../library/ctypes.rst:379 +#: ../../library/ctypes.rst:395 msgid "Calling variadic functions" msgstr "" -#: ../../library/ctypes.rst:381 +#: ../../library/ctypes.rst:397 msgid "" "On a lot of platforms calling variadic functions through ctypes is exactly " "the same as calling functions with a fixed number of parameters. On some " @@ -806,27 +888,27 @@ msgid "" "functions." msgstr "" -#: ../../library/ctypes.rst:386 +#: ../../library/ctypes.rst:402 msgid "" "On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes` " "attribute for the regular, non-variadic, function arguments:" msgstr "" -#: ../../library/ctypes.rst:389 +#: ../../library/ctypes.rst:405 msgid "libc.printf.argtypes = [ctypes.c_char_p]" msgstr "libc.printf.argtypes = [ctypes.c_char_p]" -#: ../../library/ctypes.rst:393 +#: ../../library/ctypes.rst:409 msgid "" "Because specifying the attribute does not inhibit portability it is advised " "to always specify :attr:`~_CFuncPtr.argtypes` for all variadic functions." msgstr "" -#: ../../library/ctypes.rst:400 +#: ../../library/ctypes.rst:416 msgid "Calling functions with your own custom data types" msgstr "" -#: ../../library/ctypes.rst:402 +#: ../../library/ctypes.rst:418 msgid "" "You can also customize :mod:`ctypes` argument conversion to allow instances " "of your own classes be used as function arguments. :mod:`ctypes` looks for " @@ -835,7 +917,7 @@ msgid "" "or an object with an :attr:`!_as_parameter_` attribute::" msgstr "" -#: ../../library/ctypes.rst:408 +#: ../../library/ctypes.rst:424 msgid "" ">>> class Bottles:\n" "... def __init__(self, number):\n" @@ -857,24 +939,24 @@ msgstr "" "19\n" ">>>" -#: ../../library/ctypes.rst:418 +#: ../../library/ctypes.rst:434 msgid "" "If you don't want to store the instance's data in the :attr:`!" "_as_parameter_` instance variable, you could define a :class:`property` " "which makes the attribute available on request." msgstr "" -#: ../../library/ctypes.rst:426 +#: ../../library/ctypes.rst:442 msgid "Specifying the required argument types (function prototypes)" msgstr "" -#: ../../library/ctypes.rst:428 +#: ../../library/ctypes.rst:444 msgid "" "It is possible to specify the required argument types of functions exported " "from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute." msgstr "" -#: ../../library/ctypes.rst:431 +#: ../../library/ctypes.rst:447 msgid "" ":attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!" "printf` function is probably not a good example here, because it takes a " @@ -883,7 +965,7 @@ msgid "" "feature)::" msgstr "" -#: ../../library/ctypes.rst:436 +#: ../../library/ctypes.rst:452 msgid "" ">>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]\n" ">>> printf(b\"String '%s', Int %d, Double %f\\n\", b\"Hi\", 10, 2.2)\n" @@ -897,14 +979,14 @@ msgstr "" "37\n" ">>>" -#: ../../library/ctypes.rst:442 +#: ../../library/ctypes.rst:458 msgid "" "Specifying a format protects against incompatible argument types (just as a " "prototype for a C function), and tries to convert the arguments to valid " "types::" msgstr "" -#: ../../library/ctypes.rst:445 +#: ../../library/ctypes.rst:461 msgid "" ">>> printf(b\"%d %d %d\", 1, 2, 3)\n" "Traceback (most recent call last):\n" @@ -926,7 +1008,7 @@ msgstr "" "13\n" ">>>" -#: ../../library/ctypes.rst:454 +#: ../../library/ctypes.rst:470 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 " @@ -940,43 +1022,43 @@ msgid "" "_as_parameter_` attribute." msgstr "" -#: ../../library/ctypes.rst:468 +#: ../../library/ctypes.rst:484 msgid "Return types" msgstr "" -#: ../../library/ctypes.rst:478 +#: ../../library/ctypes.rst:494 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " "return types can be specified by setting the :attr:`~_CFuncPtr.restype` " "attribute of the function object." msgstr "" -#: ../../library/ctypes.rst:482 +#: ../../library/ctypes.rst:498 msgid "" "The C prototype of :c:func:`time` is ``time_t time(time_t *)``. Because :c:" "type:`time_t` might be of a different type than the default return type :c:" "expr:`int`, you should specify the :attr:`!restype` attribute::" msgstr "" -#: ../../library/ctypes.rst:486 +#: ../../library/ctypes.rst:502 msgid ">>> libc.time.restype = c_time_t" msgstr ">>> libc.time.restype = c_time_t" -#: ../../library/ctypes.rst:488 +#: ../../library/ctypes.rst:504 msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" msgstr "" -#: ../../library/ctypes.rst:490 +#: ../../library/ctypes.rst:506 msgid ">>> libc.time.argtypes = (POINTER(c_time_t),)" msgstr ">>> libc.time.argtypes = (POINTER(c_time_t),)" -#: ../../library/ctypes.rst:492 +#: ../../library/ctypes.rst:508 msgid "" "To call the function with a ``NULL`` pointer as first argument, use " "``None``::" msgstr "" -#: ../../library/ctypes.rst:494 +#: ../../library/ctypes.rst:510 msgid "" ">>> print(libc.time(None))\n" "1150640792" @@ -984,13 +1066,13 @@ msgstr "" ">>> print(libc.time(None))\n" "1150640792" -#: ../../library/ctypes.rst:497 +#: ../../library/ctypes.rst:513 msgid "" "Here is a more advanced example, it uses the :func:`!strchr` function, which " "expects a string pointer and a char, and returns a pointer to a string::" msgstr "" -#: ../../library/ctypes.rst:500 +#: ../../library/ctypes.rst:516 msgid "" ">>> strchr = libc.strchr\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1012,14 +1094,14 @@ msgstr "" "None\n" ">>>" -#: ../../library/ctypes.rst:510 +#: ../../library/ctypes.rst:526 msgid "" "If you want to avoid the :func:`ord(\"x\") ` calls above, you can set " "the :attr:`~_CFuncPtr.argtypes` attribute, and the second argument will be " "converted from a single character Python bytes object into a C char:" msgstr "" -#: ../../library/ctypes.rst:514 +#: ../../library/ctypes.rst:530 msgid "" ">>> strchr.restype = c_char_p\n" ">>> strchr.argtypes = [c_char_p, c_char]\n" @@ -1049,7 +1131,7 @@ msgstr "" "b'def'\n" ">>>" -#: ../../library/ctypes.rst:529 +#: ../../library/ctypes.rst:545 msgid "" "You can also use a callable Python object (a function or a class for " "example) as the :attr:`~_CFuncPtr.restype` attribute, if the foreign " @@ -1059,7 +1141,7 @@ msgid "" "values and automatically raise an exception::" msgstr "" -#: ../../library/ctypes.rst:535 +#: ../../library/ctypes.rst:551 msgid "" ">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" @@ -1095,7 +1177,7 @@ msgstr "" "OSError: [Errno 126] The specified module could not be found.\n" ">>>" -#: ../../library/ctypes.rst:552 +#: ../../library/ctypes.rst:568 msgid "" "``WinError`` is a function which will call Windows ``FormatMessage()`` api " "to get the string representation of an error code, and *returns* an " @@ -1103,18 +1185,18 @@ msgid "" "used, it calls :func:`GetLastError` to retrieve it." msgstr "" -#: ../../library/ctypes.rst:557 +#: ../../library/ctypes.rst:573 msgid "" "Please note that a much more powerful error checking mechanism is available " "through the :attr:`~_CFuncPtr.errcheck` attribute; see the reference manual " "for details." msgstr "" -#: ../../library/ctypes.rst:565 +#: ../../library/ctypes.rst:581 msgid "Passing pointers (or: passing parameters by reference)" msgstr "" -#: ../../library/ctypes.rst:567 +#: ../../library/ctypes.rst:583 msgid "" "Sometimes a C api function expects a *pointer* to a data type as parameter, " "probably to write into the corresponding location, or if the data is too " @@ -1122,7 +1204,7 @@ msgid "" "reference*." msgstr "" -#: ../../library/ctypes.rst:571 +#: ../../library/ctypes.rst:587 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:" @@ -1131,7 +1213,7 @@ msgid "" "you don't need the pointer object in Python itself::" msgstr "" -#: ../../library/ctypes.rst:577 +#: ../../library/ctypes.rst:593 msgid "" ">>> i = c_int()\n" ">>> f = c_float()\n" @@ -1157,11 +1239,11 @@ msgstr "" "1 3.1400001049 b'Hello'\n" ">>>" -#: ../../library/ctypes.rst:593 +#: ../../library/ctypes.rst:609 msgid "Structures and unions" msgstr "" -#: ../../library/ctypes.rst:595 +#: ../../library/ctypes.rst:611 msgid "" "Structures and unions must derive from the :class:`Structure` and :class:" "`Union` base classes which are defined in the :mod:`ctypes` module. Each " @@ -1170,20 +1252,20 @@ msgid "" "*field type*." msgstr "" -#: ../../library/ctypes.rst:600 +#: ../../library/ctypes.rst:616 msgid "" "The field type must be a :mod:`ctypes` type like :class:`c_int`, or any " "other derived :mod:`ctypes` type: structure, union, array, pointer." msgstr "" -#: ../../library/ctypes.rst:603 +#: ../../library/ctypes.rst:619 msgid "" "Here is a simple example of a POINT structure, which contains two integers " "named *x* and *y*, and also shows how to initialize a structure in the " "constructor::" msgstr "" -#: ../../library/ctypes.rst:606 +#: ../../library/ctypes.rst:622 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1219,19 +1301,19 @@ msgstr "" "TypeError: too many initializers\n" ">>>" -#: ../../library/ctypes.rst:623 +#: ../../library/ctypes.rst:639 msgid "" "You can, however, build much more complicated structures. A structure can " "itself contain other structures by using a structure as a field type." msgstr "" -#: ../../library/ctypes.rst:626 +#: ../../library/ctypes.rst:642 msgid "" "Here is a RECT structure which contains two POINTs named *upperleft* and " "*lowerright*::" msgstr "" -#: ../../library/ctypes.rst:629 +#: ../../library/ctypes.rst:645 msgid "" ">>> class RECT(Structure):\n" "... _fields_ = [(\"upperleft\", POINT),\n" @@ -1255,13 +1337,13 @@ msgstr "" "0 0\n" ">>>" -#: ../../library/ctypes.rst:640 +#: ../../library/ctypes.rst:656 msgid "" "Nested structures can also be initialized in the constructor in several " "ways::" msgstr "" -#: ../../library/ctypes.rst:642 +#: ../../library/ctypes.rst:658 msgid "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" @@ -1269,13 +1351,13 @@ msgstr "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" -#: ../../library/ctypes.rst:645 +#: ../../library/ctypes.rst:661 msgid "" "Field :term:`descriptor`\\s can be retrieved from the *class*, they are " "useful for debugging because they can provide useful information::" msgstr "" -#: ../../library/ctypes.rst:648 +#: ../../library/ctypes.rst:664 msgid "" ">>> print(POINT.x)\n" "\n" @@ -1289,7 +1371,7 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:659 +#: ../../library/ctypes.rst:675 msgid "" ":mod:`ctypes` does not support passing unions or structures with bit-fields " "to functions by value. While this may work on 32-bit x86, it's not " @@ -1297,11 +1379,11 @@ msgid "" "structures with bit-fields should always be passed to functions by pointer." msgstr "" -#: ../../library/ctypes.rst:665 +#: ../../library/ctypes.rst:681 msgid "Structure/union alignment and byte order" msgstr "" -#: ../../library/ctypes.rst:667 +#: ../../library/ctypes.rst:683 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 :" @@ -1314,7 +1396,7 @@ msgid "" "definition." msgstr "" -#: ../../library/ctypes.rst:677 +#: ../../library/ctypes.rst:693 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:" @@ -1323,18 +1405,18 @@ msgid "" "classes cannot contain pointer fields." msgstr "" -#: ../../library/ctypes.rst:687 +#: ../../library/ctypes.rst:703 msgid "Bit fields in structures and unions" msgstr "" -#: ../../library/ctypes.rst:689 +#: ../../library/ctypes.rst:705 msgid "" "It is possible to create structures and unions containing bit fields. Bit " "fields are only possible for integer fields, the bit width is specified as " "the third item in the :attr:`~Structure._fields_` tuples::" msgstr "" -#: ../../library/ctypes.rst:693 +#: ../../library/ctypes.rst:709 msgid "" ">>> class Int(Structure):\n" "... _fields_ = [(\"first_16\", c_int, 16),\n" @@ -1356,33 +1438,33 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:707 +#: ../../library/ctypes.rst:723 msgid "Arrays" msgstr "" -#: ../../library/ctypes.rst:709 +#: ../../library/ctypes.rst:725 msgid "" "Arrays are sequences, containing a fixed number of instances of the same " "type." msgstr "" -#: ../../library/ctypes.rst:711 +#: ../../library/ctypes.rst:727 msgid "" "The recommended way to create array types is by multiplying a data type with " "a positive integer::" msgstr "" -#: ../../library/ctypes.rst:714 +#: ../../library/ctypes.rst:730 msgid "TenPointsArrayType = POINT * 10" msgstr "" -#: ../../library/ctypes.rst:716 +#: ../../library/ctypes.rst:732 msgid "" "Here is an example of a somewhat artificial data type, a structure " "containing 4 POINTs among other stuff::" msgstr "" -#: ../../library/ctypes.rst:719 +#: ../../library/ctypes.rst:735 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1410,28 +1492,31 @@ msgstr "" "4\n" ">>>" -#: ../../library/ctypes.rst:732 +#: ../../library/ctypes.rst:748 msgid "Instances are created in the usual way, by calling the class::" msgstr "" -#: ../../library/ctypes.rst:734 +#: ../../library/ctypes.rst:750 msgid "" "arr = TenPointsArrayType()\n" "for pt in arr:\n" " print(pt.x, pt.y)" msgstr "" +"arr = TenPointsArrayType()\n" +"for pt in arr:\n" +" print(pt.x, pt.y)" -#: ../../library/ctypes.rst:738 +#: ../../library/ctypes.rst:754 msgid "" "The above code print a series of ``0 0`` lines, because the array contents " "is initialized to zeros." msgstr "" -#: ../../library/ctypes.rst:741 +#: ../../library/ctypes.rst:757 msgid "Initializers of the correct type can also be specified::" msgstr "" -#: ../../library/ctypes.rst:743 +#: ../../library/ctypes.rst:759 msgid "" ">>> from ctypes import *\n" ">>> TenIntegers = c_int * 10\n" @@ -1453,17 +1538,17 @@ msgstr "" "1 2 3 4 5 6 7 8 9 10\n" ">>>" -#: ../../library/ctypes.rst:757 +#: ../../library/ctypes.rst:773 msgid "Pointers" -msgstr "" +msgstr "指標" -#: ../../library/ctypes.rst:759 +#: ../../library/ctypes.rst:775 msgid "" "Pointer instances are created by calling the :func:`pointer` function on a :" "mod:`ctypes` type::" msgstr "" -#: ../../library/ctypes.rst:762 +#: ../../library/ctypes.rst:778 msgid "" ">>> from ctypes import *\n" ">>> i = c_int(42)\n" @@ -1475,13 +1560,13 @@ msgstr "" ">>> pi = pointer(i)\n" ">>>" -#: ../../library/ctypes.rst:767 +#: ../../library/ctypes.rst:783 msgid "" "Pointer instances have a :attr:`~_Pointer.contents` attribute which returns " "the object to which the pointer points, the ``i`` object above::" msgstr "" -#: ../../library/ctypes.rst:770 +#: ../../library/ctypes.rst:786 msgid "" ">>> pi.contents\n" "c_long(42)\n" @@ -1491,13 +1576,13 @@ msgstr "" "c_long(42)\n" ">>>" -#: ../../library/ctypes.rst:774 +#: ../../library/ctypes.rst:790 msgid "" "Note that :mod:`ctypes` does not have OOR (original object return), it " "constructs a new, equivalent object each time you retrieve an attribute::" msgstr "" -#: ../../library/ctypes.rst:777 +#: ../../library/ctypes.rst:793 msgid "" ">>> pi.contents is i\n" "False\n" @@ -1511,14 +1596,14 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:783 +#: ../../library/ctypes.rst:799 msgid "" "Assigning another :class:`c_int` instance to the pointer's contents " "attribute would cause the pointer to point to the memory location where this " "is stored::" msgstr "" -#: ../../library/ctypes.rst:786 +#: ../../library/ctypes.rst:802 msgid "" ">>> i = c_int(99)\n" ">>> pi.contents = i\n" @@ -1532,11 +1617,11 @@ msgstr "" "c_long(99)\n" ">>>" -#: ../../library/ctypes.rst:795 +#: ../../library/ctypes.rst:811 msgid "Pointer instances can also be indexed with integers::" msgstr "" -#: ../../library/ctypes.rst:797 +#: ../../library/ctypes.rst:813 msgid "" ">>> pi[0]\n" "99\n" @@ -1546,11 +1631,11 @@ msgstr "" "99\n" ">>>" -#: ../../library/ctypes.rst:801 +#: ../../library/ctypes.rst:817 msgid "Assigning to an integer index changes the pointed to value::" msgstr "" -#: ../../library/ctypes.rst:803 +#: ../../library/ctypes.rst:819 msgid "" ">>> print(i)\n" "c_long(99)\n" @@ -1566,7 +1651,7 @@ msgstr "" "c_long(22)\n" ">>>" -#: ../../library/ctypes.rst:810 +#: ../../library/ctypes.rst:826 msgid "" "It is also possible to use indexes different from 0, but you must know what " "you're doing, just as in C: You can access or change arbitrary memory " @@ -1575,7 +1660,7 @@ msgid "" "instead of a single item." msgstr "" -#: ../../library/ctypes.rst:816 +#: ../../library/ctypes.rst:832 msgid "" "Behind the scenes, the :func:`pointer` function does more than simply create " "pointer instances, it has to create pointer *types* first. This is done with " @@ -1583,7 +1668,7 @@ msgid "" "returns a new type::" msgstr "" -#: ../../library/ctypes.rst:821 +#: ../../library/ctypes.rst:837 msgid "" ">>> PI = POINTER(c_int)\n" ">>> PI\n" @@ -1607,13 +1692,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:832 +#: ../../library/ctypes.rst:848 msgid "" "Calling the pointer type without an argument creates a ``NULL`` pointer. " "``NULL`` pointers have a ``False`` boolean value::" msgstr "" -#: ../../library/ctypes.rst:835 +#: ../../library/ctypes.rst:851 msgid "" ">>> null_ptr = POINTER(c_int)()\n" ">>> print(bool(null_ptr))\n" @@ -1625,13 +1710,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:840 +#: ../../library/ctypes.rst:856 msgid "" ":mod:`ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" -#: ../../library/ctypes.rst:843 +#: ../../library/ctypes.rst:859 msgid "" ">>> null_ptr[0]\n" "Traceback (most recent call last):\n" @@ -1657,11 +1742,11 @@ msgstr "" "ValueError: NULL pointer access\n" ">>>" -#: ../../library/ctypes.rst:859 +#: ../../library/ctypes.rst:875 msgid "Type conversions" msgstr "" -#: ../../library/ctypes.rst:861 +#: ../../library/ctypes.rst:877 msgid "" "Usually, ctypes does strict type checking. This means, if you have " "``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or " @@ -1672,7 +1757,7 @@ msgid "" "ctypes accepts an array of c_int::" msgstr "" -#: ../../library/ctypes.rst:868 +#: ../../library/ctypes.rst:884 msgid "" ">>> class Bar(Structure):\n" "... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" @@ -1702,7 +1787,7 @@ msgstr "" "3\n" ">>>" -#: ../../library/ctypes.rst:882 +#: ../../library/ctypes.rst:898 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " "type (such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object " @@ -1711,11 +1796,11 @@ msgid "" "automatically." msgstr "" -#: ../../library/ctypes.rst:887 +#: ../../library/ctypes.rst:903 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" msgstr "" -#: ../../library/ctypes.rst:889 +#: ../../library/ctypes.rst:905 msgid "" ">>> bar.values = None\n" ">>>" @@ -1723,7 +1808,7 @@ msgstr "" ">>> bar.values = None\n" ">>>" -#: ../../library/ctypes.rst:894 +#: ../../library/ctypes.rst:910 msgid "" "Sometimes you have instances of incompatible types. In C, you can cast one " "type into another type. :mod:`ctypes` provides a :func:`cast` function " @@ -1732,7 +1817,7 @@ msgid "" "``values`` field, but not instances of other types::" msgstr "" -#: ../../library/ctypes.rst:900 +#: ../../library/ctypes.rst:916 msgid "" ">>> bar.values = (c_byte * 4)()\n" "Traceback (most recent call last):\n" @@ -1748,11 +1833,11 @@ msgstr "" "instance\n" ">>>" -#: ../../library/ctypes.rst:906 +#: ../../library/ctypes.rst:922 msgid "For these cases, the :func:`cast` function is handy." msgstr "" -#: ../../library/ctypes.rst:908 +#: ../../library/ctypes.rst:924 msgid "" "The :func:`cast` function can be used to cast a ctypes instance into a " "pointer to a different ctypes data type. :func:`cast` takes two parameters, " @@ -1761,7 +1846,7 @@ msgid "" "references the same memory block as the first argument::" msgstr "" -#: ../../library/ctypes.rst:914 +#: ../../library/ctypes.rst:930 msgid "" ">>> a = (c_byte * 4)()\n" ">>> cast(a, POINTER(c_int))\n" @@ -1773,13 +1858,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:919 +#: ../../library/ctypes.rst:935 msgid "" "So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` " "the structure::" msgstr "" -#: ../../library/ctypes.rst:922 +#: ../../library/ctypes.rst:938 msgid "" ">>> bar = Bar()\n" ">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" @@ -1793,18 +1878,18 @@ msgstr "" "0\n" ">>>" -#: ../../library/ctypes.rst:932 +#: ../../library/ctypes.rst:948 msgid "Incomplete Types" msgstr "" -#: ../../library/ctypes.rst:934 +#: ../../library/ctypes.rst:950 msgid "" "*Incomplete Types* are structures, unions or arrays whose members are not " "yet specified. In C, they are specified by forward declarations, which are " "defined later::" msgstr "" -#: ../../library/ctypes.rst:938 +#: ../../library/ctypes.rst:954 msgid "" "struct cell; /* forward declaration */\n" "\n" @@ -1814,13 +1899,13 @@ msgid "" "};" msgstr "" -#: ../../library/ctypes.rst:945 +#: ../../library/ctypes.rst:961 msgid "" "The straightforward translation into ctypes code would be this, but it does " "not work::" msgstr "" -#: ../../library/ctypes.rst:948 +#: ../../library/ctypes.rst:964 msgid "" ">>> class cell(Structure):\n" "... _fields_ = [(\"name\", c_char_p),\n" @@ -1842,14 +1927,14 @@ msgstr "" "NameError: name 'cell' is not defined\n" ">>>" -#: ../../library/ctypes.rst:958 +#: ../../library/ctypes.rst:974 msgid "" "because the new ``class cell`` is not available in the class statement " "itself. In :mod:`ctypes`, we can define the ``cell`` class and set the :attr:" "`~Structure._fields_` attribute later, after the class statement::" msgstr "" -#: ../../library/ctypes.rst:962 +#: ../../library/ctypes.rst:978 msgid "" ">>> from ctypes import *\n" ">>> class cell(Structure):\n" @@ -1867,13 +1952,13 @@ msgstr "" "... (\"next\", POINTER(cell))]\n" ">>>" -#: ../../library/ctypes.rst:970 +#: ../../library/ctypes.rst:986 msgid "" "Let's try it. We create two instances of ``cell``, and let them point to " "each other, and finally follow the pointer chain a few times::" msgstr "" -#: ../../library/ctypes.rst:973 +#: ../../library/ctypes.rst:989 msgid "" ">>> c1 = cell()\n" ">>> c1.name = b\"foo\"\n" @@ -1903,24 +1988,24 @@ msgstr "" "foo bar foo bar foo bar foo bar\n" ">>>" -#: ../../library/ctypes.rst:991 +#: ../../library/ctypes.rst:1007 msgid "Callback functions" msgstr "回呼函式" -#: ../../library/ctypes.rst:993 +#: ../../library/ctypes.rst:1009 msgid "" ":mod:`ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" -#: ../../library/ctypes.rst:996 +#: ../../library/ctypes.rst:1012 msgid "" "First, you must create a class for the callback function. The class knows " "the calling convention, the return type, and the number and types of " "arguments this function will receive." msgstr "" -#: ../../library/ctypes.rst:1000 +#: ../../library/ctypes.rst:1016 msgid "" "The :func:`CFUNCTYPE` factory function creates types for callback functions " "using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` " @@ -1928,21 +2013,21 @@ msgid "" "calling convention." msgstr "" -#: ../../library/ctypes.rst:1005 +#: ../../library/ctypes.rst:1021 msgid "" "Both of these factory functions are called with the result type as first " "argument, and the callback functions expected argument types as the " "remaining arguments." msgstr "" -#: ../../library/ctypes.rst:1009 +#: ../../library/ctypes.rst:1025 msgid "" "I will present an example here which uses the standard C library's :c:func:`!" "qsort` function, that is used to sort items with the help of a callback " "function. :c:func:`!qsort` will be used to sort an array of integers::" msgstr "" -#: ../../library/ctypes.rst:1013 +#: ../../library/ctypes.rst:1029 msgid "" ">>> IntArray5 = c_int * 5\n" ">>> ia = IntArray5(5, 1, 7, 33, 99)\n" @@ -1956,7 +2041,7 @@ msgstr "" ">>> qsort.restype = None\n" ">>>" -#: ../../library/ctypes.rst:1019 +#: ../../library/ctypes.rst:1035 msgid "" ":func:`!qsort` must be called with a pointer to the data to sort, the number " "of items in the data array, the size of one item, and a pointer to the " @@ -1966,13 +2051,13 @@ msgid "" "otherwise." msgstr "" -#: ../../library/ctypes.rst:1025 +#: ../../library/ctypes.rst:1041 msgid "" "So our callback function receives pointers to integers, and must return an " "integer. First we create the ``type`` for the callback function::" msgstr "" -#: ../../library/ctypes.rst:1028 +#: ../../library/ctypes.rst:1044 msgid "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" @@ -1980,13 +2065,13 @@ msgstr "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" -#: ../../library/ctypes.rst:1031 +#: ../../library/ctypes.rst:1047 msgid "" "To get started, here is a simple callback that shows the values it gets " "passed::" msgstr "" -#: ../../library/ctypes.rst:1034 +#: ../../library/ctypes.rst:1050 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2002,11 +2087,11 @@ msgstr "" ">>> cmp_func = CMPFUNC(py_cmp_func)\n" ">>>" -#: ../../library/ctypes.rst:1041 +#: ../../library/ctypes.rst:1057 msgid "The result::" msgstr "結果為: ::" -#: ../../library/ctypes.rst:1043 +#: ../../library/ctypes.rst:1059 msgid "" ">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" @@ -2024,11 +2109,11 @@ msgstr "" "py_cmp_func 1 7\n" ">>>" -#: ../../library/ctypes.rst:1051 +#: ../../library/ctypes.rst:1067 msgid "Now we can actually compare the two items and return a useful result::" msgstr "" -#: ../../library/ctypes.rst:1053 +#: ../../library/ctypes.rst:1069 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2056,11 +2141,11 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1066 +#: ../../library/ctypes.rst:1082 msgid "As we can easily check, our array is sorted now::" msgstr "" -#: ../../library/ctypes.rst:1068 +#: ../../library/ctypes.rst:1084 msgid "" ">>> for i in ia: print(i, end=\" \")\n" "...\n" @@ -2072,13 +2157,13 @@ msgstr "" "1 5 7 33 99\n" ">>>" -#: ../../library/ctypes.rst:1073 +#: ../../library/ctypes.rst:1089 msgid "" "The function factories can be used as decorator factories, so we may as well " "write::" msgstr "" -#: ../../library/ctypes.rst:1076 +#: ../../library/ctypes.rst:1092 msgid "" ">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" "... def py_cmp_func(a, b):\n" @@ -2106,14 +2191,14 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1091 +#: ../../library/ctypes.rst:1107 msgid "" "Make sure you keep references to :func:`CFUNCTYPE` objects as long as they " "are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be " "garbage collected, crashing your program when a callback is made." msgstr "" -#: ../../library/ctypes.rst:1095 +#: ../../library/ctypes.rst:1111 msgid "" "Also, note that if the callback function is called in a thread created " "outside of Python's control (e.g. by the foreign code that calls the " @@ -2123,25 +2208,25 @@ msgid "" "even when those calls are made from the same C thread." msgstr "" -#: ../../library/ctypes.rst:1105 +#: ../../library/ctypes.rst:1121 msgid "Accessing values exported from dlls" msgstr "" -#: ../../library/ctypes.rst:1107 +#: ../../library/ctypes.rst:1123 msgid "" "Some shared libraries not only export functions, they also export variables. " "An example in the Python library itself is the :c:data:`Py_Version`, Python " "runtime version number encoded in a single constant integer." msgstr "" -#: ../../library/ctypes.rst:1111 +#: ../../library/ctypes.rst:1127 msgid "" ":mod:`ctypes` can access values like this with the :meth:`~_CData.in_dll` " "class methods of the type. *pythonapi* is a predefined symbol giving access " "to the Python C api::" msgstr "" -#: ../../library/ctypes.rst:1115 +#: ../../library/ctypes.rst:1131 msgid "" ">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" ">>> print(hex(version.value))\n" @@ -2151,17 +2236,17 @@ msgstr "" ">>> print(hex(version.value))\n" "0x30c00a0" -#: ../../library/ctypes.rst:1119 +#: ../../library/ctypes.rst:1135 msgid "" "An extended example which also demonstrates the use of pointers accesses " "the :c:data:`PyImport_FrozenModules` pointer exported by Python." msgstr "" -#: ../../library/ctypes.rst:1122 +#: ../../library/ctypes.rst:1138 msgid "Quoting the docs for that value:" msgstr "" -#: ../../library/ctypes.rst:1124 +#: ../../library/ctypes.rst:1140 msgid "" "This pointer is initialized to point to an array of :c:struct:`_frozen` " "records, terminated by one whose members are all ``NULL`` or zero. When a " @@ -2170,13 +2255,13 @@ msgid "" "frozen modules." msgstr "" -#: ../../library/ctypes.rst:1129 +#: ../../library/ctypes.rst:1145 msgid "" "So manipulating this pointer could even prove useful. To restrict the " "example size, we show only how this table can be read with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1132 +#: ../../library/ctypes.rst:1148 msgid "" ">>> from ctypes import *\n" ">>>\n" @@ -2200,13 +2285,13 @@ msgstr "" "...\n" ">>>" -#: ../../library/ctypes.rst:1143 +#: ../../library/ctypes.rst:1159 msgid "" "We have defined the :c:struct:`_frozen` data type, so we can get the pointer " "to the table::" msgstr "" -#: ../../library/ctypes.rst:1146 +#: ../../library/ctypes.rst:1162 msgid "" ">>> FrozenTable = POINTER(struct_frozen)\n" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" @@ -2216,7 +2301,7 @@ msgstr "" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" ">>>" -#: ../../library/ctypes.rst:1150 +#: ../../library/ctypes.rst:1166 msgid "" "Since ``table`` is a ``pointer`` to the array of ``struct_frozen`` records, " "we can iterate over it, but we just have to make sure that our loop " @@ -2225,7 +2310,7 @@ msgid "" "the loop when we hit the ``NULL`` entry::" msgstr "" -#: ../../library/ctypes.rst:1156 +#: ../../library/ctypes.rst:1172 msgid "" ">>> for item in table:\n" "... if item.name is None:\n" @@ -2247,28 +2332,28 @@ msgstr "" "zipimport 12345\n" ">>>" -#: ../../library/ctypes.rst:1166 +#: ../../library/ctypes.rst:1182 msgid "" "The fact that standard Python has a frozen module and a frozen package " "(indicated by the negative ``size`` member) is not well known, it is only " "used for testing. Try it out with ``import __hello__`` for example." msgstr "" -#: ../../library/ctypes.rst:1174 +#: ../../library/ctypes.rst:1190 msgid "Surprises" msgstr "" -#: ../../library/ctypes.rst:1176 +#: ../../library/ctypes.rst:1192 msgid "" "There are some edges in :mod:`ctypes` where you might expect something other " "than what actually happens." msgstr "" -#: ../../library/ctypes.rst:1179 +#: ../../library/ctypes.rst:1195 msgid "Consider the following example::" msgstr "" -#: ../../library/ctypes.rst:1181 +#: ../../library/ctypes.rst:1197 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -2306,13 +2391,13 @@ msgstr "" "3 4 3 4\n" ">>>" -#: ../../library/ctypes.rst:1199 +#: ../../library/ctypes.rst:1215 msgid "" "Hm. We certainly expected the last statement to print ``3 4 1 2``. What " "happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::" msgstr "" -#: ../../library/ctypes.rst:1202 +#: ../../library/ctypes.rst:1218 msgid "" ">>> temp0, temp1 = rc.b, rc.a\n" ">>> rc.a = temp0\n" @@ -2324,7 +2409,7 @@ msgstr "" ">>> rc.b = temp1\n" ">>>" -#: ../../library/ctypes.rst:1207 +#: ../../library/ctypes.rst:1223 msgid "" "Note that ``temp0`` and ``temp1`` are objects still using the internal " "buffer of the ``rc`` object above. So executing ``rc.a = temp0`` copies the " @@ -2333,20 +2418,20 @@ msgid "" "have the expected effect." msgstr "" -#: ../../library/ctypes.rst:1213 +#: ../../library/ctypes.rst:1229 msgid "" "Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays " "doesn't *copy* the sub-object, instead it retrieves a wrapper object " "accessing the root-object's underlying buffer." msgstr "" -#: ../../library/ctypes.rst:1217 +#: ../../library/ctypes.rst:1233 msgid "" "Another example that may behave differently from what one would expect is " "this::" msgstr "" -#: ../../library/ctypes.rst:1219 +#: ../../library/ctypes.rst:1235 msgid "" ">>> s = c_char_p()\n" ">>> s.value = b\"abc def ghi\"\n" @@ -2364,13 +2449,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:1229 +#: ../../library/ctypes.rst:1245 msgid "" "Objects instantiated from :class:`c_char_p` can only have their value set to " "bytes or integers." msgstr "" -#: ../../library/ctypes.rst:1232 +#: ../../library/ctypes.rst:1248 msgid "" "Why is it printing ``False``? ctypes instances are objects containing a " "memory block plus some :term:`descriptor`\\s accessing the contents of the " @@ -2379,16 +2464,16 @@ msgid "" "the contents again constructs a new Python object each time!" msgstr "" -#: ../../library/ctypes.rst:1242 +#: ../../library/ctypes.rst:1258 msgid "Variable-sized data types" msgstr "" -#: ../../library/ctypes.rst:1244 +#: ../../library/ctypes.rst:1260 msgid "" ":mod:`ctypes` provides some support for variable-sized arrays and structures." msgstr "" -#: ../../library/ctypes.rst:1246 +#: ../../library/ctypes.rst:1262 msgid "" "The :func:`resize` function can be used to resize the memory buffer of an " "existing ctypes object. The function takes the object as first argument, " @@ -2397,7 +2482,7 @@ msgid "" "objects type, a :exc:`ValueError` is raised if this is tried::" msgstr "" -#: ../../library/ctypes.rst:1252 +#: ../../library/ctypes.rst:1268 msgid "" ">>> short_array = (c_short * 4)()\n" ">>> print(sizeof(short_array))\n" @@ -2427,14 +2512,14 @@ msgstr "" "8\n" ">>>" -#: ../../library/ctypes.rst:1266 +#: ../../library/ctypes.rst:1282 msgid "" "This is nice and fine, but how would one access the additional elements " "contained in this array? Since the type still only knows about 4 elements, " "we get errors accessing other elements::" msgstr "" -#: ../../library/ctypes.rst:1270 +#: ../../library/ctypes.rst:1286 msgid "" ">>> short_array[:]\n" "[0, 0, 0, 0]\n" @@ -2452,28 +2537,28 @@ msgstr "" "IndexError: invalid index\n" ">>>" -#: ../../library/ctypes.rst:1278 +#: ../../library/ctypes.rst:1294 msgid "" "Another way to use variable-sized data types with :mod:`ctypes` is to use " "the dynamic nature of Python, and (re-)define the data type after the " "required size is already known, on a case by case basis." msgstr "" -#: ../../library/ctypes.rst:1286 +#: ../../library/ctypes.rst:1302 msgid "ctypes reference" msgstr "" -#: ../../library/ctypes.rst:1292 +#: ../../library/ctypes.rst:1308 msgid "Finding shared libraries" msgstr "" -#: ../../library/ctypes.rst:1294 +#: ../../library/ctypes.rst:1310 msgid "" "When programming in a compiled language, shared libraries are accessed when " "compiling/linking a program, and when the program is run." msgstr "" -#: ../../library/ctypes.rst:1297 +#: ../../library/ctypes.rst:1313 msgid "" "The purpose of the :func:`~ctypes.util.find_library` function is to locate a " "library in a way similar to what the compiler or runtime loader does (on " @@ -2482,13 +2567,13 @@ msgid "" "and call the runtime loader directly." msgstr "" -#: ../../library/ctypes.rst:1303 +#: ../../library/ctypes.rst:1319 msgid "" "The :mod:`!ctypes.util` module provides a function which can help to " "determine the library to load." msgstr "" -#: ../../library/ctypes.rst:1311 +#: ../../library/ctypes.rst:1327 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 " @@ -2496,29 +2581,29 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1316 ../../library/ctypes.rst:2022 +#: ../../library/ctypes.rst:1332 ../../library/ctypes.rst:2038 msgid "The exact functionality is system dependent." msgstr "" -#: ../../library/ctypes.rst:1318 +#: ../../library/ctypes.rst:1334 msgid "" "On Linux, :func:`~ctypes.util.find_library` tries to run external programs " "(``/sbin/ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library " "file. It returns the filename of the library file." msgstr "" -#: ../../library/ctypes.rst:1322 +#: ../../library/ctypes.rst:1338 msgid "" "On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used " "when searching for libraries, if a library cannot be found by any other " "means." msgstr "" -#: ../../library/ctypes.rst:1326 +#: ../../library/ctypes.rst:1342 msgid "Here are some examples::" msgstr "以下是一些範例: ::" -#: ../../library/ctypes.rst:1328 +#: ../../library/ctypes.rst:1344 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"m\")\n" @@ -2538,14 +2623,14 @@ msgstr "" "'libbz2.so.1.0'\n" ">>>" -#: ../../library/ctypes.rst:1337 +#: ../../library/ctypes.rst:1353 msgid "" "On macOS and Android, :func:`~ctypes.util.find_library` uses the system's " "standard naming schemes and paths to locate the library, and returns a full " "pathname if successful::" msgstr "" -#: ../../library/ctypes.rst:1341 +#: ../../library/ctypes.rst:1357 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"c\")\n" @@ -2569,7 +2654,7 @@ msgstr "" "'/System/Library/Frameworks/AGL.framework/AGL'\n" ">>>" -#: ../../library/ctypes.rst:1352 +#: ../../library/ctypes.rst:1368 msgid "" "On Windows, :func:`~ctypes.util.find_library` searches along the system " "search path, and returns the full pathname, but since there is no predefined " @@ -2577,7 +2662,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/ctypes.rst:1356 +#: ../../library/ctypes.rst:1372 msgid "" "If wrapping a shared library with :mod:`ctypes`, it *may* be better to " "determine the shared library name at development time, and hardcode that " @@ -2585,24 +2670,24 @@ msgid "" "to locate the library at runtime." msgstr "" -#: ../../library/ctypes.rst:1364 +#: ../../library/ctypes.rst:1380 msgid "Loading shared libraries" msgstr "" -#: ../../library/ctypes.rst:1366 +#: ../../library/ctypes.rst:1382 msgid "" "There are several ways to load shared libraries into the Python process. " "One way is to instantiate one of the following classes:" msgstr "" -#: ../../library/ctypes.rst:1372 +#: ../../library/ctypes.rst:1388 msgid "" "Instances of this class represent loaded shared libraries. Functions in " "these libraries use the standard C calling convention, and are assumed to " "return :c:expr:`int`." msgstr "" -#: ../../library/ctypes.rst:1376 +#: ../../library/ctypes.rst:1392 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:" @@ -2614,18 +2699,18 @@ msgid "" "determine which one is not found using Windows debugging and tracing tools." msgstr "" -#: ../../library/ctypes.rst:1388 ../../library/ctypes.rst:1413 -#: ../../library/ctypes.rst:1426 ../../library/ctypes.rst:1444 +#: ../../library/ctypes.rst:1404 ../../library/ctypes.rst:1429 +#: ../../library/ctypes.rst:1442 ../../library/ctypes.rst:1460 msgid "The *name* parameter can now be a :term:`path-like object`." msgstr "" -#: ../../library/ctypes.rst:1392 +#: ../../library/ctypes.rst:1408 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL dependents." msgstr "" -#: ../../library/ctypes.rst:1398 +#: ../../library/ctypes.rst:1414 msgid "" "Instances of this class represent loaded shared libraries, functions in " "these libraries use the ``stdcall`` calling convention, and are assumed to " @@ -2635,36 +2720,36 @@ msgid "" "a failure, an :class:`OSError` is automatically raised." msgstr "" -#: ../../library/ctypes.rst:1405 ../../library/ctypes.rst:1422 -#: ../../library/ctypes.rst:1566 ../../library/ctypes.rst:1574 -#: ../../library/ctypes.rst:1751 ../../library/ctypes.rst: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 +#: ../../library/ctypes.rst:1421 ../../library/ctypes.rst:1438 +#: ../../library/ctypes.rst:1582 ../../library/ctypes.rst:1590 +#: ../../library/ctypes.rst:1767 ../../library/ctypes.rst:2018 +#: ../../library/ctypes.rst:2027 ../../library/ctypes.rst:2052 +#: ../../library/ctypes.rst:2061 ../../library/ctypes.rst:2070 +#: ../../library/ctypes.rst:2085 ../../library/ctypes.rst:2142 +#: ../../library/ctypes.rst:2170 ../../library/ctypes.rst:2514 msgid "Availability" msgstr "可用性" -#: ../../library/ctypes.rst:1407 +#: ../../library/ctypes.rst:1423 msgid "" ":exc:`WindowsError` used to be raised, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/ctypes.rst:1418 +#: ../../library/ctypes.rst:1434 msgid "" "Instances of this class represent loaded shared libraries, functions in " "these libraries use the ``stdcall`` calling convention, and are assumed to " "return :c:expr:`int` by default." msgstr "" -#: ../../library/ctypes.rst:1429 +#: ../../library/ctypes.rst:1445 msgid "" "The Python :term:`global interpreter lock` is released before calling any " "function exported by these libraries, and reacquired afterwards." msgstr "" -#: ../../library/ctypes.rst:1435 +#: ../../library/ctypes.rst:1451 msgid "" "Instances of this class behave like :class:`CDLL` instances, except that the " "Python GIL is *not* released during the function call, and after the " @@ -2672,11 +2757,11 @@ msgid "" "set, a Python exception is raised." msgstr "" -#: ../../library/ctypes.rst:1440 +#: ../../library/ctypes.rst:1456 msgid "Thus, this is only useful to call Python C api functions directly." msgstr "" -#: ../../library/ctypes.rst:1446 +#: ../../library/ctypes.rst:1462 msgid "" "All these classes can be instantiated by calling them with at least one " "argument, the pathname of the shared library. If you have an existing " @@ -2686,7 +2771,7 @@ msgid "" "the process, and to get a handle to it." msgstr "" -#: ../../library/ctypes.rst:1453 +#: ../../library/ctypes.rst:1469 msgid "" "The *mode* parameter can be used to specify how the library is loaded. For " "details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is " @@ -2694,7 +2779,7 @@ msgid "" "configurable." msgstr "" -#: ../../library/ctypes.rst:1458 +#: ../../library/ctypes.rst:1474 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:" @@ -2704,14 +2789,14 @@ msgid "" "private copy, the same happens immediately after the function call." msgstr "" -#: ../../library/ctypes.rst:1465 +#: ../../library/ctypes.rst:1481 msgid "" "The function :func:`ctypes.get_errno` returns the value of the ctypes " "private copy, and the function :func:`ctypes.set_errno` changes the ctypes " "private copy to a new value and returns the former value." msgstr "" -#: ../../library/ctypes.rst:1469 +#: ../../library/ctypes.rst:1485 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 :" @@ -2720,7 +2805,7 @@ msgid "" "private copy of the windows error code." msgstr "" -#: ../../library/ctypes.rst:1475 +#: ../../library/ctypes.rst:1491 msgid "" "The *winmode* parameter is used on Windows to specify how the library is " "loaded (since *mode* is ignored). It takes any value that is valid for the " @@ -2730,29 +2815,29 @@ msgid "" "ensure the correct library and dependencies are loaded." msgstr "" -#: ../../library/ctypes.rst:1482 +#: ../../library/ctypes.rst:1498 msgid "Added *winmode* parameter." msgstr "新增 *winmode* 參數。" -#: ../../library/ctypes.rst:1489 +#: ../../library/ctypes.rst:1505 msgid "" "Flag to use as *mode* parameter. On platforms where this flag is not " "available, it is defined as the integer zero." msgstr "" -#: ../../library/ctypes.rst:1496 +#: ../../library/ctypes.rst:1512 msgid "" "Flag to use as *mode* parameter. On platforms where this is not available, " "it is the same as *RTLD_GLOBAL*." msgstr "" -#: ../../library/ctypes.rst:1503 +#: ../../library/ctypes.rst:1519 msgid "" "The default mode which is used to load shared libraries. On OSX 10.3, this " "is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*." msgstr "" -#: ../../library/ctypes.rst:1506 +#: ../../library/ctypes.rst:1522 msgid "" "Instances of these classes have no public methods. Functions exported by " "the shared library can be accessed as attributes or by index. Please note " @@ -2761,7 +2846,7 @@ msgid "" "other hand, accessing it through an index returns a new object each time::" msgstr "" -#: ../../library/ctypes.rst:1512 +#: ../../library/ctypes.rst:1528 msgid "" ">>> from ctypes import CDLL\n" ">>> libc = CDLL(\"libc.so.6\") # On Linux\n" @@ -2777,21 +2862,21 @@ msgstr "" ">>> libc['time'] == libc['time']\n" "False" -#: ../../library/ctypes.rst:1519 +#: ../../library/ctypes.rst:1535 msgid "" "The following public attributes are available, their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: ../../library/ctypes.rst:1525 +#: ../../library/ctypes.rst:1541 msgid "The system handle used to access the library." msgstr "" -#: ../../library/ctypes.rst:1530 +#: ../../library/ctypes.rst:1546 msgid "The name of the library passed in the constructor." msgstr "" -#: ../../library/ctypes.rst:1532 +#: ../../library/ctypes.rst:1548 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -2799,13 +2884,13 @@ msgid "" "library as attribute of the loader instance." msgstr "" -#: ../../library/ctypes.rst:1540 +#: ../../library/ctypes.rst:1556 msgid "" "Class which loads shared libraries. *dlltype* should be one of the :class:" "`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types." msgstr "" -#: ../../library/ctypes.rst:1543 +#: ../../library/ctypes.rst:1559 msgid "" ":meth:`!__getattr__` has special behavior: It allows loading a shared " "library by accessing it as attribute of a library loader instance. The " @@ -2813,39 +2898,39 @@ msgid "" "each time." msgstr "" -#: ../../library/ctypes.rst:1549 +#: ../../library/ctypes.rst:1565 msgid "" "Load a shared library into the process and return it. This method always " "returns a new instance of the library." msgstr "" -#: ../../library/ctypes.rst:1553 +#: ../../library/ctypes.rst:1569 msgid "These prefabricated library loaders are available:" msgstr "" -#: ../../library/ctypes.rst:1558 +#: ../../library/ctypes.rst:1574 msgid "Creates :class:`CDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1564 +#: ../../library/ctypes.rst:1580 msgid "Creates :class:`WinDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1572 +#: ../../library/ctypes.rst:1588 msgid "Creates :class:`OleDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1580 +#: ../../library/ctypes.rst:1596 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1583 +#: ../../library/ctypes.rst:1599 msgid "" "For accessing the C Python api directly, a ready-to-use Python shared " "library object is available:" msgstr "" -#: ../../library/ctypes.rst:1589 +#: ../../library/ctypes.rst:1605 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:" @@ -2853,32 +2938,32 @@ msgid "" "correct :attr:`!restype` attribute to use these functions." msgstr "" -#: ../../library/ctypes.rst:1594 ../../library/ctypes.rst:1596 +#: ../../library/ctypes.rst:1610 ../../library/ctypes.rst:1612 msgid "" "Loading a library through any of these objects raises an :ref:`auditing " "event ` ``ctypes.dlopen`` with string argument ``name``, the name " "used to load the library." msgstr "" -#: ../../library/ctypes.rst:1600 ../../library/ctypes.rst:1602 +#: ../../library/ctypes.rst:1616 ../../library/ctypes.rst:1618 msgid "" "Accessing a function on a loaded library raises an auditing event ``ctypes." "dlsym`` with arguments ``library`` (the library object) and ``name`` (the " "symbol's name as a string or integer)." msgstr "" -#: ../../library/ctypes.rst:1606 ../../library/ctypes.rst:1608 +#: ../../library/ctypes.rst:1622 ../../library/ctypes.rst:1624 msgid "" "In cases when only the library handle is available rather than the object, " "accessing a function raises an auditing event ``ctypes.dlsym/handle`` with " "arguments ``handle`` (the raw library handle) and ``name``." msgstr "" -#: ../../library/ctypes.rst:1615 +#: ../../library/ctypes.rst:1631 msgid "Foreign functions" msgstr "" -#: ../../library/ctypes.rst:1617 +#: ../../library/ctypes.rst:1633 msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " @@ -2887,13 +2972,13 @@ msgid "" "library loader." msgstr "" -#: ../../library/ctypes.rst:1622 +#: ../../library/ctypes.rst:1638 msgid "" "They are instances of a private local class :class:`!_FuncPtr` (not exposed " "in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:" msgstr "" -#: ../../library/ctypes.rst:1625 +#: ../../library/ctypes.rst:1641 msgid "" ">>> import ctypes\n" ">>> lib = ctypes.CDLL(None)\n" @@ -2903,29 +2988,29 @@ msgid "" "False" msgstr "" -#: ../../library/ctypes.rst:1636 +#: ../../library/ctypes.rst:1652 msgid "Base class for C callable foreign functions." msgstr "" -#: ../../library/ctypes.rst:1638 +#: ../../library/ctypes.rst:1654 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: ../../library/ctypes.rst:1641 +#: ../../library/ctypes.rst:1657 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: ../../library/ctypes.rst:1646 +#: ../../library/ctypes.rst:1662 msgid "" "Assign a ctypes type to specify the result type of the foreign function. Use " "``None`` for :c:expr:`void`, a function not returning anything." msgstr "" -#: ../../library/ctypes.rst:1649 +#: ../../library/ctypes.rst:1665 msgid "" "It is possible to assign a callable Python object that is not a ctypes type, " "in this case the function is assumed to return a C :c:expr:`int`, and the " @@ -2935,7 +3020,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: ../../library/ctypes.rst:1658 +#: ../../library/ctypes.rst:1674 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -2944,7 +3029,7 @@ msgid "" "unspecified arguments as well." msgstr "" -#: ../../library/ctypes.rst:1664 +#: ../../library/ctypes.rst:1680 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` " @@ -2954,7 +3039,7 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1671 +#: ../../library/ctypes.rst:1687 msgid "" "New: It is now possible to put items in argtypes which are not ctypes types, " "but each item must have a :meth:`~_CData.from_param` method which returns a " @@ -2962,44 +3047,44 @@ msgid "" "defining adapters that can adapt custom objects as function parameters." msgstr "" -#: ../../library/ctypes.rst:1678 +#: ../../library/ctypes.rst:1694 msgid "" "Assign a Python function or another callable to this attribute. The callable " "will be called with three or more arguments:" msgstr "" -#: ../../library/ctypes.rst:1685 +#: ../../library/ctypes.rst:1701 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" -#: ../../library/ctypes.rst:1688 +#: ../../library/ctypes.rst:1704 msgid "" "*func* is the foreign function object itself, this allows reusing the same " "callable object to check or post process the results of several functions." msgstr "" -#: ../../library/ctypes.rst:1692 +#: ../../library/ctypes.rst:1708 msgid "" "*arguments* is a tuple containing the parameters originally passed to the " "function call, this allows specializing the behavior on the arguments used." msgstr "" -#: ../../library/ctypes.rst:1696 +#: ../../library/ctypes.rst:1712 msgid "" "The object that this function returns will be returned from the foreign " "function call, but it can also check the result value and raise an exception " "if the foreign function call failed." msgstr "" -#: ../../library/ctypes.rst:1703 +#: ../../library/ctypes.rst:1719 msgid "" "This exception is raised when a foreign function call cannot convert one of " "the passed arguments." msgstr "" -#: ../../library/ctypes.rst:1707 ../../library/ctypes.rst:1709 +#: ../../library/ctypes.rst:1723 ../../library/ctypes.rst:1725 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 " @@ -3008,18 +3093,18 @@ msgid "" "hook to replace the exception with its own." msgstr "" -#: ../../library/ctypes.rst:1715 ../../library/ctypes.rst:1717 +#: ../../library/ctypes.rst:1731 ../../library/ctypes.rst:1733 msgid "" "Some ways to invoke foreign function calls may raise an auditing event " "``ctypes.call_function`` with arguments ``function pointer`` and " "``arguments``." msgstr "" -#: ../../library/ctypes.rst:1723 +#: ../../library/ctypes.rst:1739 msgid "Function prototypes" msgstr "" -#: ../../library/ctypes.rst:1725 +#: ../../library/ctypes.rst:1741 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -3030,7 +3115,7 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: ../../library/ctypes.rst:1736 +#: ../../library/ctypes.rst:1752 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " @@ -3039,37 +3124,37 @@ msgid "" "after the call; *use_last_error* does the same for the Windows error code." msgstr "" -#: ../../library/ctypes.rst:1746 +#: ../../library/ctypes.rst:1762 msgid "" "The returned function prototype creates functions that use the ``stdcall`` " "calling convention. The function will release the GIL during the call. " "*use_errno* and *use_last_error* have the same meaning as above." msgstr "" -#: ../../library/ctypes.rst:1756 +#: ../../library/ctypes.rst:1772 msgid "" "The returned function prototype creates functions that use the Python " "calling convention. The function will *not* release the GIL during the call." msgstr "" -#: ../../library/ctypes.rst:1759 +#: ../../library/ctypes.rst:1775 msgid "" "Function prototypes created by these factory functions can be instantiated " "in different ways, depending on the type and number of the parameters in the " "call:" msgstr "" -#: ../../library/ctypes.rst:1766 +#: ../../library/ctypes.rst:1782 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: ../../library/ctypes.rst:1773 +#: ../../library/ctypes.rst:1789 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: ../../library/ctypes.rst:1780 +#: ../../library/ctypes.rst:1796 msgid "" "Returns a foreign function exported by a shared library. *func_spec* must be " "a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of the " @@ -3077,7 +3162,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: ../../library/ctypes.rst:1790 +#: ../../library/ctypes.rst:1806 msgid "" "Returns a foreign function that will call a COM method. *vtbl_index* is the " "index into the virtual function table, a small non-negative integer. *name* " @@ -3085,79 +3170,79 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: ../../library/ctypes.rst:1795 +#: ../../library/ctypes.rst:1811 msgid "" "COM methods use a special calling convention: They require a pointer to the " "COM interface as first argument, in addition to those parameters that are " "specified in the :attr:`!argtypes` tuple." msgstr "" -#: ../../library/ctypes.rst:1799 +#: ../../library/ctypes.rst:1815 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: ../../library/ctypes.rst:1802 +#: ../../library/ctypes.rst:1818 msgid "" "*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." "argtypes`." msgstr "" -#: ../../library/ctypes.rst:1804 +#: ../../library/ctypes.rst:1820 msgid "" "Each item in this tuple contains further information about a parameter, it " "must be a tuple containing one, two, or three items." msgstr "" -#: ../../library/ctypes.rst:1807 +#: ../../library/ctypes.rst:1823 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: ../../library/ctypes.rst:1810 +#: ../../library/ctypes.rst:1826 msgid "1" msgstr "1" -#: ../../library/ctypes.rst:1811 +#: ../../library/ctypes.rst:1827 msgid "Specifies an input parameter to the function." msgstr "" -#: ../../library/ctypes.rst:1813 +#: ../../library/ctypes.rst:1829 msgid "2" msgstr "2" -#: ../../library/ctypes.rst:1814 +#: ../../library/ctypes.rst:1830 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: ../../library/ctypes.rst:1816 +#: ../../library/ctypes.rst:1832 msgid "4" msgstr "4" -#: ../../library/ctypes.rst:1817 +#: ../../library/ctypes.rst:1833 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: ../../library/ctypes.rst:1819 +#: ../../library/ctypes.rst:1835 msgid "" "The optional second item is the parameter name as string. If this is " "specified, the foreign function can be called with named parameters." msgstr "" -#: ../../library/ctypes.rst:1822 +#: ../../library/ctypes.rst:1838 msgid "The optional third item is the default value for this parameter." msgstr "" -#: ../../library/ctypes.rst:1825 +#: ../../library/ctypes.rst:1841 msgid "" "The following example demonstrates how to wrap the Windows ``MessageBoxW`` " "function so that it supports default parameters and named arguments. The C " "declaration from the windows header file is this::" msgstr "" -#: ../../library/ctypes.rst:1829 +#: ../../library/ctypes.rst:1845 msgid "" "WINUSERAPI int WINAPI\n" "MessageBoxW(\n" @@ -3173,11 +3258,11 @@ msgstr "" " LPCWSTR lpCaption,\n" " UINT uType);" -#: ../../library/ctypes.rst:1836 ../../library/ctypes.rst:1859 +#: ../../library/ctypes.rst:1852 ../../library/ctypes.rst:1875 msgid "Here is the wrapping with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1838 +#: ../../library/ctypes.rst:1854 msgid "" ">>> from ctypes import c_int, WINFUNCTYPE, windll\n" ">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" @@ -3193,11 +3278,11 @@ msgstr "" "\"Hello from ctypes\"), (1, \"flags\", 0)\n" ">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" -#: ../../library/ctypes.rst:1844 +#: ../../library/ctypes.rst:1860 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: ../../library/ctypes.rst:1846 +#: ../../library/ctypes.rst:1862 msgid "" ">>> MessageBox()\n" ">>> MessageBox(text=\"Spam, spam, spam\")\n" @@ -3207,7 +3292,7 @@ msgstr "" ">>> MessageBox(text=\"Spam, spam, spam\")\n" ">>> MessageBox(flags=2, text=\"foo bar\")" -#: ../../library/ctypes.rst:1850 +#: ../../library/ctypes.rst:1866 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -3215,7 +3300,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:1854 +#: ../../library/ctypes.rst:1870 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" @@ -3227,7 +3312,7 @@ msgstr "" " HWND hWnd,\n" " LPRECT lpRect);" -#: ../../library/ctypes.rst:1861 +#: ../../library/ctypes.rst:1877 msgid "" ">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" ">>> from ctypes.wintypes import BOOL, HWND, RECT\n" @@ -3245,7 +3330,7 @@ msgstr "" "paramflags)\n" ">>>" -#: ../../library/ctypes.rst:1868 +#: ../../library/ctypes.rst:1884 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -3253,7 +3338,7 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: ../../library/ctypes.rst:1873 +#: ../../library/ctypes.rst:1889 msgid "" "Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "protocol to do further output processing and error checking. The win32 " @@ -3262,7 +3347,7 @@ msgid "" "exception when the api call failed::" msgstr "" -#: ../../library/ctypes.rst:1878 +#: ../../library/ctypes.rst:1894 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3280,7 +3365,7 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1886 +#: ../../library/ctypes.rst:1902 msgid "" "If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`ctypes` continues the normal processing it does on " @@ -3289,7 +3374,7 @@ msgid "" "and return them instead, the normal processing will no longer take place::" msgstr "" -#: ../../library/ctypes.rst:1892 +#: ../../library/ctypes.rst:1908 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3309,17 +3394,17 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1905 +#: ../../library/ctypes.rst:1921 msgid "Utility functions" msgstr "" -#: ../../library/ctypes.rst:1909 +#: ../../library/ctypes.rst:1925 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." msgstr "" -#: ../../library/ctypes.rst:1912 +#: ../../library/ctypes.rst:1928 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." @@ -3327,34 +3412,34 @@ msgstr "" "引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` ``ctypes." "addressof``。" -#: ../../library/ctypes.rst:1917 +#: ../../library/ctypes.rst:1933 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: ../../library/ctypes.rst:1923 +#: ../../library/ctypes.rst:1939 msgid "" "Returns a light-weight pointer to *obj*, which must be an instance of a " "ctypes type. *offset* defaults to zero, and must be an integer that will be " "added to the internal pointer value." msgstr "" -#: ../../library/ctypes.rst:1927 +#: ../../library/ctypes.rst:1943 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: ../../library/ctypes.rst:1929 +#: ../../library/ctypes.rst:1945 msgid "(((char *)&obj) + offset)" msgstr "(((char *)&obj) + offset)" -#: ../../library/ctypes.rst:1931 +#: ../../library/ctypes.rst:1947 msgid "" "The returned object can only be used as a foreign function call parameter. " "It behaves similar to ``pointer(obj)``, but the construction is a lot faster." msgstr "" -#: ../../library/ctypes.rst:1937 +#: ../../library/ctypes.rst:1953 msgid "" "This function is similar to the cast operator in C. It returns a new " "instance of *type* which points to the same memory block as *obj*. *type* " @@ -3362,47 +3447,47 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:1946 +#: ../../library/ctypes.rst:1962 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:1949 +#: ../../library/ctypes.rst:1965 msgid "" "If *size* is given (and not ``None``), it must be an :class:`int`. It " "specifies the size of the returned array." msgstr "" -#: ../../library/ctypes.rst:1952 +#: ../../library/ctypes.rst:1968 msgid "" "If the *init* argument is given, it must be :class:`bytes`. It is used to " "initialize the array items. Bytes not initialized this way are set to zero " "(NUL)." msgstr "" -#: ../../library/ctypes.rst:1956 +#: ../../library/ctypes.rst:1972 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 +#: ../../library/ctypes.rst:1975 msgid "" "If both arguments are given, *size* must not be less than ``len(init)``." msgstr "" -#: ../../library/ctypes.rst:1963 +#: ../../library/ctypes.rst:1979 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 +#: ../../library/ctypes.rst:1982 msgid "For example::" msgstr "" -#: ../../library/ctypes.rst:1968 +#: ../../library/ctypes.rst:1984 msgid "" ">>> bytes(create_string_buffer(2))\n" "b'\\x00\\x00'\n" @@ -3418,7 +3503,7 @@ msgid "" "ValueError: byte string too long" msgstr "" -#: ../../library/ctypes.rst:1981 +#: ../../library/ctypes.rst:1997 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." @@ -3426,19 +3511,19 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_string_buffer``。" -#: ../../library/ctypes.rst:1987 +#: ../../library/ctypes.rst:2003 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1990 +#: ../../library/ctypes.rst:2006 msgid "" "The function takes the same arguments as :func:`~create_string_buffer` " "except *init* must be a string and *size* counts :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1993 +#: ../../library/ctypes.rst:2009 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." @@ -3446,21 +3531,21 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_unicode_buffer``。" -#: ../../library/ctypes.rst:1998 +#: ../../library/ctypes.rst:2014 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:2007 +#: ../../library/ctypes.rst:2023 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:2017 +#: ../../library/ctypes.rst:2033 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 " @@ -3468,94 +3553,94 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:2028 +#: ../../library/ctypes.rst:2044 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:2032 +#: ../../library/ctypes.rst:2048 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:2041 +#: ../../library/ctypes.rst:2057 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:2050 +#: ../../library/ctypes.rst:2066 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:2059 +#: ../../library/ctypes.rst:2075 msgid "" "Returns the current value of the ctypes-private copy of the system :data:" "`errno` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2062 +#: ../../library/ctypes.rst:2078 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_errno``。" -#: ../../library/ctypes.rst:2066 +#: ../../library/ctypes.rst:2082 msgid "" "Returns the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2071 +#: ../../library/ctypes.rst:2087 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_last_error``。" -#: ../../library/ctypes.rst:2076 +#: ../../library/ctypes.rst:2092 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:2083 +#: ../../library/ctypes.rst:2099 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:2090 +#: ../../library/ctypes.rst:2106 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:2097 +#: ../../library/ctypes.rst:2113 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:2100 +#: ../../library/ctypes.rst:2116 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:2106 +#: ../../library/ctypes.rst:2122 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 " @@ -3563,13 +3648,13 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:2114 +#: ../../library/ctypes.rst:2130 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:2117 +#: ../../library/ctypes.rst:2133 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." @@ -3577,14 +3662,14 @@ msgstr "" "引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_errno``。" -#: ../../library/ctypes.rst:2122 +#: ../../library/ctypes.rst:2138 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:2128 +#: ../../library/ctypes.rst:2144 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." @@ -3592,19 +3677,19 @@ msgstr "" "引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_last_error``。" -#: ../../library/ctypes.rst:2133 +#: ../../library/ctypes.rst:2149 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:2139 +#: ../../library/ctypes.rst:2155 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:2143 +#: ../../library/ctypes.rst:2159 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." @@ -3612,7 +3697,7 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "string_at``。" -#: ../../library/ctypes.rst:2148 +#: ../../library/ctypes.rst:2164 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 " @@ -3620,20 +3705,20 @@ msgid "" "`FormatError` is called to get a textual description of the error." msgstr "" -#: ../../library/ctypes.rst:2156 +#: ../../library/ctypes.rst:2172 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:2163 +#: ../../library/ctypes.rst:2179 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:2168 +#: ../../library/ctypes.rst:2184 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." @@ -3641,11 +3726,11 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "wstring_at``。" -#: ../../library/ctypes.rst:2174 +#: ../../library/ctypes.rst:2190 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2179 +#: ../../library/ctypes.rst:2195 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 " @@ -3655,13 +3740,13 @@ msgid "" "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2186 +#: ../../library/ctypes.rst:2202 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:2191 +#: ../../library/ctypes.rst:2207 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " @@ -3670,7 +3755,7 @@ msgid "" "exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2197 ../../library/ctypes.rst:2207 +#: ../../library/ctypes.rst:2213 ../../library/ctypes.rst:2223 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." @@ -3678,7 +3763,7 @@ msgstr "" "引發一個附帶引數 ``pointer``、``size``、``offset`` 的\\ :ref:`稽核事件 " "` ``ctypes.cdata/buffer``。" -#: ../../library/ctypes.rst:2201 +#: ../../library/ctypes.rst:2217 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -3686,19 +3771,19 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2211 +#: ../../library/ctypes.rst:2227 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: ../../library/ctypes.rst:2214 ../../library/ctypes.rst:2216 +#: ../../library/ctypes.rst:2230 ../../library/ctypes.rst:2232 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2222 +#: ../../library/ctypes.rst:2238 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 " @@ -3706,25 +3791,25 @@ msgid "" "object that can be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2227 +#: ../../library/ctypes.rst:2243 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:2233 +#: ../../library/ctypes.rst:2249 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:2237 +#: ../../library/ctypes.rst:2253 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2241 +#: ../../library/ctypes.rst:2257 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:" @@ -3732,13 +3817,13 @@ msgid "" "block." msgstr "" -#: ../../library/ctypes.rst:2248 +#: ../../library/ctypes.rst:2264 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2253 +#: ../../library/ctypes.rst:2269 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. " @@ -3746,7 +3831,7 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2266 +#: ../../library/ctypes.rst:2282 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 " @@ -3755,11 +3840,11 @@ msgid "" "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2272 +#: ../../library/ctypes.rst:2288 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2276 +#: ../../library/ctypes.rst:2292 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 " @@ -3767,7 +3852,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2281 +#: ../../library/ctypes.rst:2297 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -3775,7 +3860,7 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2287 +#: ../../library/ctypes.rst:2303 msgid "" "Fundamental data types, when returned as foreign function call results, or, " "for example, by retrieving structure field members or array items, are " @@ -3785,7 +3870,7 @@ msgid "" "instance." msgstr "" -#: ../../library/ctypes.rst:2295 +#: ../../library/ctypes.rst:2311 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 " @@ -3793,25 +3878,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: ../../library/ctypes.rst:2300 +#: ../../library/ctypes.rst:2316 msgid "These are the fundamental ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2304 +#: ../../library/ctypes.rst:2320 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:2311 +#: ../../library/ctypes.rst:2327 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:2318 +#: ../../library/ctypes.rst:2334 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 " @@ -3819,182 +3904,182 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: ../../library/ctypes.rst:2326 +#: ../../library/ctypes.rst:2342 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2332 +#: ../../library/ctypes.rst:2348 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:2338 +#: ../../library/ctypes.rst:2354 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2344 +#: ../../library/ctypes.rst:2360 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:2351 +#: ../../library/ctypes.rst:2367 msgid "" -"Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for :" +"Represents the C 8-bit :c:expr:`signed int` datatype. It is an alias for :" "class:`c_byte`." msgstr "" -#: ../../library/ctypes.rst:2357 +#: ../../library/ctypes.rst:2373 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: ../../library/ctypes.rst:2363 +#: ../../library/ctypes.rst:2379 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: ../../library/ctypes.rst:2369 +#: ../../library/ctypes.rst:2385 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: ../../library/ctypes.rst:2375 +#: ../../library/ctypes.rst:2391 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:2381 +#: ../../library/ctypes.rst:2397 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:2387 +#: ../../library/ctypes.rst:2403 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:2393 +#: ../../library/ctypes.rst:2409 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2398 +#: ../../library/ctypes.rst:2414 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2405 +#: ../../library/ctypes.rst:2421 msgid "Represents the C :c:type:`time_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2412 +#: ../../library/ctypes.rst:2428 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:2419 +#: ../../library/ctypes.rst:2435 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:2426 +#: ../../library/ctypes.rst:2442 msgid "" -"Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias " -"for :class:`c_ubyte`." +"Represents the C 8-bit :c:expr:`unsigned int` datatype. It is an alias for :" +"class:`c_ubyte`." msgstr "" -#: ../../library/ctypes.rst:2432 +#: ../../library/ctypes.rst:2448 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: ../../library/ctypes.rst:2438 +#: ../../library/ctypes.rst:2454 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: ../../library/ctypes.rst:2444 +#: ../../library/ctypes.rst:2460 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: ../../library/ctypes.rst:2450 +#: ../../library/ctypes.rst:2466 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:2456 +#: ../../library/ctypes.rst:2472 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:2462 +#: ../../library/ctypes.rst:2478 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:2468 +#: ../../library/ctypes.rst:2484 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:2474 +#: ../../library/ctypes.rst:2490 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:2481 +#: ../../library/ctypes.rst:2497 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:2488 +#: ../../library/ctypes.rst:2504 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:2495 +#: ../../library/ctypes.rst:2511 msgid "" "Represents a :c:type:`!HRESULT` value, which contains success or error " "information for a function or method call." msgstr "" -#: ../../library/ctypes.rst:2503 +#: ../../library/ctypes.rst:2519 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: ../../library/ctypes.rst:2506 +#: ../../library/ctypes.rst:2522 msgid "" "The :mod:`!ctypes.wintypes` module provides quite some other Windows " "specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:" @@ -4002,41 +4087,41 @@ msgid "" "are also defined." msgstr "" -#: ../../library/ctypes.rst:2514 +#: ../../library/ctypes.rst:2530 msgid "Structured data types" msgstr "" -#: ../../library/ctypes.rst:2519 +#: ../../library/ctypes.rst:2535 msgid "Abstract base class for unions in native byte order." msgstr "" -#: ../../library/ctypes.rst:2524 +#: ../../library/ctypes.rst:2540 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2530 +#: ../../library/ctypes.rst:2546 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2536 +#: ../../library/ctypes.rst:2552 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2541 +#: ../../library/ctypes.rst:2557 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2543 +#: ../../library/ctypes.rst:2559 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:2549 +#: ../../library/ctypes.rst:2565 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: ../../library/ctypes.rst:2551 +#: ../../library/ctypes.rst:2567 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:" @@ -4044,34 +4129,34 @@ msgid "" "the fields by direct attribute accesses. These are the" msgstr "" -#: ../../library/ctypes.rst:2559 +#: ../../library/ctypes.rst:2575 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:2563 +#: ../../library/ctypes.rst:2579 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:2567 +#: ../../library/ctypes.rst:2583 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:2570 +#: ../../library/ctypes.rst:2586 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:2574 +#: ../../library/ctypes.rst:2590 msgid "" "class List(Structure):\n" " pass\n" @@ -4085,7 +4170,7 @@ msgstr "" " ...\n" " ]" -#: ../../library/ctypes.rst:2580 +#: ../../library/ctypes.rst:2596 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, " @@ -4093,14 +4178,14 @@ msgid "" "raise an AttributeError." msgstr "" -#: ../../library/ctypes.rst:2585 +#: ../../library/ctypes.rst:2601 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:2592 +#: ../../library/ctypes.rst:2608 msgid "" "An optional small integer that allows overriding the alignment of structure " "fields in the instance. :attr:`_pack_` must already be defined when :attr:" @@ -4108,21 +4193,21 @@ msgid "" "attribute to 0 is the same as not setting it at all." msgstr "" -#: ../../library/ctypes.rst:2600 +#: ../../library/ctypes.rst:2616 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:2608 +#: ../../library/ctypes.rst:2624 msgid "" "An optional sequence that lists the names of unnamed (anonymous) fields. :" "attr:`_anonymous_` must be already defined when :attr:`_fields_` is " "assigned, otherwise it will have no effect." msgstr "" -#: ../../library/ctypes.rst:2612 +#: ../../library/ctypes.rst:2628 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 " @@ -4130,11 +4215,11 @@ msgid "" "structure or union field." msgstr "" -#: ../../library/ctypes.rst:2617 +#: ../../library/ctypes.rst:2633 msgid "Here is an example type (Windows)::" msgstr "" -#: ../../library/ctypes.rst:2619 +#: ../../library/ctypes.rst:2635 msgid "" "class _U(Union):\n" " _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" @@ -4156,7 +4241,7 @@ msgstr "" " _fields_ = [(\"u\", _U),\n" " (\"vt\", VARTYPE)]" -#: ../../library/ctypes.rst:2630 +#: ../../library/ctypes.rst:2646 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 " @@ -4166,7 +4251,7 @@ msgid "" "temporary union instance::" msgstr "" -#: ../../library/ctypes.rst:2637 +#: ../../library/ctypes.rst:2653 msgid "" "td = TYPEDESC()\n" "td.vt = VT_PTR\n" @@ -4178,7 +4263,7 @@ msgstr "" "td.lptdesc = POINTER(some_type)\n" "td.u.lptdesc = POINTER(some_type)" -#: ../../library/ctypes.rst:2642 +#: ../../library/ctypes.rst:2658 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:" @@ -4186,7 +4271,7 @@ msgid "" "of the base class." msgstr "" -#: ../../library/ctypes.rst:2647 +#: ../../library/ctypes.rst:2663 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -4196,15 +4281,15 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: ../../library/ctypes.rst:2658 +#: ../../library/ctypes.rst:2674 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:2662 +#: ../../library/ctypes.rst:2678 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:2664 +#: ../../library/ctypes.rst:2680 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 " @@ -4214,46 +4299,46 @@ msgid "" "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:2674 +#: ../../library/ctypes.rst:2690 msgid "" "A positive integer specifying the number of elements in the array. Out-of-" "range subscripts result in an :exc:`IndexError`. Will be returned by :func:" "`len`." msgstr "" -#: ../../library/ctypes.rst:2681 +#: ../../library/ctypes.rst:2697 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:2684 +#: ../../library/ctypes.rst:2700 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:2689 +#: ../../library/ctypes.rst:2705 msgid "" "Create an array. Equivalent to ``type * length``, where *type* is a :mod:" "`ctypes` data type and *length* an integer." msgstr "" -#: ../../library/ctypes.rst:2693 +#: ../../library/ctypes.rst:2709 msgid "" "This function is :term:`soft deprecated` in favor of multiplication. There " "are no plans to remove it." msgstr "" -#: ../../library/ctypes.rst:2699 +#: ../../library/ctypes.rst:2715 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:2701 +#: ../../library/ctypes.rst:2717 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:2705 +#: ../../library/ctypes.rst:2721 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 :" @@ -4262,11 +4347,11 @@ msgid "" "probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:2715 +#: ../../library/ctypes.rst:2731 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:2719 +#: ../../library/ctypes.rst:2735 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/enum.po b/library/enum.po index 285fdae837..d6d9120849 100644 --- a/library/enum.po +++ b/library/enum.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-29 11:18+0000\n" +"POT-Creation-Date: 2025-07-23 00:17+0000\n" "PO-Revision-Date: 2024-12-21 13:50+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -978,32 +977,32 @@ msgstr "" #: ../../library/enum.rst:507 msgid "" -"``StrEnum`` is the same as :class:`Enum`, but its members are also strings " -"and can be used in most of the same places that a string can be used. The " -"result of any string operation performed on or with a *StrEnum* member is " -"not part of the enumeration." +"*StrEnum* is the same as :class:`Enum`, but its members are also strings and " +"can be used in most of the same places that a string can be used. The result " +"of any string operation performed on or with a *StrEnum* member is not part " +"of the enumeration." msgstr "" -"``StrEnum`` 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使" +"*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使" "用字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:513 +#: ../../library/enum.rst:528 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " "``isinstance(unknown, str)``), and in those locations you will need to use " -"``str(StrEnum.member)``." +"``str(MyStrEnum.MY_MEMBER)``." msgstr "" "stdlib 裡有些地方會檢查只能是 :class:`str` 而不是 :class:`str` 的子類別(也就" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" -"你需要使用 ``str(StrEnum.member)``。" +"你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:520 +#: ../../library/enum.rst:535 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr ":class:`StrEnum` 使用 :class:`auto` 會產生小寫的成員名稱當作值。" -#: ../../library/enum.rst:525 +#: ../../library/enum.rst:540 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1013,7 +1012,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:533 +#: ../../library/enum.rst:548 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1023,11 +1022,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:539 +#: ../../library/enum.rst:554 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:541 +#: ../../library/enum.rst:556 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1063,11 +1062,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:560 +#: ../../library/enum.rst:575 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:562 +#: ../../library/enum.rst:577 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1079,11 +1078,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:571 +#: ../../library/enum.rst:586 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:573 +#: ../../library/enum.rst:588 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1095,11 +1094,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:582 +#: ../../library/enum.rst:597 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:584 +#: ../../library/enum.rst:599 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1117,11 +1116,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:594 +#: ../../library/enum.rst:609 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:596 +#: ../../library/enum.rst:611 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1129,11 +1128,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:601 +#: ../../library/enum.rst:616 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:603 +#: ../../library/enum.rst:618 msgid "" ">>> purple & white\n" "\n" @@ -1145,11 +1144,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:610 +#: ../../library/enum.rst:625 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:612 +#: ../../library/enum.rst:627 msgid "" ">>> purple ^ white\n" "\n" @@ -1161,11 +1160,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:619 +#: ../../library/enum.rst:634 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:621 +#: ../../library/enum.rst:636 msgid "" ">>> ~white\n" "\n" @@ -1181,7 +1180,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:630 +#: ../../library/enum.rst:645 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1189,17 +1188,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:635 +#: ../../library/enum.rst:650 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr ":class:`Flag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:638 +#: ../../library/enum.rst:653 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:646 +#: ../../library/enum.rst:661 msgid "" "``IntFlag`` is the same as :class:`Flag`, but its members are also integers " "and can be used anywhere that an integer can be used." @@ -1207,13 +1206,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:660 +#: ../../library/enum.rst:675 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:663 +#: ../../library/enum.rst:678 msgid "" ">>> Color.RED + 2\n" "3" @@ -1221,32 +1220,32 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:666 +#: ../../library/enum.rst:681 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:668 +#: ../../library/enum.rst:683 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:669 +#: ../../library/enum.rst:684 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:671 +#: ../../library/enum.rst:686 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是:" -#: ../../library/enum.rst:678 +#: ../../library/enum.rst:693 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" ":class:`IntFlag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:683 +#: ../../library/enum.rst:698 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1256,7 +1255,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:687 +#: ../../library/enum.rst:702 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " @@ -1265,7 +1264,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:693 +#: ../../library/enum.rst:708 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1273,15 +1272,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:696 +#: ../../library/enum.rst:711 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:697 +#: ../../library/enum.rst:712 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:699 +#: ../../library/enum.rst:714 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1290,7 +1289,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:708 +#: ../../library/enum.rst:723 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1298,11 +1297,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:713 +#: ../../library/enum.rst:728 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:715 +#: ../../library/enum.rst:730 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1326,13 +1325,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:729 +#: ../../library/enum.rst:744 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:732 +#: ../../library/enum.rst:747 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1354,7 +1353,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:744 +#: ../../library/enum.rst:759 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1362,7 +1361,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:747 +#: ../../library/enum.rst:762 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1390,24 +1389,24 @@ msgstr "" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" -#: ../../library/enum.rst:761 +#: ../../library/enum.rst:776 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:767 +#: ../../library/enum.rst:782 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:772 +#: ../../library/enum.rst:787 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "範圍外的值會引發 :exc:`ValueError`。這是 :class:`Flag` 的預設行為: ::" -#: ../../library/enum.rst:775 +#: ../../library/enum.rst:790 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1435,13 +1434,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:790 +#: ../../library/enum.rst:805 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:793 +#: ../../library/enum.rst:808 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1461,13 +1460,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:804 +#: ../../library/enum.rst:819 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:817 +#: ../../library/enum.rst:832 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1475,7 +1474,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:820 +#: ../../library/enum.rst:835 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1495,7 +1494,7 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:833 +#: ../../library/enum.rst:848 msgid "" "*EnumDict* is a subclass of :class:`dict` that is used as the namespace for " "defining enum classes (see :ref:`prepare`). It is exposed to allow " @@ -1509,7 +1508,7 @@ msgstr "" "如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" "稱和內部類別將無法被正確處理。" -#: ../../library/enum.rst:840 +#: ../../library/enum.rst:855 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " @@ -1520,15 +1519,15 @@ msgstr "" "__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" "dict` 操作來繞過檢查,例如 :meth:`|= `。" -#: ../../library/enum.rst:847 +#: ../../library/enum.rst:862 msgid "A list of member names." msgstr "一個成員名稱的串列。" -#: ../../library/enum.rst:854 +#: ../../library/enum.rst:869 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:856 +#: ../../library/enum.rst:871 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1536,7 +1535,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:859 +#: ../../library/enum.rst:874 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " @@ -1546,38 +1545,38 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:865 +#: ../../library/enum.rst:880 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:867 +#: ../../library/enum.rst:882 msgid "" ":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:884 msgid "" ":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " "existing member." msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" -#: ../../library/enum.rst:871 +#: ../../library/enum.rst:886 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:872 +#: ../../library/enum.rst:887 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:873 +#: ../../library/enum.rst:888 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:875 +#: ../../library/enum.rst:890 msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " @@ -1586,7 +1585,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:878 +#: ../../library/enum.rst:893 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1594,28 +1593,28 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:880 +#: ../../library/enum.rst:895 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" ":meth:`~Enum._generate_next_value_` -- 用來為列舉成員取得合適的值;可以被覆寫" -#: ../../library/enum.rst:885 +#: ../../library/enum.rst:900 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:888 +#: ../../library/enum.rst:903 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:891 +#: ../../library/enum.rst:906 msgid "" "While ``_sunder_`` names are generally reserved for the further development " "of the :class:`Enum` class and can not be used, some are explicitly allowed:" @@ -1623,30 +1622,30 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:894 +#: ../../library/enum.rst:909 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" "``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " "`_" -#: ../../library/enum.rst:896 +#: ../../library/enum.rst:911 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:897 +#: ../../library/enum.rst:912 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:898 +#: ../../library/enum.rst:913 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:904 +#: ../../library/enum.rst:919 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:908 +#: ../../library/enum.rst:923 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an " @@ -1662,16 +1661,16 @@ msgstr "" "`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" "說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:916 +#: ../../library/enum.rst:931 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:918 +#: ../../library/enum.rst:933 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:919 +#: ../../library/enum.rst:934 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1679,7 +1678,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:921 +#: ../../library/enum.rst:936 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1687,19 +1686,19 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:926 +#: ../../library/enum.rst:941 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:929 +#: ../../library/enum.rst:944 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:932 +#: ../../library/enum.rst:947 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " @@ -1708,7 +1707,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的型別就會失敗。" -#: ../../library/enum.rst:938 +#: ../../library/enum.rst:953 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1717,7 +1716,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:942 +#: ../../library/enum.rst:957 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -1727,7 +1726,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:951 +#: ../../library/enum.rst:966 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1737,7 +1736,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:955 +#: ../../library/enum.rst:970 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1763,7 +1762,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:969 +#: ../../library/enum.rst:984 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1772,15 +1771,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:977 +#: ../../library/enum.rst:992 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:983 +#: ../../library/enum.rst:998 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:989 +#: ../../library/enum.rst:1004 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " @@ -1791,19 +1790,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:998 +#: ../../library/enum.rst:1013 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:1006 +#: ../../library/enum.rst:1021 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:1008 +#: ../../library/enum.rst:1023 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:1010 +#: ../../library/enum.rst:1025 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" @@ -1811,17 +1810,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:1013 +#: ../../library/enum.rst:1028 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1015 +#: ../../library/enum.rst:1030 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "``__format__`` 因為使用 ``__str__``,也會使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1018 +#: ../../library/enum.rst:1033 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" @@ -1829,7 +1828,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:1021 +#: ../../library/enum.rst:1036 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1839,11 +1838,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1025 +#: ../../library/enum.rst:1040 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1027 +#: ../../library/enum.rst:1042 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/http.cookies.po b/library/http.cookies.po index 28b2b12d38..8c5c66d5c8 100644 --- a/library/http.cookies.po +++ b/library/http.cookies.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-14 00:14+0000\n" +"POT-Creation-Date: 2025-07-28 00:20+0000\n" "PO-Revision-Date: 2024-12-24 18:49+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -38,12 +38,12 @@ msgstr "" #: ../../library/http.cookies.rst:19 msgid "" -"The module formerly strictly applied the parsing rules described in " -"the :rfc:`2109` and :rfc:`2068` specifications. It has since been " -"discovered that MSIE 3.0x didn't follow the character rules outlined in " -"those specs; many current-day browsers and servers have also relaxed parsing " -"rules when it comes to cookie handling. As a result, this module now uses " -"parsing rules that are a bit less strict than they once were." +"The module formerly strictly applied the parsing rules described in the :rfc:" +"`2109` and :rfc:`2068` specifications. It has since been discovered that " +"MSIE 3.0x didn't follow the character rules outlined in those specs; many " +"current-day browsers and servers have also relaxed parsing rules when it " +"comes to cookie handling. As a result, this module now uses parsing rules " +"that are a bit less strict than they once were." msgstr "" "此模組原先嚴格遵循了 :rfc:`2109` 和 :rfc:`2068` 規範所描述的剖析規則。自從發" "現 MSIE 3.0x 並不遵循這些規範所描述的字元規則,許多目前的瀏覽器和伺服器也在處" @@ -55,9 +55,8 @@ msgid "" "``!#$%&'*+-.^_`|~:`` denote the set of valid characters allowed by this " "module in a cookie name (as :attr:`~Morsel.key`)." msgstr "" -"字元集 :data:`string.ascii_letters`、:data:`string.digits` 和 ``!#$" -"%&'*+-.^_`|~`` 表示此模組在 cookie 名稱 (:attr:`~Morsel.key`) 中允許的合法字" -"元集合。" +"字元集 :data:`string.ascii_letters`、:data:`string.digits` 和 ``!#$%&'*+-." +"^_`|~`` 表示此模組在 cookie 名稱 (:attr:`~Morsel.key`) 中允許的合法字元集合。" #: ../../library/http.cookies.rst:30 msgid "Allowed ':' as a valid cookie name character." @@ -96,12 +95,11 @@ msgstr "如果有給定 *input*,它會被傳遞給 :meth:`load` 方法。" #: ../../library/http.cookies.rst:58 msgid "" -"This class derives from :class:`BaseCookie` and " -"overrides :meth:`~BaseCookie.value_decode` " -"and :meth:`~BaseCookie.value_encode`. :class:`!SimpleCookie` supports " -"strings as cookie values. When setting the value, :class:`!SimpleCookie` " -"calls the builtin :func:`str` to convert the value to a string. Values " -"received from HTTP are kept as strings." +"This class derives from :class:`BaseCookie` and overrides :meth:`~BaseCookie." +"value_decode` and :meth:`~BaseCookie.value_encode`. :class:`!SimpleCookie` " +"supports strings as cookie values. When setting the value, :class:`!" +"SimpleCookie` calls the builtin :func:`str` to convert the value to a " +"string. Values received from HTTP are kept as strings." msgstr "" "這個類別繼承自 :class:`BaseCookie` 並覆寫了 :meth:`~BaseCookie.value_decode` " "和 :meth:`~BaseCookie.value_encode`。:class:`!SimpleCookie` 支援字串作為 " @@ -114,11 +112,11 @@ msgstr ":mod:`http.cookiejar` 模組" #: ../../library/http.cookies.rst:67 msgid "" -"HTTP cookie handling for web *clients*. The :mod:`http.cookiejar` " -"and :mod:`http.cookies` modules do not depend on each other." +"HTTP cookie handling for web *clients*. The :mod:`http.cookiejar` and :mod:" +"`http.cookies` modules do not depend on each other." msgstr "" -"用於網路\\ *用戶端*\\ 的 HTTP cookie 處理。:mod:`http.cookiejar` " -"和 :mod:`http.cookies` 模組互不相依。" +"用於網路\\ *用戶端*\\ 的 HTTP cookie 處理。:mod:`http.cookiejar` 和 :mod:" +"`http.cookies` 模組互不相依。" #: ../../library/http.cookies.rst:70 msgid ":rfc:`2109` - HTTP State Management Mechanism" @@ -135,8 +133,8 @@ msgstr "Cookie 物件" #: ../../library/http.cookies.rst:82 msgid "" "Return a tuple ``(real_value, coded_value)`` from a string representation. " -"``real_value`` can be any type. This method does no decoding " -"in :class:`BaseCookie` --- it exists so it can be overridden." +"``real_value`` can be any type. This method does no decoding in :class:" +"`BaseCookie` --- it exists so it can be overridden." msgstr "" "從字串表示回傳 ``(real_value, coded_value)`` 的元組。``real_value`` 可以是任" "何型別。此方法在 :class:`BaseCookie` 中不做解碼 --- 它存在以便可以被覆寫。" @@ -153,8 +151,8 @@ msgstr "" #: ../../library/http.cookies.rst:94 msgid "" -"In general, it should be the case that :meth:`value_encode` " -"and :meth:`value_decode` are inverses on the range of *value_decode*." +"In general, it should be the case that :meth:`value_encode` and :meth:" +"`value_decode` are inverses on the range of *value_decode*." msgstr "" "一般來說,:meth:`value_encode` 和 :meth:`value_decode` 應該在 *value_decode* " "的範圍內是互逆的 (inverse)。" @@ -178,8 +176,8 @@ msgstr "" "回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的" "行為會與 HTTP 標頭被傳送的情況相同。" -#: ../../library/http.cookies.rst:111 ../../library/http.cookies.rst:207 -#: ../../library/http.cookies.rst:215 +#: ../../library/http.cookies.rst:111 ../../library/http.cookies.rst:210 +#: ../../library/http.cookies.rst:218 msgid "The meaning for *attrs* is the same as in :meth:`output`." msgstr "*attrs* 的意義與 :meth:`output` 裡的相同。" @@ -227,59 +225,62 @@ msgstr "" #: ../../library/http.cookies.rst:150 msgid "" -"The attribute :attr:`samesite` specifies that the browser is not allowed to " -"send the cookie along with cross-site requests. This helps to mitigate CSRF " -"attacks. Valid values for this attribute are \"Strict\" and \"Lax\"." +"The attribute :attr:`samesite` controls when the browser sends the cookie " +"with cross-site requests. This helps to mitigate CSRF attacks. Valid values " +"are \"Strict\" (only sent with same-site requests), \"Lax\" (sent with same-" +"site requests and top-level navigations), and \"None\" (sent with same-site " +"and cross-site requests). When using \"None\", the \"secure\" attribute must " +"also be set, as required by modern browsers." msgstr "" -"屬性 :attr:`samesite` 指定瀏覽器不能將 cookie 與跨網站請求一起傳送。這有助於" -"減輕 CSRF 攻擊。此屬性的有效值為 \"Strict\" 和 \"Lax\"。" +":attr:`samesite` 屬性控制瀏覽器要在何時將 cookie 與跨網站請求一起傳送," +"這有助於減輕 CSRF 攻擊。有效值為 \"Strict\"\\ (僅在同站請求時傳送)、" +"\"Lax\"\\ (同站請求和頂層導航時傳送)和 \"None\"\\ (同站請求和跨站請求時傳送)。" +"使用 \"None\" 時,必須同時設定 \"secure\" 屬性,這是現代瀏覽器的要求。" -#: ../../library/http.cookies.rst:154 +#: ../../library/http.cookies.rst:157 msgid "The keys are case-insensitive and their default value is ``''``." msgstr "鍵不區分大小寫,其預設值為 ``''``。" -#: ../../library/http.cookies.rst:156 +#: ../../library/http.cookies.rst:159 msgid "" ":meth:`!__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` into " "account." msgstr "" ":meth:`!__eq__` 現在會考慮 :attr:`~Morsel.key` 和 :attr:`~Morsel.value`。" -#: ../../library/http.cookies.rst:160 +#: ../../library/http.cookies.rst:163 msgid "" -"Attributes :attr:`~Morsel.key`, :attr:`~Morsel.value` " -"and :attr:`~Morsel.coded_value` are read-only. Use :meth:`~Morsel.set` for " -"setting them." +"Attributes :attr:`~Morsel.key`, :attr:`~Morsel.value` and :attr:`~Morsel." +"coded_value` are read-only. Use :meth:`~Morsel.set` for setting them." msgstr "" -"屬性 :attr:`~Morsel.key`、:attr:`~Morsel.value` " -"和 :attr:`~Morsel.coded_value` 是唯讀的。請使用 :meth:`~Morsel.set` 來設定它" -"們。" +"屬性 :attr:`~Morsel.key`、:attr:`~Morsel.value` 和 :attr:`~Morsel." +"coded_value` 是唯讀的。請使用 :meth:`~Morsel.set` 來設定它們。" -#: ../../library/http.cookies.rst:165 +#: ../../library/http.cookies.rst:168 msgid "Added support for the :attr:`samesite` attribute." msgstr "新增對 :attr:`samesite` 屬性的支援。" -#: ../../library/http.cookies.rst:171 +#: ../../library/http.cookies.rst:174 msgid "The value of the cookie." msgstr "cookie 的值。" -#: ../../library/http.cookies.rst:176 +#: ../../library/http.cookies.rst:179 msgid "The encoded value of the cookie --- this is what should be sent." msgstr "cookie 的編碼值 --- 這是應該被傳送的值。" -#: ../../library/http.cookies.rst:181 +#: ../../library/http.cookies.rst:184 msgid "The name of the cookie." msgstr "cookie 的名稱。" -#: ../../library/http.cookies.rst:186 +#: ../../library/http.cookies.rst:189 msgid "Set the *key*, *value* and *coded_value* attributes." msgstr "設定 *key*、*value* 和 *coded_value* 屬性。" -#: ../../library/http.cookies.rst:191 +#: ../../library/http.cookies.rst:194 msgid "Whether *K* is a member of the set of keys of a :class:`Morsel`." msgstr "*K* 是否為 :class:`Morsel` 的鍵集合中的成員。" -#: ../../library/http.cookies.rst:196 +#: ../../library/http.cookies.rst:199 msgid "" "Return a string representation of the Morsel, suitable to be sent as an HTTP " "header. By default, all the attributes are included, unless *attrs* is " @@ -290,7 +291,7 @@ msgstr "" "定 *attrs*,在此情況下,它應該是一個要使用的屬性的串列。預設的 *header* 是 " "``\"Set-Cookie:\"``。" -#: ../../library/http.cookies.rst:204 +#: ../../library/http.cookies.rst:207 msgid "" "Return an embeddable JavaScript snippet, which, if run on a browser which " "supports JavaScript, will act the same as if the HTTP header was sent." @@ -298,13 +299,13 @@ msgstr "" "回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的" "行為會與 HTTP 標頭被傳送的情況相同。" -#: ../../library/http.cookies.rst:212 +#: ../../library/http.cookies.rst:215 msgid "" "Return a string representing the Morsel, without any surrounding HTTP or " "JavaScript." msgstr "回傳表示 Morsel 的字串,不包含周圍任何的 HTTP 或 JavaScript。" -#: ../../library/http.cookies.rst:220 +#: ../../library/http.cookies.rst:223 msgid "" "Update the values in the Morsel dictionary with the values in the dictionary " "*values*. Raise an error if any of the keys in the *values* dict is not a " @@ -313,36 +314,36 @@ msgstr "" "更新 Morsel 字典中的值為 *values* 字典中的值。如果 *values* 字典中的任何鍵不" "是有效的 :rfc:`2109` 屬性則引發錯誤。" -#: ../../library/http.cookies.rst:224 +#: ../../library/http.cookies.rst:227 msgid "an error is raised for invalid keys." msgstr "對於無效的鍵會引發錯誤。" -#: ../../library/http.cookies.rst:230 +#: ../../library/http.cookies.rst:233 msgid "Return a shallow copy of the Morsel object." msgstr "回傳 Morsel 物件的淺層複製。" -#: ../../library/http.cookies.rst:232 +#: ../../library/http.cookies.rst:235 msgid "return a Morsel object instead of a dict." msgstr "回傳 Morsel 物件而不是字典。" -#: ../../library/http.cookies.rst:238 +#: ../../library/http.cookies.rst:241 msgid "" "Raise an error if key is not a valid :rfc:`2109` attribute, otherwise behave " "the same as :meth:`dict.setdefault`." msgstr "" -"如果鍵不是一個有效的 :rfc:`2109` 屬性會引發錯誤,否則行為" -"與 :meth:`dict.setdefault` 相同。" +"如果鍵不是一個有效的 :rfc:`2109` 屬性會引發錯誤,否則行為與 :meth:`dict." +"setdefault` 相同。" -#: ../../library/http.cookies.rst:245 +#: ../../library/http.cookies.rst:248 msgid "Example" msgstr "範例" -#: ../../library/http.cookies.rst:247 +#: ../../library/http.cookies.rst:250 msgid "" "The following example demonstrates how to use the :mod:`http.cookies` module." msgstr "以下範例示範如何使用 :mod:`http.cookies` 模組。" -#: ../../library/http.cookies.rst:249 +#: ../../library/http.cookies.rst:252 msgid "" ">>> from http import cookies\n" ">>> C = cookies.SimpleCookie()\n" diff --git a/library/importlib.po b/library/importlib.po index 1f0fe603e1..4e6856b302 100644 --- a/library/importlib.po +++ b/library/importlib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-22 08:51+0000\n" +"POT-Creation-Date: 2025-07-16 17:40+0000\n" "PO-Revision-Date: 2018-05-23 16:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,9 +43,9 @@ msgid "" "to comprehend than one implemented in a programming language other than " "Python." msgstr "" -"第一是提供 Python 原始碼中 :keyword:`import` 陳述式的實作(因此,也延伸" -"到 :func:`__import__` 函式)。這讓 :keyword:`!import` 實作可以移植到任何 " -"Python 直譯器。同時,這也提供了一個比用其他程式語言實作更容易理解的版本。" +"第一是提供 Python 原始碼中 :keyword:`import` 陳述式的實作(因此,也延伸到 :" +"func:`__import__` 函式)。這讓 :keyword:`!import` 實作可以移植到任何 Python " +"直譯器。同時,這也提供了一個比用其他程式語言實作更容易理解的版本。" #: ../../library/importlib.rst:29 msgid "" @@ -89,8 +89,8 @@ msgstr "" #: ../../library/importlib.rst:47 msgid "" "Original specification of packages. Some semantics have changed since the " -"writing of this document (e.g. redirecting based on ``None`` " -"in :data:`sys.modules`)." +"writing of this document (e.g. redirecting based on ``None`` in :data:`sys." +"modules`)." msgstr "" #: ../../library/importlib.rst:51 @@ -231,11 +231,11 @@ msgstr "" #: ../../library/importlib.rst:115 msgid "" -"The :func:`import_module` function acts as a simplifying wrapper " -"around :func:`importlib.__import__`. This means all semantics of the " -"function are derived from :func:`importlib.__import__`. The most important " -"difference between these two functions is that :func:`import_module` returns " -"the specified package or module (e.g. ``pkg.mod``), while :func:`__import__` " +"The :func:`import_module` function acts as a simplifying wrapper around :" +"func:`importlib.__import__`. This means all semantics of the function are " +"derived from :func:`importlib.__import__`. The most important difference " +"between these two functions is that :func:`import_module` returns the " +"specified package or module (e.g. ``pkg.mod``), while :func:`__import__` " "returns the top-level package or module (e.g. ``pkg``)." msgstr "" @@ -347,11 +347,11 @@ msgstr "" #: ../../library/importlib.rst:193 msgid "" -"If a module imports objects from another module " -"using :keyword:`from` ... :keyword:`import` ..., calling :func:`reload` for " -"the other module does not redefine the objects imported from it --- one way " -"around this is to re-execute the :keyword:`!from` statement, another is to " -"use :keyword:`!import` and qualified names (*module.name*) instead." +"If a module imports objects from another module using :keyword:`from` ... :" +"keyword:`import` ..., calling :func:`reload` for the other module does not " +"redefine the objects imported from it --- one way around this is to re-" +"execute the :keyword:`!from` statement, another is to use :keyword:`!import` " +"and qualified names (*module.name*) instead." msgstr "" #: ../../library/importlib.rst:199 @@ -364,30 +364,37 @@ msgstr "" #: ../../library/importlib.rst:205 msgid "" -":exc:`ModuleNotFoundError` is raised when the module being reloaded lacks " -"a :class:`~importlib.machinery.ModuleSpec`." +":exc:`ModuleNotFoundError` is raised when the module being reloaded lacks a :" +"class:`~importlib.machinery.ModuleSpec`." msgstr "" -#: ../../library/importlib.rst:211 +#: ../../library/importlib.rst:210 +msgid "" +"This function is not thread-safe. Calling it from multiple threads can " +"result in unexpected behavior. It's recommended to use the :class:`threading." +"Lock` or other synchronization primitives for thread-safe module reloading." +msgstr "" + +#: ../../library/importlib.rst:215 msgid ":mod:`importlib.abc` -- Abstract base classes related to import" msgstr "" -#: ../../library/importlib.rst:216 +#: ../../library/importlib.rst:220 msgid "**Source code:** :source:`Lib/importlib/abc.py`" msgstr "**原始碼:**\\ :source:`Lib/importlib/abc.py`" -#: ../../library/importlib.rst:221 +#: ../../library/importlib.rst:225 msgid "" "The :mod:`importlib.abc` module contains all of the core abstract base " "classes used by :keyword:`import`. Some subclasses of the core abstract base " "classes are also provided to help in implementing the core ABCs." msgstr "" -#: ../../library/importlib.rst:225 +#: ../../library/importlib.rst:229 msgid "ABC hierarchy::" msgstr "" -#: ../../library/importlib.rst:227 +#: ../../library/importlib.rst:231 msgid "" "object\n" " +-- MetaPathFinder\n" @@ -409,15 +416,15 @@ msgstr "" " +-- FileLoader\n" " +-- SourceLoader" -#: ../../library/importlib.rst:240 +#: ../../library/importlib.rst:244 msgid "An abstract base class representing a :term:`meta path finder`." msgstr "" -#: ../../library/importlib.rst:244 ../../library/importlib.rst:280 +#: ../../library/importlib.rst:248 ../../library/importlib.rst:284 msgid "No longer a subclass of :class:`!Finder`." msgstr "" -#: ../../library/importlib.rst:249 +#: ../../library/importlib.rst:253 msgid "" "An abstract method for finding a :term:`spec ` for the " "specified module. If this is a top-level import, *path* will be ``None``. " @@ -429,92 +436,90 @@ msgid "" "for implementing concrete ``MetaPathFinders``." msgstr "" -#: ../../library/importlib.rst:263 +#: ../../library/importlib.rst:267 msgid "" "An optional method which, when called, should invalidate any internal cache " "used by the finder. Used by :func:`importlib.invalidate_caches` when " "invalidating the caches of all finders on :data:`sys.meta_path`." msgstr "" -#: ../../library/importlib.rst:267 +#: ../../library/importlib.rst:271 msgid "Returns ``None`` when called instead of :data:`NotImplemented`." msgstr "" -#: ../../library/importlib.rst:273 +#: ../../library/importlib.rst:277 msgid "" "An abstract base class representing a :term:`path entry finder`. Though it " "bears some similarities to :class:`MetaPathFinder`, ``PathEntryFinder`` is " -"meant for use only within the path-based import subsystem provided " -"by :class:`importlib.machinery.PathFinder`." +"meant for use only within the path-based import subsystem provided by :class:" +"`importlib.machinery.PathFinder`." msgstr "" -#: ../../library/importlib.rst:285 +#: ../../library/importlib.rst:289 msgid "" "An abstract method for finding a :term:`spec ` for the " -"specified module. The finder will search for the module only within " -"the :term:`path entry` to which it is assigned. If a spec cannot be found, " +"specified module. The finder will search for the module only within the :" +"term:`path entry` to which it is assigned. If a spec cannot be found, " "``None`` is returned. When passed in, ``target`` is a module object that " -"the finder may use to make a more educated guess about what spec to " -"return. :func:`importlib.util.spec_from_loader` may be useful for " -"implementing concrete ``PathEntryFinders``." +"the finder may use to make a more educated guess about what spec to return. :" +"func:`importlib.util.spec_from_loader` may be useful for implementing " +"concrete ``PathEntryFinders``." msgstr "" -#: ../../library/importlib.rst:297 +#: ../../library/importlib.rst:301 msgid "" "An optional method which, when called, should invalidate any internal cache " -"used by the finder. Used " -"by :meth:`importlib.machinery.PathFinder.invalidate_caches` when " -"invalidating the caches of all cached finders." +"used by the finder. Used by :meth:`importlib.machinery.PathFinder." +"invalidate_caches` when invalidating the caches of all cached finders." msgstr "" -#: ../../library/importlib.rst:305 +#: ../../library/importlib.rst:309 msgid "" "An abstract base class for a :term:`loader`. See :pep:`302` for the exact " "definition for a loader." msgstr "" -#: ../../library/importlib.rst:308 +#: ../../library/importlib.rst:312 msgid "" -"Loaders that wish to support resource reading should implement " -"a :meth:`get_resource_reader` method as specified " -"by :class:`importlib.resources.abc.ResourceReader`." +"Loaders that wish to support resource reading should implement a :meth:" +"`get_resource_reader` method as specified by :class:`importlib.resources.abc." +"ResourceReader`." msgstr "" -#: ../../library/importlib.rst:312 +#: ../../library/importlib.rst:316 msgid "Introduced the optional :meth:`get_resource_reader` method." msgstr "" -#: ../../library/importlib.rst:317 +#: ../../library/importlib.rst:321 msgid "" "A method that returns the module object to use when importing a module. " "This method may return ``None``, indicating that default module creation " "semantics should take place." msgstr "" -#: ../../library/importlib.rst:323 +#: ../../library/importlib.rst:327 msgid "This method is no longer optional when :meth:`exec_module` is defined." msgstr "" -#: ../../library/importlib.rst:329 +#: ../../library/importlib.rst:333 msgid "" "An abstract method that executes the module in its own namespace when a " "module is imported or reloaded. The module should already be initialized " -"when :meth:`exec_module` is called. When this method " -"exists, :meth:`create_module` must be defined." +"when :meth:`exec_module` is called. When this method exists, :meth:" +"`create_module` must be defined." msgstr "" -#: ../../library/importlib.rst:336 +#: ../../library/importlib.rst:340 msgid ":meth:`create_module` must also be defined." msgstr ":meth:`create_module` 也必須被定義。" -#: ../../library/importlib.rst:341 +#: ../../library/importlib.rst:345 msgid "" -"A legacy method for loading a module. If the module cannot be " -"loaded, :exc:`ImportError` is raised, otherwise the loaded module is " -"returned." +"A legacy method for loading a module. If the module cannot be loaded, :exc:" +"`ImportError` is raised, otherwise the loaded module is returned." msgstr "" -#: ../../library/importlib.rst:345 +#: ../../library/importlib.rst:349 msgid "" "If the requested module already exists in :data:`sys.modules`, that module " "should be used and reloaded. Otherwise the loader should create a new module " @@ -525,113 +530,111 @@ msgid "" "left alone." msgstr "" -#: ../../library/importlib.rst:354 +#: ../../library/importlib.rst:358 msgid "" "The loader should set several attributes on the module (note that some of " "these attributes can change when a module is reloaded):" msgstr "" -#: ../../library/importlib.rst:358 +#: ../../library/importlib.rst:362 msgid ":attr:`module.__name__`" msgstr ":attr:`module.__name__`" -#: ../../library/importlib.rst:359 +#: ../../library/importlib.rst:363 msgid ":attr:`module.__file__`" msgstr ":attr:`module.__file__`" -#: ../../library/importlib.rst:360 +#: ../../library/importlib.rst:364 msgid ":attr:`module.__cached__` *(deprecated)*" msgstr ":attr:`module.__cached__` *(已棄用)*" -#: ../../library/importlib.rst:361 +#: ../../library/importlib.rst:365 msgid ":attr:`module.__path__`" msgstr ":attr:`module.__path__`" -#: ../../library/importlib.rst:362 +#: ../../library/importlib.rst:366 msgid ":attr:`module.__package__` *(deprecated)*" msgstr ":attr:`module.__package__` *(已棄用)*" -#: ../../library/importlib.rst:363 +#: ../../library/importlib.rst:367 msgid ":attr:`module.__loader__` *(deprecated)*" msgstr ":attr:`module.__loader__` *(已棄用)*" -#: ../../library/importlib.rst:365 +#: ../../library/importlib.rst:369 msgid "" "When :meth:`exec_module` is available then backwards-compatible " "functionality is provided." msgstr "" -#: ../../library/importlib.rst:368 +#: ../../library/importlib.rst:372 msgid "" "Raise :exc:`ImportError` when called instead of :exc:`NotImplementedError`. " "Functionality provided when :meth:`exec_module` is available." msgstr "" -#: ../../library/importlib.rst:373 +#: ../../library/importlib.rst:377 msgid "" -"The recommended API for loading a module is :meth:`exec_module` " -"(and :meth:`create_module`). Loaders should implement it instead " -"of :meth:`load_module`. The import machinery takes care of all the other " +"The recommended API for loading a module is :meth:`exec_module` (and :meth:" +"`create_module`). Loaders should implement it instead of :meth:" +"`load_module`. The import machinery takes care of all the other " "responsibilities of :meth:`load_module` when :meth:`exec_module` is " "implemented." msgstr "" -#: ../../library/importlib.rst:383 ../../library/importlib.rst:636 +#: ../../library/importlib.rst:387 ../../library/importlib.rst:640 msgid "*Superseded by TraversableResources*" msgstr "" -#: ../../library/importlib.rst:385 +#: ../../library/importlib.rst:389 msgid "" -"An abstract base class for a :term:`loader` which implements the " -"optional :pep:`302` protocol for loading arbitrary resources from the " -"storage back-end." +"An abstract base class for a :term:`loader` which implements the optional :" +"pep:`302` protocol for loading arbitrary resources from the storage back-end." msgstr "" -#: ../../library/importlib.rst:389 +#: ../../library/importlib.rst:393 msgid "" -"This ABC is deprecated in favour of supporting resource loading " -"through :class:`importlib.resources.abc.TraversableResources`." +"This ABC is deprecated in favour of supporting resource loading through :" +"class:`importlib.resources.abc.TraversableResources`." msgstr "" -#: ../../library/importlib.rst:396 +#: ../../library/importlib.rst:400 msgid "" "An abstract method to return the bytes for the data located at *path*. " "Loaders that have a file-like storage back-end that allows storing arbitrary " "data can implement this abstract method to give direct access to the data " "stored. :exc:`OSError` is to be raised if the *path* cannot be found. The " -"*path* is expected to be constructed using a " -"module's :attr:`~module.__file__` attribute or an item from a " -"package's :attr:`~module.__path__`." +"*path* is expected to be constructed using a module's :attr:`~module." +"__file__` attribute or an item from a package's :attr:`~module.__path__`." msgstr "" -#: ../../library/importlib.rst:405 +#: ../../library/importlib.rst:409 msgid "Raises :exc:`OSError` instead of :exc:`NotImplementedError`." msgstr "" -#: ../../library/importlib.rst:411 +#: ../../library/importlib.rst:415 msgid "" -"An abstract base class for a :term:`loader` which implements the " -"optional :pep:`302` protocol for loaders that inspect modules." +"An abstract base class for a :term:`loader` which implements the optional :" +"pep:`302` protocol for loaders that inspect modules." msgstr "" -#: ../../library/importlib.rst:416 +#: ../../library/importlib.rst:420 msgid "" "Return the code object for a module, or ``None`` if the module does not have " "a code object (as would be the case, for example, for a built-in module). " "Raise an :exc:`ImportError` if loader cannot find the requested module." msgstr "" -#: ../../library/importlib.rst:422 +#: ../../library/importlib.rst:426 msgid "" "While the method has a default implementation, it is suggested that it be " "overridden if possible for performance." msgstr "" -#: ../../library/importlib.rst:428 +#: ../../library/importlib.rst:432 msgid "No longer abstract and a concrete implementation is provided." msgstr "" -#: ../../library/importlib.rst:434 +#: ../../library/importlib.rst:438 msgid "" "An abstract method to return the source of a module. It is returned as a " "text string using :term:`universal newlines`, translating all recognized " @@ -640,234 +643,233 @@ msgid "" "cannot find the module specified." msgstr "" -#: ../../library/importlib.rst:440 ../../library/importlib.rst:449 -#: ../../library/importlib.rst:500 +#: ../../library/importlib.rst:444 ../../library/importlib.rst:453 +#: ../../library/importlib.rst:504 msgid "Raises :exc:`ImportError` instead of :exc:`NotImplementedError`." msgstr "" -#: ../../library/importlib.rst:445 +#: ../../library/importlib.rst:449 msgid "" "An optional method to return a true value if the module is a package, a " "false value otherwise. :exc:`ImportError` is raised if the :term:`loader` " "cannot find the module." msgstr "" -#: ../../library/importlib.rst:454 +#: ../../library/importlib.rst:458 msgid "Create a code object from Python source." msgstr "" -#: ../../library/importlib.rst:456 +#: ../../library/importlib.rst:460 msgid "" -"The *data* argument can be whatever the :func:`compile` function supports " -"(i.e. string or bytes). The *path* argument should be the \"path\" to where " -"the source code originated from, which can be an abstract concept (e.g. " -"location in a zip file)." +"The *data* argument can be whatever the :func:`compile` function supports (i." +"e. string or bytes). The *path* argument should be the \"path\" to where the " +"source code originated from, which can be an abstract concept (e.g. location " +"in a zip file)." msgstr "" -#: ../../library/importlib.rst:461 +#: ../../library/importlib.rst:465 msgid "" "With the subsequent code object one can execute it in a module by running " "``exec(code, module.__dict__)``." msgstr "" -#: ../../library/importlib.rst:466 +#: ../../library/importlib.rst:470 msgid "Made the method static." msgstr "" -#: ../../library/importlib.rst:471 +#: ../../library/importlib.rst:475 msgid "Implementation of :meth:`Loader.exec_module`." msgstr ":meth:`Loader.exec_module` 的實作。" -#: ../../library/importlib.rst:477 +#: ../../library/importlib.rst:481 msgid "Implementation of :meth:`Loader.load_module`." msgstr ":meth:`Loader.load_module` 的實作。" -#: ../../library/importlib.rst:479 +#: ../../library/importlib.rst:483 msgid "use :meth:`exec_module` instead." msgstr "請改用 :meth:`exec_module`。" -#: ../../library/importlib.rst:485 +#: ../../library/importlib.rst:489 msgid "" "An abstract base class which inherits from :class:`InspectLoader` that, when " "implemented, helps a module to be executed as a script. The ABC represents " "an optional :pep:`302` protocol." msgstr "" -#: ../../library/importlib.rst:492 +#: ../../library/importlib.rst:496 msgid "" "An abstract method that is to return the value of :attr:`~module.__file__` " "for the specified module. If no path is available, :exc:`ImportError` is " "raised." msgstr "" -#: ../../library/importlib.rst:496 +#: ../../library/importlib.rst:500 msgid "" "If source code is available, then the method should return the path to the " "source file, regardless of whether a bytecode was used to load the module." msgstr "" -#: ../../library/importlib.rst:506 +#: ../../library/importlib.rst:510 msgid "" -"An abstract base class which inherits from :class:`ResourceLoader` " -"and :class:`ExecutionLoader`, providing concrete implementations " -"of :meth:`ResourceLoader.get_data` and :meth:`ExecutionLoader.get_filename`." +"An abstract base class which inherits from :class:`ResourceLoader` and :" +"class:`ExecutionLoader`, providing concrete implementations of :meth:" +"`ResourceLoader.get_data` and :meth:`ExecutionLoader.get_filename`." msgstr "" -#: ../../library/importlib.rst:510 +#: ../../library/importlib.rst:514 msgid "" "The *fullname* argument is a fully resolved name of the module the loader is " "to handle. The *path* argument is the path to the file for the module." msgstr "" -#: ../../library/importlib.rst:517 +#: ../../library/importlib.rst:521 msgid "The name of the module the loader can handle." msgstr "" -#: ../../library/importlib.rst:521 +#: ../../library/importlib.rst:525 msgid "Path to the file of the module." msgstr "" -#: ../../library/importlib.rst:525 +#: ../../library/importlib.rst:529 msgid "Calls super's ``load_module()``." msgstr "" -#: ../../library/importlib.rst:527 +#: ../../library/importlib.rst:531 msgid "Use :meth:`Loader.exec_module` instead." msgstr "" -#: ../../library/importlib.rst:533 ../../library/importlib.rst:1140 +#: ../../library/importlib.rst:537 ../../library/importlib.rst:1144 msgid "Returns :attr:`path`." msgstr "" -#: ../../library/importlib.rst:538 +#: ../../library/importlib.rst:542 msgid "Reads *path* as a binary file and returns the bytes from it." msgstr "" -#: ../../library/importlib.rst:543 +#: ../../library/importlib.rst:547 msgid "" "An abstract base class for implementing source (and optionally bytecode) " -"file loading. The class inherits from both :class:`ResourceLoader` " -"and :class:`ExecutionLoader`, requiring the implementation of:" +"file loading. The class inherits from both :class:`ResourceLoader` and :" +"class:`ExecutionLoader`, requiring the implementation of:" msgstr "" -#: ../../library/importlib.rst:547 +#: ../../library/importlib.rst:551 msgid ":meth:`ResourceLoader.get_data`" msgstr ":meth:`ResourceLoader.get_data`" -#: ../../library/importlib.rst:548 +#: ../../library/importlib.rst:552 msgid ":meth:`ExecutionLoader.get_filename`" msgstr ":meth:`ExecutionLoader.get_filename`" -#: ../../library/importlib.rst:549 +#: ../../library/importlib.rst:553 msgid "" "Should only return the path to the source file; sourceless loading is not " "supported." msgstr "" -#: ../../library/importlib.rst:552 +#: ../../library/importlib.rst:556 msgid "" "The abstract methods defined by this class are to add optional bytecode file " -"support. Not implementing these optional methods (or causing them to " -"raise :exc:`NotImplementedError`) causes the loader to only work with source " -"code. Implementing the methods allows the loader to work with source *and* " +"support. Not implementing these optional methods (or causing them to raise :" +"exc:`NotImplementedError`) causes the loader to only work with source code. " +"Implementing the methods allows the loader to work with source *and* " "bytecode files; it does not allow for *sourceless* loading where only " "bytecode is provided. Bytecode files are an optimization to speed up " "loading by removing the parsing step of Python's compiler, and so no " "bytecode-specific API is exposed." msgstr "" -#: ../../library/importlib.rst:563 +#: ../../library/importlib.rst:567 msgid "" "Optional abstract method which returns a :class:`dict` containing metadata " "about the specified path. Supported dictionary keys are:" msgstr "" -#: ../../library/importlib.rst:566 +#: ../../library/importlib.rst:570 msgid "" "``'mtime'`` (mandatory): an integer or floating-point number representing " "the modification time of the source code;" msgstr "" -#: ../../library/importlib.rst:568 +#: ../../library/importlib.rst:572 msgid "``'size'`` (optional): the size in bytes of the source code." msgstr "" -#: ../../library/importlib.rst:570 +#: ../../library/importlib.rst:574 msgid "" "Any other keys in the dictionary are ignored, to allow for future " "extensions. If the path cannot be handled, :exc:`OSError` is raised." msgstr "" -#: ../../library/importlib.rst:575 ../../library/importlib.rst:588 +#: ../../library/importlib.rst:579 ../../library/importlib.rst:592 msgid "Raise :exc:`OSError` instead of :exc:`NotImplementedError`." msgstr "" -#: ../../library/importlib.rst:580 +#: ../../library/importlib.rst:584 msgid "" "Optional abstract method which returns the modification time for the " "specified path." msgstr "" -#: ../../library/importlib.rst:583 +#: ../../library/importlib.rst:587 msgid "" "This method is deprecated in favour of :meth:`path_stats`. You don't have " "to implement it, but it is still available for compatibility purposes. " "Raise :exc:`OSError` if the path cannot be handled." msgstr "" -#: ../../library/importlib.rst:593 +#: ../../library/importlib.rst:597 msgid "" "Optional abstract method which writes the specified bytes to a file path. " "Any intermediate directories which do not exist are to be created " "automatically." msgstr "" -#: ../../library/importlib.rst:597 +#: ../../library/importlib.rst:601 msgid "" -"When writing to the path fails because the path is read-only " -"(:const:`errno.EACCES`/:exc:`PermissionError`), do not propagate the " -"exception." +"When writing to the path fails because the path is read-only (:const:`errno." +"EACCES`/:exc:`PermissionError`), do not propagate the exception." msgstr "" -#: ../../library/importlib.rst:601 +#: ../../library/importlib.rst:605 msgid "No longer raises :exc:`NotImplementedError` when called." msgstr "" -#: ../../library/importlib.rst:606 +#: ../../library/importlib.rst:610 msgid "Concrete implementation of :meth:`InspectLoader.get_code`." msgstr "" -#: ../../library/importlib.rst:610 +#: ../../library/importlib.rst:614 msgid "Concrete implementation of :meth:`Loader.exec_module`." msgstr "" -#: ../../library/importlib.rst:616 +#: ../../library/importlib.rst:620 msgid "Concrete implementation of :meth:`Loader.load_module`." msgstr "" -#: ../../library/importlib.rst:618 +#: ../../library/importlib.rst:622 msgid "Use :meth:`exec_module` instead." msgstr "" -#: ../../library/importlib.rst:623 +#: ../../library/importlib.rst:627 msgid "Concrete implementation of :meth:`InspectLoader.get_source`." msgstr "" -#: ../../library/importlib.rst:627 +#: ../../library/importlib.rst:631 msgid "" "Concrete implementation of :meth:`InspectLoader.is_package`. A module is " -"determined to be a package if its file path (as provided " -"by :meth:`ExecutionLoader.get_filename`) is a file named ``__init__`` when " -"the file extension is removed **and** the module name itself does not end in " +"determined to be a package if its file path (as provided by :meth:" +"`ExecutionLoader.get_filename`) is a file named ``__init__`` when the file " +"extension is removed **and** the module name itself does not end in " "``__init__``." msgstr "" -#: ../../library/importlib.rst:638 +#: ../../library/importlib.rst:642 msgid "" "An :term:`abstract base class` to provide the ability to read *resources*." msgstr "" -#: ../../library/importlib.rst:641 +#: ../../library/importlib.rst:645 msgid "" "From the perspective of this ABC, a *resource* is a binary artifact that is " "shipped within a package. Typically this is something like a data file that " @@ -877,11 +879,11 @@ msgid "" "file versus on the file system." msgstr "" -#: ../../library/importlib.rst:649 +#: ../../library/importlib.rst:653 msgid "" -"For any of methods of this class, a *resource* argument is expected to be " -"a :term:`path-like object` which represents conceptually just a file name. " -"This means that no subdirectory paths should be included in the *resource* " +"For any of methods of this class, a *resource* argument is expected to be a :" +"term:`path-like object` which represents conceptually just a file name. This " +"means that no subdirectory paths should be included in the *resource* " "argument. This is because the location of the package the reader is for, " "acts as the \"directory\". Hence the metaphor for directories and file names " "is packages and resources, respectively. This is also why instances of this " @@ -889,7 +891,7 @@ msgid "" "potentially representing multiple packages or a module)." msgstr "" -#: ../../library/importlib.rst:660 +#: ../../library/importlib.rst:664 msgid "" "Loaders that wish to support resource reading are expected to provide a " "method called ``get_resource_reader(fullname)`` which returns an object " @@ -898,45 +900,45 @@ msgid "" "with this ABC should only be returned when the specified module is a package." msgstr "" -#: ../../library/importlib.rst:669 ../../library/importlib.rst:789 +#: ../../library/importlib.rst:673 ../../library/importlib.rst:793 msgid "Use :class:`importlib.resources.abc.TraversableResources` instead." msgstr "" -#: ../../library/importlib.rst:675 +#: ../../library/importlib.rst:679 msgid "" "Returns an opened, :term:`file-like object` for binary reading of the " "*resource*." msgstr "" -#: ../../library/importlib.rst:678 +#: ../../library/importlib.rst:682 msgid "If the resource cannot be found, :exc:`FileNotFoundError` is raised." msgstr "" -#: ../../library/importlib.rst:684 +#: ../../library/importlib.rst:688 msgid "Returns the file system path to the *resource*." msgstr "" -#: ../../library/importlib.rst:686 +#: ../../library/importlib.rst:690 msgid "" -"If the resource does not concretely exist on the file system, " -"raise :exc:`FileNotFoundError`." +"If the resource does not concretely exist on the file system, raise :exc:" +"`FileNotFoundError`." msgstr "" -#: ../../library/importlib.rst:692 +#: ../../library/importlib.rst:696 msgid "" -"Returns ``True`` if the named *name* is considered a " -"resource. :exc:`FileNotFoundError` is raised if *name* does not exist." +"Returns ``True`` if the named *name* is considered a resource. :exc:" +"`FileNotFoundError` is raised if *name* does not exist." msgstr "" -#: ../../library/importlib.rst:698 +#: ../../library/importlib.rst:702 msgid "" "Returns an :term:`iterable` of strings over the contents of the package. Do " "note that it is not required that all names returned by the iterator be " -"actual resources, e.g. it is acceptable to return names for " -"which :meth:`is_resource` would be false." +"actual resources, e.g. it is acceptable to return names for which :meth:" +"`is_resource` would be false." msgstr "" -#: ../../library/importlib.rst:704 +#: ../../library/importlib.rst:708 msgid "" "Allowing non-resource names to be returned is to allow for situations where " "how a package and its resources are stored are known a priori and the non-" @@ -945,258 +947,254 @@ msgid "" "stored on the file system then those subdirectory names can be used directly." msgstr "" -#: ../../library/importlib.rst:712 +#: ../../library/importlib.rst:716 msgid "The abstract method returns an iterable of no items." msgstr "" -#: ../../library/importlib.rst:717 +#: ../../library/importlib.rst:721 msgid "" "An object with a subset of :class:`pathlib.Path` methods suitable for " "traversing directories and opening files." msgstr "" -#: ../../library/importlib.rst:720 +#: ../../library/importlib.rst:724 msgid "" -"For a representation of the object on the file-system, " -"use :meth:`importlib.resources.as_file`." +"For a representation of the object on the file-system, use :meth:`importlib." +"resources.as_file`." msgstr "" -#: ../../library/importlib.rst:725 +#: ../../library/importlib.rst:729 msgid "Use :class:`importlib.resources.abc.Traversable` instead." msgstr "" -#: ../../library/importlib.rst:730 +#: ../../library/importlib.rst:734 msgid "Abstract. The base name of this object without any parent references." msgstr "" -#: ../../library/importlib.rst:735 +#: ../../library/importlib.rst:739 msgid "Yield ``Traversable`` objects in ``self``." msgstr "" -#: ../../library/importlib.rst:740 +#: ../../library/importlib.rst:744 msgid "Return ``True`` if ``self`` is a directory." msgstr "" -#: ../../library/importlib.rst:745 +#: ../../library/importlib.rst:749 msgid "Return ``True`` if ``self`` is a file." msgstr "" -#: ../../library/importlib.rst:750 +#: ../../library/importlib.rst:754 msgid "Return Traversable child in ``self``." msgstr "" -#: ../../library/importlib.rst:755 +#: ../../library/importlib.rst:759 msgid "Return ``Traversable`` child in ``self``." msgstr "" -#: ../../library/importlib.rst:760 +#: ../../library/importlib.rst:764 msgid "" "*mode* may be 'r' or 'rb' to open as text or binary. Return a handle " "suitable for reading (same as :attr:`pathlib.Path.open`)." msgstr "" -#: ../../library/importlib.rst:763 +#: ../../library/importlib.rst:767 msgid "" -"When opening as text, accepts encoding parameters such as those accepted " -"by :class:`io.TextIOWrapper`." +"When opening as text, accepts encoding parameters such as those accepted by :" +"class:`io.TextIOWrapper`." msgstr "" -#: ../../library/importlib.rst:768 +#: ../../library/importlib.rst:772 msgid "Read contents of ``self`` as bytes." msgstr "" -#: ../../library/importlib.rst:772 +#: ../../library/importlib.rst:776 msgid "Read contents of ``self`` as text." msgstr "" -#: ../../library/importlib.rst:777 +#: ../../library/importlib.rst:781 msgid "" -"An abstract base class for resource readers capable of serving " -"the :meth:`importlib.resources.files` interface. " -"Subclasses :class:`importlib.resources.abc.ResourceReader` and provides " -"concrete implementations of " -"the :class:`importlib.resources.abc.ResourceReader`'s abstract methods. " +"An abstract base class for resource readers capable of serving the :meth:" +"`importlib.resources.files` interface. Subclasses :class:`importlib." +"resources.abc.ResourceReader` and provides concrete implementations of the :" +"class:`importlib.resources.abc.ResourceReader`'s abstract methods. " "Therefore, any loader supplying :class:`importlib.abc.TraversableResources` " "also supplies ResourceReader." msgstr "" -#: ../../library/importlib.rst:784 +#: ../../library/importlib.rst:788 msgid "" "Loaders that wish to support resource reading are expected to implement this " "interface." msgstr "" -#: ../../library/importlib.rst:795 +#: ../../library/importlib.rst:799 msgid "" "Returns a :class:`importlib.resources.abc.Traversable` object for the loaded " "package." msgstr "" -#: ../../library/importlib.rst:801 +#: ../../library/importlib.rst:805 msgid ":mod:`importlib.machinery` -- Importers and path hooks" msgstr "" -#: ../../library/importlib.rst:806 +#: ../../library/importlib.rst:810 msgid "**Source code:** :source:`Lib/importlib/machinery.py`" msgstr "**原始碼:**\\ :source:`Lib/importlib/machinery.py`" -#: ../../library/importlib.rst:810 +#: ../../library/importlib.rst:814 msgid "" "This module contains the various objects that help :keyword:`import` find " "and load modules." msgstr "" -#: ../../library/importlib.rst:815 +#: ../../library/importlib.rst:819 msgid "" "A list of strings representing the recognized file suffixes for source " "modules." msgstr "" -#: ../../library/importlib.rst:822 +#: ../../library/importlib.rst:826 msgid "" "A list of strings representing the file suffixes for non-optimized bytecode " "modules." msgstr "" -#: ../../library/importlib.rst:827 ../../library/importlib.rst:837 +#: ../../library/importlib.rst:831 ../../library/importlib.rst:841 msgid "Use :const:`BYTECODE_SUFFIXES` instead." msgstr "" -#: ../../library/importlib.rst:832 +#: ../../library/importlib.rst:836 msgid "" "A list of strings representing the file suffixes for optimized bytecode " "modules." msgstr "" -#: ../../library/importlib.rst:842 +#: ../../library/importlib.rst:846 msgid "" "A list of strings representing the recognized file suffixes for bytecode " "modules (including the leading dot)." msgstr "" -#: ../../library/importlib.rst:847 +#: ../../library/importlib.rst:851 msgid "The value is no longer dependent on ``__debug__``." msgstr "" -#: ../../library/importlib.rst:852 +#: ../../library/importlib.rst:856 msgid "" "A list of strings representing the recognized file suffixes for extension " "modules." msgstr "" -#: ../../library/importlib.rst:859 +#: ../../library/importlib.rst:863 msgid "" "Returns a combined list of strings representing all file suffixes for " "modules recognized by the standard import machinery. This is a helper for " "code which simply needs to know if a filesystem path potentially refers to a " -"module without needing any details on the kind of module (for " -"example, :func:`inspect.getmodulename`)." +"module without needing any details on the kind of module (for example, :func:" +"`inspect.getmodulename`)." msgstr "" -#: ../../library/importlib.rst:870 +#: ../../library/importlib.rst:874 msgid "" "An :term:`importer` for built-in modules. All known built-in modules are " -"listed in :data:`sys.builtin_module_names`. This class implements " -"the :class:`importlib.abc.MetaPathFinder` " -"and :class:`importlib.abc.InspectLoader` ABCs." +"listed in :data:`sys.builtin_module_names`. This class implements the :class:" +"`importlib.abc.MetaPathFinder` and :class:`importlib.abc.InspectLoader` ABCs." msgstr "" -#: ../../library/importlib.rst:875 ../../library/importlib.rst:889 -#: ../../library/importlib.rst:902 ../../library/importlib.rst:917 +#: ../../library/importlib.rst:879 ../../library/importlib.rst:893 +#: ../../library/importlib.rst:906 ../../library/importlib.rst:921 msgid "" "Only class methods are defined by this class to alleviate the need for " "instantiation." msgstr "" -#: ../../library/importlib.rst:878 +#: ../../library/importlib.rst:882 msgid "" -"As part of :pep:`489`, the builtin importer now " -"implements :meth:`Loader.create_module` and :meth:`Loader.exec_module`" +"As part of :pep:`489`, the builtin importer now implements :meth:`Loader." +"create_module` and :meth:`Loader.exec_module`" msgstr "" -#: ../../library/importlib.rst:885 +#: ../../library/importlib.rst:889 msgid "" -"An :term:`importer` for frozen modules. This class implements " -"the :class:`importlib.abc.MetaPathFinder` " -"and :class:`importlib.abc.InspectLoader` ABCs." +"An :term:`importer` for frozen modules. This class implements the :class:" +"`importlib.abc.MetaPathFinder` and :class:`importlib.abc.InspectLoader` ABCs." msgstr "" -#: ../../library/importlib.rst:892 +#: ../../library/importlib.rst:896 msgid "" "Gained :meth:`~Loader.create_module` and :meth:`~Loader.exec_module` methods." msgstr "" -#: ../../library/importlib.rst:899 +#: ../../library/importlib.rst:903 msgid "" ":term:`Finder ` for modules declared in the Windows registry. This " "class implements the :class:`importlib.abc.MetaPathFinder` ABC." msgstr "" -#: ../../library/importlib.rst:907 +#: ../../library/importlib.rst:911 msgid "" "Use :mod:`site` configuration instead. Future versions of Python may not " "enable this finder by default." msgstr "" -#: ../../library/importlib.rst:914 +#: ../../library/importlib.rst:918 msgid "" "A :term:`Finder ` for :data:`sys.path` and package ``__path__`` " "attributes. This class implements the :class:`importlib.abc.MetaPathFinder` " "ABC." msgstr "" -#: ../../library/importlib.rst:922 +#: ../../library/importlib.rst:926 msgid "" "Class method that attempts to find a :term:`spec ` for the " "module specified by *fullname* on :data:`sys.path` or, if defined, on " -"*path*. For each path entry that is " -"searched, :data:`sys.path_importer_cache` is checked. If a non-false object " -"is found then it is used as the :term:`path entry finder` to look for the " -"module being searched for. If no entry is found " -"in :data:`sys.path_importer_cache`, then :data:`sys.path_hooks` is searched " -"for a finder for the path entry and, if found, is stored " -"in :data:`sys.path_importer_cache` along with being queried about the " -"module. If no finder is ever found then ``None`` is both stored in the cache " -"and returned." +"*path*. For each path entry that is searched, :data:`sys." +"path_importer_cache` is checked. If a non-false object is found then it is " +"used as the :term:`path entry finder` to look for the module being searched " +"for. If no entry is found in :data:`sys.path_importer_cache`, then :data:" +"`sys.path_hooks` is searched for a finder for the path entry and, if found, " +"is stored in :data:`sys.path_importer_cache` along with being queried about " +"the module. If no finder is ever found then ``None`` is both stored in the " +"cache and returned." msgstr "" -#: ../../library/importlib.rst:936 +#: ../../library/importlib.rst:940 msgid "" "If the current working directory -- represented by an empty string -- is no " -"longer valid then ``None`` is returned but no value is cached " -"in :data:`sys.path_importer_cache`." +"longer valid then ``None`` is returned but no value is cached in :data:`sys." +"path_importer_cache`." msgstr "" -#: ../../library/importlib.rst:943 +#: ../../library/importlib.rst:947 msgid "" "Calls :meth:`importlib.abc.PathEntryFinder.invalidate_caches` on all finders " "stored in :data:`sys.path_importer_cache` that define the method. Otherwise " "entries in :data:`sys.path_importer_cache` set to ``None`` are deleted." msgstr "" -#: ../../library/importlib.rst:948 +#: ../../library/importlib.rst:952 msgid "Entries of ``None`` in :data:`sys.path_importer_cache` are deleted." msgstr "" -#: ../../library/importlib.rst:951 +#: ../../library/importlib.rst:955 msgid "" "Calls objects in :data:`sys.path_hooks` with the current working directory " "for ``''`` (i.e. the empty string)." msgstr "" -#: ../../library/importlib.rst:958 +#: ../../library/importlib.rst:962 msgid "" "A concrete implementation of :class:`importlib.abc.PathEntryFinder` which " "caches results from the file system." msgstr "" -#: ../../library/importlib.rst:961 +#: ../../library/importlib.rst:965 msgid "" "The *path* argument is the directory for which the finder is in charge of " "searching." msgstr "" -#: ../../library/importlib.rst:964 +#: ../../library/importlib.rst:968 msgid "" "The *loader_details* argument is a variable number of 2-item tuples each " "containing a loader and a sequence of file suffixes the loader recognizes. " @@ -1204,7 +1202,7 @@ msgid "" "module's name and the path to the file found." msgstr "" -#: ../../library/importlib.rst:969 +#: ../../library/importlib.rst:973 msgid "" "The finder will cache the directory contents as necessary, making stat calls " "for each module search to verify the cache is not outdated. Because cache " @@ -1217,166 +1215,166 @@ msgid "" "to call :func:`importlib.invalidate_caches`." msgstr "" -#: ../../library/importlib.rst:983 +#: ../../library/importlib.rst:987 msgid "The path the finder will search in." msgstr "" -#: ../../library/importlib.rst:987 +#: ../../library/importlib.rst:991 msgid "Attempt to find the spec to handle *fullname* within :attr:`path`." msgstr "" -#: ../../library/importlib.rst:993 +#: ../../library/importlib.rst:997 msgid "Clear out the internal cache." msgstr "" -#: ../../library/importlib.rst:997 +#: ../../library/importlib.rst:1001 msgid "" "A class method which returns a closure for use on :data:`sys.path_hooks`. An " "instance of :class:`FileFinder` is returned by the closure using the path " "argument given to the closure directly and *loader_details* indirectly." msgstr "" -#: ../../library/importlib.rst:1002 +#: ../../library/importlib.rst:1006 msgid "" -"If the argument to the closure is not an existing " -"directory, :exc:`ImportError` is raised." +"If the argument to the closure is not an existing directory, :exc:" +"`ImportError` is raised." msgstr "" -#: ../../library/importlib.rst:1008 +#: ../../library/importlib.rst:1012 msgid "" "A concrete implementation of :class:`importlib.abc.SourceLoader` by " "subclassing :class:`importlib.abc.FileLoader` and providing some concrete " "implementations of other methods." msgstr "" -#: ../../library/importlib.rst:1016 +#: ../../library/importlib.rst:1020 msgid "The name of the module that this loader will handle." msgstr "" -#: ../../library/importlib.rst:1020 +#: ../../library/importlib.rst:1024 msgid "The path to the source file." msgstr "" -#: ../../library/importlib.rst:1024 +#: ../../library/importlib.rst:1028 msgid "Return ``True`` if :attr:`path` appears to be for a package." msgstr "" -#: ../../library/importlib.rst:1028 +#: ../../library/importlib.rst:1032 msgid "" "Concrete implementation of :meth:`importlib.abc.SourceLoader.path_stats`." msgstr "" -#: ../../library/importlib.rst:1032 +#: ../../library/importlib.rst:1036 msgid "Concrete implementation of :meth:`importlib.abc.SourceLoader.set_data`." msgstr "" -#: ../../library/importlib.rst:1036 ../../library/importlib.rst:1079 +#: ../../library/importlib.rst:1040 ../../library/importlib.rst:1083 msgid "" "Concrete implementation of :meth:`importlib.abc.Loader.load_module` where " "specifying the name of the module to load is optional." msgstr "" -#: ../../library/importlib.rst:1041 ../../library/importlib.rst:1084 +#: ../../library/importlib.rst:1045 ../../library/importlib.rst:1088 msgid "Use :meth:`importlib.abc.Loader.exec_module` instead." msgstr "" -#: ../../library/importlib.rst:1046 +#: ../../library/importlib.rst:1050 msgid "" "A concrete implementation of :class:`importlib.abc.FileLoader` which can " "import bytecode files (i.e. no source code files exist)." msgstr "" -#: ../../library/importlib.rst:1049 +#: ../../library/importlib.rst:1053 msgid "" "Please note that direct use of bytecode files (and thus not source code " "files) inhibits your modules from being usable by all Python implementations " "or new versions of Python which change the bytecode format." msgstr "" -#: ../../library/importlib.rst:1058 +#: ../../library/importlib.rst:1062 msgid "The name of the module the loader will handle." msgstr "" -#: ../../library/importlib.rst:1062 +#: ../../library/importlib.rst:1066 msgid "The path to the bytecode file." msgstr "" -#: ../../library/importlib.rst:1066 +#: ../../library/importlib.rst:1070 msgid "Determines if the module is a package based on :attr:`path`." msgstr "" -#: ../../library/importlib.rst:1070 +#: ../../library/importlib.rst:1074 msgid "Returns the code object for :attr:`name` created from :attr:`path`." msgstr "" -#: ../../library/importlib.rst:1074 +#: ../../library/importlib.rst:1078 msgid "" "Returns ``None`` as bytecode files have no source when this loader is used." msgstr "" -#: ../../library/importlib.rst:1089 +#: ../../library/importlib.rst:1093 msgid "" "A concrete implementation of :class:`importlib.abc.ExecutionLoader` for " "extension modules." msgstr "" -#: ../../library/importlib.rst:1092 +#: ../../library/importlib.rst:1096 msgid "" "The *fullname* argument specifies the name of the module the loader is to " "support. The *path* argument is the path to the extension module's file." msgstr "" -#: ../../library/importlib.rst:1095 +#: ../../library/importlib.rst:1099 msgid "" "Note that, by default, importing an extension module will fail in " "subinterpreters if it doesn't implement multi-phase init (see :pep:`489`), " "even if it would otherwise import successfully." msgstr "" -#: ../../library/importlib.rst:1101 +#: ../../library/importlib.rst:1105 msgid "Multi-phase init is now required for use in subinterpreters." msgstr "" -#: ../../library/importlib.rst:1106 ../../library/importlib.rst:1292 +#: ../../library/importlib.rst:1110 ../../library/importlib.rst:1296 msgid "Name of the module the loader supports." msgstr "" -#: ../../library/importlib.rst:1110 +#: ../../library/importlib.rst:1114 msgid "Path to the extension module." msgstr "" -#: ../../library/importlib.rst:1114 +#: ../../library/importlib.rst:1118 msgid "" -"Creates the module object from the given specification in accordance " -"with :pep:`489`." +"Creates the module object from the given specification in accordance with :" +"pep:`489`." msgstr "" -#: ../../library/importlib.rst:1121 +#: ../../library/importlib.rst:1125 msgid "Initializes the given module object in accordance with :pep:`489`." msgstr "" -#: ../../library/importlib.rst:1127 +#: ../../library/importlib.rst:1131 msgid "" "Returns ``True`` if the file path points to a package's ``__init__`` module " "based on :const:`EXTENSION_SUFFIXES`." msgstr "" -#: ../../library/importlib.rst:1132 +#: ../../library/importlib.rst:1136 msgid "Returns ``None`` as extension modules lack a code object." msgstr "" -#: ../../library/importlib.rst:1136 +#: ../../library/importlib.rst:1140 msgid "Returns ``None`` as extension modules do not have source code." msgstr "" -#: ../../library/importlib.rst:1147 +#: ../../library/importlib.rst:1151 msgid "" "A concrete implementation of :class:`importlib.abc.InspectLoader` for " "namespace packages. This is an alias for a private class and is only made " "public for introspecting the ``__loader__`` attribute on namespace packages::" msgstr "" -#: ../../library/importlib.rst:1152 +#: ../../library/importlib.rst:1156 msgid "" ">>> from importlib.machinery import NamespaceLoader\n" ">>> import my_namespace\n" @@ -1394,7 +1392,7 @@ msgstr "" ">>> isinstance(my_namespace.__loader__, importlib.abc.Loader)\n" "True" -#: ../../library/importlib.rst:1165 +#: ../../library/importlib.rst:1169 msgid "" "A specification for a module's import-system-related state. This is " "typically exposed as the module's :attr:`~module.__spec__` attribute. Many " @@ -1403,40 +1401,39 @@ msgid "" "the *values* are usually equivalent, they can differ since there is no " "synchronization between the two objects. For example, it is possible to " "update the module's :attr:`~module.__file__` at runtime and this will not be " -"automatically reflected in the module's :attr:`__spec__.origin " -"`, and vice versa." +"automatically reflected in the module's :attr:`__spec__.origin `, and vice versa." msgstr "" -#: ../../library/importlib.rst:1179 +#: ../../library/importlib.rst:1183 msgid "" -"The module's fully qualified name (see :attr:`module.__name__`). " -"The :term:`finder` should always set this attribute to a non-empty string." +"The module's fully qualified name (see :attr:`module.__name__`). The :term:" +"`finder` should always set this attribute to a non-empty string." msgstr "" -#: ../../library/importlib.rst:1184 +#: ../../library/importlib.rst:1188 msgid "" "The :term:`loader` used to load the module (see :attr:`module.__loader__`). " "The :term:`finder` should always set this attribute." msgstr "" -#: ../../library/importlib.rst:1189 +#: ../../library/importlib.rst:1193 msgid "" -"The location the :term:`loader` should use to load the module " -"(see :attr:`module.__file__`). For example, for modules loaded from a " -"``.py`` file this is the filename. The :term:`finder` should always set this " -"attribute to a meaningful value for the :term:`loader` to use. In the " -"uncommon case that there is not one (like for namespace packages), it should " -"be set to ``None``." +"The location the :term:`loader` should use to load the module (see :attr:" +"`module.__file__`). For example, for modules loaded from a ``.py`` file this " +"is the filename. The :term:`finder` should always set this attribute to a " +"meaningful value for the :term:`loader` to use. In the uncommon case that " +"there is not one (like for namespace packages), it should be set to ``None``." msgstr "" -#: ../../library/importlib.rst:1198 +#: ../../library/importlib.rst:1202 msgid "" "A (possibly empty) :term:`sequence` of strings enumerating the locations in " "which a package's submodules will be found (see :attr:`module.__path__`). " "Most of the time there will only be a single directory in this list." msgstr "" -#: ../../library/importlib.rst:1203 +#: ../../library/importlib.rst:1207 msgid "" "The :term:`finder` should set this attribute to a sequence, even an empty " "one, to indicate to the import system that the module is a package. It " @@ -1444,42 +1441,41 @@ msgid "" "later to a special object for namespace packages." msgstr "" -#: ../../library/importlib.rst:1211 +#: ../../library/importlib.rst:1215 msgid "" "The :term:`finder` may set this attribute to an object containing " "additional, module-specific data to use when loading the module. Otherwise " "it should be set to ``None``." msgstr "" -#: ../../library/importlib.rst:1217 +#: ../../library/importlib.rst:1221 msgid "" -"The filename of a compiled version of the module's code " -"(see :attr:`module.__cached__`). The :term:`finder` should always set this " -"attribute but it may be ``None`` for modules that do not need compiled code " -"stored." +"The filename of a compiled version of the module's code (see :attr:`module." +"__cached__`). The :term:`finder` should always set this attribute but it may " +"be ``None`` for modules that do not need compiled code stored." msgstr "" -#: ../../library/importlib.rst:1224 +#: ../../library/importlib.rst:1228 msgid "" "(Read-only) The fully qualified name of the package the module is in (or the " "empty string for a top-level module). See :attr:`module.__package__`. If the " "module is a package then this is the same as :attr:`name`." msgstr "" -#: ../../library/importlib.rst:1231 +#: ../../library/importlib.rst:1235 msgid "" "``True`` if the spec's :attr:`origin` refers to a loadable location, " "``False`` otherwise. This value impacts how :attr:`!origin` is interpreted " "and how the module's :attr:`~module.__file__` is populated." msgstr "" -#: ../../library/importlib.rst:1238 +#: ../../library/importlib.rst:1242 msgid "" "A specialization of :class:`importlib.machinery.ExtensionFileLoader` that is " "able to load extension modules in Framework format." msgstr "" -#: ../../library/importlib.rst:1241 +#: ../../library/importlib.rst:1245 msgid "" "For compatibility with the iOS App Store, *all* binary modules in an iOS app " "must be dynamic libraries, contained in a framework with appropriate " @@ -1488,37 +1484,37 @@ msgid "" "material outside the Frameworks folder." msgstr "" -#: ../../library/importlib.rst:1247 +#: ../../library/importlib.rst:1251 msgid "" "To accommodate this requirement, when running on iOS, extension module " "binaries are *not* packaged as ``.so`` files on ``sys.path``, but as " "individual standalone frameworks. To discover those frameworks, this loader " "is be registered against the ``.fwork`` file extension, with a ``.fwork`` " -"file acting as a placeholder in the original location of the binary on " -"``sys.path``. The ``.fwork`` file contains the path of the actual binary in " -"the ``Frameworks`` folder, relative to the app bundle. To allow for " -"resolving a framework-packaged binary back to the original location, the " -"framework is expected to contain a ``.origin`` file that contains the " -"location of the ``.fwork`` file, relative to the app bundle." +"file acting as a placeholder in the original location of the binary on ``sys." +"path``. The ``.fwork`` file contains the path of the actual binary in the " +"``Frameworks`` folder, relative to the app bundle. To allow for resolving a " +"framework-packaged binary back to the original location, the framework is " +"expected to contain a ``.origin`` file that contains the location of the ``." +"fwork`` file, relative to the app bundle." msgstr "" -#: ../../library/importlib.rst:1258 +#: ../../library/importlib.rst:1262 msgid "" "For example, consider the case of an import ``from foo.bar import _whiz``, " "where ``_whiz`` is implemented with the binary module ``sources/foo/bar/" -"_whiz.abi3.so``, with ``sources`` being the location registered on " -"``sys.path``, relative to the application bundle. This module *must* be " +"_whiz.abi3.so``, with ``sources`` being the location registered on ``sys." +"path``, relative to the application bundle. This module *must* be " "distributed as ``Frameworks/foo.bar._whiz.framework/foo.bar._whiz`` " "(creating the framework name from the full import path of the module), with " "an ``Info.plist`` file in the ``.framework`` directory identifying the " "binary as a framework. The ``foo.bar._whiz`` module would be represented in " "the original location with a ``sources/foo/bar/_whiz.abi3.fwork`` marker " "file, containing the path ``Frameworks/foo.bar._whiz/foo.bar._whiz``. The " -"framework would also contain ``Frameworks/foo.bar._whiz.framework/" -"foo.bar._whiz.origin``, containing the path to the ``.fwork`` file." +"framework would also contain ``Frameworks/foo.bar._whiz.framework/foo.bar." +"_whiz.origin``, containing the path to the ``.fwork`` file." msgstr "" -#: ../../library/importlib.rst:1272 +#: ../../library/importlib.rst:1276 msgid "" "When a module is loaded with this loader, the ``__file__`` for the module " "will report as the location of the ``.fwork`` file. This allows code to use " @@ -1527,7 +1523,7 @@ msgid "" "in the ``.framework`` folder." msgstr "" -#: ../../library/importlib.rst:1278 +#: ../../library/importlib.rst:1282 msgid "" "The Xcode project building the app is responsible for converting any ``.so`` " "files from wherever they exist in the ``PYTHONPATH`` into frameworks in the " @@ -1538,45 +1534,45 @@ msgid "" "details on how to construct this build step." msgstr "" -#: ../../library/importlib.rst:1288 +#: ../../library/importlib.rst:1292 msgid "Availability" msgstr "可用性" -#: ../../library/importlib.rst:1296 +#: ../../library/importlib.rst:1300 msgid "Path to the ``.fwork`` file for the extension module." msgstr "" -#: ../../library/importlib.rst:1300 +#: ../../library/importlib.rst:1304 msgid ":mod:`importlib.util` -- Utility code for importers" msgstr "" -#: ../../library/importlib.rst:1306 +#: ../../library/importlib.rst:1310 msgid "**Source code:** :source:`Lib/importlib/util.py`" msgstr "**原始碼:**\\ :source:`Lib/importlib/util.py`" -#: ../../library/importlib.rst:1310 +#: ../../library/importlib.rst:1314 msgid "" "This module contains the various objects that help in the construction of " "an :term:`importer`." msgstr "" -#: ../../library/importlib.rst:1315 +#: ../../library/importlib.rst:1319 msgid "" "The bytes which represent the bytecode version number. If you need help with " "loading/writing bytecode then consider :class:`importlib.abc.SourceLoader`." msgstr "" -#: ../../library/importlib.rst:1322 +#: ../../library/importlib.rst:1326 msgid "" "Return the :pep:`3147`/:pep:`488` path to the byte-compiled file associated " "with the source *path*. For example, if *path* is ``/foo/bar/baz.py`` the " "return value would be ``/foo/bar/__pycache__/baz.cpython-32.pyc`` for Python " -"3.2. The ``cpython-32`` string comes from the current magic tag " -"(see :func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined " -"then :exc:`NotImplementedError` will be raised)." +"3.2. The ``cpython-32`` string comes from the current magic tag (see :func:" +"`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then :exc:" +"`NotImplementedError` will be raised)." msgstr "" -#: ../../library/importlib.rst:1329 +#: ../../library/importlib.rst:1333 msgid "" "The *optimization* parameter is used to specify the optimization level of " "the bytecode file. An empty string represents no optimization, so ``/foo/bar/" @@ -1584,12 +1580,12 @@ msgid "" "``/foo/bar/__pycache__/baz.cpython-32.pyc``. ``None`` causes the " "interpreter's optimization level to be used. Any other value's string " "representation is used, so ``/foo/bar/baz.py`` with an *optimization* of " -"``2`` will lead to the bytecode path of ``/foo/bar/__pycache__/" -"baz.cpython-32.opt-2.pyc``. The string representation of *optimization* can " -"only be alphanumeric, else :exc:`ValueError` is raised." +"``2`` will lead to the bytecode path of ``/foo/bar/__pycache__/baz." +"cpython-32.opt-2.pyc``. The string representation of *optimization* can only " +"be alphanumeric, else :exc:`ValueError` is raised." msgstr "" -#: ../../library/importlib.rst:1339 +#: ../../library/importlib.rst:1343 msgid "" "The *debug_override* parameter is deprecated and can be used to override the " "system's value for ``__debug__``. A ``True`` value is the equivalent of " @@ -1598,63 +1594,60 @@ msgid "" "are not ``None`` then :exc:`TypeError` is raised." msgstr "" -#: ../../library/importlib.rst:1347 +#: ../../library/importlib.rst:1351 msgid "" "The *optimization* parameter was added and the *debug_override* parameter " "was deprecated." msgstr "" -#: ../../library/importlib.rst:1351 ../../library/importlib.rst:1367 -#: ../../library/importlib.rst:1456 +#: ../../library/importlib.rst:1355 ../../library/importlib.rst:1371 +#: ../../library/importlib.rst:1460 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../library/importlib.rst:1357 +#: ../../library/importlib.rst:1361 msgid "" "Given the *path* to a :pep:`3147` file name, return the associated source " -"code file path. For example, if *path* is ``/foo/bar/__pycache__/" -"baz.cpython-32.pyc`` the returned path would be ``/foo/bar/baz.py``. *path* " +"code file path. For example, if *path* is ``/foo/bar/__pycache__/baz." +"cpython-32.pyc`` the returned path would be ``/foo/bar/baz.py``. *path* " "need not exist, however if it does not conform to :pep:`3147` or :pep:`488` " -"format, a :exc:`ValueError` is raised. " -"If :attr:`sys.implementation.cache_tag` is not " -"defined, :exc:`NotImplementedError` is raised." +"format, a :exc:`ValueError` is raised. If :attr:`sys.implementation." +"cache_tag` is not defined, :exc:`NotImplementedError` is raised." msgstr "" -#: ../../library/importlib.rst:1372 +#: ../../library/importlib.rst:1376 msgid "" "Decode the given bytes representing source code and return it as a string " -"with universal newlines (as required " -"by :meth:`importlib.abc.InspectLoader.get_source`)." +"with universal newlines (as required by :meth:`importlib.abc.InspectLoader." +"get_source`)." msgstr "" -#: ../../library/importlib.rst:1380 +#: ../../library/importlib.rst:1384 msgid "Resolve a relative module name to an absolute one." msgstr "" -#: ../../library/importlib.rst:1382 +#: ../../library/importlib.rst:1386 msgid "" "If **name** has no leading dots, then **name** is simply returned. This " -"allows for usage such as ``importlib.util.resolve_name('sys', " -"__spec__.parent)`` without doing a check to see if the **package** argument " -"is needed." +"allows for usage such as ``importlib.util.resolve_name('sys', __spec__." +"parent)`` without doing a check to see if the **package** argument is needed." msgstr "" -#: ../../library/importlib.rst:1387 +#: ../../library/importlib.rst:1391 msgid "" ":exc:`ImportError` is raised if **name** is a relative module name but " -"**package** is a false value (e.g. ``None`` or the empty " -"string). :exc:`ImportError` is also raised if a relative name would escape " -"its containing package (e.g. requesting ``..bacon`` from within the ``spam`` " -"package)." +"**package** is a false value (e.g. ``None`` or the empty string). :exc:" +"`ImportError` is also raised if a relative name would escape its containing " +"package (e.g. requesting ``..bacon`` from within the ``spam`` package)." msgstr "" -#: ../../library/importlib.rst:1395 +#: ../../library/importlib.rst:1399 msgid "" "To improve consistency with import statements, raise :exc:`ImportError` " "instead of :exc:`ValueError` for invalid relative import attempts." msgstr "" -#: ../../library/importlib.rst:1402 +#: ../../library/importlib.rst:1406 msgid "" "Find the :term:`spec ` for a module, optionally relative to the " "specified **package** name. If the module is in :data:`sys.modules`, then " @@ -1664,30 +1657,30 @@ msgid "" "if no spec is found." msgstr "" -#: ../../library/importlib.rst:1409 +#: ../../library/importlib.rst:1413 msgid "" "If **name** is for a submodule (contains a dot), the parent module is " "automatically imported." msgstr "" -#: ../../library/importlib.rst:1412 +#: ../../library/importlib.rst:1416 msgid "**name** and **package** work the same as for :func:`import_module`." msgstr "" -#: ../../library/importlib.rst:1416 +#: ../../library/importlib.rst:1420 msgid "" "Raises :exc:`ModuleNotFoundError` instead of :exc:`AttributeError` if " "**package** is in fact not a package (i.e. lacks a :attr:`~module.__path__` " "attribute)." msgstr "" -#: ../../library/importlib.rst:1423 +#: ../../library/importlib.rst:1427 msgid "" "Create a new module based on **spec** and :meth:`spec.loader.create_module " "`." msgstr "" -#: ../../library/importlib.rst:1426 +#: ../../library/importlib.rst:1430 msgid "" "If :meth:`spec.loader.create_module ` " "does not return ``None``, then any pre-existing attributes will not be " @@ -1695,23 +1688,23 @@ msgid "" "accessing **spec** or setting an attribute on the module." msgstr "" -#: ../../library/importlib.rst:1431 +#: ../../library/importlib.rst:1435 msgid "" "This function is preferred over using :class:`types.ModuleType` to create a " "new module as **spec** is used to set as many import-controlled attributes " "on the module as possible." msgstr "" -#: ../../library/importlib.rst:1439 +#: ../../library/importlib.rst:1443 msgid "" "A factory function for creating a :class:`~importlib.machinery.ModuleSpec` " "instance based on a loader. The parameters have the same meaning as they do " -"for ModuleSpec. The function uses available :term:`loader` APIs, such " -"as :meth:`InspectLoader.is_package`, to fill in any missing information on " -"the spec." +"for ModuleSpec. The function uses available :term:`loader` APIs, such as :" +"meth:`InspectLoader.is_package`, to fill in any missing information on the " +"spec." msgstr "" -#: ../../library/importlib.rst:1449 +#: ../../library/importlib.rst:1453 msgid "" "A factory function for creating a :class:`~importlib.machinery.ModuleSpec` " "instance based on the path to a file. Missing information will be filled in " @@ -1719,14 +1712,14 @@ msgid "" "module will be file-based." msgstr "" -#: ../../library/importlib.rst:1461 +#: ../../library/importlib.rst:1465 msgid "" "Return the hash of *source_bytes* as bytes. A hash-based ``.pyc`` file " "embeds the :func:`source_hash` of the corresponding source file's contents " "in its header." msgstr "" -#: ../../library/importlib.rst:1469 +#: ../../library/importlib.rst:1473 msgid "" "A context manager that can temporarily skip the compatibility check for " "extension modules. By default the check is enabled and will fail when a " @@ -1735,14 +1728,14 @@ msgid "" "interpreter GIL, when imported in an interpreter with its own GIL." msgstr "" -#: ../../library/importlib.rst:1476 +#: ../../library/importlib.rst:1480 msgid "" "Note that this function is meant to accommodate an unusual case; one which " "is likely to eventually go away. There's is a pretty good chance this is " "not what you were looking for." msgstr "" -#: ../../library/importlib.rst:1480 +#: ../../library/importlib.rst:1484 msgid "" "You can get the same effect as this function by implementing the basic " "interface of multi-phase init (:pep:`489`) and lying about support for " @@ -1751,33 +1744,32 @@ msgstr "" "你可以透過實作多階段初始化的基本介面 (:pep:`489`) 並假稱有多個直譯器(或直譯" "器各別持有的 GIL)的支援,來達到與此函式相同的效果。" -#: ../../library/importlib.rst:1485 +#: ../../library/importlib.rst:1489 msgid "" "Using this function to disable the check can lead to unexpected behavior and " "even crashes. It should only be used during extension module development." msgstr "" -#: ../../library/importlib.rst:1493 +#: ../../library/importlib.rst:1497 msgid "" "A class which postpones the execution of the loader of a module until the " "module has an attribute accessed." msgstr "" -#: ../../library/importlib.rst:1496 +#: ../../library/importlib.rst:1500 msgid "" -"This class **only** works with loaders that " -"define :meth:`~importlib.abc.Loader.exec_module` as control over what module " -"type is used for the module is required. For those same reasons, the " -"loader's :meth:`~importlib.abc.Loader.create_module` method must return " -"``None`` or a type for which its ``__class__`` attribute can be mutated " -"along with not using :term:`slots <__slots__>`. Finally, modules which " -"substitute the object placed into :data:`sys.modules` will not work as there " -"is no way to properly replace the module references throughout the " -"interpreter safely; :exc:`ValueError` is raised if such a substitution is " -"detected." +"This class **only** works with loaders that define :meth:`~importlib.abc." +"Loader.exec_module` as control over what module type is used for the module " +"is required. For those same reasons, the loader's :meth:`~importlib.abc." +"Loader.create_module` method must return ``None`` or a type for which its " +"``__class__`` attribute can be mutated along with not using :term:`slots " +"<__slots__>`. Finally, modules which substitute the object placed into :data:" +"`sys.modules` will not work as there is no way to properly replace the " +"module references throughout the interpreter safely; :exc:`ValueError` is " +"raised if such a substitution is detected." msgstr "" -#: ../../library/importlib.rst:1507 +#: ../../library/importlib.rst:1511 msgid "" "For projects where startup time is critical, this class allows for " "potentially minimizing the cost of loading a module if it is never used. For " @@ -1786,21 +1778,21 @@ msgid "" "postponed and thus occurring out of context." msgstr "" -#: ../../library/importlib.rst:1515 +#: ../../library/importlib.rst:1519 msgid "" "Began calling :meth:`~importlib.abc.Loader.create_module`, removing the " -"compatibility warning for :class:`importlib.machinery.BuiltinImporter` " -"and :class:`importlib.machinery.ExtensionFileLoader`." +"compatibility warning for :class:`importlib.machinery.BuiltinImporter` and :" +"class:`importlib.machinery.ExtensionFileLoader`." msgstr "" -#: ../../library/importlib.rst:1522 +#: ../../library/importlib.rst:1526 msgid "" "A class method which returns a callable that creates a lazy loader. This is " "meant to be used in situations where the loader is passed by class instead " "of by instance. ::" msgstr "" -#: ../../library/importlib.rst:1527 +#: ../../library/importlib.rst:1531 msgid "" "suffixes = importlib.machinery.SOURCE_SUFFIXES\n" "loader = importlib.machinery.SourceFileLoader\n" @@ -1812,20 +1804,20 @@ msgstr "" "lazy_loader = importlib.util.LazyLoader.factory(loader)\n" "finder = importlib.machinery.FileFinder(path, (lazy_loader, suffixes))" -#: ../../library/importlib.rst:1535 +#: ../../library/importlib.rst:1539 msgid "Examples" msgstr "範例" -#: ../../library/importlib.rst:1538 +#: ../../library/importlib.rst:1542 msgid "Importing programmatically" msgstr "" -#: ../../library/importlib.rst:1540 +#: ../../library/importlib.rst:1544 msgid "" "To programmatically import a module, use :func:`importlib.import_module`. ::" msgstr "" -#: ../../library/importlib.rst:1543 +#: ../../library/importlib.rst:1547 msgid "" "import importlib\n" "\n" @@ -1835,23 +1827,23 @@ msgstr "" "\n" "itertools = importlib.import_module('itertools')" -#: ../../library/importlib.rst:1549 +#: ../../library/importlib.rst:1553 msgid "Checking if a module can be imported" msgstr "" -#: ../../library/importlib.rst:1551 +#: ../../library/importlib.rst:1555 msgid "" "If you need to find out if a module can be imported without actually doing " "the import, then you should use :func:`importlib.util.find_spec`." msgstr "" -#: ../../library/importlib.rst:1554 +#: ../../library/importlib.rst:1558 msgid "" -"Note that if ``name`` is a submodule (contains a " -"dot), :func:`importlib.util.find_spec` will import the parent module. ::" +"Note that if ``name`` is a submodule (contains a dot), :func:`importlib.util." +"find_spec` will import the parent module. ::" msgstr "" -#: ../../library/importlib.rst:1558 +#: ../../library/importlib.rst:1562 msgid "" "import importlib.util\n" "import sys\n" @@ -1871,27 +1863,27 @@ msgid "" " print(f\"can't find the {name!r} module\")" msgstr "" -#: ../../library/importlib.rst:1577 +#: ../../library/importlib.rst:1581 msgid "Importing a source file directly" msgstr "" -#: ../../library/importlib.rst:1579 +#: ../../library/importlib.rst:1583 msgid "" "This recipe should be used with caution: it is an approximation of an import " -"statement where the file path is specified directly, rather " -"than :data:`sys.path` being searched. Alternatives should first be " -"considered first, such as modifying :data:`sys.path` when a proper module is " -"required, or using :func:`runpy.run_path` when the global namespace " -"resulting from running a Python file is appropriate." +"statement where the file path is specified directly, rather than :data:`sys." +"path` being searched. Alternatives should first be considered first, such as " +"modifying :data:`sys.path` when a proper module is required, or using :func:" +"`runpy.run_path` when the global namespace resulting from running a Python " +"file is appropriate." msgstr "" -#: ../../library/importlib.rst:1586 +#: ../../library/importlib.rst:1590 msgid "" "To import a Python source file directly from a path, use the following " "recipe::" msgstr "" -#: ../../library/importlib.rst:1588 +#: ../../library/importlib.rst:1592 msgid "" "import importlib.util\n" "import sys\n" @@ -1914,15 +1906,15 @@ msgid "" "json = import_from_path(module_name, file_path)" msgstr "" -#: ../../library/importlib.rst:1610 +#: ../../library/importlib.rst:1614 msgid "Implementing lazy imports" msgstr "" -#: ../../library/importlib.rst:1612 +#: ../../library/importlib.rst:1616 msgid "The example below shows how to implement lazy imports::" msgstr "" -#: ../../library/importlib.rst:1614 +#: ../../library/importlib.rst:1618 msgid "" ">>> import importlib.util\n" ">>> import sys\n" @@ -1942,26 +1934,25 @@ msgid "" "False" msgstr "" -#: ../../library/importlib.rst:1633 +#: ../../library/importlib.rst:1637 msgid "Setting up an importer" msgstr "" -#: ../../library/importlib.rst:1635 +#: ../../library/importlib.rst:1639 msgid "" -"For deep customizations of import, you typically want to implement " -"an :term:`importer`. This means managing both the :term:`finder` " -"and :term:`loader` side of things. For finders there are two flavours to " -"choose from depending on your needs: a :term:`meta path finder` or " -"a :term:`path entry finder`. The former is what you would put " -"on :data:`sys.meta_path` while the latter is what you create using " -"a :term:`path entry hook` on :data:`sys.path_hooks` which works " -"with :data:`sys.path` entries to potentially create a finder. This example " -"will show you how to register your own importers so that import will use " -"them (for creating an importer for yourself, read the documentation for the " -"appropriate classes defined within this package)::" +"For deep customizations of import, you typically want to implement an :term:" +"`importer`. This means managing both the :term:`finder` and :term:`loader` " +"side of things. For finders there are two flavours to choose from depending " +"on your needs: a :term:`meta path finder` or a :term:`path entry finder`. " +"The former is what you would put on :data:`sys.meta_path` while the latter " +"is what you create using a :term:`path entry hook` on :data:`sys.path_hooks` " +"which works with :data:`sys.path` entries to potentially create a finder. " +"This example will show you how to register your own importers so that import " +"will use them (for creating an importer for yourself, read the documentation " +"for the appropriate classes defined within this package)::" msgstr "" -#: ../../library/importlib.rst:1646 +#: ../../library/importlib.rst:1650 msgid "" "import importlib.machinery\n" "import sys\n" @@ -1985,11 +1976,11 @@ msgid "" "sys.path_hooks.append(SpamPathEntryFinder.path_hook(loader_details))" msgstr "" -#: ../../library/importlib.rst:1667 +#: ../../library/importlib.rst:1671 msgid "Approximating :func:`importlib.import_module`" msgstr "" -#: ../../library/importlib.rst:1669 +#: ../../library/importlib.rst:1673 msgid "" "Import itself is implemented in Python code, making it possible to expose " "most of the import machinery through importlib. The following helps " @@ -1997,7 +1988,7 @@ msgid "" "approximate implementation of :func:`importlib.import_module`::" msgstr "" -#: ../../library/importlib.rst:1675 +#: ../../library/importlib.rst:1679 msgid "" "import importlib.util\n" "import sys\n" @@ -2030,11 +2021,11 @@ msgid "" " return module" msgstr "" -#: ../../library/importlib.rst:425 +#: ../../library/importlib.rst:429 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/importlib.rst:425 +#: ../../library/importlib.rst:429 msgid "importlib.abc.InspectLoader.get_source method" msgstr "importlib.abc.InspectLoader.get_source 方法" diff --git a/library/importlib.resources.po b/library/importlib.resources.po index 8263a1f83d..63b4b181c7 100644 --- a/library/importlib.resources.po +++ b/library/importlib.resources.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # @@ -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-07-25 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,18 +37,19 @@ msgid "" "\"Resources\" are file-like resources associated with a module or package in " "Python. The resources may be contained directly in a package, within a " "subdirectory contained in that package, or adjacent to modules outside a " -"package. Resources may be text or binary. As a result, Python module sources " -"(.py) of a package and compilation artifacts (pycache) are technically de-" -"facto resources of that package. In practice, however, resources are " -"primarily those non-Python artifacts exposed specifically by the package " -"author." +"package. Resources may be text or binary. As a result, a package's Python " +"module sources (.py), compilation artifacts (pycache), and installation " +"artifacts (like :func:`reserved filenames ` in " +"directories) are technically de-facto resources of that package. In " +"practice, however, resources are primarily those non-Python artifacts " +"exposed specifically by the package author." msgstr "" -#: ../../library/importlib.resources.rst:25 +#: ../../library/importlib.resources.rst:26 msgid "Resources can be opened or read in either binary or text mode." msgstr "" -#: ../../library/importlib.resources.rst:27 +#: ../../library/importlib.resources.rst:28 msgid "" "Resources are roughly akin to files inside directories, though it's " "important to keep in mind that this is just a metaphor. Resources and " @@ -57,7 +58,7 @@ msgid "" "zip file using :py:mod:`zipimport`." msgstr "" -#: ../../library/importlib.resources.rst:35 +#: ../../library/importlib.resources.rst:36 msgid "" "This module provides functionality similar to `pkg_resources `_ `Basic Resource " @@ -67,7 +68,7 @@ msgid "" "consistent semantics." msgstr "" -#: ../../library/importlib.resources.rst:43 +#: ../../library/importlib.resources.rst:44 msgid "" "The standalone backport of this module provides more information on `using " "importlib.resources `_." msgstr "" -#: ../../library/importlib.resources.rst:49 +#: ../../library/importlib.resources.rst:50 msgid "" ":class:`Loaders ` that wish to support resource " "reading should implement a ``get_resource_reader(fullname)`` method as " "specified by :class:`importlib.resources.abc.ResourceReader`." msgstr "" -#: ../../library/importlib.resources.rst:55 +#: ../../library/importlib.resources.rst:56 msgid "" "Represents an anchor for resources, either a :class:`module object ` or a module name as a string. Defined as ``Union[str, " "ModuleType]``." msgstr "" -#: ../../library/importlib.resources.rst:61 +#: ../../library/importlib.resources.rst:62 msgid "" "Returns a :class:`~importlib.resources.abc.Traversable` object representing " "the resource container (think directory) and its resources (think files). A " "Traversable may contain other containers (think subdirectories)." msgstr "" -#: ../../library/importlib.resources.rst:66 +#: ../../library/importlib.resources.rst:67 msgid "" "*anchor* is an optional :class:`Anchor`. If the anchor is a package, " "resources are resolved from that package. If a module, resources are " @@ -104,7 +105,7 @@ msgid "" "If the anchor is omitted, the caller's module is used." msgstr "" -#: ../../library/importlib.resources.rst:74 +#: ../../library/importlib.resources.rst:75 msgid "" "*package* parameter was renamed to *anchor*. *anchor* can now be a non-" "package module and if omitted will default to the caller's module. *package* " @@ -113,7 +114,7 @@ msgid "" "``importlib_resources >= 5.10`` for a compatible interface on older Pythons." msgstr "" -#: ../../library/importlib.resources.rst:84 +#: ../../library/importlib.resources.rst:85 msgid "" "Given a :class:`~importlib.resources.abc.Traversable` object representing a " "file or directory, typically from :func:`importlib.resources.files`, return " @@ -121,60 +122,60 @@ msgid "" "manager provides a :class:`pathlib.Path` object." msgstr "" -#: ../../library/importlib.resources.rst:89 +#: ../../library/importlib.resources.rst:90 msgid "" "Exiting the context manager cleans up any temporary file or directory " "created when the resource was extracted from e.g. a zip file." msgstr "" -#: ../../library/importlib.resources.rst:92 +#: ../../library/importlib.resources.rst:93 msgid "" "Use ``as_file`` when the Traversable methods (``read_text``, etc) are " "insufficient and an actual file or directory on the file system is required." msgstr "" -#: ../../library/importlib.resources.rst:98 +#: ../../library/importlib.resources.rst:99 msgid "Added support for *traversable* representing a directory." msgstr "" -#: ../../library/importlib.resources.rst:105 +#: ../../library/importlib.resources.rst:106 msgid "Functional API" msgstr "" -#: ../../library/importlib.resources.rst:107 +#: ../../library/importlib.resources.rst:108 msgid "" "A set of simplified, backwards-compatible helpers is available. These allow " "common operations in a single function call." msgstr "" -#: ../../library/importlib.resources.rst:110 +#: ../../library/importlib.resources.rst:111 msgid "For all the following functions:" msgstr "" -#: ../../library/importlib.resources.rst:112 +#: ../../library/importlib.resources.rst:113 msgid "" "*anchor* is an :class:`~importlib.resources.Anchor`, as in :func:`~importlib." "resources.files`. Unlike in ``files``, it may not be omitted." msgstr "" -#: ../../library/importlib.resources.rst:116 +#: ../../library/importlib.resources.rst:117 msgid "" "*path_names* are components of a resource's path name, relative to the " "anchor. For example, to get the text of resource named ``info.txt``, use::" msgstr "" -#: ../../library/importlib.resources.rst:120 +#: ../../library/importlib.resources.rst:121 msgid "importlib.resources.read_text(my_module, \"info.txt\")" -msgstr "" +msgstr "importlib.resources.read_text(my_module, \"info.txt\")" -#: ../../library/importlib.resources.rst:122 +#: ../../library/importlib.resources.rst:123 msgid "" "Like :meth:`Traversable.joinpath `, The " "individual components should use forward slashes (``/``) as path separators. " "For example, the following are equivalent::" msgstr "" -#: ../../library/importlib.resources.rst:127 +#: ../../library/importlib.resources.rst:128 msgid "" "importlib.resources.read_binary(my_module, \"pics/painting.png\")\n" "importlib.resources.read_binary(my_module, \"pics\", \"painting.png\")" @@ -182,14 +183,14 @@ msgstr "" "importlib.resources.read_binary(my_module, \"pics/painting.png\")\n" "importlib.resources.read_binary(my_module, \"pics\", \"painting.png\")" -#: ../../library/importlib.resources.rst:130 +#: ../../library/importlib.resources.rst:131 msgid "" "For backward compatibility reasons, functions that read text require an " "explicit *encoding* argument if multiple *path_names* are given. For " "example, to get the text of ``info/chapter1.txt``, use::" msgstr "" -#: ../../library/importlib.resources.rst:134 +#: ../../library/importlib.resources.rst:135 msgid "" "importlib.resources.read_text(my_module, \"info\", \"chapter1.txt\",\n" " encoding='utf-8')" @@ -197,124 +198,124 @@ msgstr "" "importlib.resources.read_text(my_module, \"info\", \"chapter1.txt\",\n" " encoding='utf-8')" -#: ../../library/importlib.resources.rst:139 +#: ../../library/importlib.resources.rst:140 msgid "Open the named resource for binary reading." msgstr "" -#: ../../library/importlib.resources.rst:141 -#: ../../library/importlib.resources.rst:184 -#: ../../library/importlib.resources.rst:232 -#: ../../library/importlib.resources.rst:249 -#: ../../library/importlib.resources.rst:267 +#: ../../library/importlib.resources.rst:142 +#: ../../library/importlib.resources.rst:185 +#: ../../library/importlib.resources.rst:233 +#: ../../library/importlib.resources.rst:250 +#: ../../library/importlib.resources.rst:268 msgid "" "See :ref:`the introduction ` for details on " "*anchor* and *path_names*." msgstr "" -#: ../../library/importlib.resources.rst:144 +#: ../../library/importlib.resources.rst:145 msgid "" "This function returns a :class:`~typing.BinaryIO` object, that is, a binary " "stream open for reading." msgstr "" -#: ../../library/importlib.resources.rst:147 -#: ../../library/importlib.resources.rst:171 -#: ../../library/importlib.resources.rst:187 -#: ../../library/importlib.resources.rst:208 -#: ../../library/importlib.resources.rst:235 -#: ../../library/importlib.resources.rst:252 -#: ../../library/importlib.resources.rst:270 +#: ../../library/importlib.resources.rst:148 +#: ../../library/importlib.resources.rst:172 +#: ../../library/importlib.resources.rst:188 +#: ../../library/importlib.resources.rst:209 +#: ../../library/importlib.resources.rst:236 +#: ../../library/importlib.resources.rst:253 +#: ../../library/importlib.resources.rst:271 msgid "This function is roughly equivalent to::" -msgstr "" +msgstr "這個函式大致等同於: ::" -#: ../../library/importlib.resources.rst:149 +#: ../../library/importlib.resources.rst:150 msgid "files(anchor).joinpath(*path_names).open('rb')" msgstr "files(anchor).joinpath(*path_names).open('rb')" -#: ../../library/importlib.resources.rst:151 -#: ../../library/importlib.resources.rst:191 -#: ../../library/importlib.resources.rst:256 +#: ../../library/importlib.resources.rst:152 +#: ../../library/importlib.resources.rst:192 +#: ../../library/importlib.resources.rst:257 msgid "Multiple *path_names* are accepted." -msgstr "" +msgstr "多個 *path_names* 是被接受的。" -#: ../../library/importlib.resources.rst:157 +#: ../../library/importlib.resources.rst:158 msgid "" "Open the named resource for text reading. By default, the contents are read " "as strict UTF-8." msgstr "" -#: ../../library/importlib.resources.rst:160 -#: ../../library/importlib.resources.rst:200 +#: ../../library/importlib.resources.rst:161 +#: ../../library/importlib.resources.rst:201 msgid "" "See :ref:`the introduction ` for details on " "*anchor* and *path_names*. *encoding* and *errors* have the same meaning as " "in built-in :func:`open`." msgstr "" -#: ../../library/importlib.resources.rst:164 -#: ../../library/importlib.resources.rst:204 +#: ../../library/importlib.resources.rst:165 +#: ../../library/importlib.resources.rst:205 msgid "" "For backward compatibility reasons, the *encoding* argument must be given " "explicitly if there are multiple *path_names*. This limitation is scheduled " "to be removed in Python 3.15." msgstr "" -#: ../../library/importlib.resources.rst:168 +#: ../../library/importlib.resources.rst:169 msgid "" "This function returns a :class:`~typing.TextIO` object, that is, a text " "stream open for reading." msgstr "" -#: ../../library/importlib.resources.rst:173 +#: ../../library/importlib.resources.rst:174 msgid "files(anchor).joinpath(*path_names).open('r', encoding=encoding)" msgstr "files(anchor).joinpath(*path_names).open('r', encoding=encoding)" -#: ../../library/importlib.resources.rst:175 -#: ../../library/importlib.resources.rst:212 -#: ../../library/importlib.resources.rst:239 +#: ../../library/importlib.resources.rst:176 +#: ../../library/importlib.resources.rst:213 +#: ../../library/importlib.resources.rst:240 msgid "" "Multiple *path_names* are accepted. *encoding* and *errors* must be given as " "keyword arguments." msgstr "" -#: ../../library/importlib.resources.rst:182 +#: ../../library/importlib.resources.rst:183 msgid "Read and return the contents of the named resource as :class:`bytes`." -msgstr "" +msgstr "以 :class:`bytes` 形式讀取並回傳指定資源的內容。" -#: ../../library/importlib.resources.rst:189 +#: ../../library/importlib.resources.rst:190 msgid "files(anchor).joinpath(*path_names).read_bytes()" msgstr "files(anchor).joinpath(*path_names).read_bytes()" -#: ../../library/importlib.resources.rst:197 +#: ../../library/importlib.resources.rst:198 msgid "" "Read and return the contents of the named resource as :class:`str`. By " "default, the contents are read as strict UTF-8." msgstr "" -#: ../../library/importlib.resources.rst:210 +#: ../../library/importlib.resources.rst:211 msgid "files(anchor).joinpath(*path_names).read_text(encoding=encoding)" msgstr "files(anchor).joinpath(*path_names).read_text(encoding=encoding)" -#: ../../library/importlib.resources.rst:219 +#: ../../library/importlib.resources.rst:220 msgid "" "Provides the path to the *resource* as an actual file system path. This " "function returns a context manager for use in a :keyword:`with` statement. " "The context manager provides a :class:`pathlib.Path` object." msgstr "" -#: ../../library/importlib.resources.rst:223 +#: ../../library/importlib.resources.rst:224 msgid "" "Exiting the context manager cleans up any temporary files created, e.g. when " "the resource needs to be extracted from a zip file." msgstr "" -#: ../../library/importlib.resources.rst:226 +#: ../../library/importlib.resources.rst:227 msgid "" "For example, the :meth:`~pathlib.Path.stat` method requires an actual file " "system path; it can be used like this::" msgstr "" -#: ../../library/importlib.resources.rst:229 +#: ../../library/importlib.resources.rst:230 msgid "" "with importlib.resources.path(anchor, \"resource.txt\") as fspath:\n" " result = fspath.stat()" @@ -322,21 +323,21 @@ msgstr "" "with importlib.resources.path(anchor, \"resource.txt\") as fspath:\n" " result = fspath.stat()" -#: ../../library/importlib.resources.rst:237 +#: ../../library/importlib.resources.rst:238 msgid "as_file(files(anchor).joinpath(*path_names))" msgstr "as_file(files(anchor).joinpath(*path_names))" -#: ../../library/importlib.resources.rst:246 +#: ../../library/importlib.resources.rst:247 msgid "" "Return ``True`` if the named resource exists, otherwise ``False``. This " "function does not consider directories to be resources." msgstr "" -#: ../../library/importlib.resources.rst:254 +#: ../../library/importlib.resources.rst:255 msgid "files(anchor).joinpath(*path_names).is_file()" msgstr "files(anchor).joinpath(*path_names).is_file()" -#: ../../library/importlib.resources.rst:262 +#: ../../library/importlib.resources.rst:263 msgid "" "Return an iterable over the named items within the package or path. The " "iterable returns names of resources (e.g. files) and non-resources (e.g. " @@ -344,7 +345,7 @@ msgid "" "subdirectories." msgstr "" -#: ../../library/importlib.resources.rst:272 +#: ../../library/importlib.resources.rst:273 msgid "" "for resource in files(anchor).joinpath(*path_names).iterdir():\n" " yield resource.name" @@ -352,7 +353,7 @@ msgstr "" "for resource in files(anchor).joinpath(*path_names).iterdir():\n" " yield resource.name" -#: ../../library/importlib.resources.rst:275 +#: ../../library/importlib.resources.rst:276 msgid "" "Prefer ``iterdir()`` as above, which offers more control over the results " "and richer functionality." diff --git a/library/ipaddress.po b/library/ipaddress.po index f168829f23..7b51f912d2 100644 --- a/library/ipaddress.po +++ b/library/ipaddress.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-07-20 00:19+0000\n" "PO-Revision-Date: 2018-05-23 16:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -304,27 +304,44 @@ msgid "" msgstr "" #: ../../library/ipaddress.rst:235 -msgid "``True`` if the address is otherwise IETF reserved." +msgid "" +"``True`` if the address is noted as reserved by the IETF. For IPv4, this is " +"only ``240.0.0.0/4``, the ``Reserved`` address block. For IPv6, this is all " +"addresses `allocated `__ as ``Reserved by IETF`` " +"for future use." +msgstr "" + +#: ../../library/ipaddress.rst:240 +msgid "" +"For IPv4, ``is_reserved`` is not related to the address block value of the " +"``Reserved-by-Protocol`` column in iana-ipv4-special-registry_." msgstr "" -#: ../../library/ipaddress.rst:239 +#: ../../library/ipaddress.rst:243 +msgid "" +"For IPv6, ``fec0::/10`` a former Site-Local scoped address prefix is " +"currently excluded from that list (see :attr:`~IPv6Address.is_site_local` & :" +"rfc:`3879`)." +msgstr "" + +#: ../../library/ipaddress.rst:248 msgid "" "``True`` if this is a loopback address. See :RFC:`3330` (for IPv4) or :RFC:" "`2373` (for IPv6)." msgstr "" -#: ../../library/ipaddress.rst:244 +#: ../../library/ipaddress.rst:253 msgid "" "``True`` if the address is reserved for link-local usage. See :RFC:`3927`." msgstr "" -#: ../../library/ipaddress.rst:249 +#: ../../library/ipaddress.rst:258 msgid "" ":class:`IPv4Address` object representing the IPv4-mapped IPv6 address. See :" "RFC:`4291`." msgstr "" -#: ../../library/ipaddress.rst:259 +#: ../../library/ipaddress.rst:269 msgid "" "Returns a string representation of the IP address, controlled by an explicit " "format string. *fmt* can be one of the following: ``'s'``, the default " @@ -336,17 +353,17 @@ msgid "" "used by ``format``, ``str.format`` and f-strings." msgstr "" -#: ../../library/ipaddress.rst:286 +#: ../../library/ipaddress.rst:296 msgid "" "Construct an IPv6 address. An :exc:`AddressValueError` is raised if " "*address* is not a valid IPv6 address." msgstr "" -#: ../../library/ipaddress.rst:289 +#: ../../library/ipaddress.rst:299 msgid "The following constitutes a valid IPv6 address:" msgstr "" -#: ../../library/ipaddress.rst:291 +#: ../../library/ipaddress.rst:301 msgid "" "A string consisting of eight groups of four hexadecimal digits, each group " "representing 16 bits. The groups are separated by colons. This describes an " @@ -356,7 +373,7 @@ msgid "" "to ``\"::abc:7:def\"``." msgstr "" -#: ../../library/ipaddress.rst:299 +#: ../../library/ipaddress.rst:309 msgid "" "Optionally, the string may also have a scope zone ID, expressed with a " "suffix ``%scope_id``. If present, the scope ID must be non-empty, and may " @@ -365,39 +382,39 @@ msgid "" "the node." msgstr "" -#: ../../library/ipaddress.rst:304 +#: ../../library/ipaddress.rst:314 msgid "An integer that fits into 128 bits." msgstr "" -#: ../../library/ipaddress.rst:305 +#: ../../library/ipaddress.rst:315 msgid "" "An integer packed into a :class:`bytes` object of length 16, big-endian." msgstr "" -#: ../../library/ipaddress.rst:315 +#: ../../library/ipaddress.rst:325 msgid "" "The short form of the address representation, with leading zeroes in groups " "omitted and the longest sequence of groups consisting entirely of zeroes " "collapsed to a single empty group." msgstr "" -#: ../../library/ipaddress.rst:319 +#: ../../library/ipaddress.rst:329 msgid "This is also the value returned by ``str(addr)`` for IPv6 addresses." msgstr "" -#: ../../library/ipaddress.rst:323 +#: ../../library/ipaddress.rst:333 msgid "" "The long form of the address representation, with all leading zeroes and " "groups consisting entirely of zeroes included." msgstr "" -#: ../../library/ipaddress.rst:327 +#: ../../library/ipaddress.rst:337 msgid "" "For the following attributes and methods, see the corresponding " "documentation of the :class:`IPv4Address` class:" msgstr "" -#: ../../library/ipaddress.rst:347 +#: ../../library/ipaddress.rst:357 msgid "" "``True`` if the address is reserved for site-local usage. Note that the " "site-local address space has been deprecated by :RFC:`3879`. Use :attr:" @@ -405,21 +422,21 @@ msgid "" "local addresses as defined by :RFC:`4193`." msgstr "" -#: ../../library/ipaddress.rst:354 +#: ../../library/ipaddress.rst:364 msgid "" "For addresses that appear to be IPv4 mapped addresses (starting with ``::" "FFFF/96``), this property will report the embedded IPv4 address. For any " "other address, this property will be ``None``." msgstr "" -#: ../../library/ipaddress.rst:360 +#: ../../library/ipaddress.rst:370 msgid "" "For scoped addresses as defined by :RFC:`4007`, this property identifies the " "particular zone of the address's scope that the address belongs to, as a " "string. When no scope zone is specified, this property will be ``None``." msgstr "" -#: ../../library/ipaddress.rst:366 +#: ../../library/ipaddress.rst:376 msgid "" "For addresses that appear to be 6to4 addresses (starting with " "``2002::/16``) as defined by :RFC:`3056`, this property will report the " @@ -427,7 +444,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/ipaddress.rst:373 +#: ../../library/ipaddress.rst:383 msgid "" "For addresses that appear to be Teredo addresses (starting with " "``2001::/32``) as defined by :RFC:`4380`, this property will report the " @@ -435,23 +452,23 @@ msgid "" "property will be ``None``." msgstr "" -#: ../../library/ipaddress.rst:380 +#: ../../library/ipaddress.rst:390 msgid "" "Refer to the corresponding method documentation in :class:`IPv4Address`." msgstr "" -#: ../../library/ipaddress.rst:386 +#: ../../library/ipaddress.rst:396 msgid "Conversion to Strings and Integers" msgstr "" -#: ../../library/ipaddress.rst:388 +#: ../../library/ipaddress.rst:398 msgid "" "To interoperate with networking interfaces such as the socket module, " "addresses must be converted to strings or integers. This is handled using " "the :func:`str` and :func:`int` builtin functions::" msgstr "" -#: ../../library/ipaddress.rst:392 +#: ../../library/ipaddress.rst:402 msgid "" ">>> str(ipaddress.IPv4Address('192.168.0.1'))\n" "'192.168.0.1'\n" @@ -471,36 +488,36 @@ msgstr "" ">>> int(ipaddress.IPv6Address('::1'))\n" "1" -#: ../../library/ipaddress.rst:401 +#: ../../library/ipaddress.rst:411 msgid "" "Note that IPv6 scoped addresses are converted to integers without scope zone " "ID." msgstr "" -#: ../../library/ipaddress.rst:405 ../../library/ipaddress.rst:789 -#: ../../library/ipaddress.rst:925 +#: ../../library/ipaddress.rst:415 ../../library/ipaddress.rst:799 +#: ../../library/ipaddress.rst:935 msgid "Operators" msgstr "運算子" -#: ../../library/ipaddress.rst:407 +#: ../../library/ipaddress.rst:417 msgid "" "Address objects support some operators. Unless stated otherwise, operators " "can only be applied between compatible objects (i.e. IPv4 with IPv4, IPv6 " "with IPv6)." msgstr "" -#: ../../library/ipaddress.rst:413 +#: ../../library/ipaddress.rst:423 msgid "Comparison operators" msgstr "比較運算子" -#: ../../library/ipaddress.rst:415 +#: ../../library/ipaddress.rst:425 msgid "" "Address objects can be compared with the usual set of comparison operators. " "Same IPv6 addresses with different scope zone IDs are not equal. Some " "examples::" msgstr "" -#: ../../library/ipaddress.rst:419 +#: ../../library/ipaddress.rst:429 msgid "" ">>> IPv4Address('127.0.0.2') > IPv4Address('127.0.0.1')\n" "True\n" @@ -524,16 +541,16 @@ msgstr "" ">>> IPv6Address('fe80::1234%1') != IPv6Address('fe80::1234%2')\n" "True" -#: ../../library/ipaddress.rst:432 +#: ../../library/ipaddress.rst:442 msgid "Arithmetic operators" msgstr "算術運算子" -#: ../../library/ipaddress.rst:434 +#: ../../library/ipaddress.rst:444 msgid "" "Integers can be added to or subtracted from address objects. Some examples::" msgstr "" -#: ../../library/ipaddress.rst:436 +#: ../../library/ipaddress.rst:446 msgid "" ">>> IPv4Address('127.0.0.2') + 3\n" "IPv4Address('127.0.0.5')\n" @@ -555,11 +572,11 @@ msgstr "" "ipaddress.AddressValueError: 4294967296 (>= 2**32) is not permitted as an " "IPv4 address" -#: ../../library/ipaddress.rst:447 +#: ../../library/ipaddress.rst:457 msgid "IP Network definitions" msgstr "" -#: ../../library/ipaddress.rst:449 +#: ../../library/ipaddress.rst:459 msgid "" "The :class:`IPv4Network` and :class:`IPv6Network` objects provide a " "mechanism for defining and inspecting IP network definitions. A network " @@ -570,11 +587,11 @@ msgid "" "addresses in the inclusive range ``192.168.1.0`` to ``192.168.1.255``." msgstr "" -#: ../../library/ipaddress.rst:459 +#: ../../library/ipaddress.rst:469 msgid "Prefix, net mask and host mask" msgstr "" -#: ../../library/ipaddress.rst:461 +#: ../../library/ipaddress.rst:471 msgid "" "There are several equivalent ways to specify IP network masks. A *prefix* " "``/`` is a notation that denotes how many high-order bits are set in " @@ -586,11 +603,11 @@ msgid "" "mask equivalent to ``/24`` in IPv4 is ``0.0.0.255``." msgstr "" -#: ../../library/ipaddress.rst:472 +#: ../../library/ipaddress.rst:482 msgid "Network objects" msgstr "" -#: ../../library/ipaddress.rst:474 +#: ../../library/ipaddress.rst:484 msgid "" "All attributes implemented by address objects are implemented by network " "objects as well. In addition, network objects implement additional " @@ -600,12 +617,12 @@ msgid "" "keys in dictionaries." msgstr "" -#: ../../library/ipaddress.rst:483 +#: ../../library/ipaddress.rst:493 msgid "" "Construct an IPv4 network definition. *address* can be one of the following:" msgstr "" -#: ../../library/ipaddress.rst:485 +#: ../../library/ipaddress.rst:495 msgid "" "A string consisting of an IP address and an optional mask, separated by a " "slash (``/``). The IP address is the network address, and the mask can be " @@ -617,26 +634,26 @@ msgid "" "it's considered to be ``/32``." msgstr "" -#: ../../library/ipaddress.rst:494 +#: ../../library/ipaddress.rst:504 msgid "" "For example, the following *address* specifications are equivalent: " "``192.168.1.0/24``, ``192.168.1.0/255.255.255.0`` and " "``192.168.1.0/0.0.0.255``." msgstr "" -#: ../../library/ipaddress.rst:498 +#: ../../library/ipaddress.rst:508 msgid "" "An integer that fits into 32 bits. This is equivalent to a single-address " "network, with the network address being *address* and the mask being ``/32``." msgstr "" -#: ../../library/ipaddress.rst:502 +#: ../../library/ipaddress.rst:512 msgid "" "An integer packed into a :class:`bytes` object of length 4, big-endian. The " "interpretation is similar to an integer *address*." msgstr "" -#: ../../library/ipaddress.rst:505 +#: ../../library/ipaddress.rst:515 msgid "" "A two-tuple of an address description and a netmask, where the address " "description is either a string, a 32-bits integer, a 4-bytes packed integer, " @@ -645,92 +662,92 @@ msgid "" "prefix mask (e.g. ``255.255.255.0``)." msgstr "" -#: ../../library/ipaddress.rst:511 +#: ../../library/ipaddress.rst:521 msgid "" "An :exc:`AddressValueError` is raised if *address* is not a valid IPv4 " "address. A :exc:`NetmaskValueError` is raised if the mask is not valid for " "an IPv4 address." msgstr "" -#: ../../library/ipaddress.rst:515 ../../library/ipaddress.rst:735 +#: ../../library/ipaddress.rst:525 ../../library/ipaddress.rst:745 msgid "" "If *strict* is ``True`` and host bits are set in the supplied address, then :" "exc:`ValueError` is raised. Otherwise, the host bits are masked out to " "determine the appropriate network address." msgstr "" -#: ../../library/ipaddress.rst:519 +#: ../../library/ipaddress.rst:529 msgid "" "Unless stated otherwise, all network methods accepting other network/address " "objects will raise :exc:`TypeError` if the argument's IP version is " "incompatible to ``self``." msgstr "" -#: ../../library/ipaddress.rst:525 ../../library/ipaddress.rst:741 +#: ../../library/ipaddress.rst:535 ../../library/ipaddress.rst:751 msgid "Added the two-tuple form for the *address* constructor parameter." msgstr "" -#: ../../library/ipaddress.rst:530 +#: ../../library/ipaddress.rst:540 msgid "" "Refer to the corresponding attribute documentation in :class:`IPv4Address`." msgstr "" -#: ../../library/ipaddress.rst:540 +#: ../../library/ipaddress.rst:550 msgid "" "These attributes are true for the network as a whole if they are true for " "both the network address and the broadcast address." msgstr "" -#: ../../library/ipaddress.rst:545 +#: ../../library/ipaddress.rst:555 msgid "" "The network address for the network. The network address and the prefix " "length together uniquely define a network." msgstr "" -#: ../../library/ipaddress.rst:550 +#: ../../library/ipaddress.rst:560 msgid "" "The broadcast address for the network. Packets sent to the broadcast address " "should be received by every host on the network." msgstr "" -#: ../../library/ipaddress.rst:555 +#: ../../library/ipaddress.rst:565 msgid "The host mask, as an :class:`IPv4Address` object." msgstr "" -#: ../../library/ipaddress.rst:559 +#: ../../library/ipaddress.rst:569 msgid "The net mask, as an :class:`IPv4Address` object." msgstr "" -#: ../../library/ipaddress.rst:565 +#: ../../library/ipaddress.rst:575 msgid "" "A string representation of the network, with the mask in prefix notation." msgstr "" -#: ../../library/ipaddress.rst:568 +#: ../../library/ipaddress.rst:578 msgid "" "``with_prefixlen`` and ``compressed`` are always the same as " "``str(network)``. ``exploded`` uses the exploded form the network address." msgstr "" -#: ../../library/ipaddress.rst:574 +#: ../../library/ipaddress.rst:584 msgid "" "A string representation of the network, with the mask in net mask notation." msgstr "" -#: ../../library/ipaddress.rst:579 +#: ../../library/ipaddress.rst:589 msgid "" "A string representation of the network, with the mask in host mask notation." msgstr "" -#: ../../library/ipaddress.rst:584 +#: ../../library/ipaddress.rst:594 msgid "The total number of addresses in the network." msgstr "" -#: ../../library/ipaddress.rst:588 +#: ../../library/ipaddress.rst:598 msgid "Length of the network prefix, in bits." msgstr "" -#: ../../library/ipaddress.rst:592 +#: ../../library/ipaddress.rst:602 msgid "" "Returns an iterator over the usable hosts in the network. The usable hosts " "are all the IP addresses that belong to the network, except the network " @@ -740,20 +757,20 @@ msgid "" "containing the single host address." msgstr "" -#: ../../library/ipaddress.rst:610 +#: ../../library/ipaddress.rst:620 msgid "" "``True`` if this network is partly or wholly contained in *other* or *other* " "is wholly contained in this network." msgstr "" -#: ../../library/ipaddress.rst:615 +#: ../../library/ipaddress.rst:625 msgid "" "Computes the network definitions resulting from removing the given *network* " "from this one. Returns an iterator of network objects. Raises :exc:" "`ValueError` if *network* is not completely contained in this network." msgstr "" -#: ../../library/ipaddress.rst:628 +#: ../../library/ipaddress.rst:638 msgid "" "The subnets that join to make the current network definition, depending on " "the argument values. *prefixlen_diff* is the amount our prefix length " @@ -763,7 +780,7 @@ msgid "" "network objects." msgstr "" -#: ../../library/ipaddress.rst:653 +#: ../../library/ipaddress.rst:663 msgid "" "The supernet containing this network definition, depending on the argument " "values. *prefixlen_diff* is the amount our prefix length should be " @@ -772,33 +789,33 @@ msgid "" "*new_prefix* must be set. Returns a single network object." msgstr "" -#: ../../library/ipaddress.rst:669 +#: ../../library/ipaddress.rst:679 msgid "Return ``True`` if this network is a subnet of *other*." msgstr "" -#: ../../library/ipaddress.rst:680 +#: ../../library/ipaddress.rst:690 msgid "Return ``True`` if this network is a supernet of *other*." msgstr "" -#: ../../library/ipaddress.rst:691 +#: ../../library/ipaddress.rst:701 msgid "" "Compare this network to *other*. In this comparison only the network " "addresses are considered; host bits aren't. Returns either ``-1``, ``0`` or " "``1``." msgstr "" -#: ../../library/ipaddress.rst:702 +#: ../../library/ipaddress.rst:712 msgid "" "It uses the same ordering and comparison algorithm as \"<\", \"==\", and " "\">\"" msgstr "" -#: ../../library/ipaddress.rst:708 +#: ../../library/ipaddress.rst:718 msgid "" "Construct an IPv6 network definition. *address* can be one of the following:" msgstr "" -#: ../../library/ipaddress.rst:710 +#: ../../library/ipaddress.rst:720 msgid "" "A string consisting of an IP address and an optional prefix length, " "separated by a slash (``/``). The IP address is the network address, and " @@ -806,26 +823,26 @@ msgid "" "length is provided, it's considered to be ``/128``." msgstr "" -#: ../../library/ipaddress.rst:715 +#: ../../library/ipaddress.rst:725 msgid "" "Note that currently expanded netmasks are not supported. That means ``2001:" "db00::0/24`` is a valid argument while ``2001:db00::0/ffff:ff00::`` is not." msgstr "" -#: ../../library/ipaddress.rst:719 +#: ../../library/ipaddress.rst:729 msgid "" "An integer that fits into 128 bits. This is equivalent to a single-address " "network, with the network address being *address* and the mask being " "``/128``." msgstr "" -#: ../../library/ipaddress.rst:723 +#: ../../library/ipaddress.rst:733 msgid "" "An integer packed into a :class:`bytes` object of length 16, big-endian. The " "interpretation is similar to an integer *address*." msgstr "" -#: ../../library/ipaddress.rst:726 +#: ../../library/ipaddress.rst:736 msgid "" "A two-tuple of an address description and a netmask, where the address " "description is either a string, a 128-bits integer, a 16-bytes packed " @@ -833,14 +850,14 @@ msgid "" "representing the prefix length." msgstr "" -#: ../../library/ipaddress.rst:731 +#: ../../library/ipaddress.rst:741 msgid "" "An :exc:`AddressValueError` is raised if *address* is not a valid IPv6 " "address. A :exc:`NetmaskValueError` is raised if the mask is not valid for " "an IPv6 address." msgstr "" -#: ../../library/ipaddress.rst:764 +#: ../../library/ipaddress.rst:774 msgid "" "Returns an iterator over the usable hosts in the network. The usable hosts " "are all the IP addresses that belong to the network, except the Subnet-" @@ -849,46 +866,46 @@ msgid "" "of 128 will return a list containing the single host address." msgstr "" -#: ../../library/ipaddress.rst:779 +#: ../../library/ipaddress.rst:789 msgid "" "Refer to the corresponding attribute documentation in :class:`IPv4Network`." msgstr "" -#: ../../library/ipaddress.rst:784 +#: ../../library/ipaddress.rst:794 msgid "" "These attribute is true for the network as a whole if it is true for both " "the network address and the broadcast address." msgstr "" -#: ../../library/ipaddress.rst:791 +#: ../../library/ipaddress.rst:801 msgid "" "Network objects support some operators. Unless stated otherwise, operators " "can only be applied between compatible objects (i.e. IPv4 with IPv4, IPv6 " "with IPv6)." msgstr "" -#: ../../library/ipaddress.rst:797 ../../library/ipaddress.rst:933 +#: ../../library/ipaddress.rst:807 ../../library/ipaddress.rst:943 msgid "Logical operators" msgstr "" -#: ../../library/ipaddress.rst:799 +#: ../../library/ipaddress.rst:809 msgid "" "Network objects can be compared with the usual set of logical operators. " "Network objects are ordered first by network address, then by net mask." msgstr "" -#: ../../library/ipaddress.rst:804 +#: ../../library/ipaddress.rst:814 msgid "Iteration" msgstr "疊代" -#: ../../library/ipaddress.rst:806 +#: ../../library/ipaddress.rst:816 msgid "" "Network objects can be iterated to list all the addresses belonging to the " "network. For iteration, *all* hosts are returned, including unusable hosts " "(for usable hosts, use the :meth:`~IPv4Network.hosts` method). An example::" msgstr "" -#: ../../library/ipaddress.rst:811 +#: ../../library/ipaddress.rst:821 msgid "" ">>> for addr in IPv4Network('192.0.2.0/28'):\n" "... addr\n" @@ -930,15 +947,15 @@ msgstr "" "IPv4Address('192.0.2.14')\n" "IPv4Address('192.0.2.15')" -#: ../../library/ipaddress.rst:833 +#: ../../library/ipaddress.rst:843 msgid "Networks as containers of addresses" msgstr "" -#: ../../library/ipaddress.rst:835 +#: ../../library/ipaddress.rst:845 msgid "Network objects can act as containers of addresses. Some examples::" msgstr "" -#: ../../library/ipaddress.rst:837 +#: ../../library/ipaddress.rst:847 msgid "" ">>> IPv4Network('192.0.2.0/28')[0]\n" "IPv4Address('192.0.2.0')\n" @@ -958,92 +975,92 @@ msgstr "" ">>> IPv4Address('192.0.3.6') in IPv4Network('192.0.2.0/28')\n" "False" -#: ../../library/ipaddress.rst:848 +#: ../../library/ipaddress.rst:858 msgid "Interface objects" msgstr "" -#: ../../library/ipaddress.rst:850 +#: ../../library/ipaddress.rst:860 msgid "" "Interface objects are :term:`hashable`, so they can be used as keys in " "dictionaries." msgstr "" -#: ../../library/ipaddress.rst:855 +#: ../../library/ipaddress.rst:865 msgid "" "Construct an IPv4 interface. The meaning of *address* is as in the " "constructor of :class:`IPv4Network`, except that arbitrary host addresses " "are always accepted." msgstr "" -#: ../../library/ipaddress.rst:859 +#: ../../library/ipaddress.rst:869 msgid "" ":class:`IPv4Interface` is a subclass of :class:`IPv4Address`, so it inherits " "all the attributes from that class. In addition, the following attributes " "are available:" msgstr "" -#: ../../library/ipaddress.rst:865 +#: ../../library/ipaddress.rst:875 msgid "The address (:class:`IPv4Address`) without network information." msgstr "" -#: ../../library/ipaddress.rst:873 +#: ../../library/ipaddress.rst:883 msgid "The network (:class:`IPv4Network`) this interface belongs to." msgstr "" -#: ../../library/ipaddress.rst:881 +#: ../../library/ipaddress.rst:891 msgid "" "A string representation of the interface with the mask in prefix notation." msgstr "" -#: ../../library/ipaddress.rst:889 +#: ../../library/ipaddress.rst:899 msgid "" "A string representation of the interface with the network as a net mask." msgstr "" -#: ../../library/ipaddress.rst:897 +#: ../../library/ipaddress.rst:907 msgid "" "A string representation of the interface with the network as a host mask." msgstr "" -#: ../../library/ipaddress.rst:906 +#: ../../library/ipaddress.rst:916 msgid "" "Construct an IPv6 interface. The meaning of *address* is as in the " "constructor of :class:`IPv6Network`, except that arbitrary host addresses " "are always accepted." msgstr "" -#: ../../library/ipaddress.rst:910 +#: ../../library/ipaddress.rst:920 msgid "" ":class:`IPv6Interface` is a subclass of :class:`IPv6Address`, so it inherits " "all the attributes from that class. In addition, the following attributes " "are available:" msgstr "" -#: ../../library/ipaddress.rst:920 +#: ../../library/ipaddress.rst:930 msgid "" "Refer to the corresponding attribute documentation in :class:`IPv4Interface`." msgstr "" -#: ../../library/ipaddress.rst:927 +#: ../../library/ipaddress.rst:937 msgid "" "Interface objects support some operators. Unless stated otherwise, " "operators can only be applied between compatible objects (i.e. IPv4 with " "IPv4, IPv6 with IPv6)." msgstr "" -#: ../../library/ipaddress.rst:935 +#: ../../library/ipaddress.rst:945 msgid "" "Interface objects can be compared with the usual set of logical operators." msgstr "" -#: ../../library/ipaddress.rst:937 +#: ../../library/ipaddress.rst:947 msgid "" "For equality comparison (``==`` and ``!=``), both the IP address and network " "must be the same for the objects to be equal. An interface will not compare " "equal to any address or network object." msgstr "" -#: ../../library/ipaddress.rst:941 +#: ../../library/ipaddress.rst:951 msgid "" "For ordering (``<``, ``>``, etc) the rules are different. Interface and " "address objects with the same IP version can be compared, and the address " @@ -1052,15 +1069,15 @@ msgid "" "then by their IP addresses." msgstr "" -#: ../../library/ipaddress.rst:949 +#: ../../library/ipaddress.rst:959 msgid "Other Module Level Functions" msgstr "" -#: ../../library/ipaddress.rst:951 +#: ../../library/ipaddress.rst:961 msgid "The module also provides the following module level functions:" msgstr "" -#: ../../library/ipaddress.rst:955 +#: ../../library/ipaddress.rst:965 msgid "" "Represent an address as 4 packed bytes in network (big-endian) order. " "*address* is an integer representation of an IPv4 IP address. A :exc:" @@ -1068,7 +1085,7 @@ msgid "" "IP address." msgstr "" -#: ../../library/ipaddress.rst:968 +#: ../../library/ipaddress.rst:978 msgid "" "Represent an address as 16 packed bytes in network (big-endian) order. " "*address* is an integer representation of an IPv6 IP address. A :exc:" @@ -1076,7 +1093,7 @@ msgid "" "IP address." msgstr "" -#: ../../library/ipaddress.rst:976 +#: ../../library/ipaddress.rst:986 msgid "" "Return an iterator of the summarized network range given the first and last " "IP addresses. *first* is the first :class:`IPv4Address` or :class:" @@ -1087,7 +1104,7 @@ msgid "" "address version is not 4 or 6." msgstr "" -#: ../../library/ipaddress.rst:992 +#: ../../library/ipaddress.rst:1002 msgid "" "Return an iterator of the collapsed :class:`IPv4Network` or :class:" "`IPv6Network` objects. *addresses* is an :term:`iterable` of :class:" @@ -1095,43 +1112,43 @@ msgid "" "if *addresses* contains mixed version objects." msgstr "" -#: ../../library/ipaddress.rst:1005 +#: ../../library/ipaddress.rst:1015 msgid "" "Return a key suitable for sorting between networks and addresses. Address " "and Network objects are not sortable by default; they're fundamentally " "different, so the expression::" msgstr "" -#: ../../library/ipaddress.rst:1009 +#: ../../library/ipaddress.rst:1019 msgid "IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')" msgstr "IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')" -#: ../../library/ipaddress.rst:1011 +#: ../../library/ipaddress.rst:1021 msgid "" "doesn't make sense. There are some times however, where you may wish to " "have :mod:`ipaddress` sort these anyway. If you need to do this, you can " "use this function as the *key* argument to :func:`sorted`." msgstr "" -#: ../../library/ipaddress.rst:1015 +#: ../../library/ipaddress.rst:1025 msgid "*obj* is either a network or address object." msgstr "" -#: ../../library/ipaddress.rst:1019 +#: ../../library/ipaddress.rst:1029 msgid "Custom Exceptions" msgstr "" -#: ../../library/ipaddress.rst:1021 +#: ../../library/ipaddress.rst:1031 msgid "" "To support more specific error reporting from class constructors, the module " "defines the following exceptions:" msgstr "" -#: ../../library/ipaddress.rst:1026 +#: ../../library/ipaddress.rst:1036 msgid "Any value error related to the address." msgstr "" -#: ../../library/ipaddress.rst:1031 +#: ../../library/ipaddress.rst:1041 msgid "Any value error related to the net mask." msgstr "" diff --git a/library/itertools.po b/library/itertools.po index 5e949d15db..da0c9a2e0f 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,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-07-20 00:19+0000\n" "PO-Revision-Date: 2024-08-16 15:01+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -159,8 +158,8 @@ msgid "(p0, p1, ..., p_n-1), ..." msgstr "(p0, p1, ..., p_n-1), ..." #: ../../library/itertools.rst:50 -msgid "``batched('ABCDEFG', n=3) → ABC DEF G``" -msgstr "``batched('ABCDEFG', n=3) → ABC DEF G``" +msgid "``batched('ABCDEFG', n=2) → AB CD EF G``" +msgstr "``batched('ABCDEFG', n=2) → AB CD EF G``" #: ../../library/itertools.rst:51 msgid ":func:`chain`" @@ -479,6 +478,24 @@ msgid "" " total = function(total, element)\n" " yield total" msgstr "" +"def accumulate(iterable, function=operator.add, *, initial=None):\n" +" 'Return running totals'\n" +" # accumulate([1,2,3,4,5]) → 1 3 6 10 15\n" +" # accumulate([1,2,3,4,5], initial=100) → 100 101 103 106 110 115\n" +" # accumulate([1,2,3,4,5], operator.mul) → 1 2 6 24 120\n" +"\n" +" iterator = iter(iterable)\n" +" total = initial\n" +" if initial is None:\n" +" try:\n" +" total = next(iterator)\n" +" except StopIteration:\n" +" return\n" +"\n" +" yield total\n" +" for element in iterator:\n" +" total = function(total, element)\n" +" yield total" #: ../../library/itertools.rst:129 msgid "" @@ -506,6 +523,16 @@ msgid "" ">>> list(accumulate(repeat(90, 10), update, initial=1_000))\n" "[1000, 960, 918, 874, 828, 779, 728, 674, 618, 559, 497]" msgstr "" +">>> data = [3, 4, 6, 2, 1, 9, 0, 7, 5, 8]\n" +">>> list(accumulate(data, max)) # 運行最大值\n" +"[3, 4, 6, 6, 6, 9, 9, 9, 9, 9]\n" +">>> list(accumulate(data, operator.mul)) # 運行乘積\n" +"[3, 12, 72, 144, 144, 1296, 0, 0, 0, 0]\n" +"\n" +"# 攤銷一筆 1000 的 5% 貸款,分 10 年、每年支付 90\n" +">>> update = lambda balance, payment: round(balance * 1.05) - payment\n" +">>> list(accumulate(repeat(90, 10), update, initial=1_000))\n" +"[1000, 960, 918, 874, 828, 779, 728, 674, 618, 559, 497]" #: ../../library/itertools.rst:149 msgid "" @@ -534,6 +561,7 @@ msgid "" "If *strict* is true, will raise a :exc:`ValueError` if the final batch is " "shorter than *n*." msgstr "" +"如果 *strict* 為真,則當最後一個批次比 *n* 短時,會引發 :exc:`ValueError`。" #: ../../library/itertools.rst:169 msgid "" @@ -561,7 +589,7 @@ msgstr "" #: ../../library/itertools.rst:183 msgid "" "def batched(iterable, n, *, strict=False):\n" -" # batched('ABCDEFG', 3) → ABC DEF G\n" +" # batched('ABCDEFG', 2) → AB CD EF G\n" " if n < 1:\n" " raise ValueError('n must be at least one')\n" " iterator = iter(iterable)\n" @@ -571,7 +599,7 @@ msgid "" " yield batch" msgstr "" "def batched(iterable, n, *, strict=False):\n" -" # batched('ABCDEFG', 3) → ABC DEF G\n" +" # batched('ABCDEFG', 2) → AB CD EF G\n" " if n < 1:\n" " raise ValueError('n must be at least one')\n" " iterator = iter(iterable)\n" @@ -602,6 +630,10 @@ msgid "" " for iterable in iterables:\n" " yield from iterable" msgstr "" +"def chain(*iterables):\n" +" # chain('ABC', 'DEF') → A B C D E F\n" +" for iterable in iterables:\n" +" yield from iterable" #: ../../library/itertools.rst:214 msgid "" @@ -680,6 +712,27 @@ msgid "" " indices[j] = indices[j-1] + 1\n" " yield tuple(pool[i] for i in indices)" msgstr "" +"def combinations(iterable, r):\n" +" # combinations('ABCD', 2) → AB AC AD BC BD CD\n" +" # combinations(range(4), 3) → 012 013 023 123\n" +"\n" +" pool = tuple(iterable)\n" +" n = len(pool)\n" +" if r > n:\n" +" return\n" +" indices = list(range(r))\n" +"\n" +" yield tuple(pool[i] for i in indices)\n" +" while True:\n" +" for i in reversed(range(r)):\n" +" if indices[i] != i + n - r:\n" +" break\n" +" else:\n" +" return\n" +" indices[i] += 1\n" +" for j in range(i+1, r):\n" +" indices[j] = indices[j-1] + 1\n" +" yield tuple(pool[i] for i in indices)" #: ../../library/itertools.rst:267 msgid "" @@ -738,6 +791,24 @@ msgid "" " indices[i:] = [indices[i] + 1] * (r - i)\n" " yield tuple(pool[i] for i in indices)" msgstr "" +"def combinations_with_replacement(iterable, r):\n" +" # combinations_with_replacement('ABC', 2) → AA AB AC BB BC CC\n" +"\n" +" pool = tuple(iterable)\n" +" n = len(pool)\n" +" if not n and r:\n" +" return\n" +" indices = [0] * r\n" +"\n" +" yield tuple(pool[i] for i in indices)\n" +" while True:\n" +" for i in reversed(range(r)):\n" +" if indices[i] != n - 1:\n" +" break\n" +" else:\n" +" return\n" +" indices[i:] = [indices[i] + 1] * (r - i)\n" +" yield tuple(pool[i] for i in indices)" #: ../../library/itertools.rst:309 msgid "" @@ -754,6 +825,9 @@ msgid "" " # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n" " return (datum for datum, selector in zip(data, selectors) if selector)" msgstr "" +"def compress(data, selectors):\n" +" # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n" +" return (datum for datum, selector in zip(data, selectors) if selector)" #: ../../library/itertools.rst:323 msgid "" @@ -956,6 +1030,12 @@ msgid "" " groups.append(list(g)) # Store group iterator as a list\n" " uniquekeys.append(k)" msgstr "" +"groups = []\n" +"uniquekeys = []\n" +"data = sorted(data, key=keyfunc)\n" +"for k, g in groupby(data, keyfunc):\n" +" groups.append(list(g)) # 將群組疊代器儲存為串列\n" +" uniquekeys.append(k)" #: ../../library/itertools.rst:432 msgid ":func:`groupby` is roughly equivalent to::" @@ -1480,6 +1560,38 @@ msgid "" " value, self.link = link\n" " return value" msgstr "" +"def tee(iterable, n=2):\n" +" if n < 0:\n" +" raise ValueError\n" +" if n == 0:\n" +" return ()\n" +" iterator = _tee(iterable)\n" +" result = [iterator]\n" +" for _ in range(n - 1):\n" +" result.append(_tee(iterator))\n" +" return tuple(result)\n" +"\n" +"class _tee:\n" +"\n" +" def __init__(self, iterable):\n" +" it = iter(iterable)\n" +" if isinstance(it, _tee):\n" +" self.iterator = it.iterator\n" +" self.link = it.link\n" +" else:\n" +" self.iterator = it\n" +" self.link = [None, None]\n" +"\n" +" def __iter__(self):\n" +" return self\n" +"\n" +" def __next__(self):\n" +" link = self.link\n" +" if link[1] is None:\n" +" link[0] = next(self.iterator)\n" +" link[1] = [None, None]\n" +" value, self.link = link\n" +" return value" #: ../../library/itertools.rst:728 msgid "" @@ -1513,6 +1625,14 @@ msgid "" ">>> next(iterator) # Continue moving forward\n" "'b'" msgstr "" +">>> iterator = iter('abcdef')\n" +">>> [iterator] = tee(iterator, 1) # 使得輸入可預覽\n" +">>> next(iterator) # 往前移動疊代器\n" +"'a'\n" +">>> lookahead(iterator) # 檢查下一個值\n" +"'b'\n" +">>> next(iterator) # 繼續往前移動\n" +"'b'" #: ../../library/itertools.rst:754 msgid "" @@ -1980,14 +2100,3 @@ msgid "" " n -= n // prime\n" " return n" msgstr "" - -#~ msgid "" -#~ "These tools and their built-in counterparts also work well with the high-" -#~ "speed functions in the :mod:`operator` module. For example, the " -#~ "multiplication operator can be mapped across two vectors to form an " -#~ "efficient dot-product: ``sum(starmap(operator.mul, zip(vec1, vec2, " -#~ "strict=True)))``." -#~ msgstr "" -#~ "這些工具及其內建的對等部分 (counterpart) 也可以很好地與 :mod:`operator` 模" -#~ "組中的高速函式配合使用。例如,乘法運算子可以對映到兩個向量上以組成高效率的" -#~ "內積:``sum(starmap(operator.mul, zip(vec1, vec2, strict=True)))``。" diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 65fc4b1be7..9c7cbb4de5 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: 2025-07-07 00:17+0000\n" +"POT-Creation-Date: 2025-07-28 00:20+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-" @@ -188,21 +188,29 @@ msgid "" "necessary, see :ref:`multiprocessing-programming`." msgstr "" -#: ../../library/multiprocessing.rst:105 +#: ../../library/multiprocessing.rst:100 +msgid "" +"The arguments to :class:`Process` usually need to be unpickleable from " +"within the child process. If you tried typing the above example directly " +"into a REPL it could lead to an :exc:`AttributeError` in the child process " +"trying to locate the *f* function in the ``__main__`` module." +msgstr "" + +#: ../../library/multiprocessing.rst:109 msgid "Contexts and start methods" msgstr "" -#: ../../library/multiprocessing.rst:107 +#: ../../library/multiprocessing.rst:111 msgid "" "Depending on the platform, :mod:`multiprocessing` supports three ways to " "start a process. These *start methods* are" msgstr "" -#: ../../library/multiprocessing.rst:110 +#: ../../library/multiprocessing.rst:114 msgid "*spawn*" msgstr "*spawn*" -#: ../../library/multiprocessing.rst:111 +#: ../../library/multiprocessing.rst:115 msgid "" "The parent process starts a fresh Python interpreter process. The child " "process will only inherit those resources necessary to run the process " @@ -212,16 +220,16 @@ msgid "" "or *forkserver*." msgstr "" -#: ../../library/multiprocessing.rst:118 +#: ../../library/multiprocessing.rst:122 msgid "" "Available on POSIX and Windows platforms. The default on Windows and macOS." msgstr "" -#: ../../library/multiprocessing.rst:120 +#: ../../library/multiprocessing.rst:124 msgid "*fork*" msgstr "*fork*" -#: ../../library/multiprocessing.rst:121 +#: ../../library/multiprocessing.rst:125 msgid "" "The parent process uses :func:`os.fork` to fork the Python interpreter. The " "child process, when it begins, is effectively identical to the parent " @@ -229,19 +237,19 @@ msgid "" "Note that safely forking a multithreaded process is problematic." msgstr "" -#: ../../library/multiprocessing.rst:127 +#: ../../library/multiprocessing.rst:131 msgid "" "Available on POSIX systems. Currently the default on POSIX except macOS." msgstr "" -#: ../../library/multiprocessing.rst:130 +#: ../../library/multiprocessing.rst:134 msgid "" "The default start method will change away from *fork* in Python 3.14. Code " "that requires *fork* should explicitly specify that via :func:`get_context` " "or :func:`set_start_method`." msgstr "" -#: ../../library/multiprocessing.rst:134 +#: ../../library/multiprocessing.rst:138 msgid "" "If Python is able to detect that your process has multiple threads, the :" "func:`os.fork` function that this start method calls internally will raise " @@ -249,11 +257,11 @@ msgid "" "fork` documentation for further explanation." msgstr "" -#: ../../library/multiprocessing.rst:140 +#: ../../library/multiprocessing.rst:144 msgid "*forkserver*" msgstr "*forkserver*" -#: ../../library/multiprocessing.rst:141 +#: ../../library/multiprocessing.rst:145 msgid "" "When the program starts and selects the *forkserver* start method, a server " "process is spawned. From then on, whenever a new process is needed, the " @@ -263,27 +271,27 @@ msgid "" "for it to use :func:`os.fork`. No unnecessary resources are inherited." msgstr "" -#: ../../library/multiprocessing.rst:149 +#: ../../library/multiprocessing.rst:153 msgid "" "Available on POSIX platforms which support passing file descriptors over " "Unix pipes such as Linux." msgstr "" -#: ../../library/multiprocessing.rst:153 +#: ../../library/multiprocessing.rst:157 msgid "" "*spawn* added on all POSIX platforms, and *forkserver* added for some POSIX " "platforms. Child processes no longer inherit all of the parents inheritable " "handles on Windows." msgstr "" -#: ../../library/multiprocessing.rst:161 +#: ../../library/multiprocessing.rst:165 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess as macOS system libraries may start threads. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:165 +#: ../../library/multiprocessing.rst:169 msgid "" "On POSIX using the *spawn* or *forkserver* start methods will also start a " "*resource tracker* process which tracks the unlinked named system resources " @@ -298,13 +306,13 @@ msgid "" "space in the main memory.)" msgstr "" -#: ../../library/multiprocessing.rst:178 +#: ../../library/multiprocessing.rst:182 msgid "" "To select a start method you use the :func:`set_start_method` in the ``if " "__name__ == '__main__'`` clause of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:182 +#: ../../library/multiprocessing.rst:186 msgid "" "import multiprocessing as mp\n" "\n" @@ -332,19 +340,19 @@ msgstr "" " print(q.get())\n" " p.join()" -#: ../../library/multiprocessing.rst:195 +#: ../../library/multiprocessing.rst:199 msgid "" ":func:`set_start_method` should not be used more than once in the program." msgstr "" -#: ../../library/multiprocessing.rst:198 +#: ../../library/multiprocessing.rst:202 msgid "" "Alternatively, you can use :func:`get_context` to obtain a context object. " "Context objects have the same API as the multiprocessing module, and allow " "one to use multiple start methods in the same program. ::" msgstr "" -#: ../../library/multiprocessing.rst:203 +#: ../../library/multiprocessing.rst:207 msgid "" "import multiprocessing as mp\n" "\n" @@ -372,7 +380,7 @@ msgstr "" " print(q.get())\n" " p.join()" -#: ../../library/multiprocessing.rst:216 +#: ../../library/multiprocessing.rst:220 msgid "" "Note that objects related to one context may not be compatible with " "processes for a different context. In particular, locks created using the " @@ -380,13 +388,17 @@ msgid "" "*forkserver* start methods." msgstr "" -#: ../../library/multiprocessing.rst:221 +#: ../../library/multiprocessing.rst:225 msgid "" -"A library which wants to use a particular start method should probably use :" -"func:`get_context` to avoid interfering with the choice of the library user." +"Libraries using :mod:`multiprocessing` or :class:`~concurrent.futures." +"ProcessPoolExecutor` should be designed to allow their users to provide " +"their own multiprocessing context. Using a specific context of your own " +"within a library can lead to incompatibilities with the rest of the library " +"user's application. Always document if your library requires a specific " +"start method." msgstr "" -#: ../../library/multiprocessing.rst:227 +#: ../../library/multiprocessing.rst:234 msgid "" "The ``'spawn'`` and ``'forkserver'`` start methods generally cannot be used " "with \"frozen\" executables (i.e., binaries produced by packages like " @@ -394,27 +406,27 @@ msgid "" "method may work if code does not use threads." msgstr "" -#: ../../library/multiprocessing.rst:234 +#: ../../library/multiprocessing.rst:241 msgid "Exchanging objects between processes" msgstr "" -#: ../../library/multiprocessing.rst:236 +#: ../../library/multiprocessing.rst:243 msgid "" ":mod:`multiprocessing` supports two types of communication channel between " "processes:" msgstr "" -#: ../../library/multiprocessing.rst:239 +#: ../../library/multiprocessing.rst:246 msgid "**Queues**" msgstr "" -#: ../../library/multiprocessing.rst:241 +#: ../../library/multiprocessing.rst:248 msgid "" "The :class:`Queue` class is a near clone of :class:`queue.Queue`. For " "example::" msgstr "" -#: ../../library/multiprocessing.rst:244 +#: ../../library/multiprocessing.rst:251 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -440,23 +452,23 @@ msgstr "" " print(q.get()) # 印出 \"[42, None, 'hello']\"\n" " p.join()" -#: ../../library/multiprocessing.rst:256 +#: ../../library/multiprocessing.rst:263 msgid "" "Queues are thread and process safe. Any object put into a :mod:" "`~multiprocessing` queue will be serialized." msgstr "" -#: ../../library/multiprocessing.rst:259 +#: ../../library/multiprocessing.rst:266 msgid "**Pipes**" msgstr "" -#: ../../library/multiprocessing.rst:261 +#: ../../library/multiprocessing.rst:268 msgid "" "The :func:`Pipe` function returns a pair of connection objects connected by " "a pipe which by default is duplex (two-way). For example::" msgstr "" -#: ../../library/multiprocessing.rst:264 +#: ../../library/multiprocessing.rst:271 msgid "" "from multiprocessing import Process, Pipe\n" "\n" @@ -484,7 +496,7 @@ msgstr "" " print(parent_conn.recv()) # 印出 \"[42, None, 'hello']\"\n" " p.join()" -#: ../../library/multiprocessing.rst:277 +#: ../../library/multiprocessing.rst:284 msgid "" "The two connection objects returned by :func:`Pipe` represent the two ends " "of the pipe. Each connection object has :meth:`~Connection.send` and :meth:" @@ -494,24 +506,24 @@ msgid "" "corruption from processes using different ends of the pipe at the same time." msgstr "" -#: ../../library/multiprocessing.rst:285 +#: ../../library/multiprocessing.rst:292 msgid "" "The :meth:`~Connection.send` method serializes the object and :meth:" "`~Connection.recv` re-creates the object." msgstr "" -#: ../../library/multiprocessing.rst:289 +#: ../../library/multiprocessing.rst:296 msgid "Synchronization between processes" msgstr "" -#: ../../library/multiprocessing.rst:291 +#: ../../library/multiprocessing.rst:298 msgid "" ":mod:`multiprocessing` contains equivalents of all the synchronization " "primitives from :mod:`threading`. For instance one can use a lock to ensure " "that only one process prints to standard output at a time::" msgstr "" -#: ../../library/multiprocessing.rst:295 +#: ../../library/multiprocessing.rst:302 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -543,40 +555,40 @@ msgstr "" " for num in range(10):\n" " Process(target=f, args=(lock, num)).start()" -#: ../../library/multiprocessing.rst:310 +#: ../../library/multiprocessing.rst:317 msgid "" "Without using the lock output from the different processes is liable to get " "all mixed up." msgstr "" -#: ../../library/multiprocessing.rst:315 +#: ../../library/multiprocessing.rst:322 msgid "Sharing state between processes" msgstr "" -#: ../../library/multiprocessing.rst:317 +#: ../../library/multiprocessing.rst:324 msgid "" "As mentioned above, when doing concurrent programming it is usually best to " "avoid using shared state as far as possible. This is particularly true when " "using multiple processes." msgstr "" -#: ../../library/multiprocessing.rst:321 +#: ../../library/multiprocessing.rst:328 msgid "" "However, if you really do need to use some shared data then :mod:" "`multiprocessing` provides a couple of ways of doing so." msgstr "" -#: ../../library/multiprocessing.rst:324 +#: ../../library/multiprocessing.rst:331 msgid "**Shared memory**" msgstr "" -#: ../../library/multiprocessing.rst:326 +#: ../../library/multiprocessing.rst:333 msgid "" "Data can be stored in a shared memory map using :class:`Value` or :class:" "`Array`. For example, the following code ::" msgstr "" -#: ../../library/multiprocessing.rst:329 +#: ../../library/multiprocessing.rst:336 msgid "" "from multiprocessing import Process, Value, Array\n" "\n" @@ -614,11 +626,11 @@ msgstr "" " print(num.value)\n" " print(arr[:])" -#: ../../library/multiprocessing.rst:347 ../../library/multiprocessing.rst:393 +#: ../../library/multiprocessing.rst:354 ../../library/multiprocessing.rst:400 msgid "will print ::" msgstr "" -#: ../../library/multiprocessing.rst:349 +#: ../../library/multiprocessing.rst:356 msgid "" "3.1415927\n" "[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]" @@ -626,7 +638,7 @@ msgstr "" "3.1415927\n" "[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]" -#: ../../library/multiprocessing.rst:352 +#: ../../library/multiprocessing.rst:359 msgid "" "The ``'d'`` and ``'i'`` arguments used when creating ``num`` and ``arr`` are " "typecodes of the kind used by the :mod:`array` module: ``'d'`` indicates a " @@ -634,25 +646,25 @@ msgid "" "objects will be process and thread-safe." msgstr "" -#: ../../library/multiprocessing.rst:357 +#: ../../library/multiprocessing.rst:364 msgid "" "For more flexibility in using shared memory one can use the :mod:" "`multiprocessing.sharedctypes` module which supports the creation of " "arbitrary ctypes objects allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:361 +#: ../../library/multiprocessing.rst:368 msgid "**Server process**" msgstr "" -#: ../../library/multiprocessing.rst:363 +#: ../../library/multiprocessing.rst:370 msgid "" "A manager object returned by :func:`Manager` controls a server process which " "holds Python objects and allows other processes to manipulate them using " "proxies." msgstr "" -#: ../../library/multiprocessing.rst:367 +#: ../../library/multiprocessing.rst:374 msgid "" "A manager returned by :func:`Manager` will support types :class:`list`, :" "class:`dict`, :class:`~managers.Namespace`, :class:`Lock`, :class:`RLock`, :" @@ -661,7 +673,7 @@ msgid "" "`Array`. For example, ::" msgstr "" -#: ../../library/multiprocessing.rst:373 +#: ../../library/multiprocessing.rst:380 msgid "" "from multiprocessing import Process, Manager\n" "\n" @@ -703,7 +715,7 @@ msgstr "" " print(d)\n" " print(l)" -#: ../../library/multiprocessing.rst:395 +#: ../../library/multiprocessing.rst:402 msgid "" "{0.25: None, 1: '1', '2': 2}\n" "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]" @@ -711,7 +723,7 @@ msgstr "" "{0.25: None, 1: '1', '2': 2}\n" "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]" -#: ../../library/multiprocessing.rst:398 +#: ../../library/multiprocessing.rst:405 msgid "" "Server process managers are more flexible than using shared memory objects " "because they can be made to support arbitrary object types. Also, a single " @@ -719,22 +731,22 @@ msgid "" "They are, however, slower than using shared memory." msgstr "" -#: ../../library/multiprocessing.rst:405 +#: ../../library/multiprocessing.rst:412 msgid "Using a pool of workers" msgstr "" -#: ../../library/multiprocessing.rst:407 +#: ../../library/multiprocessing.rst:414 msgid "" "The :class:`~multiprocessing.pool.Pool` class represents a pool of worker " "processes. It has methods which allows tasks to be offloaded to the worker " "processes in a few different ways." msgstr "" -#: ../../library/multiprocessing.rst:411 +#: ../../library/multiprocessing.rst:418 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/multiprocessing.rst:413 +#: ../../library/multiprocessing.rst:420 msgid "" "from multiprocessing import Pool, TimeoutError\n" "import time\n" @@ -783,13 +795,13 @@ msgid "" " print(\"Now the pool is closed and no longer available\")" msgstr "" -#: ../../library/multiprocessing.rst:455 +#: ../../library/multiprocessing.rst:462 msgid "" "Note that the methods of a pool should only ever be used by the process " "which created it." msgstr "" -#: ../../library/multiprocessing.rst:460 +#: ../../library/multiprocessing.rst:467 msgid "" "Functionality within this package requires that the ``__main__`` module be " "importable by the children. This is covered in :ref:`multiprocessing-" @@ -798,7 +810,7 @@ msgid "" "work in the interactive interpreter. For example::" msgstr "" -#: ../../library/multiprocessing.rst:466 +#: ../../library/multiprocessing.rst:473 msgid "" ">>> from multiprocessing import Pool\n" ">>> p = Pool(5)\n" @@ -840,35 +852,35 @@ msgstr "" "AttributeError: Can't get attribute 'f' on )>" -#: ../../library/multiprocessing.rst:483 +#: ../../library/multiprocessing.rst:490 msgid "" "(If you try this it will actually output three full tracebacks interleaved " "in a semi-random fashion, and then you may have to stop the parent process " "somehow.)" msgstr "" -#: ../../library/multiprocessing.rst:489 +#: ../../library/multiprocessing.rst:496 msgid "Reference" msgstr "" -#: ../../library/multiprocessing.rst:491 +#: ../../library/multiprocessing.rst:498 msgid "" "The :mod:`multiprocessing` package mostly replicates the API of the :mod:" "`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:496 +#: ../../library/multiprocessing.rst:503 msgid ":class:`Process` and exceptions" msgstr ":class:`Process` 與例外" -#: ../../library/multiprocessing.rst:501 +#: ../../library/multiprocessing.rst:508 msgid "" "Process objects represent activity that is run in a separate process. The :" "class:`Process` class has equivalents of all the methods of :class:" "`threading.Thread`." msgstr "" -#: ../../library/multiprocessing.rst:505 +#: ../../library/multiprocessing.rst:512 msgid "" "The constructor should always be called with keyword arguments. *group* " "should always be ``None``; it exists solely for compatibility with :class:" @@ -882,29 +894,87 @@ msgid "" "creating process." msgstr "" -#: ../../library/multiprocessing.rst:516 +#: ../../library/multiprocessing.rst:523 msgid "" "By default, no arguments are passed to *target*. The *args* argument, which " "defaults to ``()``, can be used to specify a list or tuple of the arguments " "to pass to *target*." msgstr "" -#: ../../library/multiprocessing.rst:520 +#: ../../library/multiprocessing.rst:527 msgid "" "If a subclass overrides the constructor, it must make sure it invokes the " -"base class constructor (:meth:`Process.__init__`) before doing anything else " +"base class constructor (``super().__init__()``) before doing anything else " "to the process." msgstr "" -#: ../../library/multiprocessing.rst:524 +#: ../../library/multiprocessing.rst:533 +msgid "" +"In general, all arguments to :class:`Process` must be picklable. This is " +"frequently observed when trying to create a :class:`Process` or use a :class:" +"`concurrent.futures.ProcessPoolExecutor` from a REPL with a locally defined " +"*target* function." +msgstr "" + +#: ../../library/multiprocessing.rst:538 +msgid "" +"Passing a callable object defined in the current REPL session causes the " +"child process to die via an uncaught :exc:`AttributeError` exception when " +"starting as *target* must have been defined within an importable module in " +"order to be loaded during unpickling." +msgstr "" + +#: ../../library/multiprocessing.rst:543 +msgid "Example of this uncatchable error from the child::" +msgstr "" + +#: ../../library/multiprocessing.rst:545 +msgid "" +">>> import multiprocessing as mp\n" +">>> def knigit():\n" +"... print(\"Ni!\")\n" +"...\n" +">>> process = mp.Process(target=knigit)\n" +">>> process.start()\n" +">>> Traceback (most recent call last):\n" +" File \".../multiprocessing/spawn.py\", line ..., in spawn_main\n" +" File \".../multiprocessing/spawn.py\", line ..., in _main\n" +"AttributeError: module '__main__' has no attribute 'knigit'\n" +">>> process\n" +"" +msgstr "" +">>> import multiprocessing as mp\n" +">>> def knigit():\n" +"... print(\"Ni!\")\n" +"...\n" +">>> process = mp.Process(target=knigit)\n" +">>> process.start()\n" +">>> Traceback (most recent call last):\n" +" File \".../multiprocessing/spawn.py\", line ..., in spawn_main\n" +" File \".../multiprocessing/spawn.py\", line ..., in _main\n" +"AttributeError: module '__main__' has no attribute 'knigit'\n" +">>> process\n" +"" + +#: ../../library/multiprocessing.rst:558 +msgid "" +"See :ref:`multiprocessing-programming-spawn`. While this restriction is not " +"true if using the ``\"fork\"`` start method, as of Python ``3.14`` that is " +"no longer the default on any platform. See :ref:`multiprocessing-start-" +"methods`. See also :gh:`132898`." +msgstr "" + +#: ../../library/multiprocessing.rst:564 msgid "Added the *daemon* parameter." msgstr "新增 *daemon* 參數。" -#: ../../library/multiprocessing.rst:529 +#: ../../library/multiprocessing.rst:569 msgid "Method representing the process's activity." msgstr "" -#: ../../library/multiprocessing.rst:531 +#: ../../library/multiprocessing.rst:571 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 target " @@ -912,17 +982,17 @@ msgid "" "*args* and *kwargs* arguments, respectively." msgstr "" -#: ../../library/multiprocessing.rst:536 +#: ../../library/multiprocessing.rst:576 msgid "" "Using a list or tuple as the *args* argument passed to :class:`Process` " "achieves the same effect." msgstr "" -#: ../../library/multiprocessing.rst:539 +#: ../../library/multiprocessing.rst:579 msgid "Example::" msgstr "範例: ::" -#: ../../library/multiprocessing.rst:541 +#: ../../library/multiprocessing.rst:581 msgid "" ">>> from multiprocessing import Process\n" ">>> p = Process(target=print, args=[1])\n" @@ -940,17 +1010,17 @@ msgstr "" ">>> p.run()\n" "1" -#: ../../library/multiprocessing.rst:551 +#: ../../library/multiprocessing.rst:591 msgid "Start the process's activity." msgstr "" -#: ../../library/multiprocessing.rst:553 +#: ../../library/multiprocessing.rst:593 msgid "" "This must be called at most once per process object. It arranges for the " "object's :meth:`run` method to be invoked in a separate process." msgstr "" -#: ../../library/multiprocessing.rst:558 +#: ../../library/multiprocessing.rst:598 msgid "" "If the optional argument *timeout* is ``None`` (the default), the method " "blocks until the process whose :meth:`join` method is called terminates. If " @@ -960,23 +1030,23 @@ msgid "" "terminated." msgstr "" -#: ../../library/multiprocessing.rst:565 +#: ../../library/multiprocessing.rst:605 msgid "A process can be joined many times." msgstr "" -#: ../../library/multiprocessing.rst:567 +#: ../../library/multiprocessing.rst:607 msgid "" "A process cannot join itself because this would cause a deadlock. It is an " "error to attempt to join a process before it has been started." msgstr "" -#: ../../library/multiprocessing.rst:572 +#: ../../library/multiprocessing.rst:612 msgid "" "The process's name. The name is a string used for identification purposes " "only. It has no semantics. Multiple processes may be given the same name." msgstr "" -#: ../../library/multiprocessing.rst:576 +#: ../../library/multiprocessing.rst:616 msgid "" "The initial name is set by the constructor. If no explicit name is provided " "to the constructor, a name of the form 'Process-N\\ :sub:`1`:N\\ :sub:" @@ -984,33 +1054,33 @@ msgid "" "child of its parent." msgstr "" -#: ../../library/multiprocessing.rst:583 +#: ../../library/multiprocessing.rst:623 msgid "Return whether the process is alive." msgstr "" -#: ../../library/multiprocessing.rst:585 +#: ../../library/multiprocessing.rst:625 msgid "" "Roughly, a process object is alive from the moment the :meth:`start` method " "returns until the child process terminates." msgstr "" -#: ../../library/multiprocessing.rst:590 +#: ../../library/multiprocessing.rst:630 msgid "" "The process's daemon flag, a Boolean value. This must be set before :meth:" "`start` is called." msgstr "" -#: ../../library/multiprocessing.rst:593 +#: ../../library/multiprocessing.rst:633 msgid "The initial value is inherited from the creating process." msgstr "" -#: ../../library/multiprocessing.rst:595 +#: ../../library/multiprocessing.rst:635 msgid "" "When a process exits, it attempts to terminate all of its daemonic child " "processes." msgstr "" -#: ../../library/multiprocessing.rst:598 +#: ../../library/multiprocessing.rst:638 msgid "" "Note that a daemonic process is not allowed to create child processes. " "Otherwise a daemonic process would leave its children orphaned if it gets " @@ -1019,92 +1089,92 @@ msgid "" "(and not joined) if non-daemonic processes have exited." msgstr "" -#: ../../library/multiprocessing.rst:604 +#: ../../library/multiprocessing.rst:644 msgid "" "In addition to the :class:`threading.Thread` API, :class:`Process` objects " "also support the following attributes and methods:" msgstr "" -#: ../../library/multiprocessing.rst:609 +#: ../../library/multiprocessing.rst:649 msgid "" "Return the process ID. Before the process is spawned, this will be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:614 +#: ../../library/multiprocessing.rst:654 msgid "" "The child's exit code. This will be ``None`` if the process has not yet " "terminated." msgstr "" -#: ../../library/multiprocessing.rst:617 +#: ../../library/multiprocessing.rst:657 msgid "" "If the child's :meth:`run` method returned normally, the exit code will be " "0. If it terminated via :func:`sys.exit` with an integer argument *N*, the " "exit code will be *N*." msgstr "" -#: ../../library/multiprocessing.rst:621 +#: ../../library/multiprocessing.rst:661 msgid "" "If the child terminated due to an exception not caught within :meth:`run`, " "the exit code will be 1. If it was terminated by signal *N*, the exit code " "will be the negative value *-N*." msgstr "" -#: ../../library/multiprocessing.rst:627 +#: ../../library/multiprocessing.rst:667 msgid "The process's authentication key (a byte string)." msgstr "" -#: ../../library/multiprocessing.rst:629 +#: ../../library/multiprocessing.rst:669 msgid "" "When :mod:`multiprocessing` is initialized the main process is assigned a " "random string using :func:`os.urandom`." msgstr "" -#: ../../library/multiprocessing.rst:632 +#: ../../library/multiprocessing.rst:672 msgid "" "When a :class:`Process` object is created, it will inherit the " "authentication key of its parent process, although this may be changed by " "setting :attr:`authkey` to another byte string." msgstr "" -#: ../../library/multiprocessing.rst:636 +#: ../../library/multiprocessing.rst:676 msgid "See :ref:`multiprocessing-auth-keys`." msgstr "參閱 :ref:`multiprocessing-auth-keys`。" -#: ../../library/multiprocessing.rst:640 +#: ../../library/multiprocessing.rst:680 msgid "" "A numeric handle of a system object which will become \"ready\" when the " "process ends." msgstr "" -#: ../../library/multiprocessing.rst:643 +#: ../../library/multiprocessing.rst:683 msgid "" "You can use this value if you want to wait on several events at once using :" "func:`multiprocessing.connection.wait`. Otherwise calling :meth:`join` is " "simpler." msgstr "" -#: ../../library/multiprocessing.rst:647 +#: ../../library/multiprocessing.rst:687 msgid "" "On Windows, this is an OS handle usable with the ``WaitForSingleObject`` and " "``WaitForMultipleObjects`` family of API calls. On POSIX, this is a file " "descriptor usable with primitives from the :mod:`select` module." msgstr "" -#: ../../library/multiprocessing.rst:655 +#: ../../library/multiprocessing.rst:695 msgid "" "Terminate the process. On POSIX this is done using the :py:const:`~signal." "SIGTERM` signal; on Windows :c:func:`!TerminateProcess` is used. Note that " "exit handlers and finally clauses, etc., will not be executed." msgstr "" -#: ../../library/multiprocessing.rst:659 +#: ../../library/multiprocessing.rst:699 msgid "" "Note that descendant processes of the process will *not* be terminated -- " "they will simply become orphaned." msgstr "" -#: ../../library/multiprocessing.rst:664 +#: ../../library/multiprocessing.rst:704 msgid "" "If this method is used when the associated process is using a pipe or queue " "then the pipe or queue is liable to become corrupted and may become unusable " @@ -1113,11 +1183,11 @@ msgid "" "deadlock." msgstr "" -#: ../../library/multiprocessing.rst:672 +#: ../../library/multiprocessing.rst:712 msgid "Same as :meth:`terminate` but using the ``SIGKILL`` signal on POSIX." msgstr "" -#: ../../library/multiprocessing.rst:678 +#: ../../library/multiprocessing.rst:718 msgid "" "Close the :class:`Process` object, releasing all resources associated with " "it. :exc:`ValueError` is raised if the underlying process is still " @@ -1125,18 +1195,18 @@ msgid "" "attributes of the :class:`Process` object will raise :exc:`ValueError`." msgstr "" -#: ../../library/multiprocessing.rst:686 +#: ../../library/multiprocessing.rst:726 msgid "" "Note that the :meth:`start`, :meth:`join`, :meth:`is_alive`, :meth:" "`terminate` and :attr:`exitcode` methods should only be called by the " "process that created the process object." msgstr "" -#: ../../library/multiprocessing.rst:690 +#: ../../library/multiprocessing.rst:730 msgid "Example usage of some of the methods of :class:`Process`:" msgstr "" -#: ../../library/multiprocessing.rst:692 +#: ../../library/multiprocessing.rst:732 msgid "" ">>> import multiprocessing, time, signal\n" ">>> mp_context = multiprocessing.get_context('spawn')\n" @@ -1168,48 +1238,48 @@ msgstr "" ">>> p.exitcode == -signal.SIGTERM\n" "True" -#: ../../library/multiprocessing.rst:711 +#: ../../library/multiprocessing.rst:751 msgid "The base class of all :mod:`multiprocessing` exceptions." msgstr "" -#: ../../library/multiprocessing.rst:715 +#: ../../library/multiprocessing.rst:755 msgid "" "Exception raised by :meth:`Connection.recv_bytes_into` when the supplied " "buffer object is too small for the message read." msgstr "" -#: ../../library/multiprocessing.rst:718 +#: ../../library/multiprocessing.rst:758 msgid "" "If ``e`` is an instance of :exc:`BufferTooShort` then ``e.args[0]`` will " "give the message as a byte string." msgstr "" -#: ../../library/multiprocessing.rst:723 +#: ../../library/multiprocessing.rst:763 msgid "Raised when there is an authentication error." msgstr "" -#: ../../library/multiprocessing.rst:727 +#: ../../library/multiprocessing.rst:767 msgid "Raised by methods with a timeout when the timeout expires." msgstr "" -#: ../../library/multiprocessing.rst:730 +#: ../../library/multiprocessing.rst:770 msgid "Pipes and Queues" msgstr "" -#: ../../library/multiprocessing.rst:732 +#: ../../library/multiprocessing.rst:772 msgid "" "When using multiple processes, one generally uses message passing for " "communication between processes and avoids having to use any synchronization " "primitives like locks." msgstr "" -#: ../../library/multiprocessing.rst:736 +#: ../../library/multiprocessing.rst:776 msgid "" "For passing messages one can use :func:`Pipe` (for a connection between two " "processes) or a queue (which allows multiple producers and consumers)." msgstr "" -#: ../../library/multiprocessing.rst:739 +#: ../../library/multiprocessing.rst:779 msgid "" "The :class:`Queue`, :class:`SimpleQueue` and :class:`JoinableQueue` types " "are multi-producer, multi-consumer :abbr:`FIFO (first-in, first-out)` queues " @@ -1219,7 +1289,7 @@ msgid "" "Queue` class." msgstr "" -#: ../../library/multiprocessing.rst:746 +#: ../../library/multiprocessing.rst:786 msgid "" "If you use :class:`JoinableQueue` then you **must** call :meth:" "`JoinableQueue.task_done` for each task removed from the queue or else the " @@ -1227,7 +1297,7 @@ msgid "" "overflow, raising an exception." msgstr "" -#: ../../library/multiprocessing.rst:751 +#: ../../library/multiprocessing.rst:791 msgid "" "One difference from other Python queue implementations, is that :mod:" "`multiprocessing` queues serializes all objects that are put into them " @@ -1235,20 +1305,20 @@ msgid "" "object that does not share memory with the original object." msgstr "" -#: ../../library/multiprocessing.rst:756 +#: ../../library/multiprocessing.rst:796 msgid "" "Note that one can also create a shared queue by using a manager object -- " "see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:761 +#: ../../library/multiprocessing.rst:801 msgid "" ":mod:`multiprocessing` uses the usual :exc:`queue.Empty` and :exc:`queue." "Full` exceptions to signal a timeout. They are not available in the :mod:" "`multiprocessing` namespace so you need to import them from :mod:`queue`." msgstr "" -#: ../../library/multiprocessing.rst:768 +#: ../../library/multiprocessing.rst:808 msgid "" "When an object is put on a queue, the object is pickled and a background " "thread later flushes the pickled data to an underlying pipe. This has some " @@ -1257,14 +1327,14 @@ msgid "" "a queue created with a :ref:`manager `." msgstr "" -#: ../../library/multiprocessing.rst:775 +#: ../../library/multiprocessing.rst:815 msgid "" "After putting an object on an empty queue there may be an infinitesimal " "delay before the queue's :meth:`~Queue.empty` method returns :const:`False` " "and :meth:`~Queue.get_nowait` can return without raising :exc:`queue.Empty`." msgstr "" -#: ../../library/multiprocessing.rst:780 +#: ../../library/multiprocessing.rst:820 msgid "" "If multiple processes are enqueuing objects, it is possible for the objects " "to be received at the other end out-of-order. However, objects enqueued by " @@ -1272,7 +1342,7 @@ msgid "" "other." msgstr "" -#: ../../library/multiprocessing.rst:787 +#: ../../library/multiprocessing.rst:827 msgid "" "If a process is killed using :meth:`Process.terminate` or :func:`os.kill` " "while it is trying to use a :class:`Queue`, then the data in the queue is " @@ -1280,7 +1350,7 @@ msgid "" "exception when it tries to use the queue later on." msgstr "" -#: ../../library/multiprocessing.rst:794 +#: ../../library/multiprocessing.rst:834 msgid "" "As mentioned above, if a child process has put items on a queue (and it has " "not used :meth:`JoinableQueue.cancel_join_thread ` flag or :envvar:`PYTHON_CPU_COUNT` as this is merely a wrapper around " "the :mod:`os` cpu count APIs." msgstr "" -#: ../../library/multiprocessing.rst:1030 +#: ../../library/multiprocessing.rst:1075 msgid "" "Return the :class:`Process` object corresponding to the current process." msgstr "" -#: ../../library/multiprocessing.rst:1032 +#: ../../library/multiprocessing.rst:1077 msgid "An analogue of :func:`threading.current_thread`." msgstr "" -#: ../../library/multiprocessing.rst:1036 +#: ../../library/multiprocessing.rst:1081 msgid "" "Return the :class:`Process` object corresponding to the parent process of " "the :func:`current_process`. For the main process, ``parent_process`` will " "be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1044 +#: ../../library/multiprocessing.rst:1089 msgid "" "Add support for when a program which uses :mod:`multiprocessing` has been " "frozen to produce an executable. (Has been tested with **py2exe**, " "**PyInstaller** and **cx_Freeze**.)" msgstr "" -#: ../../library/multiprocessing.rst:1048 +#: ../../library/multiprocessing.rst:1093 msgid "" "One needs to call this function straight after the ``if __name__ == " "'__main__'`` line of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:1051 +#: ../../library/multiprocessing.rst:1096 msgid "" "from multiprocessing import Process, freeze_support\n" "\n" @@ -1635,13 +1710,13 @@ msgstr "" " freeze_support()\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:1060 +#: ../../library/multiprocessing.rst:1105 msgid "" "If the ``freeze_support()`` line is omitted then trying to run the frozen " "executable will raise :exc:`RuntimeError`." msgstr "" -#: ../../library/multiprocessing.rst:1063 +#: ../../library/multiprocessing.rst:1108 msgid "" "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 " @@ -1649,7 +1724,7 @@ msgid "" "no effect." msgstr "" -#: ../../library/multiprocessing.rst:1070 +#: ../../library/multiprocessing.rst:1115 msgid "" "Returns a list of the supported start methods, the first of which is the " "default. The possible start methods are ``'fork'``, ``'spawn'`` and " @@ -1657,13 +1732,13 @@ msgid "" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1079 +#: ../../library/multiprocessing.rst:1124 msgid "" "Return a context object which has the same attributes as the :mod:" "`multiprocessing` module." msgstr "" -#: ../../library/multiprocessing.rst:1082 +#: ../../library/multiprocessing.rst:1127 msgid "" "If *method* is ``None`` then the default context is returned. Note that if " "the global start method has not been set, this will set it to the default " @@ -1672,11 +1747,11 @@ msgid "" "is not available. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1093 +#: ../../library/multiprocessing.rst:1138 msgid "Return the name of start method used for starting processes." msgstr "" -#: ../../library/multiprocessing.rst:1095 +#: ../../library/multiprocessing.rst:1140 msgid "" "If the global start method has not been set and *allow_none* is ``False``, " "then the start method is set to the default and the name is returned. If the " @@ -1684,43 +1759,43 @@ msgid "" "returned." msgstr "" -#: ../../library/multiprocessing.rst:1100 +#: ../../library/multiprocessing.rst:1145 msgid "" "The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` or " "``None``. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1107 +#: ../../library/multiprocessing.rst:1152 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:1113 +#: ../../library/multiprocessing.rst:1158 msgid "" "Set the path of the Python interpreter to use when starting a child process. " "(By default :data:`sys.executable` is used). Embedders will probably need " "to do some thing like ::" msgstr "" -#: ../../library/multiprocessing.rst:1117 +#: ../../library/multiprocessing.rst:1162 msgid "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" msgstr "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" -#: ../../library/multiprocessing.rst:1119 +#: ../../library/multiprocessing.rst:1164 msgid "before they can create child processes." msgstr "" -#: ../../library/multiprocessing.rst:1121 +#: ../../library/multiprocessing.rst:1166 msgid "Now supported on POSIX when the ``'spawn'`` start method is used." msgstr "" -#: ../../library/multiprocessing.rst:1124 +#: ../../library/multiprocessing.rst:1169 msgid "Accepts a :term:`path-like object`." msgstr "接受一個\\ :term:`類路徑物件 `。" -#: ../../library/multiprocessing.rst:1129 +#: ../../library/multiprocessing.rst:1174 msgid "" "Set a list of module names for the forkserver main process to attempt to " "import so that their already imported state is inherited by forked " @@ -1729,19 +1804,19 @@ msgid "" "process." msgstr "" -#: ../../library/multiprocessing.rst:1135 +#: ../../library/multiprocessing.rst:1180 msgid "" "For this to work, it must be called before the forkserver process has been " "launched (before creating a :class:`Pool` or starting a :class:`Process`)." msgstr "" -#: ../../library/multiprocessing.rst:1138 +#: ../../library/multiprocessing.rst:1183 msgid "" "Only meaningful when using the ``'forkserver'`` start method. See :ref:" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1145 +#: ../../library/multiprocessing.rst:1190 msgid "" "Set the method which should be used to start child processes. The *method* " "argument can be ``'fork'``, ``'spawn'`` or ``'forkserver'``. Raises :exc:" @@ -1751,17 +1826,17 @@ msgid "" "then the context is set to the default context." msgstr "" -#: ../../library/multiprocessing.rst:1152 +#: ../../library/multiprocessing.rst:1197 msgid "" "Note that this should be called at most once, and it should be protected " "inside the ``if __name__ == '__main__'`` clause of the main module." msgstr "" -#: ../../library/multiprocessing.rst:1156 +#: ../../library/multiprocessing.rst:1201 msgid "See :ref:`multiprocessing-start-methods`." msgstr "參閱 :ref:`multiprocessing-start-methods`。" -#: ../../library/multiprocessing.rst:1162 +#: ../../library/multiprocessing.rst:1207 msgid "" ":mod:`multiprocessing` contains no analogues of :func:`threading." "active_count`, :func:`threading.enumerate`, :func:`threading.settrace`, :" @@ -1769,75 +1844,75 @@ msgid "" "local`." msgstr "" -#: ../../library/multiprocessing.rst:1169 +#: ../../library/multiprocessing.rst:1214 msgid "Connection Objects" msgstr "" -#: ../../library/multiprocessing.rst:1173 +#: ../../library/multiprocessing.rst:1218 msgid "" "Connection objects allow the sending and receiving of picklable objects or " "strings. They can be thought of as message oriented connected sockets." msgstr "" -#: ../../library/multiprocessing.rst:1176 +#: ../../library/multiprocessing.rst:1221 msgid "" "Connection objects are usually created using :func:`Pipe ` -- see also :ref:`multiprocessing-listeners-clients`." msgstr "" -#: ../../library/multiprocessing.rst:1184 +#: ../../library/multiprocessing.rst:1229 msgid "" "Send an object to the other end of the connection which should be read " "using :meth:`recv`." msgstr "" -#: ../../library/multiprocessing.rst:1187 +#: ../../library/multiprocessing.rst:1232 msgid "" "The object must be picklable. Very large pickles (approximately 32 MiB+, " "though it depends on the OS) may raise a :exc:`ValueError` exception." msgstr "" -#: ../../library/multiprocessing.rst:1192 +#: ../../library/multiprocessing.rst:1237 msgid "" "Return an object sent from the other end of the connection using :meth:" "`send`. Blocks until there is something to receive. Raises :exc:`EOFError` " "if there is nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1199 +#: ../../library/multiprocessing.rst:1244 msgid "Return the file descriptor or handle used by the connection." msgstr "" -#: ../../library/multiprocessing.rst:1203 +#: ../../library/multiprocessing.rst:1248 msgid "Close the connection." msgstr "" -#: ../../library/multiprocessing.rst:1205 +#: ../../library/multiprocessing.rst:1250 msgid "This is called automatically when the connection is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1209 +#: ../../library/multiprocessing.rst:1254 msgid "Return whether there is any data available to be read." msgstr "" -#: ../../library/multiprocessing.rst:1211 +#: ../../library/multiprocessing.rst:1256 msgid "" "If *timeout* is not specified then it will return immediately. If *timeout* " "is a number then this specifies the maximum time in seconds to block. If " "*timeout* is ``None`` then an infinite timeout is used." msgstr "" -#: ../../library/multiprocessing.rst:1215 +#: ../../library/multiprocessing.rst:1260 msgid "" "Note that multiple connection objects may be polled at once by using :func:" "`multiprocessing.connection.wait`." msgstr "" -#: ../../library/multiprocessing.rst:1220 +#: ../../library/multiprocessing.rst:1265 msgid "Send byte data from a :term:`bytes-like object` as a complete message." msgstr "" -#: ../../library/multiprocessing.rst:1222 +#: ../../library/multiprocessing.rst:1267 msgid "" "If *offset* is given then data is read from that position in *buffer*. If " "*size* is given then that many bytes will be read from buffer. Very large " @@ -1845,7 +1920,7 @@ msgid "" "exc:`ValueError` exception" msgstr "" -#: ../../library/multiprocessing.rst:1229 +#: ../../library/multiprocessing.rst:1274 msgid "" "Return a complete message of byte data sent from the other end of the " "connection as a string. Blocks until there is something to receive. Raises :" @@ -1853,19 +1928,19 @@ msgid "" "closed." msgstr "" -#: ../../library/multiprocessing.rst:1234 +#: ../../library/multiprocessing.rst:1279 msgid "" "If *maxlength* is specified and the message is longer than *maxlength* then :" "exc:`OSError` is raised and the connection will no longer be readable." msgstr "" -#: ../../library/multiprocessing.rst:1238 +#: ../../library/multiprocessing.rst:1283 msgid "" "This function used to raise :exc:`IOError`, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:1245 +#: ../../library/multiprocessing.rst:1290 msgid "" "Read into *buffer* a complete message of byte data sent from the other end " "of the connection and return the number of bytes in the message. Blocks " @@ -1873,38 +1948,38 @@ msgid "" "nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1251 +#: ../../library/multiprocessing.rst:1296 msgid "" "*buffer* must be a writable :term:`bytes-like object`. If *offset* is given " "then the message will be written into the buffer from that position. Offset " "must be a non-negative integer less than the length of *buffer* (in bytes)." msgstr "" -#: ../../library/multiprocessing.rst:1256 +#: ../../library/multiprocessing.rst:1301 msgid "" "If the buffer is too short then a :exc:`BufferTooShort` exception is raised " "and the complete message is available as ``e.args[0]`` where ``e`` is the " "exception instance." msgstr "" -#: ../../library/multiprocessing.rst:1260 +#: ../../library/multiprocessing.rst:1305 msgid "" "Connection objects themselves can now be transferred between processes " "using :meth:`Connection.send` and :meth:`Connection.recv`." msgstr "" -#: ../../library/multiprocessing.rst:1264 +#: ../../library/multiprocessing.rst:1309 msgid "" "Connection objects also now support the context management protocol -- see :" "ref:`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "connection object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:1268 +#: ../../library/multiprocessing.rst:1313 msgid "For example:" msgstr "舉例來說:" -#: ../../library/multiprocessing.rst:1270 +#: ../../library/multiprocessing.rst:1315 msgid "" ">>> from multiprocessing import Pipe\n" ">>> a, b = Pipe()\n" @@ -1940,14 +2015,14 @@ msgstr "" ">>> arr2\n" "array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])" -#: ../../library/multiprocessing.rst:1293 +#: ../../library/multiprocessing.rst:1338 msgid "" "The :meth:`Connection.recv` method automatically unpickles the data it " "receives, which can be a security risk unless you can trust the process " "which sent the message." msgstr "" -#: ../../library/multiprocessing.rst:1297 +#: ../../library/multiprocessing.rst:1342 msgid "" "Therefore, unless the connection object was produced using :func:`Pipe` you " "should only use the :meth:`~Connection.recv` and :meth:`~Connection.send` " @@ -1955,73 +2030,73 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:1304 +#: ../../library/multiprocessing.rst:1349 msgid "" "If a process is killed while it is trying to read or write to a pipe then " "the data in the pipe is likely to become corrupted, because it may become " "impossible to be sure where the message boundaries lie." msgstr "" -#: ../../library/multiprocessing.rst:1310 +#: ../../library/multiprocessing.rst:1355 msgid "Synchronization primitives" msgstr "" -#: ../../library/multiprocessing.rst:1314 +#: ../../library/multiprocessing.rst:1359 msgid "" "Generally synchronization primitives are not as necessary in a multiprocess " "program as they are in a multithreaded program. See the documentation for :" "mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:1318 +#: ../../library/multiprocessing.rst:1363 msgid "" "Note that one can also create synchronization primitives by using a manager " "object -- see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:1323 +#: ../../library/multiprocessing.rst:1368 msgid "A barrier object: a clone of :class:`threading.Barrier`." msgstr "" -#: ../../library/multiprocessing.rst:1329 +#: ../../library/multiprocessing.rst:1374 msgid "" "A bounded semaphore object: a close analog of :class:`threading." "BoundedSemaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1332 -#: ../../library/multiprocessing.rst:1470 +#: ../../library/multiprocessing.rst:1377 +#: ../../library/multiprocessing.rst:1515 msgid "" "A solitary difference from its close analog exists: its ``acquire`` method's " "first argument is named *block*, as is consistent with :meth:`Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1336 +#: ../../library/multiprocessing.rst:1381 msgid "" "On macOS, this is indistinguishable from :class:`Semaphore` because " "``sem_getvalue()`` is not implemented on that platform." msgstr "" -#: ../../library/multiprocessing.rst:1341 +#: ../../library/multiprocessing.rst:1386 msgid "A condition variable: an alias for :class:`threading.Condition`." msgstr "" -#: ../../library/multiprocessing.rst:1343 +#: ../../library/multiprocessing.rst:1388 msgid "" "If *lock* is specified then it should be a :class:`Lock` or :class:`RLock` " "object from :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:1346 -#: ../../library/multiprocessing.rst:1884 +#: ../../library/multiprocessing.rst:1391 +#: ../../library/multiprocessing.rst:1929 msgid "The :meth:`~threading.Condition.wait_for` method was added." msgstr "" -#: ../../library/multiprocessing.rst:1351 +#: ../../library/multiprocessing.rst:1396 msgid "A clone of :class:`threading.Event`." msgstr "" -#: ../../library/multiprocessing.rst:1356 +#: ../../library/multiprocessing.rst:1401 msgid "" "A non-recursive lock object: a close analog of :class:`threading.Lock`. Once " "a process or thread has acquired a lock, subsequent attempts to acquire it " @@ -2032,25 +2107,25 @@ msgid "" "as noted." msgstr "" -#: ../../library/multiprocessing.rst:1364 +#: ../../library/multiprocessing.rst:1409 msgid "" "Note that :class:`Lock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.Lock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1368 +#: ../../library/multiprocessing.rst:1413 msgid "" ":class:`Lock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1373 -#: ../../library/multiprocessing.rst:1424 +#: ../../library/multiprocessing.rst:1418 +#: ../../library/multiprocessing.rst:1469 msgid "Acquire a lock, blocking or non-blocking." msgstr "" -#: ../../library/multiprocessing.rst:1375 +#: ../../library/multiprocessing.rst:1420 msgid "" "With the *block* argument set to ``True`` (the default), the method call " "will block until the lock is in an unlocked state, then set it to locked and " @@ -2058,14 +2133,14 @@ msgid "" "that in :meth:`threading.Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1380 +#: ../../library/multiprocessing.rst:1425 msgid "" "With the *block* argument set to ``False``, the method call does not block. " "If the lock is currently in a locked state, return ``False``; otherwise set " "the lock to a locked state and return ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1384 +#: ../../library/multiprocessing.rst:1429 msgid "" "When invoked with a positive, floating-point value for *timeout*, block for " "at most the number of seconds specified by *timeout* as long as the lock can " @@ -2079,19 +2154,19 @@ msgid "" "acquired or ``False`` if the timeout period has elapsed." msgstr "" -#: ../../library/multiprocessing.rst:1399 +#: ../../library/multiprocessing.rst:1444 msgid "" "Release a lock. This can be called from any process or thread, not only the " "process or thread which originally acquired the lock." msgstr "" -#: ../../library/multiprocessing.rst:1402 +#: ../../library/multiprocessing.rst:1447 msgid "" "Behavior is the same as in :meth:`threading.Lock.release` except that when " "invoked on an unlocked lock, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:1408 +#: ../../library/multiprocessing.rst:1453 msgid "" "A recursive lock object: a close analog of :class:`threading.RLock`. A " "recursive lock must be released by the process or thread that acquired it. " @@ -2100,20 +2175,20 @@ msgid "" "release it once for each time it has been acquired." msgstr "" -#: ../../library/multiprocessing.rst:1414 +#: ../../library/multiprocessing.rst:1459 msgid "" "Note that :class:`RLock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.RLock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1418 +#: ../../library/multiprocessing.rst:1463 msgid "" ":class:`RLock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1426 +#: ../../library/multiprocessing.rst:1471 msgid "" "When invoked with the *block* argument set to ``True``, block until the lock " "is in an unlocked state (not owned by any process or thread) unless the lock " @@ -2126,7 +2201,7 @@ msgid "" "itself." msgstr "" -#: ../../library/multiprocessing.rst:1436 +#: ../../library/multiprocessing.rst:1481 msgid "" "When invoked with the *block* argument set to ``False``, do not block. If " "the lock has already been acquired (and thus is owned) by another process or " @@ -2137,14 +2212,14 @@ msgid "" "a return value of ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1444 +#: ../../library/multiprocessing.rst:1489 msgid "" "Use and behaviors of the *timeout* argument are the same as in :meth:`Lock." "acquire`. Note that some of these behaviors of *timeout* differ from the " "implemented behaviors in :meth:`threading.RLock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1451 +#: ../../library/multiprocessing.rst:1496 msgid "" "Release a lock, decrementing the recursion level. If after the decrement " "the recursion level is zero, reset the lock to unlocked (not owned by any " @@ -2154,7 +2229,7 @@ msgid "" "locked and owned by the calling process or thread." msgstr "" -#: ../../library/multiprocessing.rst:1459 +#: ../../library/multiprocessing.rst:1504 msgid "" "Only call this method when the calling process or thread owns the lock. An :" "exc:`AssertionError` is raised if this method is called by a process or " @@ -2163,17 +2238,17 @@ msgid "" "from the implemented behavior in :meth:`threading.RLock.release`." msgstr "" -#: ../../library/multiprocessing.rst:1468 +#: ../../library/multiprocessing.rst:1513 msgid "A semaphore object: a close analog of :class:`threading.Semaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1475 +#: ../../library/multiprocessing.rst:1520 msgid "" "On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with a " "timeout will emulate that function's behavior using a sleeping loop." msgstr "" -#: ../../library/multiprocessing.rst:1480 +#: ../../library/multiprocessing.rst:1525 msgid "" "Some of this package's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the :mod:" @@ -2182,32 +2257,32 @@ msgid "" "additional information." msgstr "" -#: ../../library/multiprocessing.rst:1488 +#: ../../library/multiprocessing.rst:1533 msgid "Shared :mod:`ctypes` Objects" msgstr "共享的 :mod:`ctypes` 物件" -#: ../../library/multiprocessing.rst:1490 +#: ../../library/multiprocessing.rst:1535 msgid "" "It is possible to create shared objects using shared memory which can be " "inherited by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1495 +#: ../../library/multiprocessing.rst:1540 msgid "" "Return a :mod:`ctypes` object allocated from shared memory. By default the " "return value is actually a synchronized wrapper for the object. The object " "itself can be accessed via the *value* attribute of a :class:`Value`." msgstr "" -#: ../../library/multiprocessing.rst:1499 -#: ../../library/multiprocessing.rst:1586 +#: ../../library/multiprocessing.rst:1544 +#: ../../library/multiprocessing.rst:1631 msgid "" "*typecode_or_type* determines the type of the returned object: it is either " "a ctypes type or a one character typecode of the kind used by the :mod:" "`array` module. *\\*args* is passed on to the constructor for the type." msgstr "" -#: ../../library/multiprocessing.rst:1503 +#: ../../library/multiprocessing.rst:1548 msgid "" "If *lock* is ``True`` (the default) then a new recursive lock object is " "created to synchronize access to the value. If *lock* is a :class:`Lock` " @@ -2217,24 +2292,24 @@ msgid "" "\"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1510 +#: ../../library/multiprocessing.rst:1555 msgid "" "Operations like ``+=`` which involve a read and write are not atomic. So " "if, for instance, you want to atomically increment a shared value it is " "insufficient to just do ::" msgstr "" -#: ../../library/multiprocessing.rst:1514 +#: ../../library/multiprocessing.rst:1559 msgid "counter.value += 1" msgstr "counter.value += 1" -#: ../../library/multiprocessing.rst:1516 +#: ../../library/multiprocessing.rst:1561 msgid "" "Assuming the associated lock is recursive (which it is by default) you can " "instead do ::" msgstr "" -#: ../../library/multiprocessing.rst:1519 +#: ../../library/multiprocessing.rst:1564 msgid "" "with counter.get_lock():\n" " counter.value += 1" @@ -2242,19 +2317,19 @@ msgstr "" "with counter.get_lock():\n" " counter.value += 1" -#: ../../library/multiprocessing.rst:1522 -#: ../../library/multiprocessing.rst:1612 -#: ../../library/multiprocessing.rst:1627 +#: ../../library/multiprocessing.rst:1567 +#: ../../library/multiprocessing.rst:1657 +#: ../../library/multiprocessing.rst:1672 msgid "Note that *lock* is a keyword-only argument." msgstr "" -#: ../../library/multiprocessing.rst:1526 +#: ../../library/multiprocessing.rst:1571 msgid "" "Return a ctypes array allocated from shared memory. By default the return " "value is actually a synchronized wrapper for the array." msgstr "" -#: ../../library/multiprocessing.rst:1529 +#: ../../library/multiprocessing.rst:1574 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2264,7 +2339,7 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1536 +#: ../../library/multiprocessing.rst:1581 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`Lock` or :class:" @@ -2274,28 +2349,28 @@ msgid "" "safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1543 +#: ../../library/multiprocessing.rst:1588 msgid "Note that *lock* is a keyword only argument." msgstr "" -#: ../../library/multiprocessing.rst:1545 +#: ../../library/multiprocessing.rst:1590 msgid "" "Note that an array of :data:`ctypes.c_char` has *value* and *raw* attributes " "which allow one to use it to store and retrieve strings." msgstr "" -#: ../../library/multiprocessing.rst:1550 +#: ../../library/multiprocessing.rst:1595 msgid "The :mod:`multiprocessing.sharedctypes` module" msgstr ":mod:`multiprocessing.sharedctypes` 模組" -#: ../../library/multiprocessing.rst:1555 +#: ../../library/multiprocessing.rst:1600 msgid "" "The :mod:`multiprocessing.sharedctypes` module provides functions for " "allocating :mod:`ctypes` objects from shared memory which can be inherited " "by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1561 +#: ../../library/multiprocessing.rst:1606 msgid "" "Although it is possible to store a pointer in shared memory remember that " "this will refer to a location in the address space of a specific process. " @@ -2304,11 +2379,11 @@ msgid "" "may cause a crash." msgstr "" -#: ../../library/multiprocessing.rst:1569 +#: ../../library/multiprocessing.rst:1614 msgid "Return a ctypes array allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1571 +#: ../../library/multiprocessing.rst:1616 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2318,40 +2393,40 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1578 +#: ../../library/multiprocessing.rst:1623 msgid "" "Note that setting and getting an element is potentially non-atomic -- use :" "func:`Array` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1584 +#: ../../library/multiprocessing.rst:1629 msgid "Return a ctypes object allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1590 +#: ../../library/multiprocessing.rst:1635 msgid "" "Note that setting and getting the value is potentially non-atomic -- use :" "func:`Value` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1594 +#: ../../library/multiprocessing.rst:1639 msgid "" "Note that an array of :data:`ctypes.c_char` has ``value`` and ``raw`` " "attributes which allow one to use it to store and retrieve strings -- see " "documentation for :mod:`ctypes`." msgstr "" -#: ../../library/multiprocessing.rst:1600 +#: ../../library/multiprocessing.rst:1645 msgid "" "The same as :func:`RawArray` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "array." msgstr "" -#: ../../library/multiprocessing.rst:1604 -#: ../../library/multiprocessing.rst:1620 +#: ../../library/multiprocessing.rst:1649 +#: ../../library/multiprocessing.rst:1665 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`~multiprocessing." @@ -2361,113 +2436,113 @@ msgid "" "not necessarily be \"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1616 +#: ../../library/multiprocessing.rst:1661 msgid "" "The same as :func:`RawValue` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "object." msgstr "" -#: ../../library/multiprocessing.rst:1631 +#: ../../library/multiprocessing.rst:1676 msgid "" "Return a ctypes object allocated from shared memory which is a copy of the " "ctypes object *obj*." msgstr "" -#: ../../library/multiprocessing.rst:1636 +#: ../../library/multiprocessing.rst:1681 msgid "" "Return a process-safe wrapper object for a ctypes object which uses *lock* " "to synchronize access. If *lock* is ``None`` (the default) then a :class:" "`multiprocessing.RLock` object is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1640 +#: ../../library/multiprocessing.rst:1685 msgid "" "A synchronized wrapper will have two methods in addition to those of the " "object it wraps: :meth:`get_obj` returns the wrapped object and :meth:" "`get_lock` returns the lock object used for synchronization." msgstr "" -#: ../../library/multiprocessing.rst:1644 +#: ../../library/multiprocessing.rst:1689 msgid "" "Note that accessing the ctypes object through the wrapper can be a lot " "slower than accessing the raw ctypes object." msgstr "" -#: ../../library/multiprocessing.rst:1647 +#: ../../library/multiprocessing.rst:1692 msgid "Synchronized objects support the :term:`context manager` protocol." msgstr "" -#: ../../library/multiprocessing.rst:1651 +#: ../../library/multiprocessing.rst:1696 msgid "" "The table below compares the syntax for creating shared ctypes objects from " "shared memory with the normal ctypes syntax. (In the table ``MyStruct`` is " "some subclass of :class:`ctypes.Structure`.)" msgstr "" -#: ../../library/multiprocessing.rst:1656 +#: ../../library/multiprocessing.rst:1701 msgid "ctypes" msgstr "ctypes" -#: ../../library/multiprocessing.rst:1656 +#: ../../library/multiprocessing.rst:1701 msgid "sharedctypes using type" msgstr "" -#: ../../library/multiprocessing.rst:1656 +#: ../../library/multiprocessing.rst:1701 msgid "sharedctypes using typecode" msgstr "" -#: ../../library/multiprocessing.rst:1658 +#: ../../library/multiprocessing.rst:1703 msgid "c_double(2.4)" msgstr "c_double(2.4)" -#: ../../library/multiprocessing.rst:1658 +#: ../../library/multiprocessing.rst:1703 msgid "RawValue(c_double, 2.4)" msgstr "RawValue(c_double, 2.4)" -#: ../../library/multiprocessing.rst:1658 +#: ../../library/multiprocessing.rst:1703 msgid "RawValue('d', 2.4)" msgstr "RawValue('d', 2.4)" -#: ../../library/multiprocessing.rst:1659 +#: ../../library/multiprocessing.rst:1704 msgid "MyStruct(4, 6)" msgstr "MyStruct(4, 6)" -#: ../../library/multiprocessing.rst:1659 +#: ../../library/multiprocessing.rst:1704 msgid "RawValue(MyStruct, 4, 6)" msgstr "RawValue(MyStruct, 4, 6)" -#: ../../library/multiprocessing.rst:1660 +#: ../../library/multiprocessing.rst:1705 msgid "(c_short * 7)()" msgstr "(c_short * 7)()" -#: ../../library/multiprocessing.rst:1660 +#: ../../library/multiprocessing.rst:1705 msgid "RawArray(c_short, 7)" msgstr "RawArray(c_short, 7)" -#: ../../library/multiprocessing.rst:1660 +#: ../../library/multiprocessing.rst:1705 msgid "RawArray('h', 7)" msgstr "RawArray('h', 7)" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1706 msgid "(c_int * 3)(9, 2, 8)" msgstr "(c_int * 3)(9, 2, 8)" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1706 msgid "RawArray(c_int, (9, 2, 8))" msgstr "RawArray(c_int, (9, 2, 8))" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1706 msgid "RawArray('i', (9, 2, 8))" msgstr "RawArray('i', (9, 2, 8))" -#: ../../library/multiprocessing.rst:1665 +#: ../../library/multiprocessing.rst:1710 msgid "" "Below is an example where a number of ctypes objects are modified by a child " "process::" msgstr "" -#: ../../library/multiprocessing.rst:1668 +#: ../../library/multiprocessing.rst:1713 msgid "" "from multiprocessing import Process, Lock\n" "from multiprocessing.sharedctypes import Value, Array\n" @@ -2533,11 +2608,11 @@ msgstr "" " print(s.value)\n" " print([(a.x, a.y) for a in A])" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1748 msgid "The results printed are ::" msgstr "" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1750 msgid "" "49\n" "0.1111111111111111\n" @@ -2549,11 +2624,11 @@ msgstr "" "HELLO WORLD\n" "[(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]" -#: ../../library/multiprocessing.rst:1716 +#: ../../library/multiprocessing.rst:1761 msgid "Managers" msgstr "" -#: ../../library/multiprocessing.rst:1718 +#: ../../library/multiprocessing.rst:1763 msgid "" "Managers provide a way to create data which can be shared between different " "processes, including sharing over a network between processes running on " @@ -2562,7 +2637,7 @@ msgid "" "proxies." msgstr "" -#: ../../library/multiprocessing.rst:1727 +#: ../../library/multiprocessing.rst:1772 msgid "" "Returns a started :class:`~multiprocessing.managers.SyncManager` object " "which can be used for sharing objects between processes. The returned " @@ -2570,31 +2645,31 @@ msgid "" "will create shared objects and return corresponding proxies." msgstr "" -#: ../../library/multiprocessing.rst:1735 +#: ../../library/multiprocessing.rst:1780 msgid "" "Manager processes will be shutdown as soon as they are garbage collected or " "their parent process exits. The manager classes are defined in the :mod:" "`multiprocessing.managers` module:" msgstr "" -#: ../../library/multiprocessing.rst:1741 +#: ../../library/multiprocessing.rst:1786 msgid "Create a BaseManager object." msgstr "建立一個 BaseManager 物件。" -#: ../../library/multiprocessing.rst:1743 +#: ../../library/multiprocessing.rst:1788 msgid "" "Once created one should call :meth:`start` or ``get_server()." "serve_forever()`` to ensure that the manager object refers to a started " "manager process." msgstr "" -#: ../../library/multiprocessing.rst:1746 +#: ../../library/multiprocessing.rst:1791 msgid "" "*address* is the address on which the manager process listens for new " "connections. If *address* is ``None`` then an arbitrary one is chosen." msgstr "" -#: ../../library/multiprocessing.rst:1749 +#: ../../library/multiprocessing.rst:1794 msgid "" "*authkey* is the authentication key which will be used to check the validity " "of incoming connections to the server process. If *authkey* is ``None`` " @@ -2602,19 +2677,19 @@ msgid "" "it must be a byte string." msgstr "" -#: ../../library/multiprocessing.rst:1754 +#: ../../library/multiprocessing.rst:1799 msgid "" "*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or " "``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization)." msgstr "" -#: ../../library/multiprocessing.rst:1757 +#: ../../library/multiprocessing.rst:1802 msgid "" "*ctx* is a context object, or ``None`` (use the current context). See the :" "func:`get_context` function." msgstr "" -#: ../../library/multiprocessing.rst:1760 +#: ../../library/multiprocessing.rst:1805 msgid "" "*shutdown_timeout* is a timeout in seconds used to wait until the process " "used by the manager completes in the :meth:`shutdown` method. If the " @@ -2622,24 +2697,24 @@ msgid "" "also times out, the process is killed." msgstr "" -#: ../../library/multiprocessing.rst:1765 +#: ../../library/multiprocessing.rst:1810 msgid "Added the *shutdown_timeout* parameter." msgstr "新增 *shutdown_timeout* 參數。" -#: ../../library/multiprocessing.rst:1770 +#: ../../library/multiprocessing.rst:1815 msgid "" "Start a subprocess to start the manager. If *initializer* is not ``None`` " "then the subprocess will call ``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:1775 +#: ../../library/multiprocessing.rst:1820 msgid "" "Returns a :class:`Server` object which represents the actual server under " "the control of the Manager. The :class:`Server` object supports the :meth:" "`serve_forever` method::" msgstr "" -#: ../../library/multiprocessing.rst:1779 +#: ../../library/multiprocessing.rst:1824 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> manager = BaseManager(address=('', 50000), authkey=b'abc')\n" @@ -2651,15 +2726,15 @@ msgstr "" ">>> server = manager.get_server()\n" ">>> server.serve_forever()" -#: ../../library/multiprocessing.rst:1784 +#: ../../library/multiprocessing.rst:1829 msgid ":class:`Server` additionally has an :attr:`address` attribute." msgstr "" -#: ../../library/multiprocessing.rst:1788 +#: ../../library/multiprocessing.rst:1833 msgid "Connect a local manager object to a remote manager process::" msgstr "" -#: ../../library/multiprocessing.rst:1790 +#: ../../library/multiprocessing.rst:1835 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" @@ -2669,29 +2744,29 @@ msgstr "" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" ">>> m.connect()" -#: ../../library/multiprocessing.rst:1796 +#: ../../library/multiprocessing.rst:1841 msgid "" "Stop the process used by the manager. This is only available if :meth:" "`start` has been used to start the server process." msgstr "" -#: ../../library/multiprocessing.rst:1799 +#: ../../library/multiprocessing.rst:1844 msgid "This can be called multiple times." msgstr "" -#: ../../library/multiprocessing.rst:1803 +#: ../../library/multiprocessing.rst:1848 msgid "" "A classmethod which can be used for registering a type or callable with the " "manager class." msgstr "" -#: ../../library/multiprocessing.rst:1806 +#: ../../library/multiprocessing.rst:1851 msgid "" "*typeid* is a \"type identifier\" which is used to identify a particular " "type of shared object. This must be a string." msgstr "" -#: ../../library/multiprocessing.rst:1809 +#: ../../library/multiprocessing.rst:1854 msgid "" "*callable* is a callable used for creating objects for this type " "identifier. If a manager instance will be connected to the server using " @@ -2699,14 +2774,14 @@ msgid "" "then this can be left as ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1815 +#: ../../library/multiprocessing.rst:1860 msgid "" "*proxytype* is a subclass of :class:`BaseProxy` which is used to create " "proxies for shared objects with this *typeid*. If ``None`` then a proxy " "class is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1819 +#: ../../library/multiprocessing.rst:1864 msgid "" "*exposed* is used to specify a sequence of method names which proxies for " "this typeid should be allowed to access using :meth:`BaseProxy." @@ -2717,7 +2792,7 @@ msgid "" "method and whose name does not begin with ``'_'``.)" msgstr "" -#: ../../library/multiprocessing.rst:1828 +#: ../../library/multiprocessing.rst:1873 msgid "" "*method_to_typeid* is a mapping used to specify the return type of those " "exposed methods which should return a proxy. It maps method names to typeid " @@ -2727,22 +2802,22 @@ msgid "" "returned by the method will be copied by value." msgstr "" -#: ../../library/multiprocessing.rst:1835 +#: ../../library/multiprocessing.rst:1880 msgid "" "*create_method* determines whether a method should be created with name " "*typeid* which can be used to tell the server process to create a new shared " "object and return a proxy for it. By default it is ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1839 +#: ../../library/multiprocessing.rst:1884 msgid ":class:`BaseManager` instances also have one read-only property:" msgstr "" -#: ../../library/multiprocessing.rst:1843 +#: ../../library/multiprocessing.rst:1888 msgid "The address used by the manager." msgstr "" -#: ../../library/multiprocessing.rst:1845 +#: ../../library/multiprocessing.rst:1890 msgid "" "Manager objects support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` starts the server " @@ -2750,121 +2825,121 @@ msgid "" "object. :meth:`~contextmanager.__exit__` calls :meth:`shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:1851 +#: ../../library/multiprocessing.rst:1896 msgid "" "In previous versions :meth:`~contextmanager.__enter__` did not start the " "manager's server process if it was not already started." msgstr "" -#: ../../library/multiprocessing.rst:1856 +#: ../../library/multiprocessing.rst:1901 msgid "" "A subclass of :class:`BaseManager` which can be used for the synchronization " "of processes. Objects of this type are returned by :func:`multiprocessing." "Manager`." msgstr "" -#: ../../library/multiprocessing.rst:1860 +#: ../../library/multiprocessing.rst:1905 msgid "" "Its methods create and return :ref:`multiprocessing-proxy_objects` for a " "number of commonly used data types to be synchronized across processes. This " "notably includes shared lists and dictionaries." msgstr "" -#: ../../library/multiprocessing.rst:1866 +#: ../../library/multiprocessing.rst:1911 msgid "" "Create a shared :class:`threading.Barrier` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1873 +#: ../../library/multiprocessing.rst:1918 msgid "" "Create a shared :class:`threading.BoundedSemaphore` object and return a " "proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1878 +#: ../../library/multiprocessing.rst:1923 msgid "" "Create a shared :class:`threading.Condition` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1881 +#: ../../library/multiprocessing.rst:1926 msgid "" "If *lock* is supplied then it should be a proxy for a :class:`threading." "Lock` or :class:`threading.RLock` object." msgstr "" -#: ../../library/multiprocessing.rst:1889 +#: ../../library/multiprocessing.rst:1934 msgid "" "Create a shared :class:`threading.Event` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1893 +#: ../../library/multiprocessing.rst:1938 msgid "" "Create a shared :class:`threading.Lock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1897 +#: ../../library/multiprocessing.rst:1942 msgid "Create a shared :class:`Namespace` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1901 +#: ../../library/multiprocessing.rst:1946 msgid "Create a shared :class:`queue.Queue` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1905 +#: ../../library/multiprocessing.rst:1950 msgid "" "Create a shared :class:`threading.RLock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1909 +#: ../../library/multiprocessing.rst:1954 msgid "" "Create a shared :class:`threading.Semaphore` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1914 +#: ../../library/multiprocessing.rst:1959 msgid "Create an array and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1918 +#: ../../library/multiprocessing.rst:1963 msgid "" "Create an object with a writable ``value`` attribute and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1925 +#: ../../library/multiprocessing.rst:1970 msgid "Create a shared :class:`dict` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1930 +#: ../../library/multiprocessing.rst:1975 msgid "Create a shared :class:`list` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1932 +#: ../../library/multiprocessing.rst:1977 msgid "" "Shared objects are capable of being nested. For example, a shared container " "object such as a shared list can contain other shared objects which will all " "be managed and synchronized by the :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1939 +#: ../../library/multiprocessing.rst:1984 msgid "A type that can register with :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1941 +#: ../../library/multiprocessing.rst:1986 msgid "" "A namespace object has no public methods, but does have writable attributes. " "Its representation shows the values of its attributes." msgstr "" -#: ../../library/multiprocessing.rst:1944 +#: ../../library/multiprocessing.rst:1989 msgid "" "However, when using a proxy for a namespace object, an attribute beginning " "with ``'_'`` will be an attribute of the proxy and not an attribute of the " "referent:" msgstr "" -#: ../../library/multiprocessing.rst:1948 +#: ../../library/multiprocessing.rst:1993 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -2876,18 +2951,18 @@ msgid "" "Namespace(x=10, y='hello')" msgstr "" -#: ../../library/multiprocessing.rst:1961 +#: ../../library/multiprocessing.rst:2006 msgid "Customized managers" msgstr "" -#: ../../library/multiprocessing.rst:1963 +#: ../../library/multiprocessing.rst:2008 msgid "" "To create one's own manager, one creates a subclass of :class:`BaseManager` " "and uses the :meth:`~BaseManager.register` classmethod to register new types " "or callables with the manager class. For example::" msgstr "" -#: ../../library/multiprocessing.rst:1967 +#: ../../library/multiprocessing.rst:2012 msgid "" "from multiprocessing.managers import BaseManager\n" "\n" @@ -2927,23 +3002,23 @@ msgstr "" " print(maths.add(4, 3)) # 印出 7\n" " print(maths.mul(7, 8)) # 印出 56" -#: ../../library/multiprocessing.rst:1988 +#: ../../library/multiprocessing.rst:2033 msgid "Using a remote manager" msgstr "" -#: ../../library/multiprocessing.rst:1990 +#: ../../library/multiprocessing.rst:2035 msgid "" "It is possible to run a manager server on one machine and have clients use " "it from other machines (assuming that the firewalls involved allow it)." msgstr "" -#: ../../library/multiprocessing.rst:1993 +#: ../../library/multiprocessing.rst:2038 msgid "" "Running the following commands creates a server for a single shared queue " "which remote clients can access::" msgstr "" -#: ../../library/multiprocessing.rst:1996 +#: ../../library/multiprocessing.rst:2041 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> from queue import Queue\n" @@ -2963,11 +3038,11 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2005 +#: ../../library/multiprocessing.rst:2050 msgid "One client can access the server as follows::" msgstr "" -#: ../../library/multiprocessing.rst:2007 +#: ../../library/multiprocessing.rst:2052 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -2987,11 +3062,11 @@ msgstr "" ">>> queue = m.get_queue()\n" ">>> queue.put('hello')" -#: ../../library/multiprocessing.rst:2015 +#: ../../library/multiprocessing.rst:2060 msgid "Another client can also use it::" msgstr "" -#: ../../library/multiprocessing.rst:2017 +#: ../../library/multiprocessing.rst:2062 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3013,13 +3088,13 @@ msgstr "" ">>> queue.get()\n" "'hello'" -#: ../../library/multiprocessing.rst:2026 +#: ../../library/multiprocessing.rst:2071 msgid "" "Local processes can also access that queue, using the code from above on the " "client to access it remotely::" msgstr "" -#: ../../library/multiprocessing.rst:2029 +#: ../../library/multiprocessing.rst:2074 msgid "" ">>> from multiprocessing import Process, Queue\n" ">>> from multiprocessing.managers import BaseManager\n" @@ -3059,18 +3134,18 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2051 +#: ../../library/multiprocessing.rst:2096 msgid "Proxy Objects" msgstr "" -#: ../../library/multiprocessing.rst:2053 +#: ../../library/multiprocessing.rst:2098 msgid "" "A proxy is an object which *refers* to a shared object which lives " "(presumably) in a different process. The shared object is said to be the " "*referent* of the proxy. Multiple proxy objects may have the same referent." msgstr "" -#: ../../library/multiprocessing.rst:2057 +#: ../../library/multiprocessing.rst:2102 msgid "" "A proxy object has methods which invoke corresponding methods of its " "referent (although not every method of the referent will necessarily be " @@ -3078,7 +3153,7 @@ msgid "" "its referent can:" msgstr "" -#: ../../library/multiprocessing.rst:2061 +#: ../../library/multiprocessing.rst:2106 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3104,14 +3179,14 @@ msgstr "" ">>> l[2:5]\n" "[4, 9, 16]" -#: ../../library/multiprocessing.rst:2075 +#: ../../library/multiprocessing.rst:2120 msgid "" "Notice that applying :func:`str` to a proxy will return the representation " "of the referent, whereas applying :func:`repr` will return the " "representation of the proxy." msgstr "" -#: ../../library/multiprocessing.rst:2079 +#: ../../library/multiprocessing.rst:2124 msgid "" "An important feature of proxy objects is that they are picklable so they can " "be passed between processes. As such, a referent can contain :ref:" @@ -3119,7 +3194,7 @@ msgid "" "lists, dicts, and other :ref:`multiprocessing-proxy_objects`:" msgstr "" -#: ../../library/multiprocessing.rst:2084 +#: ../../library/multiprocessing.rst:2129 msgid "" ">>> a = manager.list()\n" ">>> b = manager.list()\n" @@ -3131,11 +3206,11 @@ msgid "" "['hello'] ['hello']" msgstr "" -#: ../../library/multiprocessing.rst:2095 +#: ../../library/multiprocessing.rst:2140 msgid "Similarly, dict and list proxies may be nested inside one another::" msgstr "" -#: ../../library/multiprocessing.rst:2097 +#: ../../library/multiprocessing.rst:2142 msgid "" ">>> l_outer = manager.list([ manager.dict() for i in range(2) ])\n" ">>> d_first_inner = l_outer[0]\n" @@ -3159,7 +3234,7 @@ msgstr "" ">>> print(l_outer[1])\n" "{'c': 3, 'z': 26}" -#: ../../library/multiprocessing.rst:2108 +#: ../../library/multiprocessing.rst:2153 msgid "" "If standard (non-proxy) :class:`list` or :class:`dict` objects are contained " "in a referent, modifications to those mutable values will not be propagated " @@ -3170,7 +3245,7 @@ msgid "" "assign the modified value to the container proxy::" msgstr "" -#: ../../library/multiprocessing.rst:2116 +#: ../../library/multiprocessing.rst:2161 msgid "" "# create a list proxy and append a mutable object (a dictionary)\n" "lproxy = manager.list()\n" @@ -3184,20 +3259,20 @@ msgid "" "lproxy[0] = d" msgstr "" -#: ../../library/multiprocessing.rst:2127 +#: ../../library/multiprocessing.rst:2172 msgid "" "This approach is perhaps less convenient than employing nested :ref:" "`multiprocessing-proxy_objects` for most use cases but also demonstrates a " "level of control over the synchronization." msgstr "" -#: ../../library/multiprocessing.rst:2133 +#: ../../library/multiprocessing.rst:2178 msgid "" "The proxy types in :mod:`multiprocessing` do nothing to support comparisons " "by value. So, for instance, we have:" msgstr "" -#: ../../library/multiprocessing.rst:2136 +#: ../../library/multiprocessing.rst:2181 msgid "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" @@ -3205,48 +3280,48 @@ msgstr "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" -#: ../../library/multiprocessing.rst:2141 +#: ../../library/multiprocessing.rst:2186 msgid "" "One should just use a copy of the referent instead when making comparisons." msgstr "" -#: ../../library/multiprocessing.rst:2145 +#: ../../library/multiprocessing.rst:2190 msgid "Proxy objects are instances of subclasses of :class:`BaseProxy`." msgstr "" -#: ../../library/multiprocessing.rst:2149 +#: ../../library/multiprocessing.rst:2194 msgid "Call and return the result of a method of the proxy's referent." msgstr "" -#: ../../library/multiprocessing.rst:2151 +#: ../../library/multiprocessing.rst:2196 msgid "" "If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2153 +#: ../../library/multiprocessing.rst:2198 msgid "proxy._callmethod(methodname, args, kwds)" msgstr "proxy._callmethod(methodname, args, kwds)" -#: ../../library/multiprocessing.rst:2155 +#: ../../library/multiprocessing.rst:2200 msgid "will evaluate the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2157 +#: ../../library/multiprocessing.rst:2202 msgid "getattr(obj, methodname)(*args, **kwds)" msgstr "getattr(obj, methodname)(*args, **kwds)" -#: ../../library/multiprocessing.rst:2159 +#: ../../library/multiprocessing.rst:2204 msgid "in the manager's process." msgstr "" -#: ../../library/multiprocessing.rst:2161 +#: ../../library/multiprocessing.rst:2206 msgid "" "The returned value will be a copy of the result of the call or a proxy to a " "new shared object -- see documentation for the *method_to_typeid* argument " "of :meth:`BaseManager.register`." msgstr "" -#: ../../library/multiprocessing.rst:2165 +#: ../../library/multiprocessing.rst:2210 msgid "" "If an exception is raised by the call, then is re-raised by :meth:" "`_callmethod`. If some other exception is raised in the manager's process " @@ -3254,17 +3329,17 @@ msgid "" "meth:`_callmethod`." msgstr "" -#: ../../library/multiprocessing.rst:2170 +#: ../../library/multiprocessing.rst:2215 msgid "" "Note in particular that an exception will be raised if *methodname* has not " "been *exposed*." msgstr "" -#: ../../library/multiprocessing.rst:2173 +#: ../../library/multiprocessing.rst:2218 msgid "An example of the usage of :meth:`_callmethod`:" msgstr "" -#: ../../library/multiprocessing.rst:2175 +#: ../../library/multiprocessing.rst:2220 msgid "" ">>> l = manager.list(range(10))\n" ">>> l._callmethod('__len__')\n" @@ -3286,69 +3361,69 @@ msgstr "" "...\n" "IndexError: list index out of range" -#: ../../library/multiprocessing.rst:2189 +#: ../../library/multiprocessing.rst:2234 msgid "Return a copy of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2191 +#: ../../library/multiprocessing.rst:2236 msgid "If the referent is unpicklable then this will raise an exception." msgstr "" -#: ../../library/multiprocessing.rst:2195 +#: ../../library/multiprocessing.rst:2240 msgid "Return a representation of the proxy object." msgstr "" -#: ../../library/multiprocessing.rst:2199 +#: ../../library/multiprocessing.rst:2244 msgid "Return the representation of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2203 +#: ../../library/multiprocessing.rst:2248 msgid "Cleanup" msgstr "" -#: ../../library/multiprocessing.rst:2205 +#: ../../library/multiprocessing.rst:2250 msgid "" "A proxy object uses a weakref callback so that when it gets garbage " "collected it deregisters itself from the manager which owns its referent." msgstr "" -#: ../../library/multiprocessing.rst:2208 +#: ../../library/multiprocessing.rst:2253 msgid "" "A shared object gets deleted from the manager process when there are no " "longer any proxies referring to it." msgstr "" -#: ../../library/multiprocessing.rst:2213 +#: ../../library/multiprocessing.rst:2258 msgid "Process Pools" msgstr "" -#: ../../library/multiprocessing.rst:2218 +#: ../../library/multiprocessing.rst:2263 msgid "" "One can create a pool of processes which will carry out tasks submitted to " "it with the :class:`Pool` class." msgstr "" -#: ../../library/multiprocessing.rst:2223 +#: ../../library/multiprocessing.rst:2268 msgid "" "A process pool object which controls a pool of worker processes to which " "jobs can be submitted. It supports asynchronous results with timeouts and " "callbacks and has a parallel map implementation." msgstr "" -#: ../../library/multiprocessing.rst:2227 +#: ../../library/multiprocessing.rst:2272 msgid "" "*processes* is the number of worker processes to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2230 -#: ../../library/multiprocessing.rst:2794 +#: ../../library/multiprocessing.rst:2275 +#: ../../library/multiprocessing.rst:2839 msgid "" "If *initializer* is not ``None`` then each worker process will call " "``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:2233 +#: ../../library/multiprocessing.rst:2278 msgid "" "*maxtasksperchild* is the number of tasks a worker process can complete " "before it will exit and be replaced with a fresh worker process, to enable " @@ -3356,7 +3431,7 @@ msgid "" "which means worker processes will live as long as the pool." msgstr "" -#: ../../library/multiprocessing.rst:2238 +#: ../../library/multiprocessing.rst:2283 msgid "" "*context* can be used to specify the context used for starting the worker " "processes. Usually a pool is created using the function :func:" @@ -3364,13 +3439,13 @@ msgid "" "both cases *context* is set appropriately." msgstr "" -#: ../../library/multiprocessing.rst:2244 +#: ../../library/multiprocessing.rst:2289 msgid "" "Note that the methods of the pool object should only be called by the " "process which created the pool." msgstr "" -#: ../../library/multiprocessing.rst:2248 +#: ../../library/multiprocessing.rst:2293 msgid "" ":class:`multiprocessing.pool` objects have internal resources that need to " "be properly managed (like any other resource) by using the pool as a context " @@ -3378,28 +3453,28 @@ msgid "" "to do this can lead to the process hanging on finalization." msgstr "" -#: ../../library/multiprocessing.rst:2253 +#: ../../library/multiprocessing.rst:2298 msgid "" "Note that it is **not correct** to rely on the garbage collector to destroy " "the pool as CPython does not assure that the finalizer of the pool will be " "called (see :meth:`object.__del__` for more information)." msgstr "" -#: ../../library/multiprocessing.rst:2257 +#: ../../library/multiprocessing.rst:2302 msgid "Added the *maxtasksperchild* parameter." msgstr "新增 *maxtasksperchild* 參數。" -#: ../../library/multiprocessing.rst:2260 +#: ../../library/multiprocessing.rst:2305 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/multiprocessing.rst:2263 +#: ../../library/multiprocessing.rst:2308 msgid "" "*processes* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/multiprocessing.rst:2269 +#: ../../library/multiprocessing.rst:2314 msgid "" "Worker processes within a :class:`Pool` typically live for the complete " "duration of the Pool's work queue. A frequent pattern found in other systems " @@ -3410,7 +3485,7 @@ msgid "" "ability to the end user." msgstr "" -#: ../../library/multiprocessing.rst:2279 +#: ../../library/multiprocessing.rst:2324 msgid "" "Call *func* with arguments *args* and keyword arguments *kwds*. It blocks " "until the result is ready. Given this blocks, :meth:`apply_async` is better " @@ -3418,14 +3493,14 @@ msgid "" "executed in one of the workers of the pool." msgstr "" -#: ../../library/multiprocessing.rst:2286 +#: ../../library/multiprocessing.rst:2331 msgid "" "A variant of the :meth:`apply` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2289 -#: ../../library/multiprocessing.rst:2320 +#: ../../library/multiprocessing.rst:2334 +#: ../../library/multiprocessing.rst:2365 msgid "" "If *callback* is specified then it should be a callable which accepts a " "single argument. When the result becomes ready *callback* is applied to it, " @@ -3433,60 +3508,60 @@ msgid "" "applied instead." msgstr "" -#: ../../library/multiprocessing.rst:2294 -#: ../../library/multiprocessing.rst:2325 +#: ../../library/multiprocessing.rst:2339 +#: ../../library/multiprocessing.rst:2370 msgid "" "If *error_callback* is specified then it should be a callable which accepts " "a single argument. If the target function fails, then the *error_callback* " "is called with the exception instance." msgstr "" -#: ../../library/multiprocessing.rst:2298 -#: ../../library/multiprocessing.rst:2329 +#: ../../library/multiprocessing.rst:2343 +#: ../../library/multiprocessing.rst:2374 msgid "" "Callbacks should complete immediately since otherwise the thread which " "handles the results will get blocked." msgstr "" -#: ../../library/multiprocessing.rst:2303 +#: ../../library/multiprocessing.rst:2348 msgid "" "A parallel equivalent of the :func:`map` built-in function (it supports only " "one *iterable* argument though, for multiple iterables see :meth:`starmap`). " "It blocks until the result is ready." msgstr "" -#: ../../library/multiprocessing.rst:2307 +#: ../../library/multiprocessing.rst:2352 msgid "" "This method chops the iterable into a number of chunks which it submits to " "the process pool as separate tasks. The (approximate) size of these chunks " "can be specified by setting *chunksize* to a positive integer." msgstr "" -#: ../../library/multiprocessing.rst:2311 +#: ../../library/multiprocessing.rst:2356 msgid "" "Note that it may cause high memory usage for very long iterables. Consider " "using :meth:`imap` or :meth:`imap_unordered` with explicit *chunksize* " "option for better efficiency." msgstr "" -#: ../../library/multiprocessing.rst:2317 +#: ../../library/multiprocessing.rst:2362 msgid "" "A variant of the :meth:`.map` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2334 +#: ../../library/multiprocessing.rst:2379 msgid "A lazier version of :meth:`.map`." msgstr "" -#: ../../library/multiprocessing.rst:2336 +#: ../../library/multiprocessing.rst:2381 msgid "" "The *chunksize* argument is the same as the one used by the :meth:`.map` " "method. For very long iterables using a large value for *chunksize* can " "make the job complete **much** faster than using the default value of ``1``." msgstr "" -#: ../../library/multiprocessing.rst:2341 +#: ../../library/multiprocessing.rst:2386 msgid "" "Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator " "returned by the :meth:`imap` method has an optional *timeout* parameter: " @@ -3494,65 +3569,65 @@ msgid "" "result cannot be returned within *timeout* seconds." msgstr "" -#: ../../library/multiprocessing.rst:2348 +#: ../../library/multiprocessing.rst:2393 msgid "" "The same as :meth:`imap` except that the ordering of the results from the " "returned iterator should be considered arbitrary. (Only when there is only " "one worker process is the order guaranteed to be \"correct\".)" msgstr "" -#: ../../library/multiprocessing.rst:2354 +#: ../../library/multiprocessing.rst:2399 msgid "" "Like :meth:`~multiprocessing.pool.Pool.map` except that the elements of the " "*iterable* are expected to be iterables that are unpacked as arguments." msgstr "" -#: ../../library/multiprocessing.rst:2358 +#: ../../library/multiprocessing.rst:2403 msgid "" "Hence an *iterable* of ``[(1,2), (3, 4)]`` results in ``[func(1,2), " "func(3,4)]``." msgstr "" -#: ../../library/multiprocessing.rst:2365 +#: ../../library/multiprocessing.rst:2410 msgid "" "A combination of :meth:`starmap` and :meth:`map_async` that iterates over " "*iterable* of iterables and calls *func* with the iterables unpacked. " "Returns a result object." msgstr "" -#: ../../library/multiprocessing.rst:2373 +#: ../../library/multiprocessing.rst:2418 msgid "" "Prevents any more tasks from being submitted to the pool. Once all the " "tasks have been completed the worker processes will exit." msgstr "" -#: ../../library/multiprocessing.rst:2378 +#: ../../library/multiprocessing.rst:2423 msgid "" "Stops the worker processes immediately without completing outstanding work. " "When the pool object is garbage collected :meth:`terminate` will be called " "immediately." msgstr "" -#: ../../library/multiprocessing.rst:2384 +#: ../../library/multiprocessing.rst:2429 msgid "" "Wait for the worker processes to exit. One must call :meth:`close` or :meth:" "`terminate` before using :meth:`join`." msgstr "" -#: ../../library/multiprocessing.rst:2387 +#: ../../library/multiprocessing.rst:2432 msgid "" "Pool objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the pool " "object, and :meth:`~contextmanager.__exit__` calls :meth:`terminate`." msgstr "" -#: ../../library/multiprocessing.rst:2395 +#: ../../library/multiprocessing.rst:2440 msgid "" "The class of the result returned by :meth:`Pool.apply_async` and :meth:`Pool." "map_async`." msgstr "" -#: ../../library/multiprocessing.rst:2400 +#: ../../library/multiprocessing.rst:2445 msgid "" "Return the result when it arrives. If *timeout* is not ``None`` and the " "result does not arrive within *timeout* seconds then :exc:`multiprocessing." @@ -3560,31 +3635,31 @@ msgid "" "exception will be reraised by :meth:`get`." msgstr "" -#: ../../library/multiprocessing.rst:2407 +#: ../../library/multiprocessing.rst:2452 msgid "Wait until the result is available or until *timeout* seconds pass." msgstr "" -#: ../../library/multiprocessing.rst:2411 +#: ../../library/multiprocessing.rst:2456 msgid "Return whether the call has completed." msgstr "" -#: ../../library/multiprocessing.rst:2415 +#: ../../library/multiprocessing.rst:2460 msgid "" "Return whether the call completed without raising an exception. Will raise :" "exc:`ValueError` if the result is not ready." msgstr "" -#: ../../library/multiprocessing.rst:2418 +#: ../../library/multiprocessing.rst:2463 msgid "" "If the result is not ready, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:2422 +#: ../../library/multiprocessing.rst:2467 msgid "The following example demonstrates the use of a pool::" msgstr "" -#: ../../library/multiprocessing.rst:2424 +#: ../../library/multiprocessing.rst:2469 msgid "" "from multiprocessing import Pool\n" "import time\n" @@ -3612,17 +3687,17 @@ msgid "" "TimeoutError" msgstr "" -#: ../../library/multiprocessing.rst:2449 +#: ../../library/multiprocessing.rst:2494 msgid "Listeners and Clients" msgstr "" -#: ../../library/multiprocessing.rst:2454 +#: ../../library/multiprocessing.rst:2499 msgid "" "Usually message passing between processes is done using queues or by using :" "class:`~Connection` objects returned by :func:`~multiprocessing.Pipe`." msgstr "" -#: ../../library/multiprocessing.rst:2458 +#: ../../library/multiprocessing.rst:2503 msgid "" "However, the :mod:`multiprocessing.connection` module allows some extra " "flexibility. It basically gives a high level message oriented API for " @@ -3631,46 +3706,46 @@ msgid "" "multiple connections at the same time." msgstr "" -#: ../../library/multiprocessing.rst:2467 +#: ../../library/multiprocessing.rst:2512 msgid "" "Send a randomly generated message to the other end of the connection and " "wait for a reply." msgstr "" -#: ../../library/multiprocessing.rst:2470 +#: ../../library/multiprocessing.rst:2515 msgid "" "If the reply matches the digest of the message using *authkey* as the key " "then a welcome message is sent to the other end of the connection. " "Otherwise :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2476 +#: ../../library/multiprocessing.rst:2521 msgid "" "Receive a message, calculate the digest of the message using *authkey* as " "the key, and then send the digest back." msgstr "" -#: ../../library/multiprocessing.rst:2479 +#: ../../library/multiprocessing.rst:2524 msgid "" "If a welcome message is not received, then :exc:`~multiprocessing." "AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2484 +#: ../../library/multiprocessing.rst:2529 msgid "" "Attempt to set up a connection to the listener which is using address " "*address*, returning a :class:`~Connection`." msgstr "" -#: ../../library/multiprocessing.rst:2487 +#: ../../library/multiprocessing.rst:2532 msgid "" "The type of the connection is determined by *family* argument, but this can " "generally be omitted since it can usually be inferred from the format of " "*address*. (See :ref:`multiprocessing-address-formats`)" msgstr "" -#: ../../library/multiprocessing.rst:2491 -#: ../../library/multiprocessing.rst:2526 +#: ../../library/multiprocessing.rst:2536 +#: ../../library/multiprocessing.rst:2571 msgid "" "If *authkey* is given and not ``None``, it should be a byte string and will " "be used as the secret key for an HMAC-based authentication challenge. No " @@ -3679,26 +3754,26 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:2499 +#: ../../library/multiprocessing.rst:2544 msgid "" "A wrapper for a bound socket or Windows named pipe which is 'listening' for " "connections." msgstr "" -#: ../../library/multiprocessing.rst:2502 +#: ../../library/multiprocessing.rst:2547 msgid "" "*address* is the address to be used by the bound socket or named pipe of the " "listener object." msgstr "" -#: ../../library/multiprocessing.rst:2507 +#: ../../library/multiprocessing.rst:2552 msgid "" "If an address of '0.0.0.0' is used, the address will not be a connectable " "end point on Windows. If you require a connectable end-point, you should use " "'127.0.0.1'." msgstr "" -#: ../../library/multiprocessing.rst:2511 +#: ../../library/multiprocessing.rst:2556 msgid "" "*family* is the type of socket (or named pipe) to use. This can be one of " "the strings ``'AF_INET'`` (for a TCP socket), ``'AF_UNIX'`` (for a Unix " @@ -3712,49 +3787,49 @@ msgid "" "using :func:`tempfile.mkstemp`." msgstr "" -#: ../../library/multiprocessing.rst:2522 +#: ../../library/multiprocessing.rst:2567 msgid "" "If the listener object uses a socket then *backlog* (1 by default) is passed " "to the :meth:`~socket.socket.listen` method of the socket once it has been " "bound." msgstr "" -#: ../../library/multiprocessing.rst:2534 +#: ../../library/multiprocessing.rst:2579 msgid "" "Accept a connection on the bound socket or named pipe of the listener object " "and return a :class:`~Connection` object. If authentication is attempted and " "fails, then :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2541 +#: ../../library/multiprocessing.rst:2586 msgid "" "Close the bound socket or named pipe of the listener object. This is called " "automatically when the listener is garbage collected. However it is " "advisable to call it explicitly." msgstr "" -#: ../../library/multiprocessing.rst:2545 +#: ../../library/multiprocessing.rst:2590 msgid "Listener objects have the following read-only properties:" msgstr "" -#: ../../library/multiprocessing.rst:2549 +#: ../../library/multiprocessing.rst:2594 msgid "The address which is being used by the Listener object." msgstr "" -#: ../../library/multiprocessing.rst:2553 +#: ../../library/multiprocessing.rst:2598 msgid "" "The address from which the last accepted connection came. If this is " "unavailable then it is ``None``." msgstr "" -#: ../../library/multiprocessing.rst:2556 +#: ../../library/multiprocessing.rst:2601 msgid "" "Listener objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "listener object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:2563 +#: ../../library/multiprocessing.rst:2608 msgid "" "Wait till an object in *object_list* is ready. Returns the list of those " "objects in *object_list* which are ready. If *timeout* is a float then the " @@ -3763,32 +3838,32 @@ msgid "" "zero timeout." msgstr "" -#: ../../library/multiprocessing.rst:2569 +#: ../../library/multiprocessing.rst:2614 msgid "" "For both POSIX and Windows, an object can appear in *object_list* if it is" msgstr "" -#: ../../library/multiprocessing.rst:2572 +#: ../../library/multiprocessing.rst:2617 msgid "a readable :class:`~multiprocessing.connection.Connection` object;" msgstr "" -#: ../../library/multiprocessing.rst:2573 +#: ../../library/multiprocessing.rst:2618 msgid "a connected and readable :class:`socket.socket` object; or" msgstr "" -#: ../../library/multiprocessing.rst:2574 +#: ../../library/multiprocessing.rst:2619 msgid "" "the :attr:`~multiprocessing.Process.sentinel` attribute of a :class:" "`~multiprocessing.Process` object." msgstr "" -#: ../../library/multiprocessing.rst:2577 +#: ../../library/multiprocessing.rst:2622 msgid "" "A connection or socket object is ready when there is data available to be " "read from it, or the other end has been closed." msgstr "" -#: ../../library/multiprocessing.rst:2580 +#: ../../library/multiprocessing.rst:2625 msgid "" "**POSIX**: ``wait(object_list, timeout)`` almost equivalent ``select." "select(object_list, [], [], timeout)``. The difference is that, if :func:" @@ -3796,7 +3871,7 @@ msgid "" "an error number of ``EINTR``, whereas :func:`wait` will not." msgstr "" -#: ../../library/multiprocessing.rst:2586 +#: ../../library/multiprocessing.rst:2631 msgid "" "**Windows**: An item in *object_list* must either be an integer handle which " "is waitable (according to the definition used by the documentation of the " @@ -3806,18 +3881,18 @@ msgid "" "handles.)" msgstr "" -#: ../../library/multiprocessing.rst:2596 +#: ../../library/multiprocessing.rst:2641 msgid "**Examples**" msgstr "" -#: ../../library/multiprocessing.rst:2598 +#: ../../library/multiprocessing.rst:2643 msgid "" "The following server code creates a listener which uses ``'secret " "password'`` as an authentication key. It then waits for a connection and " "sends some data to the client::" msgstr "" -#: ../../library/multiprocessing.rst:2602 +#: ../../library/multiprocessing.rst:2647 msgid "" "from multiprocessing.connection import Listener\n" "from array import array\n" @@ -3835,13 +3910,13 @@ msgid "" " conn.send_bytes(array('i', [42, 1729]))" msgstr "" -#: ../../library/multiprocessing.rst:2617 +#: ../../library/multiprocessing.rst:2662 msgid "" "The following code connects to the server and receives some data from the " "server::" msgstr "" -#: ../../library/multiprocessing.rst:2620 +#: ../../library/multiprocessing.rst:2665 msgid "" "from multiprocessing.connection import Client\n" "from array import array\n" @@ -3871,13 +3946,13 @@ msgstr "" " print(conn.recv_bytes_into(arr)) # => 8\n" " print(arr) # => array('i', [42, 1729, 0, 0, 0])" -#: ../../library/multiprocessing.rst:2634 +#: ../../library/multiprocessing.rst:2679 msgid "" "The following code uses :func:`~multiprocessing.connection.wait` to wait for " "messages from multiple processes at once::" msgstr "" -#: ../../library/multiprocessing.rst:2637 +#: ../../library/multiprocessing.rst:2682 msgid "" "from multiprocessing import Process, Pipe, current_process\n" "from multiprocessing.connection import wait\n" @@ -3911,23 +3986,23 @@ msgid "" " print(msg)" msgstr "" -#: ../../library/multiprocessing.rst:2672 +#: ../../library/multiprocessing.rst:2717 msgid "Address Formats" msgstr "" -#: ../../library/multiprocessing.rst:2674 +#: ../../library/multiprocessing.rst:2719 msgid "" "An ``'AF_INET'`` address is a tuple of the form ``(hostname, port)`` where " "*hostname* is a string and *port* is an integer." msgstr "" -#: ../../library/multiprocessing.rst:2677 +#: ../../library/multiprocessing.rst:2722 msgid "" "An ``'AF_UNIX'`` address is a string representing a filename on the " "filesystem." msgstr "" -#: ../../library/multiprocessing.rst:2680 +#: ../../library/multiprocessing.rst:2725 msgid "" "An ``'AF_PIPE'`` address is a string of the form :samp:`r'\\\\\\\\\\\\.\\" "\\pipe\\\\\\\\{PipeName}'`. To use :func:`Client` to connect to a named " @@ -3936,17 +4011,17 @@ msgid "" "instead." msgstr "" -#: ../../library/multiprocessing.rst:2685 +#: ../../library/multiprocessing.rst:2730 msgid "" "Note that any string beginning with two backslashes is assumed by default to " "be an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address." msgstr "" -#: ../../library/multiprocessing.rst:2692 +#: ../../library/multiprocessing.rst:2737 msgid "Authentication keys" msgstr "" -#: ../../library/multiprocessing.rst:2694 +#: ../../library/multiprocessing.rst:2739 msgid "" "When one uses :meth:`Connection.recv `, the data received " "is automatically unpickled. Unfortunately unpickling data from an untrusted " @@ -3954,7 +4029,7 @@ msgid "" "use the :mod:`hmac` module to provide digest authentication." msgstr "" -#: ../../library/multiprocessing.rst:2700 +#: ../../library/multiprocessing.rst:2745 msgid "" "An authentication key is a byte string which can be thought of as a " "password: once a connection is established both ends will demand proof that " @@ -3962,7 +4037,7 @@ msgid "" "using the same key does **not** involve sending the key over the connection.)" msgstr "" -#: ../../library/multiprocessing.rst:2706 +#: ../../library/multiprocessing.rst:2751 msgid "" "If authentication is requested but no authentication key is specified then " "the return value of ``current_process().authkey`` is used (see :class:" @@ -3973,17 +4048,17 @@ msgid "" "setting up connections between themselves." msgstr "" -#: ../../library/multiprocessing.rst:2714 +#: ../../library/multiprocessing.rst:2759 msgid "" "Suitable authentication keys can also be generated by using :func:`os." "urandom`." msgstr "" -#: ../../library/multiprocessing.rst:2718 +#: ../../library/multiprocessing.rst:2763 msgid "Logging" msgstr "" -#: ../../library/multiprocessing.rst:2720 +#: ../../library/multiprocessing.rst:2765 msgid "" "Some support for logging is available. Note, however, that the :mod:" "`logging` package does not use process shared locks so it is possible " @@ -3991,27 +4066,27 @@ msgid "" "mixed up." msgstr "" -#: ../../library/multiprocessing.rst:2727 +#: ../../library/multiprocessing.rst:2772 msgid "" "Returns the logger used by :mod:`multiprocessing`. If necessary, a new one " "will be created." msgstr "" -#: ../../library/multiprocessing.rst:2730 +#: ../../library/multiprocessing.rst:2775 msgid "" "When first created the logger has level :const:`logging.NOTSET` and no " "default handler. Messages sent to this logger will not by default propagate " "to the root logger." msgstr "" -#: ../../library/multiprocessing.rst:2734 +#: ../../library/multiprocessing.rst:2779 msgid "" "Note that on Windows child processes will only inherit the level of the " "parent process's logger -- any other customization of the logger will not be " "inherited." msgstr "" -#: ../../library/multiprocessing.rst:2741 +#: ../../library/multiprocessing.rst:2786 msgid "" "This function performs a call to :func:`get_logger` but in addition to " "returning the logger created by get_logger, it adds a handler which sends " @@ -4020,11 +4095,11 @@ msgid "" "``level`` argument." msgstr "" -#: ../../library/multiprocessing.rst:2747 +#: ../../library/multiprocessing.rst:2792 msgid "Below is an example session with logging turned on::" msgstr "" -#: ../../library/multiprocessing.rst:2749 +#: ../../library/multiprocessing.rst:2794 msgid "" ">>> import multiprocessing, logging\n" ">>> logger = multiprocessing.log_to_stderr()\n" @@ -4052,21 +4127,21 @@ msgstr "" "[INFO/MainProcess] sending shutdown message to manager\n" "[INFO/SyncManager-...] manager exiting with exitcode 0" -#: ../../library/multiprocessing.rst:2762 +#: ../../library/multiprocessing.rst:2807 msgid "For a full table of logging levels, see the :mod:`logging` module." msgstr "" -#: ../../library/multiprocessing.rst:2766 +#: ../../library/multiprocessing.rst:2811 msgid "The :mod:`multiprocessing.dummy` module" msgstr ":mod:`multiprocessing.dummy` 模組" -#: ../../library/multiprocessing.rst:2771 +#: ../../library/multiprocessing.rst:2816 msgid "" ":mod:`multiprocessing.dummy` replicates the API of :mod:`multiprocessing` " "but is no more than a wrapper around the :mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:2776 +#: ../../library/multiprocessing.rst:2821 msgid "" "In particular, the ``Pool`` function provided by :mod:`multiprocessing." "dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :" @@ -4074,7 +4149,7 @@ msgid "" "worker threads rather than worker processes." msgstr "" -#: ../../library/multiprocessing.rst:2784 +#: ../../library/multiprocessing.rst:2829 msgid "" "A thread pool object which controls a pool of worker threads to which jobs " "can be submitted. :class:`ThreadPool` instances are fully interface " @@ -4084,18 +4159,18 @@ msgid "" "pool.Pool.terminate` manually." msgstr "" -#: ../../library/multiprocessing.rst:2791 +#: ../../library/multiprocessing.rst:2836 msgid "" "*processes* is the number of worker threads to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2797 +#: ../../library/multiprocessing.rst:2842 msgid "" "Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided." msgstr "" -#: ../../library/multiprocessing.rst:2801 +#: ../../library/multiprocessing.rst:2846 msgid "" "A :class:`ThreadPool` shares the same interface as :class:`Pool`, which is " "designed around a pool of processes and predates the introduction of the :" @@ -4105,7 +4180,7 @@ msgid "" "is not understood by any other libraries." msgstr "" -#: ../../library/multiprocessing.rst:2808 +#: ../../library/multiprocessing.rst:2853 msgid "" "Users should generally prefer to use :class:`concurrent.futures." "ThreadPoolExecutor`, which has a simpler interface that was designed around " @@ -4114,69 +4189,69 @@ msgid "" "`asyncio`." msgstr "" -#: ../../library/multiprocessing.rst:2818 +#: ../../library/multiprocessing.rst:2863 msgid "Programming guidelines" msgstr "" -#: ../../library/multiprocessing.rst:2820 +#: ../../library/multiprocessing.rst:2865 msgid "" "There are certain guidelines and idioms which should be adhered to when " "using :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:2825 +#: ../../library/multiprocessing.rst:2870 msgid "All start methods" msgstr "" -#: ../../library/multiprocessing.rst:2827 +#: ../../library/multiprocessing.rst:2872 msgid "The following applies to all start methods." msgstr "" -#: ../../library/multiprocessing.rst:2829 +#: ../../library/multiprocessing.rst:2874 msgid "Avoid shared state" msgstr "" -#: ../../library/multiprocessing.rst:2831 +#: ../../library/multiprocessing.rst:2876 msgid "" "As far as possible one should try to avoid shifting large amounts of data " "between processes." msgstr "" -#: ../../library/multiprocessing.rst:2834 +#: ../../library/multiprocessing.rst:2879 msgid "" "It is probably best to stick to using queues or pipes for communication " "between processes rather than using the lower level synchronization " "primitives." msgstr "" -#: ../../library/multiprocessing.rst:2838 +#: ../../library/multiprocessing.rst:2883 msgid "Picklability" msgstr "" -#: ../../library/multiprocessing.rst:2840 +#: ../../library/multiprocessing.rst:2885 msgid "Ensure that the arguments to the methods of proxies are picklable." msgstr "" -#: ../../library/multiprocessing.rst:2842 +#: ../../library/multiprocessing.rst:2887 msgid "Thread safety of proxies" msgstr "" -#: ../../library/multiprocessing.rst:2844 +#: ../../library/multiprocessing.rst:2889 msgid "" "Do not use a proxy object from more than one thread unless you protect it " "with a lock." msgstr "" -#: ../../library/multiprocessing.rst:2847 +#: ../../library/multiprocessing.rst:2892 msgid "" "(There is never a problem with different processes using the *same* proxy.)" msgstr "" -#: ../../library/multiprocessing.rst:2849 +#: ../../library/multiprocessing.rst:2894 msgid "Joining zombie processes" msgstr "" -#: ../../library/multiprocessing.rst:2851 +#: ../../library/multiprocessing.rst:2896 msgid "" "On POSIX when a process finishes but has not been joined it becomes a " "zombie. There should never be very many because each time a new process " @@ -4187,11 +4262,11 @@ msgid "" "explicitly join all the processes that you start." msgstr "" -#: ../../library/multiprocessing.rst:2859 +#: ../../library/multiprocessing.rst:2904 msgid "Better to inherit than pickle/unpickle" msgstr "" -#: ../../library/multiprocessing.rst:2861 +#: ../../library/multiprocessing.rst:2906 msgid "" "When using the *spawn* or *forkserver* start methods many types from :mod:" "`multiprocessing` need to be picklable so that child processes can use " @@ -4201,11 +4276,11 @@ msgid "" "inherit it from an ancestor process." msgstr "" -#: ../../library/multiprocessing.rst:2869 +#: ../../library/multiprocessing.rst:2914 msgid "Avoid terminating processes" msgstr "" -#: ../../library/multiprocessing.rst:2871 +#: ../../library/multiprocessing.rst:2916 msgid "" "Using the :meth:`Process.terminate ` " "method to stop a process is liable to cause any shared resources (such as " @@ -4213,18 +4288,18 @@ msgid "" "become broken or unavailable to other processes." msgstr "" -#: ../../library/multiprocessing.rst:2877 +#: ../../library/multiprocessing.rst:2922 msgid "" "Therefore it is probably best to only consider using :meth:`Process." "terminate ` on processes which never use " "any shared resources." msgstr "" -#: ../../library/multiprocessing.rst:2881 +#: ../../library/multiprocessing.rst:2926 msgid "Joining processes that use queues" msgstr "" -#: ../../library/multiprocessing.rst:2883 +#: ../../library/multiprocessing.rst:2928 msgid "" "Bear in mind that a process that has put items in a queue will wait before " "terminating until all the buffered items are fed by the \"feeder\" thread to " @@ -4233,7 +4308,7 @@ msgid "" "queue to avoid this behaviour.)" msgstr "" -#: ../../library/multiprocessing.rst:2889 +#: ../../library/multiprocessing.rst:2934 msgid "" "This means that whenever you use a queue you need to make sure that all " "items which have been put on the queue will eventually be removed before the " @@ -4242,11 +4317,11 @@ msgid "" "processes will be joined automatically." msgstr "" -#: ../../library/multiprocessing.rst:2895 +#: ../../library/multiprocessing.rst:2940 msgid "An example which will deadlock is the following::" msgstr "" -#: ../../library/multiprocessing.rst:2897 +#: ../../library/multiprocessing.rst:2942 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -4261,17 +4336,17 @@ msgid "" " obj = queue.get()" msgstr "" -#: ../../library/multiprocessing.rst:2909 +#: ../../library/multiprocessing.rst:2954 msgid "" "A fix here would be to swap the last two lines (or simply remove the ``p." "join()`` line)." msgstr "" -#: ../../library/multiprocessing.rst:2912 +#: ../../library/multiprocessing.rst:2957 msgid "Explicitly pass resources to child processes" msgstr "" -#: ../../library/multiprocessing.rst:2914 +#: ../../library/multiprocessing.rst:2959 msgid "" "On POSIX using the *fork* start method, a child process can make use of a " "shared resource created in a parent process using a global resource. " @@ -4279,7 +4354,7 @@ msgid "" "for the child process." msgstr "" -#: ../../library/multiprocessing.rst:2919 +#: ../../library/multiprocessing.rst:2964 msgid "" "Apart from making the code (potentially) compatible with Windows and the " "other start methods this also ensures that as long as the child process is " @@ -4288,11 +4363,11 @@ msgid "" "collected in the parent process." msgstr "" -#: ../../library/multiprocessing.rst:2926 +#: ../../library/multiprocessing.rst:2971 msgid "So for instance ::" msgstr "" -#: ../../library/multiprocessing.rst:2928 +#: ../../library/multiprocessing.rst:2973 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4314,11 +4389,11 @@ msgstr "" " for i in range(10):\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:2938 +#: ../../library/multiprocessing.rst:2983 msgid "should be rewritten as ::" msgstr "" -#: ../../library/multiprocessing.rst:2940 +#: ../../library/multiprocessing.rst:2985 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4340,25 +4415,25 @@ msgstr "" " for i in range(10):\n" " Process(target=f, args=(lock,)).start()" -#: ../../library/multiprocessing.rst:2950 +#: ../../library/multiprocessing.rst:2995 msgid "Beware of replacing :data:`sys.stdin` with a \"file like object\"" msgstr "" -#: ../../library/multiprocessing.rst:2952 +#: ../../library/multiprocessing.rst:2997 msgid ":mod:`multiprocessing` originally unconditionally called::" msgstr "" -#: ../../library/multiprocessing.rst:2954 +#: ../../library/multiprocessing.rst:2999 msgid "os.close(sys.stdin.fileno())" msgstr "os.close(sys.stdin.fileno())" -#: ../../library/multiprocessing.rst:2956 +#: ../../library/multiprocessing.rst:3001 msgid "" "in the :meth:`multiprocessing.Process._bootstrap` method --- this resulted " "in issues with processes-in-processes. This has been changed to::" msgstr "" -#: ../../library/multiprocessing.rst:2959 +#: ../../library/multiprocessing.rst:3004 msgid "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" @@ -4366,7 +4441,7 @@ msgstr "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" -#: ../../library/multiprocessing.rst:2962 +#: ../../library/multiprocessing.rst:3007 msgid "" "Which solves the fundamental issue of processes colliding with each other " "resulting in a bad file descriptor error, but introduces a potential danger " @@ -4376,14 +4451,14 @@ msgid "" "data being flushed to the object multiple times, resulting in corruption." msgstr "" -#: ../../library/multiprocessing.rst:2969 +#: ../../library/multiprocessing.rst:3014 msgid "" "If you write a file-like object and implement your own caching, you can make " "it fork-safe by storing the pid whenever you append to the cache, and " "discarding the cache when the pid changes. For example::" msgstr "" -#: ../../library/multiprocessing.rst:2973 +#: ../../library/multiprocessing.rst:3018 msgid "" "@property\n" "def cache(self):\n" @@ -4401,38 +4476,38 @@ msgstr "" " self._cache = []\n" " return self._cache" -#: ../../library/multiprocessing.rst:2981 +#: ../../library/multiprocessing.rst:3026 msgid "" "For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`" msgstr "" -#: ../../library/multiprocessing.rst:2984 +#: ../../library/multiprocessing.rst:3029 msgid "The *spawn* and *forkserver* start methods" msgstr "" -#: ../../library/multiprocessing.rst:2986 +#: ../../library/multiprocessing.rst:3031 msgid "" "There are a few extra restrictions which don't apply to the *fork* start " "method." msgstr "" -#: ../../library/multiprocessing.rst:2989 +#: ../../library/multiprocessing.rst:3034 msgid "More picklability" msgstr "" -#: ../../library/multiprocessing.rst:2991 +#: ../../library/multiprocessing.rst:3036 msgid "" -"Ensure that all arguments to :meth:`Process.__init__` are picklable. Also, " -"if you subclass :class:`~multiprocessing.Process` then make sure that " -"instances will be picklable when the :meth:`Process.start ` method is called." +"Ensure that all arguments to :class:`~multiprocessing.Process` are " +"picklable. Also, if you subclass ``Process.__init__``, you must make sure " +"that instances will be picklable when the :meth:`Process.start " +"` method is called." msgstr "" -#: ../../library/multiprocessing.rst:2996 +#: ../../library/multiprocessing.rst:3041 msgid "Global variables" msgstr "" -#: ../../library/multiprocessing.rst:2998 +#: ../../library/multiprocessing.rst:3043 msgid "" "Bear in mind that if code run in a child process tries to access a global " "variable, then the value it sees (if any) may not be the same as the value " @@ -4440,30 +4515,30 @@ msgid "" "Process.start>` was called." msgstr "" -#: ../../library/multiprocessing.rst:3003 +#: ../../library/multiprocessing.rst:3048 msgid "" "However, global variables which are just module level constants cause no " "problems." msgstr "" -#: ../../library/multiprocessing.rst:3008 +#: ../../library/multiprocessing.rst:3053 msgid "Safe importing of main module" msgstr "" -#: ../../library/multiprocessing.rst:3010 +#: ../../library/multiprocessing.rst:3055 msgid "" "Make sure that the main module can be safely imported by a new Python " "interpreter without causing unintended side effects (such as starting a new " "process)." msgstr "" -#: ../../library/multiprocessing.rst:3014 +#: ../../library/multiprocessing.rst:3059 msgid "" "For example, using the *spawn* or *forkserver* start method running the " "following module would fail with a :exc:`RuntimeError`::" msgstr "" -#: ../../library/multiprocessing.rst:3018 +#: ../../library/multiprocessing.rst:3063 msgid "" "from multiprocessing import Process\n" "\n" @@ -4481,13 +4556,13 @@ msgstr "" "p = Process(target=foo)\n" "p.start()" -#: ../../library/multiprocessing.rst:3026 +#: ../../library/multiprocessing.rst:3071 msgid "" "Instead one should protect the \"entry point\" of the program by using ``if " "__name__ == '__main__':`` as follows::" msgstr "" -#: ../../library/multiprocessing.rst:3029 +#: ../../library/multiprocessing.rst:3074 msgid "" "from multiprocessing import Process, freeze_support, set_start_method\n" "\n" @@ -4511,33 +4586,33 @@ msgstr "" " p = Process(target=foo)\n" " p.start()" -#: ../../library/multiprocessing.rst:3040 +#: ../../library/multiprocessing.rst:3085 msgid "" "(The ``freeze_support()`` line can be omitted if the program will be run " "normally instead of frozen.)" msgstr "" -#: ../../library/multiprocessing.rst:3043 +#: ../../library/multiprocessing.rst:3088 msgid "" "This allows the newly spawned Python interpreter to safely import the module " "and then run the module's ``foo()`` function." msgstr "" -#: ../../library/multiprocessing.rst:3046 +#: ../../library/multiprocessing.rst:3091 msgid "" "Similar restrictions apply if a pool or manager is created in the main " "module." msgstr "" -#: ../../library/multiprocessing.rst:3053 +#: ../../library/multiprocessing.rst:3098 msgid "Examples" msgstr "範例" -#: ../../library/multiprocessing.rst:3055 +#: ../../library/multiprocessing.rst:3100 msgid "Demonstration of how to create and use customized managers and proxies:" msgstr "" -#: ../../library/multiprocessing.rst:3057 +#: ../../library/multiprocessing.rst:3102 msgid "" "from multiprocessing import freeze_support\n" "from multiprocessing.managers import BaseManager, BaseProxy\n" @@ -4631,11 +4706,11 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3061 +#: ../../library/multiprocessing.rst:3106 msgid "Using :class:`~multiprocessing.pool.Pool`:" msgstr "使用 :class:`~multiprocessing.pool.Pool`:" -#: ../../library/multiprocessing.rst:3063 +#: ../../library/multiprocessing.rst:3108 msgid "" "import multiprocessing\n" "import time\n" @@ -4795,13 +4870,13 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3067 +#: ../../library/multiprocessing.rst:3112 msgid "" "An example showing how to use queues to feed tasks to a collection of worker " "processes and collect the results:" msgstr "" -#: ../../library/multiprocessing.rst:3070 +#: ../../library/multiprocessing.rst:3115 msgid "" "import time\n" "import random\n" diff --git a/library/queue.po b/library/queue.po index 601d813016..ba0d4abd76 100644 --- a/library/queue.po +++ b/library/queue.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-07-26 00:17+0000\n" "PO-Revision-Date: 2022-09-27 00:12+0800\n" "Last-Translator: Allen Wu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -175,13 +175,12 @@ msgstr "" "meth:`~Queue.put_nowait`\\ )將引發此例外。" #: ../../library/queue.rst:98 -#, fuzzy msgid "" "Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is called on " "a :class:`Queue` object which has been shut down." msgstr "" -"當對一個空的 :class:`Queue` 物件呼叫非阻塞的 (non-blocking) :meth:`~Queue." -"get`\\ (或 :meth:`~Queue.get_nowait`\\ )將引發此例外。" +"當對一個已關閉的 :class:`Queue` 物件呼叫 :meth:`~Queue.put` 或 :meth:`~Queue.get` " +"時將引發此例外。" #: ../../library/queue.rst:107 msgid "Queue Objects" @@ -244,13 +243,13 @@ msgstr "" #: ../../library/queue.rst:146 msgid "Raises :exc:`ShutDown` if the queue has been shut down." -msgstr "" +msgstr "如果佇列已被關閉,則引發 :exc:`ShutDown`。" #: ../../library/queue.rst:151 msgid "Equivalent to ``put(item, block=False)``." msgstr "等效於 ``put(item, block=False)``。" -#: ../../library/queue.rst:156 ../../library/queue.rst:297 +#: ../../library/queue.rst:156 ../../library/queue.rst:314 msgid "" "Remove and return an item from the queue. If optional args *block* is true " "and *timeout* is ``None`` (the default), block if necessary until an item is " @@ -283,8 +282,9 @@ msgid "" "Raises :exc:`ShutDown` if the queue has been shut down and is empty, or if " "the queue has been shut down immediately." msgstr "" +"如果佇列已被關閉且為空,或佇列已立即關閉,則引發 :exc:`ShutDown`。" -#: ../../library/queue.rst:174 ../../library/queue.rst:307 +#: ../../library/queue.rst:174 ../../library/queue.rst:324 msgid "Equivalent to ``get(False)``." msgstr "等效於 ``get(False)``。" @@ -316,21 +316,15 @@ msgstr "" #: ../../library/queue.rst:190 msgid "" -"``shutdown(immediate=True)`` calls :meth:`task_done` for each remaining item " -"in the queue." -msgstr "" - -#: ../../library/queue.rst:193 -msgid "" "Raises a :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "如果呼叫次數超過佇列中放置的項目數量,則引發 :exc:`ValueError`。" -#: ../../library/queue.rst:199 +#: ../../library/queue.rst:196 msgid "Blocks until all items in the queue have been gotten and processed." msgstr "持續阻塞直到佇列中的所有項目都已被取得並處理完畢。" -#: ../../library/queue.rst:201 +#: ../../library/queue.rst:198 msgid "" "The count of unfinished tasks goes up whenever an item is added to the " "queue. The count goes down whenever a consumer thread calls :meth:" @@ -342,6 +336,10 @@ msgstr "" "`task_done` 以指示該項目已被取出並且對其的所有工作都已完成時,計數就會下降。" "當未完成任務的計數降至零時,:meth:`join` 將停止阻塞。" +#: ../../library/queue.rst:205 +msgid "Waiting for task completion" +msgstr "" + #: ../../library/queue.rst:207 msgid "Example of how to wait for enqueued tasks to be completed::" msgstr "如何等待放入佇列的任務完成的範例: ::" @@ -378,48 +376,72 @@ msgstr "" #: ../../library/queue.rst:236 msgid "" -":class:`Queue` objects can be made to prevent further interaction by " -"shutting them down." +"When no longer needed, :class:`Queue` objects can be wound down until empty " +"or terminated immediately with a hard shutdown." msgstr "" #: ../../library/queue.rst:241 -msgid "" -"Shut down the queue, making :meth:`~Queue.get` and :meth:`~Queue.put` raise :" -"exc:`ShutDown`." +msgid "Put a :class:`Queue` instance into a shutdown mode." msgstr "" -#: ../../library/queue.rst:244 +#: ../../library/queue.rst:243 msgid "" -"By default, :meth:`~Queue.get` on a shut down queue will only raise once the " -"queue is empty. Set *immediate* to true to make :meth:`~Queue.get` raise " -"immediately instead." +"The queue can no longer grow. Future calls to :meth:`~Queue.put` raise :exc:" +"`ShutDown`. Currently blocked callers of :meth:`~Queue.put` will be " +"unblocked and will raise :exc:`ShutDown` in the formerly blocked thread." msgstr "" #: ../../library/queue.rst:248 msgid "" -"All blocked callers of :meth:`~Queue.put` and :meth:`~Queue.get` will be " -"unblocked. If *immediate* is true, a task will be marked as done for each " -"remaining item in the queue, which may unblock callers of :meth:`~Queue." -"join`." +"If *immediate* is false (the default), the queue can be wound down normally " +"with :meth:`~Queue.get` calls to extract tasks that have already been loaded." +msgstr "" + +#: ../../library/queue.rst:252 +msgid "" +"And if :meth:`~Queue.task_done` is called for each remaining task, a " +"pending :meth:`~Queue.join` will be unblocked normally." +msgstr "" + +#: ../../library/queue.rst:255 +msgid "" +"Once the queue is empty, future calls to :meth:`~Queue.get` will raise :exc:" +"`ShutDown`." +msgstr "" + +#: ../../library/queue.rst:258 +msgid "" +"If *immediate* is true, the queue is terminated immediately. The queue is " +"drained to be completely empty and the count of unfinished tasks is reduced " +"by the number of tasks drained. If unfinished tasks is zero, callers of :" +"meth:`~Queue.join` are unblocked. Also, blocked callers of :meth:`~Queue." +"get` are unblocked and will raise :exc:`ShutDown` because the queue is empty." +msgstr "" + +#: ../../library/queue.rst:266 +msgid "" +"Use caution when using :meth:`~Queue.join` with *immediate* set to true. " +"This unblocks the join even when no work has been done on the tasks, " +"violating the usual invariant for joining a queue." msgstr "" -#: ../../library/queue.rst:257 +#: ../../library/queue.rst:274 msgid "SimpleQueue Objects" msgstr "SimpleQueue 物件" -#: ../../library/queue.rst:259 +#: ../../library/queue.rst:276 msgid "" ":class:`SimpleQueue` objects provide the public methods described below." msgstr ":class:`SimpleQueue` 物件提供下面描述的公用 method。" -#: ../../library/queue.rst:263 +#: ../../library/queue.rst:280 msgid "" "Return the approximate size of the queue. Note, qsize() > 0 doesn't " "guarantee that a subsequent get() will not block." msgstr "" "傳回佇列的近似大小。注意,qsize() > 0 並不能保證後續的 get() 不會阻塞。" -#: ../../library/queue.rst:269 +#: ../../library/queue.rst:286 msgid "" "Return ``True`` if the queue is empty, ``False`` otherwise. If empty() " "returns ``False`` it doesn't guarantee that a subsequent call to get() will " @@ -428,7 +450,7 @@ msgstr "" "如果佇列為空,則回傳 ``True``,否則回傳 ``False``。如果 empty() 回傳 " "``False``,則不保證後續呼叫 get() 不會阻塞。" -#: ../../library/queue.rst:276 +#: ../../library/queue.rst:293 msgid "" "Put *item* into the queue. The method never blocks and always succeeds " "(except for potential low-level errors such as failure to allocate memory). " @@ -439,7 +461,7 @@ msgstr "" "像是分配記憶體失敗)。可選的 args *block* 和 *timeout* 會被忽略,它們僅是為了" "與 :meth:`Queue.put` 相容才存在。" -#: ../../library/queue.rst:282 +#: ../../library/queue.rst:299 msgid "" "This method has a C implementation which is reentrant. That is, a ``put()`` " "or ``get()`` call can be interrupted by another ``put()`` call in the same " @@ -452,18 +474,18 @@ msgstr "" "鎖 (deadlock) 或損壞佇列中的內部狀態。這使得它適合在解構子 (destructor) 中使" "用,像是 ``__del__`` method 或 :mod:`weakref` 回呼函式 (callback)。" -#: ../../library/queue.rst:291 +#: ../../library/queue.rst:308 msgid "" "Equivalent to ``put(item, block=False)``, provided for compatibility with :" "meth:`Queue.put_nowait`." msgstr "" "等效於 ``put(item, block=False)``,用於與 :meth:`Queue.put_nowait` 相容。" -#: ../../library/queue.rst:312 +#: ../../library/queue.rst:329 msgid "Class :class:`multiprocessing.Queue`" msgstr "Class :class:`multiprocessing.Queue`" -#: ../../library/queue.rst:313 +#: ../../library/queue.rst:330 msgid "" "A queue class for use in a multi-processing (rather than multi-threading) " "context." @@ -471,7 +493,7 @@ msgstr "" "用於多行程處理 (multi-processing)(而非多執行緒)情境 (context) 的佇列 " "class。" -#: ../../library/queue.rst:316 +#: ../../library/queue.rst:333 msgid "" ":class:`collections.deque` is an alternative implementation of unbounded " "queues with fast atomic :meth:`~collections.deque.append` and :meth:" diff --git a/library/sys.monitoring.po b/library/sys.monitoring.po index ff8a42a082..357c7407c4 100644 --- a/library/sys.monitoring.po +++ b/library/sys.monitoring.po @@ -6,7 +6,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-07-18 00:17+0000\n" "PO-Revision-Date: 2024-10-21 17:51+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,8 +27,8 @@ msgid "" "``import sys`` and then use ``sys.monitoring``." msgstr "" ":mod:`sys.monitoring` 是 :mod:`sys` 模組內的一個命名空間,不是一個獨立的模" -"組,所以不需要 ``import sys.monitoring``,只需 ``import sys`` 然後使用 " -"``sys.monitoring``。" +"組,所以不需要 ``import sys.monitoring``,只需 ``import sys`` 然後使用 ``sys." +"monitoring``。" #: ../../library/sys.monitoring.rst:19 msgid "" @@ -221,8 +221,8 @@ msgstr "" #: ../../library/sys.monitoring.rst:142 msgid "" -"An exception is raised, except those that cause a :monitoring-" -"event:`STOP_ITERATION` event." +"An exception is raised, except those that cause a :monitoring-event:" +"`STOP_ITERATION` event." msgstr "" "例外被引發,除了那些會導致 :monitoring-event:`STOP_ITERATION` 的事件外。" @@ -347,14 +347,14 @@ msgstr ":monitoring-event:`C_RETURN`" #: ../../library/sys.monitoring.rst:199 msgid "" "The :monitoring-event:`C_RETURN` and :monitoring-event:`C_RAISE` events are " -"controlled by the :monitoring-event:`CALL` event. :monitoring-" -"event:`C_RETURN` and :monitoring-event:`C_RAISE` events will only be seen if " -"the corresponding :monitoring-event:`CALL` event is being monitored." +"controlled by the :monitoring-event:`CALL` event. :monitoring-event:" +"`C_RETURN` and :monitoring-event:`C_RAISE` events will only be seen if the " +"corresponding :monitoring-event:`CALL` event is being monitored." msgstr "" -":monitoring-event:`C_RETURN` 和 :monitoring-event:`C_RAISE` 事件" -"由 :monitoring-event:`CALL` 事件控制。只有當對應的 :monitoring-event:`CALL` " -"事件受到監控時,才會看到 :monitoring-event:`C_RETURN` 和 :monitoring-" -"event:`C_RAISE` 事件。" +":monitoring-event:`C_RETURN` 和 :monitoring-event:`C_RAISE` 事件由 :" +"monitoring-event:`CALL` 事件控制。只有當對應的 :monitoring-event:`CALL` 事件" +"受到監控時,才會看到 :monitoring-event:`C_RETURN` 和 :monitoring-event:" +"`C_RAISE` 事件。" #: ../../library/sys.monitoring.rst:205 msgid "Other events" @@ -392,8 +392,8 @@ msgstr "STOP_ITERATION 事件" #: ../../library/sys.monitoring.rst:221 msgid "" -":pep:`PEP 380 <380#use-of-stopiteration-to-return-values>` specifies that " -"a :exc:`StopIteration` exception is raised when returning a value from a " +":pep:`PEP 380 <380#use-of-stopiteration-to-return-values>` specifies that a :" +"exc:`StopIteration` exception is raised when returning a value from a " "generator or coroutine. However, this is a very inefficient way to return a " "value, so some Python implementations, notably CPython 3.12+, do not raise " "an exception unless it would be visible to other code." @@ -443,11 +443,11 @@ msgstr "回傳代表所有有效事件的 ``int``。" #: ../../library/sys.monitoring.rst:252 msgid "" -"Activates all events which are set in *event_set*. Raises " -"a :exc:`ValueError` if *tool_id* is not in use." +"Activates all events which are set in *event_set*. Raises a :exc:" +"`ValueError` if *tool_id* is not in use." msgstr "" -"啟動 *event_set* 中設定的所有事件。如果 *tool_id* 並未正在被使用,則引" -"發 :exc:`ValueError`。" +"啟動 *event_set* 中設定的所有事件。如果 *tool_id* 並未正在被使用,則引發 :" +"exc:`ValueError`。" #: ../../library/sys.monitoring.rst:255 msgid "No events are active by default." @@ -464,9 +464,9 @@ msgid "" "accept a look-alike object from functions which are not defined in Python " "(see :ref:`c-api-monitoring`)." msgstr "" -"事件還可以基於各別程式碼物件進行控制。下面定義的、接" -"受 :class:`types.CodeType` 的函式應該準備好接受來自 Python 中未定義函式的類似" -"物件(請參閱 :ref:`c-api-monitoring`)。" +"事件還可以基於各別程式碼物件進行控制。下面定義的、接受 :class:`types." +"CodeType` 的函式應該準備好接受來自 Python 中未定義函式的類似物件(請參閱 :" +"ref:`c-api-monitoring`)。" #: ../../library/sys.monitoring.rst:267 msgid "Returns all the local events for *code*" @@ -500,10 +500,9 @@ msgstr "可以從回呼函式回傳的特殊值,以停用目前程式碼位置 #: ../../library/sys.monitoring.rst:287 msgid "" -"Local events can be disabled for a specific code location by " -"returning :data:`sys.monitoring.DISABLE` from a callback function. This does " -"not change which events are set, or any other code locations for the same " -"event." +"Local events can be disabled for a specific code location by returning :data:" +"`sys.monitoring.DISABLE` from a callback function. This does not change " +"which events are set, or any other code locations for the same event." msgstr "" "可透過回呼函式回傳 :data:`sys.monitoring.DISABLE` 來停用特定程式碼位置的區域" "事件。這不會改變被設定的事件,或相同事件的任何其他程式碼位置。" @@ -545,35 +544,37 @@ msgstr "" "如果給定的 *tool_id* 和 *event* 已經註冊了另一個回呼,則會取消註冊並回傳。否" "則 :func:`register_callback` 會回傳 ``None``。" -#: ../../library/sys.monitoring.rst:318 +#: ../../library/sys.monitoring.rst:317 msgid "" -"Functions can be unregistered by calling " -"``sys.monitoring.register_callback(tool_id, event, None)``." +"Raises an :ref:`auditing event ` ``sys.monitoring." +"register_callback`` with argument ``func``." +msgstr "" +"以 ``func`` 引數引發一個\\ :ref:`稽核事件 (auditing event) ` " +"``sys.monitoring.register_callback``。" + +#: ../../library/sys.monitoring.rst:319 +msgid "" +"Functions can be unregistered by calling ``sys.monitoring." +"register_callback(tool_id, event, None)``." msgstr "" "可以透過呼叫 ``sys.monitoring.register_callback(tool_id, event, None)`` 來取" "消註冊函式。" -#: ../../library/sys.monitoring.rst:321 +#: ../../library/sys.monitoring.rst:322 msgid "Callback functions can be registered and unregistered at any time." msgstr "回呼函式可以隨時被註冊和取消註冊。" -#: ../../library/sys.monitoring.rst:323 -msgid "" -"Registering or unregistering a callback function will generate " -"a :func:`sys.audit` event." -msgstr "註冊或取消註冊回呼函式將產生 :func:`sys.audit` 事件。" - -#: ../../library/sys.monitoring.rst:327 +#: ../../library/sys.monitoring.rst:326 msgid "Callback function arguments" msgstr "回呼函式引數" -#: ../../library/sys.monitoring.rst:331 +#: ../../library/sys.monitoring.rst:330 msgid "" "A special value that is passed to a callback function to indicate that there " "are no arguments to the call." msgstr "傳遞給回呼函式的特殊值,表示該呼叫沒有引數。" -#: ../../library/sys.monitoring.rst:334 +#: ../../library/sys.monitoring.rst:333 msgid "" "When an active event occurs, the registered callback function is called. " "Different events will provide the callback function with different " @@ -582,19 +583,19 @@ msgstr "" "當有效事件發生時,已註冊的回呼函式會被呼叫。不同的事件會為回呼函式提供不同的" "引數,如下所示:" -#: ../../library/sys.monitoring.rst:337 +#: ../../library/sys.monitoring.rst:336 msgid ":monitoring-event:`PY_START` and :monitoring-event:`PY_RESUME`::" msgstr ":monitoring-event:`PY_START` 和 :monitoring-event:`PY_RESUME`: ::" -#: ../../library/sys.monitoring.rst:339 ../../library/sys.monitoring.rst:370 +#: ../../library/sys.monitoring.rst:338 ../../library/sys.monitoring.rst:369 msgid "func(code: CodeType, instruction_offset: int) -> DISABLE | Any" msgstr "func(code: CodeType, instruction_offset: int) -> DISABLE | Any" -#: ../../library/sys.monitoring.rst:341 +#: ../../library/sys.monitoring.rst:340 msgid ":monitoring-event:`PY_RETURN` and :monitoring-event:`PY_YIELD`::" msgstr ":monitoring-event:`PY_RETURN` 和 :monitoring-event:`PY_YIELD`: ::" -#: ../../library/sys.monitoring.rst:343 +#: ../../library/sys.monitoring.rst:342 msgid "" "func(code: CodeType, instruction_offset: int, retval: object) -> DISABLE | " "Any" @@ -602,15 +603,15 @@ msgstr "" "func(code: CodeType, instruction_offset: int, retval: object) -> DISABLE | " "Any" -#: ../../library/sys.monitoring.rst:345 +#: ../../library/sys.monitoring.rst:344 msgid "" -":monitoring-event:`CALL`, :monitoring-event:`C_RAISE` and :monitoring-" -"event:`C_RETURN`::" +":monitoring-event:`CALL`, :monitoring-event:`C_RAISE` and :monitoring-event:" +"`C_RETURN`::" msgstr "" -":monitoring-event:`CALL`、:monitoring-event:`C_RAISE` 和 :monitoring-" -"event:`C_RETURN`: ::" +":monitoring-event:`CALL`、:monitoring-event:`C_RAISE` 和 :monitoring-event:" +"`C_RETURN`: ::" -#: ../../library/sys.monitoring.rst:347 +#: ../../library/sys.monitoring.rst:346 msgid "" "func(code: CodeType, instruction_offset: int, callable: object, arg0: object " "| MISSING) -> DISABLE | Any" @@ -618,22 +619,22 @@ msgstr "" "func(code: CodeType, instruction_offset: int, callable: object, arg0: object " "| MISSING) -> DISABLE | Any" -#: ../../library/sys.monitoring.rst:349 +#: ../../library/sys.monitoring.rst:348 msgid "" "If there are no arguments, *arg0* is set to :data:`sys.monitoring.MISSING`." msgstr "如果沒有引數,*arg0* 將被設定為 :data:`sys.monitoring.MISSING`。" -#: ../../library/sys.monitoring.rst:351 +#: ../../library/sys.monitoring.rst:350 msgid "" -":monitoring-event:`RAISE`, :monitoring-event:`RERAISE`, :monitoring-" -"event:`EXCEPTION_HANDLED`, :monitoring-event:`PY_UNWIND`, :monitoring-" -"event:`PY_THROW` and :monitoring-event:`STOP_ITERATION`::" +":monitoring-event:`RAISE`, :monitoring-event:`RERAISE`, :monitoring-event:" +"`EXCEPTION_HANDLED`, :monitoring-event:`PY_UNWIND`, :monitoring-event:" +"`PY_THROW` and :monitoring-event:`STOP_ITERATION`::" msgstr "" -":monitoring-event:`RAISE`、:monitoring-event:`RERAISE`、:monitoring-" -"event:`EXCEPTION_HANDLED`、:monitoring-event:`PY_UNWIND`、:monitoring-" -"event:`PY_THROW` 和 :monitoring-event:`STOP_ITERATION`: ::" +":monitoring-event:`RAISE`、:monitoring-event:`RERAISE`、:monitoring-event:" +"`EXCEPTION_HANDLED`、:monitoring-event:`PY_UNWIND`、:monitoring-event:" +"`PY_THROW` 和 :monitoring-event:`STOP_ITERATION`: ::" -#: ../../library/sys.monitoring.rst:354 +#: ../../library/sys.monitoring.rst:353 msgid "" "func(code: CodeType, instruction_offset: int, exception: BaseException) -> " "DISABLE | Any" @@ -641,19 +642,19 @@ msgstr "" "func(code: CodeType, instruction_offset: int, exception: BaseException) -> " "DISABLE | Any" -#: ../../library/sys.monitoring.rst:356 +#: ../../library/sys.monitoring.rst:355 msgid ":monitoring-event:`LINE`::" msgstr ":monitoring-event:`LINE`: ::" -#: ../../library/sys.monitoring.rst:358 +#: ../../library/sys.monitoring.rst:357 msgid "func(code: CodeType, line_number: int) -> DISABLE | Any" msgstr "func(code: CodeType, line_number: int) -> DISABLE | Any" -#: ../../library/sys.monitoring.rst:360 +#: ../../library/sys.monitoring.rst:359 msgid ":monitoring-event:`BRANCH` and :monitoring-event:`JUMP`::" msgstr ":monitoring-event:`BRANCH` 和 :monitoring-event:`JUMP`: ::" -#: ../../library/sys.monitoring.rst:362 +#: ../../library/sys.monitoring.rst:361 msgid "" "func(code: CodeType, instruction_offset: int, destination_offset: int) -> " "DISABLE | Any" @@ -661,7 +662,7 @@ msgstr "" "func(code: CodeType, instruction_offset: int, destination_offset: int) -> " "DISABLE | Any" -#: ../../library/sys.monitoring.rst:364 +#: ../../library/sys.monitoring.rst:363 msgid "" "Note that the *destination_offset* is where the code will next execute. For " "an untaken branch this will be the offset of the instruction following the " @@ -670,6 +671,11 @@ msgstr "" "請注意,*destination_offset* 是程式碼接下來要執行的地方。對於未採用的分支,這" "將是該分支之後的指令的偏移量。" -#: ../../library/sys.monitoring.rst:368 +#: ../../library/sys.monitoring.rst:367 msgid ":monitoring-event:`INSTRUCTION`::" msgstr ":monitoring-event:`INSTRUCTION`: ::" + +#~ msgid "" +#~ "Registering or unregistering a callback function will generate a :func:" +#~ "`sys.audit` event." +#~ msgstr "註冊或取消註冊回呼函式將產生 :func:`sys.audit` 事件。" diff --git a/library/tarfile.po b/library/tarfile.po index 5ea736c950..9442373297 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: 2025-07-07 01:58+0000\n" +"POT-Creation-Date: 2025-07-21 00:18+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-" @@ -91,8 +91,8 @@ msgid "" "*mode* has to be a string of the form ``'filemode[:compression]'``, it " "defaults to ``'r'``. Here is a full list of mode combinations:" msgstr "" -"*mode* 必須是 ``'filemode[:compression]'`` 形式的字串,預設為 ``'r'``。以下是所有可" -"能的模式組合:" +"*mode* 必須是 ``'filemode[:compression]'`` 形式的字串,預設為 ``'r'``。以下是" +"所有可能的模式組合:" #: ../../library/tarfile.rst:57 msgid "mode" @@ -1746,11 +1746,15 @@ msgstr "" msgid "Examples" msgstr "範例" -#: ../../library/tarfile.rst:1307 +#: ../../library/tarfile.rst:1308 +msgid "Reading examples" +msgstr "" + +#: ../../library/tarfile.rst:1310 msgid "How to extract an entire tar archive to the current working directory::" msgstr "" -#: ../../library/tarfile.rst:1309 +#: ../../library/tarfile.rst:1312 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar.gz\")\n" @@ -1762,13 +1766,13 @@ msgstr "" "tar.extractall(filter='data')\n" "tar.close()" -#: ../../library/tarfile.rst:1314 +#: ../../library/tarfile.rst:1317 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:1317 +#: ../../library/tarfile.rst:1320 msgid "" "import os\n" "import tarfile\n" @@ -1794,11 +1798,37 @@ msgstr "" "tar.extractall(members=py_files(tar))\n" "tar.close()" -#: ../../library/tarfile.rst:1329 +#: ../../library/tarfile.rst:1332 +msgid "" +"How to read a gzip compressed tar archive and display some member " +"information::" +msgstr "" + +#: ../../library/tarfile.rst:1334 +msgid "" +"import tarfile\n" +"tar = tarfile.open(\"sample.tar.gz\", \"r:gz\")\n" +"for tarinfo in tar:\n" +" print(tarinfo.name, \"is\", tarinfo.size, \"bytes in size and is \", " +"end=\"\")\n" +" if tarinfo.isreg():\n" +" print(\"a regular file.\")\n" +" elif tarinfo.isdir():\n" +" print(\"a directory.\")\n" +" else:\n" +" print(\"something else.\")\n" +"tar.close()" +msgstr "" + +#: ../../library/tarfile.rst:1347 +msgid "Writing examples" +msgstr "" + +#: ../../library/tarfile.rst:1349 msgid "How to create an uncompressed tar archive from a list of filenames::" msgstr "" -#: ../../library/tarfile.rst:1331 +#: ../../library/tarfile.rst:1351 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar\", \"w\")\n" @@ -1812,11 +1842,11 @@ msgstr "" " tar.add(name)\n" "tar.close()" -#: ../../library/tarfile.rst:1337 +#: ../../library/tarfile.rst:1357 msgid "The same example using the :keyword:`with` statement::" msgstr "" -#: ../../library/tarfile.rst:1339 +#: ../../library/tarfile.rst:1359 msgid "" "import tarfile\n" "with tarfile.open(\"sample.tar\", \"w\") as tar:\n" @@ -1828,35 +1858,35 @@ msgstr "" " for name in [\"foo\", \"bar\", \"quux\"]:\n" " tar.add(name)" -#: ../../library/tarfile.rst:1344 +#: ../../library/tarfile.rst:1364 msgid "" -"How to read a gzip compressed tar archive and display some member " -"information::" +"How to create and write an archive to stdout using :data:`sys.stdout.buffer " +"` in the *fileobj* parameter in :meth:`TarFile.add`::" msgstr "" -#: ../../library/tarfile.rst:1346 +#: ../../library/tarfile.rst:1368 msgid "" +"import sys\n" "import tarfile\n" -"tar = tarfile.open(\"sample.tar.gz\", \"r:gz\")\n" -"for tarinfo in tar:\n" -" print(tarinfo.name, \"is\", tarinfo.size, \"bytes in size and is \", " -"end=\"\")\n" -" if tarinfo.isreg():\n" -" print(\"a regular file.\")\n" -" elif tarinfo.isdir():\n" -" print(\"a directory.\")\n" -" else:\n" -" print(\"something else.\")\n" -"tar.close()" +"with tarfile.open(\"sample.tar.gz\", \"w|gz\", fileobj=sys.stdout.buffer) as " +"tar:\n" +" for name in [\"foo\", \"bar\", \"quux\"]:\n" +" tar.add(name)" msgstr "" +"import sys\n" +"import tarfile\n" +"with tarfile.open(\"sample.tar.gz\", \"w|gz\", fileobj=sys.stdout.buffer) as " +"tar:\n" +" for name in [\"foo\", \"bar\", \"quux\"]:\n" +" tar.add(name)" -#: ../../library/tarfile.rst:1358 +#: ../../library/tarfile.rst:1374 msgid "" "How to create an archive and reset the user information using the *filter* " "parameter in :meth:`TarFile.add`::" msgstr "" -#: ../../library/tarfile.rst:1361 +#: ../../library/tarfile.rst:1377 msgid "" "import tarfile\n" "def reset(tarinfo):\n" @@ -1876,17 +1906,17 @@ msgstr "" "tar.add(\"foo\", filter=reset)\n" "tar.close()" -#: ../../library/tarfile.rst:1374 +#: ../../library/tarfile.rst:1390 msgid "Supported tar formats" -msgstr "" +msgstr "支援的 tar 格式" -#: ../../library/tarfile.rst:1376 +#: ../../library/tarfile.rst:1392 msgid "" "There are three tar formats that can be created with the :mod:`tarfile` " "module:" msgstr "" -#: ../../library/tarfile.rst:1378 +#: ../../library/tarfile.rst:1394 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. " @@ -1894,7 +1924,7 @@ msgid "" "supported format." msgstr "" -#: ../../library/tarfile.rst:1383 +#: ../../library/tarfile.rst:1399 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 " @@ -1902,7 +1932,7 @@ msgid "" "extensions for long names, sparse file support is read-only." msgstr "" -#: ../../library/tarfile.rst:1388 +#: ../../library/tarfile.rst:1404 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, " @@ -1913,7 +1943,7 @@ msgid "" "*ustar* format. It is the current default format for new archives." msgstr "" -#: ../../library/tarfile.rst:1396 +#: ../../library/tarfile.rst:1412 msgid "" "It extends the existing *ustar* format with extra headers for information " "that cannot be stored otherwise. There are two flavours of pax headers: " @@ -1922,13 +1952,13 @@ msgid "" "in a pax header is encoded in *UTF-8* for portability reasons." msgstr "" -#: ../../library/tarfile.rst:1402 +#: ../../library/tarfile.rst:1418 msgid "" "There are some more variants of the tar format which can be read, but not " "created:" msgstr "" -#: ../../library/tarfile.rst:1405 +#: ../../library/tarfile.rst:1421 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 " @@ -1937,17 +1967,17 @@ msgid "" "ASCII characters." msgstr "" -#: ../../library/tarfile.rst:1410 +#: ../../library/tarfile.rst:1426 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:1416 +#: ../../library/tarfile.rst:1432 msgid "Unicode issues" msgstr "" -#: ../../library/tarfile.rst:1418 +#: ../../library/tarfile.rst:1434 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 " @@ -1962,13 +1992,13 @@ msgid "" "It stores non-ASCII metadata using the universal character encoding *UTF-8*." msgstr "" -#: ../../library/tarfile.rst:1430 +#: ../../library/tarfile.rst:1446 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:1433 +#: ../../library/tarfile.rst:1449 msgid "" "*encoding* defines the character encoding to use for the metadata in the " "archive. The default value is :func:`sys.getfilesystemencoding` or " @@ -1977,7 +2007,7 @@ msgid "" "not set appropriately, this conversion may fail." msgstr "" -#: ../../library/tarfile.rst:1439 +#: ../../library/tarfile.rst:1455 msgid "" "The *errors* argument defines how characters are treated that cannot be " "converted. Possible values are listed in section :ref:`error-handlers`. The " @@ -1985,16 +2015,10 @@ msgid "" "system calls, see :ref:`os-filenames`." msgstr "" -#: ../../library/tarfile.rst:1444 +#: ../../library/tarfile.rst:1460 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 " "used in the rare cases when binary pax headers are decoded or when strings " "with surrogate characters are stored." msgstr "" - -#~ msgid "``'a' or 'a:'``" -#~ msgstr "``'a' 或 'a:'``" - -#~ msgid "``'w' or 'w:'``" -#~ msgstr "``'w' 或 'w:'``" diff --git a/library/urllib.request.po b/library/urllib.request.po index 4bae8ca900..93b77f5e59 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-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-07-23 00:17+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-" @@ -694,7 +694,7 @@ msgstr "" msgid "A catch-all class to handle unknown URLs." msgstr "" -#: ../../library/urllib.request.rst:468 ../../library/urllib.request.rst:1174 +#: ../../library/urllib.request.rst:468 ../../library/urllib.request.rst:1177 msgid "Process HTTP error responses." msgstr "" @@ -1079,55 +1079,72 @@ msgstr "" #: ../../library/urllib.request.rst:787 msgid "" -"*req* will be a :class:`Request` object, *fp* will be a file-like object " -"with the HTTP error body, *code* will be the three-digit code of the error, " -"*msg* will be the user-visible explanation of the code and *hdrs* will be a " -"mapping object with the headers of the error." -msgstr "" +":class:`OpenerDirector` will call this method with five positional arguments:" +msgstr ":class:`OpenerDirector` 會以五個位置引數呼叫此方法:" + +#: ../../library/urllib.request.rst:789 +msgid "a :class:`Request` object," +msgstr "一個 :class:`Request` 物件" + +#: ../../library/urllib.request.rst:790 +msgid "a file-like object with the HTTP error body," +msgstr "一個類檔案物件,包含 HTTP 錯誤主體," + +#: ../../library/urllib.request.rst:791 +msgid "the three-digit code of the error, as a string," +msgstr "HTTP 錯誤的三位數代號字串," #: ../../library/urllib.request.rst:792 +msgid "the user-visible explanation of the code, as as string, and" +msgstr "HTTP 錯誤代號的使用者可見解釋字串,以及" + +#: ../../library/urllib.request.rst:793 +msgid "the headers of the error, as a mapping object." +msgstr "HTTP 錯誤的標頭,為一個對映物件。" + +#: ../../library/urllib.request.rst:795 msgid "" "Return values and exceptions raised should be the same as those of :func:" "`urlopen`." msgstr "" -#: ../../library/urllib.request.rst:799 +#: ../../library/urllib.request.rst:802 msgid "" "*nnn* should be a three-digit HTTP error code. This method is also not " "defined in :class:`BaseHandler`, but will be called, if it exists, on an " "instance of a subclass, when an HTTP error with code *nnn* occurs." msgstr "" -#: ../../library/urllib.request.rst:803 +#: ../../library/urllib.request.rst:806 msgid "Subclasses should override this method to handle specific HTTP errors." msgstr "" -#: ../../library/urllib.request.rst:805 +#: ../../library/urllib.request.rst:808 msgid "" "Arguments, return values and exceptions raised should be the same as for :" "meth:`~BaseHandler.http_error_default`." msgstr "" -#: ../../library/urllib.request.rst:813 +#: ../../library/urllib.request.rst:816 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to pre-process requests of the given protocol." msgstr "" -#: ../../library/urllib.request.rst:816 +#: ../../library/urllib.request.rst:819 msgid "" "This method, if defined, will be called by the parent :class:" "`OpenerDirector`. *req* will be a :class:`Request` object. The return value " "should be a :class:`Request` object." msgstr "" -#: ../../library/urllib.request.rst:825 +#: ../../library/urllib.request.rst:828 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to post-process responses of the given protocol." msgstr "" -#: ../../library/urllib.request.rst:828 +#: ../../library/urllib.request.rst:831 msgid "" "This method, if defined, will be called by the parent :class:" "`OpenerDirector`. *req* will be a :class:`Request` object. *response* will " @@ -1136,25 +1153,25 @@ msgid "" "return value of :func:`urlopen`." msgstr "" -#: ../../library/urllib.request.rst:838 +#: ../../library/urllib.request.rst:841 msgid "HTTPRedirectHandler Objects" msgstr "HTTPRedirectHandler 物件" -#: ../../library/urllib.request.rst:842 +#: ../../library/urllib.request.rst:845 msgid "" "Some HTTP redirections require action from this module's client code. If " "this is the case, :exc:`~urllib.error.HTTPError` is raised. See :rfc:`2616` " "for details of the precise meanings of the various redirection codes." msgstr "" -#: ../../library/urllib.request.rst:846 +#: ../../library/urllib.request.rst:849 msgid "" "An :exc:`~urllib.error.HTTPError` exception raised as a security " "consideration if the HTTPRedirectHandler is presented with a redirected URL " "which is not an HTTP, HTTPS or FTP URL." msgstr "" -#: ../../library/urllib.request.rst:853 +#: ../../library/urllib.request.rst:856 msgid "" "Return a :class:`Request` or ``None`` in response to a redirect. This is " "called by the default implementations of the :meth:`!http_error_30\\*` " @@ -1165,7 +1182,7 @@ msgid "" "URL, or return ``None`` if you can't but another handler might." msgstr "" -#: ../../library/urllib.request.rst:863 +#: ../../library/urllib.request.rst:866 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 " @@ -1174,54 +1191,54 @@ msgid "" "POST to a ``GET``, and the default implementation reproduces this behavior." msgstr "" -#: ../../library/urllib.request.rst:872 +#: ../../library/urllib.request.rst:875 msgid "" "Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the " "parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' " "response." msgstr "" -#: ../../library/urllib.request.rst:878 +#: ../../library/urllib.request.rst:881 msgid "" "The same as :meth:`http_error_301`, but called for the 'found' response." msgstr "" -#: ../../library/urllib.request.rst:883 +#: ../../library/urllib.request.rst:886 msgid "" "The same as :meth:`http_error_301`, but called for the 'see other' response." msgstr "" -#: ../../library/urllib.request.rst:888 +#: ../../library/urllib.request.rst:891 msgid "" "The same as :meth:`http_error_301`, but called for the 'temporary redirect' " "response. It does not allow changing the request method from ``POST`` to " "``GET``." msgstr "" -#: ../../library/urllib.request.rst:895 +#: ../../library/urllib.request.rst:898 msgid "" "The same as :meth:`http_error_301`, but called for the 'permanent redirect' " "response. It does not allow changing the request method from ``POST`` to " "``GET``." msgstr "" -#: ../../library/urllib.request.rst:905 +#: ../../library/urllib.request.rst:908 msgid "HTTPCookieProcessor Objects" msgstr "HTTPCookieProcessor 物件" -#: ../../library/urllib.request.rst:907 +#: ../../library/urllib.request.rst:910 msgid ":class:`HTTPCookieProcessor` instances have one attribute:" msgstr "" -#: ../../library/urllib.request.rst:911 +#: ../../library/urllib.request.rst:914 msgid "The :class:`http.cookiejar.CookieJar` in which cookies are stored." msgstr "" -#: ../../library/urllib.request.rst:917 +#: ../../library/urllib.request.rst:920 msgid "ProxyHandler Objects" msgstr "ProxyHandler 物件" -#: ../../library/urllib.request.rst:923 +#: ../../library/urllib.request.rst:926 msgid "" "The :class:`ProxyHandler` will have a method :meth:`!_open` for " "every *protocol* which has a proxy in the *proxies* dictionary given in the " @@ -1230,17 +1247,17 @@ msgid "" "actually execute the protocol." msgstr "" -#: ../../library/urllib.request.rst:933 +#: ../../library/urllib.request.rst:936 msgid "HTTPPasswordMgr Objects" msgstr "HTTPPasswordMgr 物件" -#: ../../library/urllib.request.rst:935 +#: ../../library/urllib.request.rst:938 msgid "" "These methods are available on :class:`HTTPPasswordMgr` and :class:" "`HTTPPasswordMgrWithDefaultRealm` objects." msgstr "" -#: ../../library/urllib.request.rst:941 +#: ../../library/urllib.request.rst:944 msgid "" "*uri* can be either a single URI, or a sequence of URIs. *realm*, *user* and " "*passwd* must be strings. This causes ``(user, passwd)`` to be used as " @@ -1248,30 +1265,30 @@ msgid "" "of the given URIs is given." msgstr "" -#: ../../library/urllib.request.rst:949 +#: ../../library/urllib.request.rst:952 msgid "" "Get user/password for given realm and URI, if any. This method will return " "``(None, None)`` if there is no matching user/password." msgstr "" -#: ../../library/urllib.request.rst:952 +#: ../../library/urllib.request.rst:955 msgid "" "For :class:`HTTPPasswordMgrWithDefaultRealm` objects, the realm ``None`` " "will be searched if the given *realm* has no matching user/password." msgstr "" -#: ../../library/urllib.request.rst:959 +#: ../../library/urllib.request.rst:962 msgid "HTTPPasswordMgrWithPriorAuth Objects" msgstr "HTTPPasswordMgrWithPriorAuth 物件" -#: ../../library/urllib.request.rst:961 +#: ../../library/urllib.request.rst:964 msgid "" "This password manager extends :class:`HTTPPasswordMgrWithDefaultRealm` to " "support tracking URIs for which authentication credentials should always be " "sent." msgstr "" -#: ../../library/urllib.request.rst:968 +#: ../../library/urllib.request.rst:971 msgid "" "*realm*, *uri*, *user*, *passwd* are as for :meth:`HTTPPasswordMgr." "add_password`. *is_authenticated* sets the initial value of the " @@ -1279,25 +1296,25 @@ msgid "" "*is_authenticated* is specified as ``True``, *realm* is ignored." msgstr "" -#: ../../library/urllib.request.rst:976 +#: ../../library/urllib.request.rst:979 msgid "Same as for :class:`HTTPPasswordMgrWithDefaultRealm` objects" msgstr "" -#: ../../library/urllib.request.rst:982 +#: ../../library/urllib.request.rst:985 msgid "" "Update the ``is_authenticated`` flag for the given *uri* or list of URIs." msgstr "" -#: ../../library/urllib.request.rst:988 +#: ../../library/urllib.request.rst:991 msgid "" "Returns the current state of the ``is_authenticated`` flag for the given URI." msgstr "" -#: ../../library/urllib.request.rst:995 +#: ../../library/urllib.request.rst:998 msgid "AbstractBasicAuthHandler Objects" msgstr "AbstractBasicAuthHandler 物件" -#: ../../library/urllib.request.rst:1000 +#: ../../library/urllib.request.rst:1003 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 " @@ -1306,7 +1323,7 @@ msgid "" "`Request` object, and *headers* should be the error headers." msgstr "" -#: ../../library/urllib.request.rst:1006 +#: ../../library/urllib.request.rst:1009 msgid "" "*host* is either an authority (e.g. ``\"python.org\"``) or a URL containing " "an authority component (e.g. ``\"http://python.org/\"``). In either case, " @@ -1314,24 +1331,24 @@ msgid "" "and ``\"python.org:80\"`` are fine, ``\"joe:password@python.org\"`` is not)." msgstr "" -#: ../../library/urllib.request.rst:1015 +#: ../../library/urllib.request.rst:1018 msgid "HTTPBasicAuthHandler Objects" msgstr "HTTPBasicAuthHandler 物件" -#: ../../library/urllib.request.rst:1020 ../../library/urllib.request.rst:1031 -#: ../../library/urllib.request.rst:1056 ../../library/urllib.request.rst:1067 +#: ../../library/urllib.request.rst:1023 ../../library/urllib.request.rst:1034 +#: ../../library/urllib.request.rst:1059 ../../library/urllib.request.rst:1070 msgid "Retry the request with authentication information, if available." msgstr "" -#: ../../library/urllib.request.rst:1026 +#: ../../library/urllib.request.rst:1029 msgid "ProxyBasicAuthHandler Objects" msgstr "ProxyBasicAuthHandler 物件" -#: ../../library/urllib.request.rst:1037 +#: ../../library/urllib.request.rst:1040 msgid "AbstractDigestAuthHandler Objects" msgstr "AbstractDigestAuthHandler 物件" -#: ../../library/urllib.request.rst:1042 +#: ../../library/urllib.request.rst:1045 msgid "" "*authreq* should be the name of the header where the information about the " "realm is included in the request, *host* should be the host to authenticate " @@ -1339,55 +1356,55 @@ msgid "" "should be the error headers." msgstr "" -#: ../../library/urllib.request.rst:1051 +#: ../../library/urllib.request.rst:1054 msgid "HTTPDigestAuthHandler Objects" msgstr "HTTPDigestAuthHandler 物件" -#: ../../library/urllib.request.rst:1062 +#: ../../library/urllib.request.rst:1065 msgid "ProxyDigestAuthHandler Objects" msgstr "ProxyDigestAuthHandler 物件" -#: ../../library/urllib.request.rst:1073 +#: ../../library/urllib.request.rst:1076 msgid "HTTPHandler Objects" msgstr "HTTPHandler 物件" -#: ../../library/urllib.request.rst:1078 +#: ../../library/urllib.request.rst:1081 msgid "" "Send an HTTP request, which can be either GET or POST, depending on ``req." "data``." msgstr "" -#: ../../library/urllib.request.rst:1085 +#: ../../library/urllib.request.rst:1088 msgid "HTTPSHandler Objects" msgstr "HTTPSHandler 物件" -#: ../../library/urllib.request.rst:1090 +#: ../../library/urllib.request.rst:1093 msgid "" "Send an HTTPS request, which can be either GET or POST, depending on ``req." "data``." msgstr "" -#: ../../library/urllib.request.rst:1097 +#: ../../library/urllib.request.rst:1100 msgid "FileHandler Objects" msgstr "FileHandler 物件" -#: ../../library/urllib.request.rst:1102 +#: ../../library/urllib.request.rst:1105 msgid "" "Open the file locally, if there is no host name, or the host name is " "``'localhost'``." msgstr "" -#: ../../library/urllib.request.rst:1105 +#: ../../library/urllib.request.rst:1108 msgid "" "This method is applicable only for local hostnames. When a remote hostname " "is given, a :exc:`~urllib.error.URLError` is raised." msgstr "" -#: ../../library/urllib.request.rst:1113 +#: ../../library/urllib.request.rst:1116 msgid "DataHandler Objects" msgstr "DataHandler 物件" -#: ../../library/urllib.request.rst:1117 +#: ../../library/urllib.request.rst:1120 msgid "" "Read a data URL. This kind of URL contains the content encoded in the URL " "itself. The data URL syntax is specified in :rfc:`2397`. This implementation " @@ -1397,51 +1414,51 @@ msgid "" "implementation will raise a :exc:`ValueError` in that case." msgstr "" -#: ../../library/urllib.request.rst:1128 +#: ../../library/urllib.request.rst:1131 msgid "FTPHandler Objects" msgstr "FTPHandler 物件" -#: ../../library/urllib.request.rst:1133 +#: ../../library/urllib.request.rst:1136 msgid "" "Open the FTP file indicated by *req*. The login is always done with empty " "username and password." msgstr "" -#: ../../library/urllib.request.rst:1140 +#: ../../library/urllib.request.rst:1143 msgid "CacheFTPHandler Objects" msgstr "CacheFTPHandler 物件" -#: ../../library/urllib.request.rst:1142 +#: ../../library/urllib.request.rst:1145 msgid "" ":class:`CacheFTPHandler` objects are :class:`FTPHandler` objects with the " "following additional methods:" msgstr "" -#: ../../library/urllib.request.rst:1148 +#: ../../library/urllib.request.rst:1151 msgid "Set timeout of connections to *t* seconds." msgstr "" -#: ../../library/urllib.request.rst:1153 +#: ../../library/urllib.request.rst:1156 msgid "Set maximum number of cached connections to *m*." msgstr "" -#: ../../library/urllib.request.rst:1159 +#: ../../library/urllib.request.rst:1162 msgid "UnknownHandler Objects" msgstr "UnknownHandler 物件" -#: ../../library/urllib.request.rst:1164 +#: ../../library/urllib.request.rst:1167 msgid "Raise a :exc:`~urllib.error.URLError` exception." msgstr "" -#: ../../library/urllib.request.rst:1170 +#: ../../library/urllib.request.rst:1173 msgid "HTTPErrorProcessor Objects" msgstr "HTTPErrorProcessor 物件" -#: ../../library/urllib.request.rst:1176 +#: ../../library/urllib.request.rst:1179 msgid "For 200 error codes, the response object is returned immediately." msgstr "" -#: ../../library/urllib.request.rst:1178 +#: ../../library/urllib.request.rst:1181 msgid "" "For non-200 error codes, this simply passes the job on to the :meth:`!" "http_error_\\` handler methods, via :meth:`OpenerDirector.error`. " @@ -1449,31 +1466,31 @@ msgid "" "error.HTTPError` if no other handler handles the error." msgstr "" -#: ../../library/urllib.request.rst:1186 +#: ../../library/urllib.request.rst:1189 msgid "Process HTTPS error responses." msgstr "" -#: ../../library/urllib.request.rst:1188 +#: ../../library/urllib.request.rst:1191 msgid "The behavior is same as :meth:`http_response`." msgstr "" -#: ../../library/urllib.request.rst:1194 +#: ../../library/urllib.request.rst:1197 msgid "Examples" msgstr "範例" -#: ../../library/urllib.request.rst:1196 +#: ../../library/urllib.request.rst:1199 msgid "" "In addition to the examples below, more examples are given in :ref:`urllib-" "howto`." msgstr "" -#: ../../library/urllib.request.rst:1199 +#: ../../library/urllib.request.rst:1202 msgid "" "This example gets the python.org main page and displays the first 300 bytes " "of it::" msgstr "" -#: ../../library/urllib.request.rst:1202 +#: ../../library/urllib.request.rst:1205 msgid "" ">>> import urllib.request\n" ">>> with urllib.request.urlopen('http://www.python.org/') as f:\n" @@ -1485,7 +1502,7 @@ msgid "" "class=\"no-js ie8 lt-ie9\">" msgstr "" -#: ../../library/urllib.request.rst:1208 +#: ../../library/urllib.request.rst:1211 msgid "" "Note that urlopen returns a bytes object. This is because there is no way " "for urlopen to automatically determine the encoding of the byte stream it " @@ -1494,26 +1511,26 @@ msgid "" "appropriate encoding." msgstr "" -#: ../../library/urllib.request.rst:1214 +#: ../../library/urllib.request.rst:1217 msgid "" "The following HTML spec document, https://html.spec.whatwg.org/#charset, " "lists the various ways in which an HTML or an XML document could have " "specified its encoding information." msgstr "" -#: ../../library/urllib.request.rst:1218 +#: ../../library/urllib.request.rst:1221 msgid "" "For additional information, see the W3C document: https://www.w3.org/" "International/questions/qa-html-encoding-declarations." msgstr "" -#: ../../library/urllib.request.rst:1220 +#: ../../library/urllib.request.rst:1223 msgid "" "As the python.org website uses *utf-8* encoding as specified in its meta " "tag, we will use the same for decoding the bytes object::" msgstr "" -#: ../../library/urllib.request.rst:1223 +#: ../../library/urllib.request.rst:1226 msgid "" ">>> with urllib.request.urlopen('http://www.python.org/') as f:\n" "... print(f.read(100).decode('utf-8'))\n" @@ -1531,13 +1548,13 @@ msgstr "" "[endif]-->\n" ">> import urllib.request\n" ">>> f = urllib.request.urlopen('http://www.python.org/')\n" @@ -1563,14 +1580,14 @@ msgstr "" "[endif]-->\n" "