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/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/ctypes.po b/library/ctypes.po index 7125493c1f..1b06865816 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,225 @@ msgid ":c:expr:`int`" msgstr ":c:expr:`int`" #: ../../library/ctypes.rst:235 +#, fuzzy +msgid ":class:`c_int8`" +msgstr ":class:`c_int`" + +#: ../../library/ctypes.rst:235 +#, fuzzy +msgid ":c:type:`int8_t`" +msgstr ":c:type:`size_t`" + +#: ../../library/ctypes.rst:237 +#, fuzzy +msgid ":class:`c_int16`" +msgstr ":class:`c_int`" + +#: ../../library/ctypes.rst:237 +#, fuzzy +msgid ":c:type:`int16_t`" +msgstr ":c:type:`size_t`" + +#: ../../library/ctypes.rst:239 +#, fuzzy +msgid ":class:`c_int32`" +msgstr ":class:`c_int`" + +#: ../../library/ctypes.rst:239 +#, fuzzy +msgid ":c:type:`int32_t`" +msgstr ":c:type:`size_t`" + +#: ../../library/ctypes.rst:241 +#, fuzzy +msgid ":class:`c_int64`" +msgstr ":class:`c_int`" + +#: ../../library/ctypes.rst:241 +#, fuzzy +msgid ":c:type:`int64_t`" +msgstr ":c:type:`size_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 +#, fuzzy +msgid ":class:`c_uint8`" +msgstr ":class:`c_uint`" + +#: ../../library/ctypes.rst:245 +#, fuzzy +msgid ":c:type:`uint8_t`" +msgstr ":c:type:`size_t`" + +#: ../../library/ctypes.rst:247 +#, fuzzy +msgid ":class:`c_uint16`" +msgstr ":class:`c_uint`" + +#: ../../library/ctypes.rst:247 +#, fuzzy +msgid ":c:type:`uint16_t`" +msgstr ":c:type:`size_t`" + +#: ../../library/ctypes.rst:249 +#, fuzzy +msgid ":class:`c_uint32`" +msgstr ":class:`c_uint`" + +#: ../../library/ctypes.rst:249 +#, fuzzy +msgid ":c:type:`uint32_t`" +msgstr ":c:type:`size_t`" + +#: ../../library/ctypes.rst:251 +#, fuzzy +msgid ":class:`c_uint64`" +msgstr ":class:`c_uint`" + +#: ../../library/ctypes.rst:251 +#, fuzzy +msgid ":c:type:`uint64_t`" +msgstr ":c:type:`size_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 "" -#: ../../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 +718,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 +745,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 +753,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" @@ -687,7 +771,7 @@ msgid "" ">>>" msgstr "" -#: ../../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 +781,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 +803,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 +811,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 +858,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 +877,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 +890,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 +919,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 +941,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 +967,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 +981,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 +1010,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 +1024,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 +1068,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 +1096,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 +1133,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 +1143,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 +1179,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 +1187,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 +1206,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 +1215,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 +1241,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 +1254,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 +1303,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 +1339,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 +1353,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 +1373,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 +1381,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 +1398,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 +1407,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 +1440,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 +1494,28 @@ 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 "" -#: ../../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 +1537,17 @@ msgstr "" "1 2 3 4 5 6 7 8 9 10\n" ">>>" -#: ../../library/ctypes.rst:757 +#: ../../library/ctypes.rst:773 msgid "Pointers" 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 +1559,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 +1575,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 +1595,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 +1616,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 +1630,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 +1650,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 +1659,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 +1667,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 +1691,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 +1709,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 +1741,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 +1756,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 +1786,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 +1795,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 +1807,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 +1816,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 +1832,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 +1845,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 +1857,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 +1877,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 +1898,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 +1926,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 +1951,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 +1987,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 +2012,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 +2040,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 +2050,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 +2064,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 +2086,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 +2108,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 +2140,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 +2156,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 +2190,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 +2207,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 +2235,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 +2254,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 +2284,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 +2300,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 +2309,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 +2331,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 +2390,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 +2408,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 +2417,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 +2448,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 +2463,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 +2481,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 +2511,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 +2536,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 +2566,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 +2580,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 +2622,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 +2653,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 +2661,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 +2669,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 +2698,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 +2719,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 +2756,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 +2770,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 +2778,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 +2788,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 +2804,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 +2814,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 +2845,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 +2861,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 +2883,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 +2897,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 +2937,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 +2971,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 +2987,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 +3019,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 +3028,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 +3038,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 +3046,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 +3092,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 +3114,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 +3123,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 +3161,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 +3169,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 +3257,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 +3277,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 +3291,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 +3299,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:1854 +#: ../../library/ctypes.rst:1870 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" @@ -3227,7 +3311,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 +3329,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 +3337,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 +3346,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 +3364,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 +3373,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 +3393,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 +3411,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 +3446,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 +3502,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 +3510,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 +3530,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 +3552,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 +3647,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 +3661,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 +3676,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 +3696,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 +3704,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 +3725,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 +3739,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 +3754,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 +3762,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 +3770,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 +3790,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 +3816,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 +3830,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 +3839,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 +3851,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 +3859,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 +3869,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 +3877,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 +3903,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 +4086,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 +4128,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 +4169,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 +4177,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 +4192,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 +4214,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 +4240,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 +4250,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 +4262,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 +4270,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 +4280,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 +4298,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 +4346,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/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/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..37282bf5d2 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -7,7 +7,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,7 +159,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``" +#, fuzzy +msgid "``batched('ABCDEFG', n=2) → AB CD EF G``" msgstr "``batched('ABCDEFG', n=3) → ABC DEF G``" #: ../../library/itertools.rst:51 @@ -559,9 +560,10 @@ msgstr "" "[('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet')]" #: ../../library/itertools.rst:183 +#, fuzzy 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" diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 65fc4b1be7..db7adac0c4 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-20 00:19+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-" @@ -1425,36 +1425,45 @@ msgid "" "class:`queue.Queue`. These methods are usually unnecessary for most code:" msgstr "" -#: ../../library/multiprocessing.rst:900 +#: ../../library/multiprocessing.rst:900 ../../library/multiprocessing.rst:948 +msgid "Close the queue: release internal resources." +msgstr "" + +#: ../../library/multiprocessing.rst:902 +msgid "" +"A queue must not be used anymore after it is closed. For example, :meth:" +"`~Queue.get`, :meth:`~Queue.put` and :meth:`~Queue.empty` methods must no " +"longer be called." +msgstr "" + +#: ../../library/multiprocessing.rst:906 msgid "" -"Indicate that no more data will be put on this queue by the current " -"process. The background thread will quit once it has flushed all buffered " -"data to the pipe. This is called automatically when the queue is garbage " -"collected." +"The background thread will quit once it has flushed all buffered data to the " +"pipe. This is called automatically when the queue is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:907 +#: ../../library/multiprocessing.rst:912 msgid "" "Join the background thread. This can only be used after :meth:`close` has " "been called. It blocks until the background thread exits, ensuring that all " "data in the buffer has been flushed to the pipe." msgstr "" -#: ../../library/multiprocessing.rst:911 +#: ../../library/multiprocessing.rst:916 msgid "" "By default if a process is not the creator of the queue then on exit it will " "attempt to join the queue's background thread. The process can call :meth:" "`cancel_join_thread` to make :meth:`join_thread` do nothing." msgstr "" -#: ../../library/multiprocessing.rst:917 +#: ../../library/multiprocessing.rst:922 msgid "" "Prevent :meth:`join_thread` from blocking. In particular, this prevents the " "background thread from being joined automatically when the process exits -- " "see :meth:`join_thread`." msgstr "" -#: ../../library/multiprocessing.rst:921 +#: ../../library/multiprocessing.rst:926 msgid "" "A better name for this method might be ``allow_exit_without_flush()``. It " "is likely to cause enqueued data to be lost, and you almost certainly will " @@ -1463,7 +1472,7 @@ msgid "" "pipe, and you don't care about lost data." msgstr "" -#: ../../library/multiprocessing.rst:930 +#: ../../library/multiprocessing.rst:935 msgid "" "This class's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the functionality " @@ -1473,44 +1482,40 @@ msgid "" "listed below." msgstr "" -#: ../../library/multiprocessing.rst:939 +#: ../../library/multiprocessing.rst:944 msgid "" "It is a simplified :class:`Queue` type, very close to a locked :class:`Pipe`." msgstr "" -#: ../../library/multiprocessing.rst:943 -msgid "Close the queue: release internal resources." -msgstr "" - -#: ../../library/multiprocessing.rst:945 +#: ../../library/multiprocessing.rst:950 msgid "" "A queue must not be used anymore after it is closed. For example, :meth:" "`get`, :meth:`put` and :meth:`empty` methods must no longer be called." msgstr "" -#: ../../library/multiprocessing.rst:953 +#: ../../library/multiprocessing.rst:958 msgid "Return ``True`` if the queue is empty, ``False`` otherwise." msgstr "" -#: ../../library/multiprocessing.rst:955 +#: ../../library/multiprocessing.rst:960 msgid "Always raises an :exc:`OSError` if the SimpleQueue is closed." msgstr "" -#: ../../library/multiprocessing.rst:959 +#: ../../library/multiprocessing.rst:964 msgid "Remove and return an item from the queue." msgstr "" -#: ../../library/multiprocessing.rst:963 +#: ../../library/multiprocessing.rst:968 msgid "Put *item* into the queue." msgstr "" -#: ../../library/multiprocessing.rst:968 +#: ../../library/multiprocessing.rst:973 msgid "" ":class:`JoinableQueue`, a :class:`Queue` subclass, is a queue which " "additionally has :meth:`task_done` and :meth:`join` methods." msgstr "" -#: ../../library/multiprocessing.rst:973 +#: ../../library/multiprocessing.rst:978 msgid "" "Indicate that a formerly enqueued task is complete. Used by queue " "consumers. For each :meth:`~Queue.get` used to fetch a task, a subsequent " @@ -1518,24 +1523,24 @@ msgid "" "complete." msgstr "" -#: ../../library/multiprocessing.rst:978 +#: ../../library/multiprocessing.rst:983 msgid "" "If a :meth:`~queue.Queue.join` is currently blocking, it will resume when " "all items have been processed (meaning that a :meth:`task_done` call was " "received for every item that had been :meth:`~Queue.put` into the queue)." msgstr "" -#: ../../library/multiprocessing.rst:982 +#: ../../library/multiprocessing.rst:987 msgid "" "Raises a :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "" -#: ../../library/multiprocessing.rst:988 +#: ../../library/multiprocessing.rst:993 msgid "Block until all items in the queue have been gotten and processed." msgstr "" -#: ../../library/multiprocessing.rst:990 +#: ../../library/multiprocessing.rst:995 msgid "" "The count of unfinished tasks goes up whenever an item is added to the " "queue. The count goes down whenever a consumer calls :meth:`task_done` to " @@ -1544,78 +1549,78 @@ msgid "" "unblocks." msgstr "" -#: ../../library/multiprocessing.rst:998 +#: ../../library/multiprocessing.rst:1003 msgid "Miscellaneous" msgstr "" -#: ../../library/multiprocessing.rst:1002 +#: ../../library/multiprocessing.rst:1007 msgid "Return list of all live children of the current process." msgstr "" -#: ../../library/multiprocessing.rst:1004 +#: ../../library/multiprocessing.rst:1009 msgid "" "Calling this has the side effect of \"joining\" any processes which have " "already finished." msgstr "" -#: ../../library/multiprocessing.rst:1009 +#: ../../library/multiprocessing.rst:1014 msgid "Return the number of CPUs in the system." msgstr "" -#: ../../library/multiprocessing.rst:1011 +#: ../../library/multiprocessing.rst:1016 msgid "" "This number is not equivalent to the number of CPUs the current process can " "use. The number of usable CPUs can be obtained with :func:`os." "process_cpu_count` (or ``len(os.sched_getaffinity(0))``)." msgstr "" -#: ../../library/multiprocessing.rst:1015 +#: ../../library/multiprocessing.rst:1020 msgid "" "When the number of CPUs cannot be determined a :exc:`NotImplementedError` is " "raised." msgstr "" -#: ../../library/multiprocessing.rst:1019 +#: ../../library/multiprocessing.rst:1024 msgid ":func:`os.cpu_count` :func:`os.process_cpu_count`" msgstr ":func:`os.cpu_count` :func:`os.process_cpu_count`" -#: ../../library/multiprocessing.rst:1024 +#: ../../library/multiprocessing.rst:1029 msgid "" "The return value can also be overridden using the :option:`-X cpu_count <-" "X>` 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:1035 msgid "" "Return the :class:`Process` object corresponding to the current process." msgstr "" -#: ../../library/multiprocessing.rst:1032 +#: ../../library/multiprocessing.rst:1037 msgid "An analogue of :func:`threading.current_thread`." msgstr "" -#: ../../library/multiprocessing.rst:1036 +#: ../../library/multiprocessing.rst:1041 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:1049 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:1053 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:1056 msgid "" "from multiprocessing import Process, freeze_support\n" "\n" @@ -1635,13 +1640,13 @@ msgstr "" " freeze_support()\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:1060 +#: ../../library/multiprocessing.rst:1065 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:1068 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 +1654,7 @@ msgid "" "no effect." msgstr "" -#: ../../library/multiprocessing.rst:1070 +#: ../../library/multiprocessing.rst:1075 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 +1662,13 @@ msgid "" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1079 +#: ../../library/multiprocessing.rst:1084 msgid "" "Return a context object which has the same attributes as the :mod:" "`multiprocessing` module." msgstr "" -#: ../../library/multiprocessing.rst:1082 +#: ../../library/multiprocessing.rst:1087 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 +1677,11 @@ msgid "" "is not available. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1093 +#: ../../library/multiprocessing.rst:1098 msgid "Return the name of start method used for starting processes." msgstr "" -#: ../../library/multiprocessing.rst:1095 +#: ../../library/multiprocessing.rst:1100 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 +1689,43 @@ msgid "" "returned." msgstr "" -#: ../../library/multiprocessing.rst:1100 +#: ../../library/multiprocessing.rst:1105 msgid "" "The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` or " "``None``. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1107 +#: ../../library/multiprocessing.rst:1112 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:1118 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:1122 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:1124 msgid "before they can create child processes." msgstr "" -#: ../../library/multiprocessing.rst:1121 +#: ../../library/multiprocessing.rst:1126 msgid "Now supported on POSIX when the ``'spawn'`` start method is used." msgstr "" -#: ../../library/multiprocessing.rst:1124 +#: ../../library/multiprocessing.rst:1129 msgid "Accepts a :term:`path-like object`." msgstr "接受一個\\ :term:`類路徑物件 `。" -#: ../../library/multiprocessing.rst:1129 +#: ../../library/multiprocessing.rst:1134 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 +1734,19 @@ msgid "" "process." msgstr "" -#: ../../library/multiprocessing.rst:1135 +#: ../../library/multiprocessing.rst:1140 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:1143 msgid "" "Only meaningful when using the ``'forkserver'`` start method. See :ref:" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1145 +#: ../../library/multiprocessing.rst:1150 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 +1756,17 @@ msgid "" "then the context is set to the default context." msgstr "" -#: ../../library/multiprocessing.rst:1152 +#: ../../library/multiprocessing.rst:1157 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:1161 msgid "See :ref:`multiprocessing-start-methods`." msgstr "參閱 :ref:`multiprocessing-start-methods`。" -#: ../../library/multiprocessing.rst:1162 +#: ../../library/multiprocessing.rst:1167 msgid "" ":mod:`multiprocessing` contains no analogues of :func:`threading." "active_count`, :func:`threading.enumerate`, :func:`threading.settrace`, :" @@ -1769,75 +1774,75 @@ msgid "" "local`." msgstr "" -#: ../../library/multiprocessing.rst:1169 +#: ../../library/multiprocessing.rst:1174 msgid "Connection Objects" msgstr "" -#: ../../library/multiprocessing.rst:1173 +#: ../../library/multiprocessing.rst:1178 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:1181 msgid "" "Connection objects are usually created using :func:`Pipe ` -- see also :ref:`multiprocessing-listeners-clients`." msgstr "" -#: ../../library/multiprocessing.rst:1184 +#: ../../library/multiprocessing.rst:1189 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:1192 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:1197 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:1204 msgid "Return the file descriptor or handle used by the connection." msgstr "" -#: ../../library/multiprocessing.rst:1203 +#: ../../library/multiprocessing.rst:1208 msgid "Close the connection." msgstr "" -#: ../../library/multiprocessing.rst:1205 +#: ../../library/multiprocessing.rst:1210 msgid "This is called automatically when the connection is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1209 +#: ../../library/multiprocessing.rst:1214 msgid "Return whether there is any data available to be read." msgstr "" -#: ../../library/multiprocessing.rst:1211 +#: ../../library/multiprocessing.rst:1216 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:1220 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:1225 msgid "Send byte data from a :term:`bytes-like object` as a complete message." msgstr "" -#: ../../library/multiprocessing.rst:1222 +#: ../../library/multiprocessing.rst:1227 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 +1850,7 @@ msgid "" "exc:`ValueError` exception" msgstr "" -#: ../../library/multiprocessing.rst:1229 +#: ../../library/multiprocessing.rst:1234 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 +1858,19 @@ msgid "" "closed." msgstr "" -#: ../../library/multiprocessing.rst:1234 +#: ../../library/multiprocessing.rst:1239 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:1243 msgid "" "This function used to raise :exc:`IOError`, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:1245 +#: ../../library/multiprocessing.rst:1250 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 +1878,38 @@ msgid "" "nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1251 +#: ../../library/multiprocessing.rst:1256 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:1261 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:1265 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:1269 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:1273 msgid "For example:" msgstr "舉例來說:" -#: ../../library/multiprocessing.rst:1270 +#: ../../library/multiprocessing.rst:1275 msgid "" ">>> from multiprocessing import Pipe\n" ">>> a, b = Pipe()\n" @@ -1940,14 +1945,14 @@ msgstr "" ">>> arr2\n" "array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])" -#: ../../library/multiprocessing.rst:1293 +#: ../../library/multiprocessing.rst:1298 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:1302 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 +1960,73 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:1304 +#: ../../library/multiprocessing.rst:1309 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:1315 msgid "Synchronization primitives" msgstr "" -#: ../../library/multiprocessing.rst:1314 +#: ../../library/multiprocessing.rst:1319 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:1323 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:1328 msgid "A barrier object: a clone of :class:`threading.Barrier`." msgstr "" -#: ../../library/multiprocessing.rst:1329 +#: ../../library/multiprocessing.rst:1334 msgid "" "A bounded semaphore object: a close analog of :class:`threading." "BoundedSemaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1332 -#: ../../library/multiprocessing.rst:1470 +#: ../../library/multiprocessing.rst:1337 +#: ../../library/multiprocessing.rst:1475 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:1341 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:1346 msgid "A condition variable: an alias for :class:`threading.Condition`." msgstr "" -#: ../../library/multiprocessing.rst:1343 +#: ../../library/multiprocessing.rst:1348 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:1351 +#: ../../library/multiprocessing.rst:1889 msgid "The :meth:`~threading.Condition.wait_for` method was added." msgstr "" -#: ../../library/multiprocessing.rst:1351 +#: ../../library/multiprocessing.rst:1356 msgid "A clone of :class:`threading.Event`." msgstr "" -#: ../../library/multiprocessing.rst:1356 +#: ../../library/multiprocessing.rst:1361 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 +2037,25 @@ msgid "" "as noted." msgstr "" -#: ../../library/multiprocessing.rst:1364 +#: ../../library/multiprocessing.rst:1369 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:1373 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:1378 +#: ../../library/multiprocessing.rst:1429 msgid "Acquire a lock, blocking or non-blocking." msgstr "" -#: ../../library/multiprocessing.rst:1375 +#: ../../library/multiprocessing.rst:1380 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 +2063,14 @@ msgid "" "that in :meth:`threading.Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1380 +#: ../../library/multiprocessing.rst:1385 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:1389 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 +2084,19 @@ msgid "" "acquired or ``False`` if the timeout period has elapsed." msgstr "" -#: ../../library/multiprocessing.rst:1399 +#: ../../library/multiprocessing.rst:1404 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:1407 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:1413 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 +2105,20 @@ msgid "" "release it once for each time it has been acquired." msgstr "" -#: ../../library/multiprocessing.rst:1414 +#: ../../library/multiprocessing.rst:1419 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:1423 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:1431 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 +2131,7 @@ msgid "" "itself." msgstr "" -#: ../../library/multiprocessing.rst:1436 +#: ../../library/multiprocessing.rst:1441 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 +2142,14 @@ msgid "" "a return value of ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1444 +#: ../../library/multiprocessing.rst:1449 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:1456 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 +2159,7 @@ msgid "" "locked and owned by the calling process or thread." msgstr "" -#: ../../library/multiprocessing.rst:1459 +#: ../../library/multiprocessing.rst:1464 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 +2168,17 @@ msgid "" "from the implemented behavior in :meth:`threading.RLock.release`." msgstr "" -#: ../../library/multiprocessing.rst:1468 +#: ../../library/multiprocessing.rst:1473 msgid "A semaphore object: a close analog of :class:`threading.Semaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1475 +#: ../../library/multiprocessing.rst:1480 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:1485 msgid "" "Some of this package's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the :mod:" @@ -2182,32 +2187,32 @@ msgid "" "additional information." msgstr "" -#: ../../library/multiprocessing.rst:1488 +#: ../../library/multiprocessing.rst:1493 msgid "Shared :mod:`ctypes` Objects" msgstr "共享的 :mod:`ctypes` 物件" -#: ../../library/multiprocessing.rst:1490 +#: ../../library/multiprocessing.rst:1495 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:1500 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:1504 +#: ../../library/multiprocessing.rst:1591 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:1508 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 +2222,24 @@ msgid "" "\"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1510 +#: ../../library/multiprocessing.rst:1515 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:1519 msgid "counter.value += 1" msgstr "counter.value += 1" -#: ../../library/multiprocessing.rst:1516 +#: ../../library/multiprocessing.rst:1521 msgid "" "Assuming the associated lock is recursive (which it is by default) you can " "instead do ::" msgstr "" -#: ../../library/multiprocessing.rst:1519 +#: ../../library/multiprocessing.rst:1524 msgid "" "with counter.get_lock():\n" " counter.value += 1" @@ -2242,19 +2247,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:1527 +#: ../../library/multiprocessing.rst:1617 +#: ../../library/multiprocessing.rst:1632 msgid "Note that *lock* is a keyword-only argument." msgstr "" -#: ../../library/multiprocessing.rst:1526 +#: ../../library/multiprocessing.rst:1531 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:1534 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 +2269,7 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1536 +#: ../../library/multiprocessing.rst:1541 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 +2279,28 @@ msgid "" "safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1543 +#: ../../library/multiprocessing.rst:1548 msgid "Note that *lock* is a keyword only argument." msgstr "" -#: ../../library/multiprocessing.rst:1545 +#: ../../library/multiprocessing.rst:1550 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:1555 msgid "The :mod:`multiprocessing.sharedctypes` module" msgstr ":mod:`multiprocessing.sharedctypes` 模組" -#: ../../library/multiprocessing.rst:1555 +#: ../../library/multiprocessing.rst:1560 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:1566 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 +2309,11 @@ msgid "" "may cause a crash." msgstr "" -#: ../../library/multiprocessing.rst:1569 +#: ../../library/multiprocessing.rst:1574 msgid "Return a ctypes array allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1571 +#: ../../library/multiprocessing.rst:1576 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 +2323,40 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1578 +#: ../../library/multiprocessing.rst:1583 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:1589 msgid "Return a ctypes object allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1590 +#: ../../library/multiprocessing.rst:1595 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:1599 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:1605 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:1609 +#: ../../library/multiprocessing.rst:1625 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 +2366,113 @@ msgid "" "not necessarily be \"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1616 +#: ../../library/multiprocessing.rst:1621 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:1636 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:1641 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:1645 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:1649 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:1652 msgid "Synchronized objects support the :term:`context manager` protocol." msgstr "" -#: ../../library/multiprocessing.rst:1651 +#: ../../library/multiprocessing.rst:1656 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:1661 msgid "ctypes" msgstr "ctypes" -#: ../../library/multiprocessing.rst:1656 +#: ../../library/multiprocessing.rst:1661 msgid "sharedctypes using type" msgstr "" -#: ../../library/multiprocessing.rst:1656 +#: ../../library/multiprocessing.rst:1661 msgid "sharedctypes using typecode" msgstr "" -#: ../../library/multiprocessing.rst:1658 +#: ../../library/multiprocessing.rst:1663 msgid "c_double(2.4)" msgstr "c_double(2.4)" -#: ../../library/multiprocessing.rst:1658 +#: ../../library/multiprocessing.rst:1663 msgid "RawValue(c_double, 2.4)" msgstr "RawValue(c_double, 2.4)" -#: ../../library/multiprocessing.rst:1658 +#: ../../library/multiprocessing.rst:1663 msgid "RawValue('d', 2.4)" msgstr "RawValue('d', 2.4)" -#: ../../library/multiprocessing.rst:1659 +#: ../../library/multiprocessing.rst:1664 msgid "MyStruct(4, 6)" msgstr "MyStruct(4, 6)" -#: ../../library/multiprocessing.rst:1659 +#: ../../library/multiprocessing.rst:1664 msgid "RawValue(MyStruct, 4, 6)" msgstr "RawValue(MyStruct, 4, 6)" -#: ../../library/multiprocessing.rst:1660 +#: ../../library/multiprocessing.rst:1665 msgid "(c_short * 7)()" msgstr "(c_short * 7)()" -#: ../../library/multiprocessing.rst:1660 +#: ../../library/multiprocessing.rst:1665 msgid "RawArray(c_short, 7)" msgstr "RawArray(c_short, 7)" -#: ../../library/multiprocessing.rst:1660 +#: ../../library/multiprocessing.rst:1665 msgid "RawArray('h', 7)" msgstr "RawArray('h', 7)" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1666 msgid "(c_int * 3)(9, 2, 8)" msgstr "(c_int * 3)(9, 2, 8)" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1666 msgid "RawArray(c_int, (9, 2, 8))" msgstr "RawArray(c_int, (9, 2, 8))" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1666 msgid "RawArray('i', (9, 2, 8))" msgstr "RawArray('i', (9, 2, 8))" -#: ../../library/multiprocessing.rst:1665 +#: ../../library/multiprocessing.rst:1670 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:1673 msgid "" "from multiprocessing import Process, Lock\n" "from multiprocessing.sharedctypes import Value, Array\n" @@ -2533,11 +2538,11 @@ msgstr "" " print(s.value)\n" " print([(a.x, a.y) for a in A])" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1708 msgid "The results printed are ::" msgstr "" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1710 msgid "" "49\n" "0.1111111111111111\n" @@ -2549,11 +2554,11 @@ msgstr "" "HELLO WORLD\n" "[(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]" -#: ../../library/multiprocessing.rst:1716 +#: ../../library/multiprocessing.rst:1721 msgid "Managers" msgstr "" -#: ../../library/multiprocessing.rst:1718 +#: ../../library/multiprocessing.rst:1723 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 +2567,7 @@ msgid "" "proxies." msgstr "" -#: ../../library/multiprocessing.rst:1727 +#: ../../library/multiprocessing.rst:1732 msgid "" "Returns a started :class:`~multiprocessing.managers.SyncManager` object " "which can be used for sharing objects between processes. The returned " @@ -2570,31 +2575,31 @@ msgid "" "will create shared objects and return corresponding proxies." msgstr "" -#: ../../library/multiprocessing.rst:1735 +#: ../../library/multiprocessing.rst:1740 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:1746 msgid "Create a BaseManager object." msgstr "建立一個 BaseManager 物件。" -#: ../../library/multiprocessing.rst:1743 +#: ../../library/multiprocessing.rst:1748 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:1751 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:1754 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 +2607,19 @@ msgid "" "it must be a byte string." msgstr "" -#: ../../library/multiprocessing.rst:1754 +#: ../../library/multiprocessing.rst:1759 msgid "" "*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or " "``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization)." msgstr "" -#: ../../library/multiprocessing.rst:1757 +#: ../../library/multiprocessing.rst:1762 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:1765 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 +2627,24 @@ msgid "" "also times out, the process is killed." msgstr "" -#: ../../library/multiprocessing.rst:1765 +#: ../../library/multiprocessing.rst:1770 msgid "Added the *shutdown_timeout* parameter." msgstr "新增 *shutdown_timeout* 參數。" -#: ../../library/multiprocessing.rst:1770 +#: ../../library/multiprocessing.rst:1775 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:1780 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:1784 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> manager = BaseManager(address=('', 50000), authkey=b'abc')\n" @@ -2651,15 +2656,15 @@ msgstr "" ">>> server = manager.get_server()\n" ">>> server.serve_forever()" -#: ../../library/multiprocessing.rst:1784 +#: ../../library/multiprocessing.rst:1789 msgid ":class:`Server` additionally has an :attr:`address` attribute." msgstr "" -#: ../../library/multiprocessing.rst:1788 +#: ../../library/multiprocessing.rst:1793 msgid "Connect a local manager object to a remote manager process::" msgstr "" -#: ../../library/multiprocessing.rst:1790 +#: ../../library/multiprocessing.rst:1795 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" @@ -2669,29 +2674,29 @@ msgstr "" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" ">>> m.connect()" -#: ../../library/multiprocessing.rst:1796 +#: ../../library/multiprocessing.rst:1801 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:1804 msgid "This can be called multiple times." msgstr "" -#: ../../library/multiprocessing.rst:1803 +#: ../../library/multiprocessing.rst:1808 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:1811 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:1814 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 +2704,14 @@ msgid "" "then this can be left as ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1815 +#: ../../library/multiprocessing.rst:1820 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:1824 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 +2722,7 @@ msgid "" "method and whose name does not begin with ``'_'``.)" msgstr "" -#: ../../library/multiprocessing.rst:1828 +#: ../../library/multiprocessing.rst:1833 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 +2732,22 @@ msgid "" "returned by the method will be copied by value." msgstr "" -#: ../../library/multiprocessing.rst:1835 +#: ../../library/multiprocessing.rst:1840 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:1844 msgid ":class:`BaseManager` instances also have one read-only property:" msgstr "" -#: ../../library/multiprocessing.rst:1843 +#: ../../library/multiprocessing.rst:1848 msgid "The address used by the manager." msgstr "" -#: ../../library/multiprocessing.rst:1845 +#: ../../library/multiprocessing.rst:1850 msgid "" "Manager objects support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` starts the server " @@ -2750,121 +2755,121 @@ msgid "" "object. :meth:`~contextmanager.__exit__` calls :meth:`shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:1851 +#: ../../library/multiprocessing.rst:1856 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:1861 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:1865 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:1871 msgid "" "Create a shared :class:`threading.Barrier` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1873 +#: ../../library/multiprocessing.rst:1878 msgid "" "Create a shared :class:`threading.BoundedSemaphore` object and return a " "proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1878 +#: ../../library/multiprocessing.rst:1883 msgid "" "Create a shared :class:`threading.Condition` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1881 +#: ../../library/multiprocessing.rst:1886 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:1894 msgid "" "Create a shared :class:`threading.Event` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1893 +#: ../../library/multiprocessing.rst:1898 msgid "" "Create a shared :class:`threading.Lock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1897 +#: ../../library/multiprocessing.rst:1902 msgid "Create a shared :class:`Namespace` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1901 +#: ../../library/multiprocessing.rst:1906 msgid "Create a shared :class:`queue.Queue` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1905 +#: ../../library/multiprocessing.rst:1910 msgid "" "Create a shared :class:`threading.RLock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1909 +#: ../../library/multiprocessing.rst:1914 msgid "" "Create a shared :class:`threading.Semaphore` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1914 +#: ../../library/multiprocessing.rst:1919 msgid "Create an array and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1918 +#: ../../library/multiprocessing.rst:1923 msgid "" "Create an object with a writable ``value`` attribute and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1925 +#: ../../library/multiprocessing.rst:1930 msgid "Create a shared :class:`dict` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1930 +#: ../../library/multiprocessing.rst:1935 msgid "Create a shared :class:`list` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1932 +#: ../../library/multiprocessing.rst:1937 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:1944 msgid "A type that can register with :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1941 +#: ../../library/multiprocessing.rst:1946 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:1949 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:1953 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -2876,18 +2881,18 @@ msgid "" "Namespace(x=10, y='hello')" msgstr "" -#: ../../library/multiprocessing.rst:1961 +#: ../../library/multiprocessing.rst:1966 msgid "Customized managers" msgstr "" -#: ../../library/multiprocessing.rst:1963 +#: ../../library/multiprocessing.rst:1968 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:1972 msgid "" "from multiprocessing.managers import BaseManager\n" "\n" @@ -2927,23 +2932,23 @@ msgstr "" " print(maths.add(4, 3)) # 印出 7\n" " print(maths.mul(7, 8)) # 印出 56" -#: ../../library/multiprocessing.rst:1988 +#: ../../library/multiprocessing.rst:1993 msgid "Using a remote manager" msgstr "" -#: ../../library/multiprocessing.rst:1990 +#: ../../library/multiprocessing.rst:1995 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:1998 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:2001 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> from queue import Queue\n" @@ -2963,11 +2968,11 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2005 +#: ../../library/multiprocessing.rst:2010 msgid "One client can access the server as follows::" msgstr "" -#: ../../library/multiprocessing.rst:2007 +#: ../../library/multiprocessing.rst:2012 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -2987,11 +2992,11 @@ msgstr "" ">>> queue = m.get_queue()\n" ">>> queue.put('hello')" -#: ../../library/multiprocessing.rst:2015 +#: ../../library/multiprocessing.rst:2020 msgid "Another client can also use it::" msgstr "" -#: ../../library/multiprocessing.rst:2017 +#: ../../library/multiprocessing.rst:2022 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3013,13 +3018,13 @@ msgstr "" ">>> queue.get()\n" "'hello'" -#: ../../library/multiprocessing.rst:2026 +#: ../../library/multiprocessing.rst:2031 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:2034 msgid "" ">>> from multiprocessing import Process, Queue\n" ">>> from multiprocessing.managers import BaseManager\n" @@ -3059,18 +3064,18 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2051 +#: ../../library/multiprocessing.rst:2056 msgid "Proxy Objects" msgstr "" -#: ../../library/multiprocessing.rst:2053 +#: ../../library/multiprocessing.rst:2058 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:2062 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 +3083,7 @@ msgid "" "its referent can:" msgstr "" -#: ../../library/multiprocessing.rst:2061 +#: ../../library/multiprocessing.rst:2066 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3104,14 +3109,14 @@ msgstr "" ">>> l[2:5]\n" "[4, 9, 16]" -#: ../../library/multiprocessing.rst:2075 +#: ../../library/multiprocessing.rst:2080 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:2084 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 +3124,7 @@ msgid "" "lists, dicts, and other :ref:`multiprocessing-proxy_objects`:" msgstr "" -#: ../../library/multiprocessing.rst:2084 +#: ../../library/multiprocessing.rst:2089 msgid "" ">>> a = manager.list()\n" ">>> b = manager.list()\n" @@ -3131,11 +3136,11 @@ msgid "" "['hello'] ['hello']" msgstr "" -#: ../../library/multiprocessing.rst:2095 +#: ../../library/multiprocessing.rst:2100 msgid "Similarly, dict and list proxies may be nested inside one another::" msgstr "" -#: ../../library/multiprocessing.rst:2097 +#: ../../library/multiprocessing.rst:2102 msgid "" ">>> l_outer = manager.list([ manager.dict() for i in range(2) ])\n" ">>> d_first_inner = l_outer[0]\n" @@ -3159,7 +3164,7 @@ msgstr "" ">>> print(l_outer[1])\n" "{'c': 3, 'z': 26}" -#: ../../library/multiprocessing.rst:2108 +#: ../../library/multiprocessing.rst:2113 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 +3175,7 @@ msgid "" "assign the modified value to the container proxy::" msgstr "" -#: ../../library/multiprocessing.rst:2116 +#: ../../library/multiprocessing.rst:2121 msgid "" "# create a list proxy and append a mutable object (a dictionary)\n" "lproxy = manager.list()\n" @@ -3184,20 +3189,20 @@ msgid "" "lproxy[0] = d" msgstr "" -#: ../../library/multiprocessing.rst:2127 +#: ../../library/multiprocessing.rst:2132 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:2138 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:2141 msgid "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" @@ -3205,48 +3210,48 @@ msgstr "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" -#: ../../library/multiprocessing.rst:2141 +#: ../../library/multiprocessing.rst:2146 msgid "" "One should just use a copy of the referent instead when making comparisons." msgstr "" -#: ../../library/multiprocessing.rst:2145 +#: ../../library/multiprocessing.rst:2150 msgid "Proxy objects are instances of subclasses of :class:`BaseProxy`." msgstr "" -#: ../../library/multiprocessing.rst:2149 +#: ../../library/multiprocessing.rst:2154 msgid "Call and return the result of a method of the proxy's referent." msgstr "" -#: ../../library/multiprocessing.rst:2151 +#: ../../library/multiprocessing.rst:2156 msgid "" "If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2153 +#: ../../library/multiprocessing.rst:2158 msgid "proxy._callmethod(methodname, args, kwds)" msgstr "proxy._callmethod(methodname, args, kwds)" -#: ../../library/multiprocessing.rst:2155 +#: ../../library/multiprocessing.rst:2160 msgid "will evaluate the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2157 +#: ../../library/multiprocessing.rst:2162 msgid "getattr(obj, methodname)(*args, **kwds)" msgstr "getattr(obj, methodname)(*args, **kwds)" -#: ../../library/multiprocessing.rst:2159 +#: ../../library/multiprocessing.rst:2164 msgid "in the manager's process." msgstr "" -#: ../../library/multiprocessing.rst:2161 +#: ../../library/multiprocessing.rst:2166 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:2170 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 +3259,17 @@ msgid "" "meth:`_callmethod`." msgstr "" -#: ../../library/multiprocessing.rst:2170 +#: ../../library/multiprocessing.rst:2175 msgid "" "Note in particular that an exception will be raised if *methodname* has not " "been *exposed*." msgstr "" -#: ../../library/multiprocessing.rst:2173 +#: ../../library/multiprocessing.rst:2178 msgid "An example of the usage of :meth:`_callmethod`:" msgstr "" -#: ../../library/multiprocessing.rst:2175 +#: ../../library/multiprocessing.rst:2180 msgid "" ">>> l = manager.list(range(10))\n" ">>> l._callmethod('__len__')\n" @@ -3286,69 +3291,69 @@ msgstr "" "...\n" "IndexError: list index out of range" -#: ../../library/multiprocessing.rst:2189 +#: ../../library/multiprocessing.rst:2194 msgid "Return a copy of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2191 +#: ../../library/multiprocessing.rst:2196 msgid "If the referent is unpicklable then this will raise an exception." msgstr "" -#: ../../library/multiprocessing.rst:2195 +#: ../../library/multiprocessing.rst:2200 msgid "Return a representation of the proxy object." msgstr "" -#: ../../library/multiprocessing.rst:2199 +#: ../../library/multiprocessing.rst:2204 msgid "Return the representation of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2203 +#: ../../library/multiprocessing.rst:2208 msgid "Cleanup" msgstr "" -#: ../../library/multiprocessing.rst:2205 +#: ../../library/multiprocessing.rst:2210 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:2213 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:2218 msgid "Process Pools" msgstr "" -#: ../../library/multiprocessing.rst:2218 +#: ../../library/multiprocessing.rst:2223 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:2228 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:2232 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:2235 +#: ../../library/multiprocessing.rst:2799 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:2238 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 +3361,7 @@ msgid "" "which means worker processes will live as long as the pool." msgstr "" -#: ../../library/multiprocessing.rst:2238 +#: ../../library/multiprocessing.rst:2243 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 +3369,13 @@ msgid "" "both cases *context* is set appropriately." msgstr "" -#: ../../library/multiprocessing.rst:2244 +#: ../../library/multiprocessing.rst:2249 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:2253 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 +3383,28 @@ msgid "" "to do this can lead to the process hanging on finalization." msgstr "" -#: ../../library/multiprocessing.rst:2253 +#: ../../library/multiprocessing.rst:2258 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:2262 msgid "Added the *maxtasksperchild* parameter." msgstr "新增 *maxtasksperchild* 參數。" -#: ../../library/multiprocessing.rst:2260 +#: ../../library/multiprocessing.rst:2265 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/multiprocessing.rst:2263 +#: ../../library/multiprocessing.rst:2268 msgid "" "*processes* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/multiprocessing.rst:2269 +#: ../../library/multiprocessing.rst:2274 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 +3415,7 @@ msgid "" "ability to the end user." msgstr "" -#: ../../library/multiprocessing.rst:2279 +#: ../../library/multiprocessing.rst:2284 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 +3423,14 @@ msgid "" "executed in one of the workers of the pool." msgstr "" -#: ../../library/multiprocessing.rst:2286 +#: ../../library/multiprocessing.rst:2291 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:2294 +#: ../../library/multiprocessing.rst:2325 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 +3438,60 @@ msgid "" "applied instead." msgstr "" -#: ../../library/multiprocessing.rst:2294 -#: ../../library/multiprocessing.rst:2325 +#: ../../library/multiprocessing.rst:2299 +#: ../../library/multiprocessing.rst:2330 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:2303 +#: ../../library/multiprocessing.rst:2334 msgid "" "Callbacks should complete immediately since otherwise the thread which " "handles the results will get blocked." msgstr "" -#: ../../library/multiprocessing.rst:2303 +#: ../../library/multiprocessing.rst:2308 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:2312 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:2316 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:2322 msgid "" "A variant of the :meth:`.map` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2334 +#: ../../library/multiprocessing.rst:2339 msgid "A lazier version of :meth:`.map`." msgstr "" -#: ../../library/multiprocessing.rst:2336 +#: ../../library/multiprocessing.rst:2341 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:2346 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 +3499,65 @@ msgid "" "result cannot be returned within *timeout* seconds." msgstr "" -#: ../../library/multiprocessing.rst:2348 +#: ../../library/multiprocessing.rst:2353 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:2359 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:2363 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:2370 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:2378 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:2383 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:2389 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:2392 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:2400 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:2405 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 +3565,31 @@ msgid "" "exception will be reraised by :meth:`get`." msgstr "" -#: ../../library/multiprocessing.rst:2407 +#: ../../library/multiprocessing.rst:2412 msgid "Wait until the result is available or until *timeout* seconds pass." msgstr "" -#: ../../library/multiprocessing.rst:2411 +#: ../../library/multiprocessing.rst:2416 msgid "Return whether the call has completed." msgstr "" -#: ../../library/multiprocessing.rst:2415 +#: ../../library/multiprocessing.rst:2420 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:2423 msgid "" "If the result is not ready, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:2422 +#: ../../library/multiprocessing.rst:2427 msgid "The following example demonstrates the use of a pool::" msgstr "" -#: ../../library/multiprocessing.rst:2424 +#: ../../library/multiprocessing.rst:2429 msgid "" "from multiprocessing import Pool\n" "import time\n" @@ -3612,17 +3617,17 @@ msgid "" "TimeoutError" msgstr "" -#: ../../library/multiprocessing.rst:2449 +#: ../../library/multiprocessing.rst:2454 msgid "Listeners and Clients" msgstr "" -#: ../../library/multiprocessing.rst:2454 +#: ../../library/multiprocessing.rst:2459 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:2463 msgid "" "However, the :mod:`multiprocessing.connection` module allows some extra " "flexibility. It basically gives a high level message oriented API for " @@ -3631,46 +3636,46 @@ msgid "" "multiple connections at the same time." msgstr "" -#: ../../library/multiprocessing.rst:2467 +#: ../../library/multiprocessing.rst:2472 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:2475 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:2481 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:2484 msgid "" "If a welcome message is not received, then :exc:`~multiprocessing." "AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2484 +#: ../../library/multiprocessing.rst:2489 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:2492 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:2496 +#: ../../library/multiprocessing.rst:2531 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 +3684,26 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:2499 +#: ../../library/multiprocessing.rst:2504 msgid "" "A wrapper for a bound socket or Windows named pipe which is 'listening' for " "connections." msgstr "" -#: ../../library/multiprocessing.rst:2502 +#: ../../library/multiprocessing.rst:2507 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:2512 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:2516 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 +3717,49 @@ msgid "" "using :func:`tempfile.mkstemp`." msgstr "" -#: ../../library/multiprocessing.rst:2522 +#: ../../library/multiprocessing.rst:2527 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:2539 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:2546 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:2550 msgid "Listener objects have the following read-only properties:" msgstr "" -#: ../../library/multiprocessing.rst:2549 +#: ../../library/multiprocessing.rst:2554 msgid "The address which is being used by the Listener object." msgstr "" -#: ../../library/multiprocessing.rst:2553 +#: ../../library/multiprocessing.rst:2558 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:2561 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:2568 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 +3768,32 @@ msgid "" "zero timeout." msgstr "" -#: ../../library/multiprocessing.rst:2569 +#: ../../library/multiprocessing.rst:2574 msgid "" "For both POSIX and Windows, an object can appear in *object_list* if it is" msgstr "" -#: ../../library/multiprocessing.rst:2572 +#: ../../library/multiprocessing.rst:2577 msgid "a readable :class:`~multiprocessing.connection.Connection` object;" msgstr "" -#: ../../library/multiprocessing.rst:2573 +#: ../../library/multiprocessing.rst:2578 msgid "a connected and readable :class:`socket.socket` object; or" msgstr "" -#: ../../library/multiprocessing.rst:2574 +#: ../../library/multiprocessing.rst:2579 msgid "" "the :attr:`~multiprocessing.Process.sentinel` attribute of a :class:" "`~multiprocessing.Process` object." msgstr "" -#: ../../library/multiprocessing.rst:2577 +#: ../../library/multiprocessing.rst:2582 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:2585 msgid "" "**POSIX**: ``wait(object_list, timeout)`` almost equivalent ``select." "select(object_list, [], [], timeout)``. The difference is that, if :func:" @@ -3796,7 +3801,7 @@ msgid "" "an error number of ``EINTR``, whereas :func:`wait` will not." msgstr "" -#: ../../library/multiprocessing.rst:2586 +#: ../../library/multiprocessing.rst:2591 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 +3811,18 @@ msgid "" "handles.)" msgstr "" -#: ../../library/multiprocessing.rst:2596 +#: ../../library/multiprocessing.rst:2601 msgid "**Examples**" msgstr "" -#: ../../library/multiprocessing.rst:2598 +#: ../../library/multiprocessing.rst:2603 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:2607 msgid "" "from multiprocessing.connection import Listener\n" "from array import array\n" @@ -3835,13 +3840,13 @@ msgid "" " conn.send_bytes(array('i', [42, 1729]))" msgstr "" -#: ../../library/multiprocessing.rst:2617 +#: ../../library/multiprocessing.rst:2622 msgid "" "The following code connects to the server and receives some data from the " "server::" msgstr "" -#: ../../library/multiprocessing.rst:2620 +#: ../../library/multiprocessing.rst:2625 msgid "" "from multiprocessing.connection import Client\n" "from array import array\n" @@ -3871,13 +3876,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:2639 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:2642 msgid "" "from multiprocessing import Process, Pipe, current_process\n" "from multiprocessing.connection import wait\n" @@ -3911,23 +3916,23 @@ msgid "" " print(msg)" msgstr "" -#: ../../library/multiprocessing.rst:2672 +#: ../../library/multiprocessing.rst:2677 msgid "Address Formats" msgstr "" -#: ../../library/multiprocessing.rst:2674 +#: ../../library/multiprocessing.rst:2679 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:2682 msgid "" "An ``'AF_UNIX'`` address is a string representing a filename on the " "filesystem." msgstr "" -#: ../../library/multiprocessing.rst:2680 +#: ../../library/multiprocessing.rst:2685 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 +3941,17 @@ msgid "" "instead." msgstr "" -#: ../../library/multiprocessing.rst:2685 +#: ../../library/multiprocessing.rst:2690 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:2697 msgid "Authentication keys" msgstr "" -#: ../../library/multiprocessing.rst:2694 +#: ../../library/multiprocessing.rst:2699 msgid "" "When one uses :meth:`Connection.recv `, the data received " "is automatically unpickled. Unfortunately unpickling data from an untrusted " @@ -3954,7 +3959,7 @@ msgid "" "use the :mod:`hmac` module to provide digest authentication." msgstr "" -#: ../../library/multiprocessing.rst:2700 +#: ../../library/multiprocessing.rst:2705 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 +3967,7 @@ msgid "" "using the same key does **not** involve sending the key over the connection.)" msgstr "" -#: ../../library/multiprocessing.rst:2706 +#: ../../library/multiprocessing.rst:2711 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 +3978,17 @@ msgid "" "setting up connections between themselves." msgstr "" -#: ../../library/multiprocessing.rst:2714 +#: ../../library/multiprocessing.rst:2719 msgid "" "Suitable authentication keys can also be generated by using :func:`os." "urandom`." msgstr "" -#: ../../library/multiprocessing.rst:2718 +#: ../../library/multiprocessing.rst:2723 msgid "Logging" msgstr "" -#: ../../library/multiprocessing.rst:2720 +#: ../../library/multiprocessing.rst:2725 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 +3996,27 @@ msgid "" "mixed up." msgstr "" -#: ../../library/multiprocessing.rst:2727 +#: ../../library/multiprocessing.rst:2732 msgid "" "Returns the logger used by :mod:`multiprocessing`. If necessary, a new one " "will be created." msgstr "" -#: ../../library/multiprocessing.rst:2730 +#: ../../library/multiprocessing.rst:2735 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:2739 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:2746 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 +4025,11 @@ msgid "" "``level`` argument." msgstr "" -#: ../../library/multiprocessing.rst:2747 +#: ../../library/multiprocessing.rst:2752 msgid "Below is an example session with logging turned on::" msgstr "" -#: ../../library/multiprocessing.rst:2749 +#: ../../library/multiprocessing.rst:2754 msgid "" ">>> import multiprocessing, logging\n" ">>> logger = multiprocessing.log_to_stderr()\n" @@ -4052,21 +4057,21 @@ msgstr "" "[INFO/MainProcess] sending shutdown message to manager\n" "[INFO/SyncManager-...] manager exiting with exitcode 0" -#: ../../library/multiprocessing.rst:2762 +#: ../../library/multiprocessing.rst:2767 msgid "For a full table of logging levels, see the :mod:`logging` module." msgstr "" -#: ../../library/multiprocessing.rst:2766 +#: ../../library/multiprocessing.rst:2771 msgid "The :mod:`multiprocessing.dummy` module" msgstr ":mod:`multiprocessing.dummy` 模組" -#: ../../library/multiprocessing.rst:2771 +#: ../../library/multiprocessing.rst:2776 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:2781 msgid "" "In particular, the ``Pool`` function provided by :mod:`multiprocessing." "dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :" @@ -4074,7 +4079,7 @@ msgid "" "worker threads rather than worker processes." msgstr "" -#: ../../library/multiprocessing.rst:2784 +#: ../../library/multiprocessing.rst:2789 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 +4089,18 @@ msgid "" "pool.Pool.terminate` manually." msgstr "" -#: ../../library/multiprocessing.rst:2791 +#: ../../library/multiprocessing.rst:2796 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:2802 msgid "" "Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided." msgstr "" -#: ../../library/multiprocessing.rst:2801 +#: ../../library/multiprocessing.rst:2806 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 +4110,7 @@ msgid "" "is not understood by any other libraries." msgstr "" -#: ../../library/multiprocessing.rst:2808 +#: ../../library/multiprocessing.rst:2813 msgid "" "Users should generally prefer to use :class:`concurrent.futures." "ThreadPoolExecutor`, which has a simpler interface that was designed around " @@ -4114,69 +4119,69 @@ msgid "" "`asyncio`." msgstr "" -#: ../../library/multiprocessing.rst:2818 +#: ../../library/multiprocessing.rst:2823 msgid "Programming guidelines" msgstr "" -#: ../../library/multiprocessing.rst:2820 +#: ../../library/multiprocessing.rst:2825 msgid "" "There are certain guidelines and idioms which should be adhered to when " "using :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:2825 +#: ../../library/multiprocessing.rst:2830 msgid "All start methods" msgstr "" -#: ../../library/multiprocessing.rst:2827 +#: ../../library/multiprocessing.rst:2832 msgid "The following applies to all start methods." msgstr "" -#: ../../library/multiprocessing.rst:2829 +#: ../../library/multiprocessing.rst:2834 msgid "Avoid shared state" msgstr "" -#: ../../library/multiprocessing.rst:2831 +#: ../../library/multiprocessing.rst:2836 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:2839 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:2843 msgid "Picklability" msgstr "" -#: ../../library/multiprocessing.rst:2840 +#: ../../library/multiprocessing.rst:2845 msgid "Ensure that the arguments to the methods of proxies are picklable." msgstr "" -#: ../../library/multiprocessing.rst:2842 +#: ../../library/multiprocessing.rst:2847 msgid "Thread safety of proxies" msgstr "" -#: ../../library/multiprocessing.rst:2844 +#: ../../library/multiprocessing.rst:2849 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:2852 msgid "" "(There is never a problem with different processes using the *same* proxy.)" msgstr "" -#: ../../library/multiprocessing.rst:2849 +#: ../../library/multiprocessing.rst:2854 msgid "Joining zombie processes" msgstr "" -#: ../../library/multiprocessing.rst:2851 +#: ../../library/multiprocessing.rst:2856 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 +4192,11 @@ msgid "" "explicitly join all the processes that you start." msgstr "" -#: ../../library/multiprocessing.rst:2859 +#: ../../library/multiprocessing.rst:2864 msgid "Better to inherit than pickle/unpickle" msgstr "" -#: ../../library/multiprocessing.rst:2861 +#: ../../library/multiprocessing.rst:2866 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 +4206,11 @@ msgid "" "inherit it from an ancestor process." msgstr "" -#: ../../library/multiprocessing.rst:2869 +#: ../../library/multiprocessing.rst:2874 msgid "Avoid terminating processes" msgstr "" -#: ../../library/multiprocessing.rst:2871 +#: ../../library/multiprocessing.rst:2876 msgid "" "Using the :meth:`Process.terminate ` " "method to stop a process is liable to cause any shared resources (such as " @@ -4213,18 +4218,18 @@ msgid "" "become broken or unavailable to other processes." msgstr "" -#: ../../library/multiprocessing.rst:2877 +#: ../../library/multiprocessing.rst:2882 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:2886 msgid "Joining processes that use queues" msgstr "" -#: ../../library/multiprocessing.rst:2883 +#: ../../library/multiprocessing.rst:2888 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 +4238,7 @@ msgid "" "queue to avoid this behaviour.)" msgstr "" -#: ../../library/multiprocessing.rst:2889 +#: ../../library/multiprocessing.rst:2894 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 +4247,11 @@ msgid "" "processes will be joined automatically." msgstr "" -#: ../../library/multiprocessing.rst:2895 +#: ../../library/multiprocessing.rst:2900 msgid "An example which will deadlock is the following::" msgstr "" -#: ../../library/multiprocessing.rst:2897 +#: ../../library/multiprocessing.rst:2902 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -4261,17 +4266,17 @@ msgid "" " obj = queue.get()" msgstr "" -#: ../../library/multiprocessing.rst:2909 +#: ../../library/multiprocessing.rst:2914 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:2917 msgid "Explicitly pass resources to child processes" msgstr "" -#: ../../library/multiprocessing.rst:2914 +#: ../../library/multiprocessing.rst:2919 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 +4284,7 @@ msgid "" "for the child process." msgstr "" -#: ../../library/multiprocessing.rst:2919 +#: ../../library/multiprocessing.rst:2924 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 +4293,11 @@ msgid "" "collected in the parent process." msgstr "" -#: ../../library/multiprocessing.rst:2926 +#: ../../library/multiprocessing.rst:2931 msgid "So for instance ::" msgstr "" -#: ../../library/multiprocessing.rst:2928 +#: ../../library/multiprocessing.rst:2933 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4314,11 +4319,11 @@ msgstr "" " for i in range(10):\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:2938 +#: ../../library/multiprocessing.rst:2943 msgid "should be rewritten as ::" msgstr "" -#: ../../library/multiprocessing.rst:2940 +#: ../../library/multiprocessing.rst:2945 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4340,25 +4345,25 @@ msgstr "" " for i in range(10):\n" " Process(target=f, args=(lock,)).start()" -#: ../../library/multiprocessing.rst:2950 +#: ../../library/multiprocessing.rst:2955 msgid "Beware of replacing :data:`sys.stdin` with a \"file like object\"" msgstr "" -#: ../../library/multiprocessing.rst:2952 +#: ../../library/multiprocessing.rst:2957 msgid ":mod:`multiprocessing` originally unconditionally called::" msgstr "" -#: ../../library/multiprocessing.rst:2954 +#: ../../library/multiprocessing.rst:2959 msgid "os.close(sys.stdin.fileno())" msgstr "os.close(sys.stdin.fileno())" -#: ../../library/multiprocessing.rst:2956 +#: ../../library/multiprocessing.rst:2961 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:2964 msgid "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" @@ -4366,7 +4371,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:2967 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 +4381,14 @@ msgid "" "data being flushed to the object multiple times, resulting in corruption." msgstr "" -#: ../../library/multiprocessing.rst:2969 +#: ../../library/multiprocessing.rst:2974 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:2978 msgid "" "@property\n" "def cache(self):\n" @@ -4401,26 +4406,26 @@ msgstr "" " self._cache = []\n" " return self._cache" -#: ../../library/multiprocessing.rst:2981 +#: ../../library/multiprocessing.rst:2986 msgid "" "For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`" msgstr "" -#: ../../library/multiprocessing.rst:2984 +#: ../../library/multiprocessing.rst:2989 msgid "The *spawn* and *forkserver* start methods" msgstr "" -#: ../../library/multiprocessing.rst:2986 +#: ../../library/multiprocessing.rst:2991 msgid "" "There are a few extra restrictions which don't apply to the *fork* start " "method." msgstr "" -#: ../../library/multiprocessing.rst:2989 +#: ../../library/multiprocessing.rst:2994 msgid "More picklability" msgstr "" -#: ../../library/multiprocessing.rst:2991 +#: ../../library/multiprocessing.rst:2996 msgid "" "Ensure that all arguments to :meth:`Process.__init__` are picklable. Also, " "if you subclass :class:`~multiprocessing.Process` then make sure that " @@ -4428,11 +4433,11 @@ msgid "" "Process.start>` method is called." msgstr "" -#: ../../library/multiprocessing.rst:2996 +#: ../../library/multiprocessing.rst:3001 msgid "Global variables" msgstr "" -#: ../../library/multiprocessing.rst:2998 +#: ../../library/multiprocessing.rst:3003 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 +4445,30 @@ msgid "" "Process.start>` was called." msgstr "" -#: ../../library/multiprocessing.rst:3003 +#: ../../library/multiprocessing.rst:3008 msgid "" "However, global variables which are just module level constants cause no " "problems." msgstr "" -#: ../../library/multiprocessing.rst:3008 +#: ../../library/multiprocessing.rst:3013 msgid "Safe importing of main module" msgstr "" -#: ../../library/multiprocessing.rst:3010 +#: ../../library/multiprocessing.rst:3015 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:3019 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:3023 msgid "" "from multiprocessing import Process\n" "\n" @@ -4481,13 +4486,13 @@ msgstr "" "p = Process(target=foo)\n" "p.start()" -#: ../../library/multiprocessing.rst:3026 +#: ../../library/multiprocessing.rst:3031 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:3034 msgid "" "from multiprocessing import Process, freeze_support, set_start_method\n" "\n" @@ -4511,33 +4516,33 @@ msgstr "" " p = Process(target=foo)\n" " p.start()" -#: ../../library/multiprocessing.rst:3040 +#: ../../library/multiprocessing.rst:3045 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:3048 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:3051 msgid "" "Similar restrictions apply if a pool or manager is created in the main " "module." msgstr "" -#: ../../library/multiprocessing.rst:3053 +#: ../../library/multiprocessing.rst:3058 msgid "Examples" msgstr "範例" -#: ../../library/multiprocessing.rst:3055 +#: ../../library/multiprocessing.rst:3060 msgid "Demonstration of how to create and use customized managers and proxies:" msgstr "" -#: ../../library/multiprocessing.rst:3057 +#: ../../library/multiprocessing.rst:3062 msgid "" "from multiprocessing import freeze_support\n" "from multiprocessing.managers import BaseManager, BaseProxy\n" @@ -4631,11 +4636,11 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3061 +#: ../../library/multiprocessing.rst:3066 msgid "Using :class:`~multiprocessing.pool.Pool`:" msgstr "使用 :class:`~multiprocessing.pool.Pool`:" -#: ../../library/multiprocessing.rst:3063 +#: ../../library/multiprocessing.rst:3068 msgid "" "import multiprocessing\n" "import time\n" @@ -4795,13 +4800,13 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3067 +#: ../../library/multiprocessing.rst:3072 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:3075 msgid "" "import time\n" "import random\n" diff --git a/library/sys.monitoring.po b/library/sys.monitoring.po index ff8a42a082..a5492dea11 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,38 @@ msgstr "" "如果給定的 *tool_id* 和 *event* 已經註冊了另一個回呼,則會取消註冊並回傳。否" "則 :func:`register_callback` 會回傳 ``None``。" -#: ../../library/sys.monitoring.rst:318 +#: ../../library/sys.monitoring.rst:317 +#, fuzzy 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 "" "可以透過呼叫 ``sys.monitoring.register_callback(tool_id, event, None)`` 來取" "消註冊函式。" -#: ../../library/sys.monitoring.rst:321 +#: ../../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: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 +584,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 +604,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 +620,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 +643,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 +663,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 +672,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..3277f78d08 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,34 @@ 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 +#, fuzzy 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 tarfile\n" +"with tarfile.open(\"sample.tar\", \"w\") 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 +1905,17 @@ msgstr "" "tar.add(\"foo\", filter=reset)\n" "tar.close()" -#: ../../library/tarfile.rst:1374 +#: ../../library/tarfile.rst:1390 msgid "Supported tar formats" msgstr "" -#: ../../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 +1923,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 +1931,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 +1942,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 +1951,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 +1966,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 +1991,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 +2006,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,7 +2014,7 @@ 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 " diff --git a/library/venv.po b/library/venv.po index 659bbd17f1..dd60f24edc 100644 --- a/library/venv.po +++ b/library/venv.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-12 00:16+0000\n" +"POT-Creation-Date: 2025-07-18 00:17+0000\n" "PO-Revision-Date: 2025-05-23 10:20+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,13 +29,14 @@ msgid "**Source code:** :source:`Lib/venv/`" msgstr "**原始碼:**\\ :source:`Lib/venv/`" #: ../../library/venv.rst:21 +#, fuzzy msgid "" "The :mod:`!venv` module supports creating lightweight \"virtual " "environments\", each with their own independent set of Python packages " "installed in their :mod:`site` directories. A virtual environment is created " "on top of an existing Python installation, known as the virtual " -"environment's \"base\" Python, and may optionally be isolated from the " -"packages in the base environment, so only those explicitly installed in the " +"environment's \"base\" Python, and by default is isolated from the packages " +"in the base environment, so that only those explicitly installed in the " "virtual environment are available." msgstr "" ":mod:`!venv` 模組支援建立輕量級的「虛擬環境」,每個虛擬環境都有獨立安裝在其 :" diff --git a/tutorial/modules.po b/tutorial/modules.po index 83ea14a296..fa7b486881 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-07-22 00:17+0000\n" "PO-Revision-Date: 2022-10-23 20:30+0800\n" "Last-Translator: Phil Lin \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1176,11 +1176,12 @@ msgstr "" "from ..filters import equalizer" #: ../../tutorial/modules.rst:582 +#, fuzzy msgid "" -"Note that relative imports are based on the name of the current module. " -"Since the name of the main module is always ``\"__main__\"``, modules " -"intended for use as the main module of a Python application must always use " -"absolute imports." +"Note that relative imports are based on the name of the current module's " +"package. Since the main module does not have a package, modules intended for " +"use as the main module of a Python application must always use absolute " +"imports." msgstr "" "請注意,相對 import 的運作是以目前的模組名稱為依據。因為主模組的名稱永遠是 " "``\"__main__\"``,所以如果一個模組預期被用作 Python 應用程式的主模組,那它必" diff --git a/using/configure.po b/using/configure.po index 29c14f2637..010752d836 100644 --- a/using/configure.po +++ b/using/configure.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-04 00:16+0000\n" +"POT-Creation-Date: 2025-07-21 00:18+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-" @@ -606,11 +606,11 @@ msgstr "``pkg-config`` 選項。" msgid "C compiler options" msgstr "C 編譯器選項。" -#: ../../using/configure.rst:341 ../../using/configure.rst:1254 +#: ../../using/configure.rst:341 ../../using/configure.rst:1257 msgid "C compiler command." msgstr "C 編譯器指令。" -#: ../../using/configure.rst:345 ../../using/configure.rst:1266 +#: ../../using/configure.rst:345 ../../using/configure.rst:1269 msgid "C compiler flags." msgstr "C 編譯器旗標。" @@ -622,7 +622,7 @@ msgstr "C 預處理器指令。" msgid "C preprocessor flags, e.g. :samp:`-I{include_dir}`." msgstr "C 預處理器旗標,例如::samp:`-I{include_dir}`。" -#: ../../using/configure.rst:357 ../../using/configure.rst:799 +#: ../../using/configure.rst:357 ../../using/configure.rst:802 msgid "Linker options" msgstr "" @@ -1175,30 +1175,33 @@ msgstr "" #: ../../using/configure.rst:773 msgid "" -"Enable AddressSanitizer memory error detector, ``asan`` (default is no)." -msgstr "啟用 AddressSanitizer 記憶體錯誤偵測器 ``asan``\\ (預設不啟用)。" +"Enable AddressSanitizer memory error detector, ``asan`` (default is no). To " +"improve ASan detection capabilities you may also want to combine this with :" +"option:`--without-pymalloc` to disable the specialized small-object " +"allocator whose allocations are not tracked by ASan." +msgstr "" -#: ../../using/configure.rst:779 +#: ../../using/configure.rst:782 msgid "" "Enable MemorySanitizer allocation error detector, ``msan`` (default is no)." msgstr "啟用 MemorySanitizer 分配錯誤偵測器 ``msan``\\ (預設不啟用)。" -#: ../../using/configure.rst:785 +#: ../../using/configure.rst:788 msgid "" "Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan`` " "(default is no)." msgstr "" "啟用 UndefinedBehaviorSanitizer 未定義行為偵測器 ``ubsan``\\ (預設不啟用)。" -#: ../../using/configure.rst:792 +#: ../../using/configure.rst:795 msgid "Enable ThreadSanitizer data race detector, ``tsan`` (default is no)." msgstr "啟用 ThreadSanitizer 資料競爭偵測器 ``tsan``\\ (預設不啟用)。" -#: ../../using/configure.rst:803 +#: ../../using/configure.rst:806 msgid "Enable building a shared Python library: ``libpython`` (default is no)." msgstr "啟用建置共享 Python 函式庫:``libpython``\\ (預設不啟用)。" -#: ../../using/configure.rst:807 +#: ../../using/configure.rst:810 msgid "" "Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o`` " "(built and enabled by default)." @@ -1206,21 +1209,21 @@ msgstr "" "不要建置 ``libpythonMAJOR.MINOR.a`` 並且不要安裝 ``python.o``\\ (預設會建置" "並啟用)。" -#: ../../using/configure.rst:814 +#: ../../using/configure.rst:817 msgid "Libraries options" msgstr "函式庫選項" -#: ../../using/configure.rst:818 +#: ../../using/configure.rst:821 msgid "Link against additional libraries (default is no)." msgstr "" -#: ../../using/configure.rst:822 +#: ../../using/configure.rst:825 msgid "" "Build the :mod:`!pyexpat` module using an installed ``expat`` library " "(default is no)." msgstr "使用已安裝的 ``expat`` 函式庫建置 :mod:`!pyexpat` 模組(預設不建置)。" -#: ../../using/configure.rst:827 +#: ../../using/configure.rst:830 msgid "" "Build the ``_decimal`` extension module using an installed ``mpdecimal`` " "library, see the :mod:`decimal` module (default is yes)." @@ -1228,211 +1231,211 @@ msgstr "" "使用已安裝的 ``mpdecimal`` 函式庫建置 ``_decimal`` 擴充模組,請參閱 :mod:" "`decimal` 模組(預設建置)。" -#: ../../using/configure.rst:832 +#: ../../using/configure.rst:835 msgid "Default to using the installed ``mpdecimal`` library." msgstr "預設使用已安裝的 ``mpdecimal`` 函式庫。" -#: ../../using/configure.rst:835 +#: ../../using/configure.rst:838 msgid "" "A copy of the ``mpdecimal`` library sources will no longer be distributed " "with Python 3.15." msgstr "Python 3.15 不再隨附 ``mpdecimal`` 函式庫的原始碼副本。" -#: ../../using/configure.rst:839 +#: ../../using/configure.rst:842 msgid ":option:`LIBMPDEC_CFLAGS` and :option:`LIBMPDEC_LIBS`." msgstr ":option:`LIBMPDEC_CFLAGS` 和 :option:`LIBMPDEC_LIBS`。" -#: ../../using/configure.rst:843 +#: ../../using/configure.rst:846 msgid "Designate a backend library for the :mod:`readline` module." msgstr "" -#: ../../using/configure.rst:845 +#: ../../using/configure.rst:848 msgid "readline: Use readline as the backend." msgstr "" -#: ../../using/configure.rst:846 +#: ../../using/configure.rst:849 msgid "editline: Use editline as the backend." msgstr "" -#: ../../using/configure.rst:852 +#: ../../using/configure.rst:855 msgid "Don't build the :mod:`readline` module (built by default)." msgstr "不要建置 :mod:`readline` 模組(預設會建置)。" -#: ../../using/configure.rst:854 +#: ../../using/configure.rst:857 msgid "Don't define the ``HAVE_LIBREADLINE`` macro." msgstr "不要定義 ``HAVE_LIBREADLINE`` 巨集。" -#: ../../using/configure.rst:860 +#: ../../using/configure.rst:863 msgid "" "Override ``libm`` math library to *STRING* (default is system-dependent)." msgstr "" -#: ../../using/configure.rst:864 +#: ../../using/configure.rst:867 msgid "Override ``libc`` C library to *STRING* (default is system-dependent)." msgstr "" -#: ../../using/configure.rst:868 +#: ../../using/configure.rst:871 msgid "Root of the OpenSSL directory." msgstr "OpenSSL 目錄的根目錄。" -#: ../../using/configure.rst:874 +#: ../../using/configure.rst:877 msgid "Set runtime library directory (rpath) for OpenSSL libraries:" msgstr "" -#: ../../using/configure.rst:876 +#: ../../using/configure.rst:879 msgid "``no`` (default): don't set rpath;" msgstr "" -#: ../../using/configure.rst:877 +#: ../../using/configure.rst:880 msgid "" "``auto``: auto-detect rpath from :option:`--with-openssl` and ``pkg-config``;" msgstr "" -#: ../../using/configure.rst:879 +#: ../../using/configure.rst:882 msgid "*DIR*: set an explicit rpath." msgstr "" -#: ../../using/configure.rst:885 +#: ../../using/configure.rst:888 msgid "Security Options" msgstr "安全性選項" -#: ../../using/configure.rst:889 +#: ../../using/configure.rst:892 msgid "Select hash algorithm for use in ``Python/pyhash.c``:" msgstr "" -#: ../../using/configure.rst:891 +#: ../../using/configure.rst:894 msgid "``siphash13`` (default);" msgstr "``siphash13``\\ (預設);" -#: ../../using/configure.rst:892 +#: ../../using/configure.rst:895 msgid "``siphash24``;" msgstr "``siphash24``;" -#: ../../using/configure.rst:893 +#: ../../using/configure.rst:896 msgid "``fnv``." msgstr "``fnv``。" -#: ../../using/configure.rst:897 +#: ../../using/configure.rst:900 msgid "``siphash13`` is added and it is the new default." msgstr "" -#: ../../using/configure.rst:902 +#: ../../using/configure.rst:905 msgid "Built-in hash modules:" msgstr "內建雜湊模組:" -#: ../../using/configure.rst:904 +#: ../../using/configure.rst:907 msgid "``md5``;" msgstr "``md5``;" -#: ../../using/configure.rst:905 +#: ../../using/configure.rst:908 msgid "``sha1``;" msgstr "``sha1``;" -#: ../../using/configure.rst:906 +#: ../../using/configure.rst:909 msgid "``sha256``;" msgstr "``sha256``;" -#: ../../using/configure.rst:907 +#: ../../using/configure.rst:910 msgid "``sha512``;" msgstr "``sha512``;" -#: ../../using/configure.rst:908 +#: ../../using/configure.rst:911 msgid "``sha3`` (with shake);" msgstr "" -#: ../../using/configure.rst:909 +#: ../../using/configure.rst:912 msgid "``blake2``." msgstr "``blake2``。" -#: ../../using/configure.rst:915 +#: ../../using/configure.rst:918 msgid "Override the OpenSSL default cipher suites string:" msgstr "" -#: ../../using/configure.rst:917 +#: ../../using/configure.rst:920 msgid "``python`` (default): use Python's preferred selection;" msgstr "" -#: ../../using/configure.rst:918 +#: ../../using/configure.rst:921 msgid "``openssl``: leave OpenSSL's defaults untouched;" msgstr "" -#: ../../using/configure.rst:919 +#: ../../using/configure.rst:922 msgid "*STRING*: use a custom string" msgstr "" -#: ../../using/configure.rst:921 +#: ../../using/configure.rst:924 msgid "See the :mod:`ssl` module." msgstr "請見 :mod:`ssl` 模組。" -#: ../../using/configure.rst:927 +#: ../../using/configure.rst:930 msgid "" "The settings ``python`` and *STRING* also set TLS 1.2 as minimum protocol " "version." msgstr "" -#: ../../using/configure.rst:931 +#: ../../using/configure.rst:934 msgid "macOS Options" msgstr "macOS 選項" -#: ../../using/configure.rst:933 +#: ../../using/configure.rst:936 msgid "See :source:`Mac/README.rst`." msgstr "參閱 :source:`Mac/README.rst`。" -#: ../../using/configure.rst:938 +#: ../../using/configure.rst:941 msgid "" "Create a universal binary build. *SDKDIR* specifies which macOS SDK should " "be used to perform the build (default is no)." msgstr "" -#: ../../using/configure.rst:944 +#: ../../using/configure.rst:947 msgid "" "Create a Python.framework rather than a traditional Unix install. Optional " "*INSTALLDIR* specifies the installation path (default is no)." msgstr "" -#: ../../using/configure.rst:949 +#: ../../using/configure.rst:952 msgid "" "Specify the kind of universal binary that should be created. This option is " "only valid when :option:`--enable-universalsdk` is set." msgstr "" -#: ../../using/configure.rst:952 +#: ../../using/configure.rst:955 msgid "Options:" msgstr "選項:" -#: ../../using/configure.rst:954 +#: ../../using/configure.rst:957 msgid "``universal2`` (x86-64 and arm64);" msgstr "``universal2``\\ (x86-64 與 arm64);" -#: ../../using/configure.rst:955 +#: ../../using/configure.rst:958 msgid "``32-bit`` (PPC and i386);" msgstr "``32-bit``\\ (PPC 與 i386);" -#: ../../using/configure.rst:956 +#: ../../using/configure.rst:959 msgid "``64-bit`` (PPC64 and x86-64);" msgstr "``64-bit``\\ (PPC64 與 x86-64);" -#: ../../using/configure.rst:957 +#: ../../using/configure.rst:960 msgid "``3-way`` (i386, PPC and x86-64);" msgstr "``3-way``\\ (i386、PPC 與 x86-64);" -#: ../../using/configure.rst:958 +#: ../../using/configure.rst:961 msgid "``intel`` (i386 and x86-64);" msgstr "``intel``\\ (i386 與 x86-64);" -#: ../../using/configure.rst:959 +#: ../../using/configure.rst:962 msgid "``intel-32`` (i386);" msgstr "``intel-32``\\ (i386);" -#: ../../using/configure.rst:960 +#: ../../using/configure.rst:963 msgid "``intel-64`` (x86-64);" msgstr "``intel-64``\\ (x86-64);" -#: ../../using/configure.rst:961 +#: ../../using/configure.rst:964 msgid "``all`` (PPC, i386, PPC64 and x86-64)." msgstr "``all``\\ (PPC、i386、PPC64 與 x86-64)。" -#: ../../using/configure.rst:963 +#: ../../using/configure.rst:966 msgid "" "Note that values for this configuration item are *not* the same as the " "identifiers used for universal binary wheels on macOS. See the Python " @@ -1441,13 +1444,13 @@ msgid "" "platform-compatibility-tags/#macos>`_" msgstr "" -#: ../../using/configure.rst:971 +#: ../../using/configure.rst:974 msgid "" "Specify the name for the python framework on macOS only valid when :option:" "`--enable-framework` is set (default: ``Python``)." msgstr "" -#: ../../using/configure.rst:977 +#: ../../using/configure.rst:980 msgid "" "The Python standard library contains strings that are known to trigger " "automated inspection tool errors when submitted for distribution by the " @@ -1456,29 +1459,29 @@ msgid "" "can also be specified. This option is disabled by default." msgstr "" -#: ../../using/configure.rst:986 +#: ../../using/configure.rst:989 msgid "iOS Options" msgstr "iOS 選項" -#: ../../using/configure.rst:988 +#: ../../using/configure.rst:991 msgid "See :source:`iOS/README.rst`." msgstr "參閱 :source:`iOS/README.rst`。" -#: ../../using/configure.rst:992 +#: ../../using/configure.rst:995 msgid "" "Create a Python.framework. Unlike macOS, the *INSTALLDIR* argument " "specifying the installation path is mandatory." msgstr "" -#: ../../using/configure.rst:997 +#: ../../using/configure.rst:1000 msgid "Specify the name for the framework (default: ``Python``)." msgstr "指定框架的名稱(預設值:``Python``)。" -#: ../../using/configure.rst:1001 +#: ../../using/configure.rst:1004 msgid "Cross Compiling Options" msgstr "" -#: ../../using/configure.rst:1003 +#: ../../using/configure.rst:1006 msgid "" "Cross compiling, also known as cross building, can be used to build Python " "for another CPU architecture or platform. Cross compiling requires a Python " @@ -1486,28 +1489,28 @@ msgid "" "match the version of the cross compiled host Python." msgstr "" -#: ../../using/configure.rst:1010 +#: ../../using/configure.rst:1013 msgid "" "configure for building on BUILD, usually guessed by :program:`config.guess`." msgstr "" -#: ../../using/configure.rst:1014 +#: ../../using/configure.rst:1017 msgid "cross-compile to build programs to run on HOST (target platform)" msgstr "" -#: ../../using/configure.rst:1018 +#: ../../using/configure.rst:1021 msgid "path to build ``python`` binary for cross compiling" msgstr "" -#: ../../using/configure.rst:1024 +#: ../../using/configure.rst:1027 msgid "An environment variable that points to a file with configure overrides." msgstr "" -#: ../../using/configure.rst:1026 +#: ../../using/configure.rst:1029 msgid "Example *config.site* file:" msgstr "範例 *config.site* 檔案:" -#: ../../using/configure.rst:1028 +#: ../../using/configure.rst:1031 msgid "" "# config.site-aarch64\n" "ac_cv_buggy_getaddrinfo=no\n" @@ -1519,15 +1522,15 @@ msgstr "" "ac_cv_file__dev_ptmx=yes\n" "ac_cv_file__dev_ptc=no" -#: ../../using/configure.rst:1037 +#: ../../using/configure.rst:1040 msgid "Program to run CPython for the host platform for cross-compilation." msgstr "" -#: ../../using/configure.rst:1042 +#: ../../using/configure.rst:1045 msgid "Cross compiling example::" msgstr "" -#: ../../using/configure.rst:1044 +#: ../../using/configure.rst:1047 msgid "" "CONFIG_SITE=config.site-aarch64 ../configure \\\n" " --build=x86_64-pc-linux-gnu \\\n" @@ -1539,65 +1542,65 @@ msgstr "" " --host=aarch64-unknown-linux-gnu \\\n" " --with-build-python=../x86_64/python" -#: ../../using/configure.rst:1051 +#: ../../using/configure.rst:1054 msgid "Python Build System" msgstr "Python 建置系統" -#: ../../using/configure.rst:1054 +#: ../../using/configure.rst:1057 msgid "Main files of the build system" msgstr "建置系統的主要檔案" -#: ../../using/configure.rst:1056 +#: ../../using/configure.rst:1059 msgid ":file:`configure.ac` => :file:`configure`;" msgstr ":file:`configure.ac` => :file:`configure`;" -#: ../../using/configure.rst:1057 +#: ../../using/configure.rst:1060 msgid "" ":file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`);" msgstr "" ":file:`Makefile.pre.in` => :file:`Makefile`\\ (由 :file:`configure` 建立);" -#: ../../using/configure.rst:1058 +#: ../../using/configure.rst:1061 msgid ":file:`pyconfig.h` (created by :file:`configure`);" msgstr ":file:`pyconfig.h`\\ (由 :file:`configure` 建立);" -#: ../../using/configure.rst:1059 +#: ../../using/configure.rst:1062 msgid "" ":file:`Modules/Setup`: C extensions built by the Makefile using :file:" "`Module/makesetup` shell script;" msgstr "" -#: ../../using/configure.rst:1063 +#: ../../using/configure.rst:1066 msgid "Main build steps" msgstr "主要建置步驟" -#: ../../using/configure.rst:1065 +#: ../../using/configure.rst:1068 msgid "C files (``.c``) are built as object files (``.o``)." msgstr "C 檔案(``.c``)被建置為目的檔(``.o``)。" -#: ../../using/configure.rst:1066 +#: ../../using/configure.rst:1069 msgid "A static ``libpython`` library (``.a``) is created from objects files." msgstr "" -#: ../../using/configure.rst:1067 +#: ../../using/configure.rst:1070 msgid "" "``python.o`` and the static ``libpython`` library are linked into the final " "``python`` program." msgstr "" -#: ../../using/configure.rst:1069 +#: ../../using/configure.rst:1072 msgid "C extensions are built by the Makefile (see :file:`Modules/Setup`)." msgstr "" -#: ../../using/configure.rst:1072 +#: ../../using/configure.rst:1075 msgid "Main Makefile targets" msgstr "主要 Makefile 目標" -#: ../../using/configure.rst:1075 +#: ../../using/configure.rst:1078 msgid "make" msgstr "make" -#: ../../using/configure.rst:1077 +#: ../../using/configure.rst:1080 msgid "" "For the most part, when rebuilding after editing some code or refreshing " "your checkout from upstream, all you need to do is execute ``make``, which " @@ -1608,20 +1611,20 @@ msgid "" "all`` will build. The three choices are:" msgstr "" -#: ../../using/configure.rst:1086 +#: ../../using/configure.rst:1089 msgid "``profile-opt`` (configured with ``--enable-optimizations``)" msgstr "``profile-opt``\\ (使用 ``--enable-optimizations`` 配置)" -#: ../../using/configure.rst:1087 +#: ../../using/configure.rst:1090 msgid "``build_wasm`` (configured with ``--with-emscripten-target``)" msgstr "``build_wasm``\\ (使用 ``--with-emscripten-target`` 配置)" -#: ../../using/configure.rst:1088 +#: ../../using/configure.rst:1091 msgid "" "``build_all`` (configured without explicitly using either of the others)" msgstr "``build_all``\\ (未明確使用其他選項進行配置)" -#: ../../using/configure.rst:1090 +#: ../../using/configure.rst:1093 msgid "" "Depending on the most recent source file changes, Make will rebuild any " "targets (object files and executables) deemed out-of-date, including running " @@ -1634,11 +1637,11 @@ msgid "" "problems, at the expense of longer build times." msgstr "" -#: ../../using/configure.rst:1103 +#: ../../using/configure.rst:1106 msgid "make platform" msgstr "make platform" -#: ../../using/configure.rst:1105 +#: ../../using/configure.rst:1108 msgid "" "Build the ``python`` program, but don't build the standard library extension " "modules. This generates a file named ``platform`` which contains a single " @@ -1646,81 +1649,81 @@ msgid "" "arm64-3.12`` or ``linux-x86_64-3.13``." msgstr "" -#: ../../using/configure.rst:1112 +#: ../../using/configure.rst:1115 msgid "make profile-opt" msgstr "make profile-opt" -#: ../../using/configure.rst:1114 +#: ../../using/configure.rst:1117 msgid "" "Build Python using profile-guided optimization (PGO). You can use the " "configure :option:`--enable-optimizations` option to make this the default " "target of the ``make`` command (``make all`` or just ``make``)." msgstr "" -#: ../../using/configure.rst:1122 +#: ../../using/configure.rst:1125 msgid "make clean" msgstr "make clean" -#: ../../using/configure.rst:1124 +#: ../../using/configure.rst:1127 msgid "Remove built files." msgstr "移除建置的檔案。" -#: ../../using/configure.rst:1128 +#: ../../using/configure.rst:1131 msgid "make distclean" msgstr "make distclean" -#: ../../using/configure.rst:1130 +#: ../../using/configure.rst:1133 msgid "" "In addition to the work done by ``make clean``, remove files created by the " "configure script. ``configure`` will have to be run before building again. " "[#]_" msgstr "" -#: ../../using/configure.rst:1136 +#: ../../using/configure.rst:1139 msgid "make install" msgstr "make install" -#: ../../using/configure.rst:1138 +#: ../../using/configure.rst:1141 msgid "Build the ``all`` target and install Python." msgstr "建置 ``all`` 目標並安裝 Python。" -#: ../../using/configure.rst:1142 +#: ../../using/configure.rst:1145 msgid "make test" msgstr "make test" -#: ../../using/configure.rst:1144 +#: ../../using/configure.rst:1147 msgid "" "Build the ``all`` target and run the Python test suite with the ``--fast-" "ci`` option. Variables:" msgstr "" -#: ../../using/configure.rst:1147 +#: ../../using/configure.rst:1150 msgid "``TESTOPTS``: additional regrtest command-line options." msgstr "``TESTOPTS``:額外的 regrtest 命令列選項。" -#: ../../using/configure.rst:1148 +#: ../../using/configure.rst:1151 msgid "``TESTPYTHONOPTS``: additional Python command-line options." msgstr "``TESTPYTHONOPTS``:額外的 Python 命令列選項。" -#: ../../using/configure.rst:1149 +#: ../../using/configure.rst:1152 msgid "``TESTTIMEOUT``: timeout in seconds (default: 10 minutes)." msgstr "``TESTTIMEOUT``:秒數表示的超時設定(預設值:10 分鐘)。" -#: ../../using/configure.rst:1153 +#: ../../using/configure.rst:1156 msgid "make buildbottest" msgstr "make buildbottest" -#: ../../using/configure.rst:1155 +#: ../../using/configure.rst:1158 msgid "" "This is similar to ``make test``, but uses the ``--slow-ci`` option and " "default timeout of 20 minutes, instead of ``--fast-ci`` option." msgstr "" -#: ../../using/configure.rst:1160 +#: ../../using/configure.rst:1163 msgid "make regen-all" msgstr "make regen-all" -#: ../../using/configure.rst:1162 +#: ../../using/configure.rst:1165 msgid "" "Regenerate (almost) all generated files. These include (but are not limited " "to) bytecode cases, and parser generator file. ``make regen-stdlib-module-" @@ -1728,18 +1731,18 @@ msgid "" "files <#generated-files>`_." msgstr "" -#: ../../using/configure.rst:1169 +#: ../../using/configure.rst:1172 msgid "C extensions" msgstr "C 擴充模組" -#: ../../using/configure.rst:1171 +#: ../../using/configure.rst:1174 msgid "" "Some C extensions are built as built-in modules, like the ``sys`` module. " "They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined. Built-in " "modules have no ``__file__`` attribute:" msgstr "" -#: ../../using/configure.rst:1175 +#: ../../using/configure.rst:1178 msgid "" ">>> import sys\n" ">>> sys\n" @@ -1757,14 +1760,14 @@ msgstr "" " File \"\", line 1, in \n" "AttributeError: module 'sys' has no attribute '__file__'" -#: ../../using/configure.rst:1185 +#: ../../using/configure.rst:1188 msgid "" "Other C extensions are built as dynamic libraries, like the ``_asyncio`` " "module. They are built with the ``Py_BUILD_CORE_MODULE`` macro defined. " "Example on Linux x86-64:" msgstr "" -#: ../../using/configure.rst:1189 +#: ../../using/configure.rst:1192 msgid "" ">>> import _asyncio\n" ">>> _asyncio\n" @@ -1780,7 +1783,7 @@ msgstr "" ">>> _asyncio.__file__\n" "'/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'" -#: ../../using/configure.rst:1197 +#: ../../using/configure.rst:1200 msgid "" ":file:`Modules/Setup` is used to generate Makefile targets to build C " "extensions. At the beginning of the files, C extensions are built as built-" @@ -1788,164 +1791,164 @@ msgid "" "dynamic libraries." msgstr "" -#: ../../using/configure.rst:1201 +#: ../../using/configure.rst:1204 msgid "" "The :c:macro:`!PyAPI_FUNC()`, :c:macro:`!PyAPI_DATA()` and :c:macro:" "`PyMODINIT_FUNC` macros of :file:`Include/exports.h` are defined differently " "depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:" msgstr "" -#: ../../using/configure.rst:1205 +#: ../../using/configure.rst:1208 msgid "Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined" msgstr "如果定義了 ``Py_BUILD_CORE_MODULE``,則使用 ``Py_EXPORTED_SYMBOL``" -#: ../../using/configure.rst:1206 +#: ../../using/configure.rst:1209 msgid "Use ``Py_IMPORTED_SYMBOL`` otherwise." msgstr "否則使用 ``Py_IMPORTED_SYMBOL``。" -#: ../../using/configure.rst:1208 +#: ../../using/configure.rst:1211 msgid "" "If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension " "built as a shared library, its :samp:`PyInit_{xxx}()` function is not " "exported, causing an :exc:`ImportError` on import." msgstr "" -#: ../../using/configure.rst:1214 +#: ../../using/configure.rst:1217 msgid "Compiler and linker flags" msgstr "" -#: ../../using/configure.rst:1216 +#: ../../using/configure.rst:1219 msgid "" "Options set by the ``./configure`` script and environment variables and used " "by ``Makefile``." msgstr "" -#: ../../using/configure.rst:1220 +#: ../../using/configure.rst:1223 msgid "Preprocessor flags" msgstr "預處理器旗標" -#: ../../using/configure.rst:1224 +#: ../../using/configure.rst:1227 msgid "" "Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script." msgstr "" -#: ../../using/configure.rst:1230 +#: ../../using/configure.rst:1233 msgid "" "(Objective) C/C++ preprocessor flags, e.g. :samp:`-I{include_dir}` if you " "have headers in a nonstandard directory *include_dir*." msgstr "" -#: ../../using/configure.rst:1233 ../../using/configure.rst:1423 +#: ../../using/configure.rst:1236 ../../using/configure.rst:1426 msgid "" "Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's " "value to be able to build extension modules using the directories specified " "in the environment variables." msgstr "" -#: ../../using/configure.rst:1243 +#: ../../using/configure.rst:1246 msgid "" "Extra preprocessor flags added for building the interpreter object files." msgstr "" -#: ../../using/configure.rst:1245 +#: ../../using/configure.rst:1248 msgid "" "Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) " "$(CPPFLAGS)``." msgstr "" -#: ../../using/configure.rst:1250 +#: ../../using/configure.rst:1253 msgid "Compiler flags" msgstr "編譯器旗標" -#: ../../using/configure.rst:1256 +#: ../../using/configure.rst:1259 msgid "Example: ``gcc -pthread``." msgstr "範例:``gcc -pthread``。" -#: ../../using/configure.rst:1260 +#: ../../using/configure.rst:1263 msgid "C++ compiler command." msgstr "C++ 編譯器指令。" -#: ../../using/configure.rst:1262 +#: ../../using/configure.rst:1265 msgid "Example: ``g++ -pthread``." msgstr "範例:``g++ -pthread``。" -#: ../../using/configure.rst:1270 +#: ../../using/configure.rst:1273 msgid "" ":envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C " "extensions. Use it when a compiler flag should *not* be part of :envvar:" "`CFLAGS` once Python is installed (:gh:`65320`)." msgstr "" -#: ../../using/configure.rst:1274 +#: ../../using/configure.rst:1277 msgid "In particular, :envvar:`CFLAGS` should not contain:" msgstr "" -#: ../../using/configure.rst:1276 +#: ../../using/configure.rst:1279 msgid "" "the compiler flag ``-I`` (for setting the search path for include files). " "The ``-I`` flags are processed from left to right, and any flags in :envvar:" "`CFLAGS` would take precedence over user- and package-supplied ``-I`` flags." msgstr "" -#: ../../using/configure.rst:1281 +#: ../../using/configure.rst:1284 msgid "" "hardening flags such as ``-Werror`` because distributions cannot control " "whether packages installed by users conform to such heightened standards." msgstr "" -#: ../../using/configure.rst:1289 +#: ../../using/configure.rst:1292 msgid "" "Options passed to the :mod:`compileall` command line when building PYC files " "in ``make install``. Default: ``-j0``." msgstr "" -#: ../../using/configure.rst:1296 +#: ../../using/configure.rst:1299 msgid "Extra C compiler flags." msgstr "額外的 C 編譯器旗標。" -#: ../../using/configure.rst:1300 +#: ../../using/configure.rst:1303 msgid "" "Value of :envvar:`CFLAGS` variable passed to the ``./configure`` script." msgstr "" -#: ../../using/configure.rst:1307 +#: ../../using/configure.rst:1310 msgid "" "Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure`` " "script." msgstr "" -#: ../../using/configure.rst:1314 +#: ../../using/configure.rst:1317 msgid "Base compiler flags." msgstr "基本編譯器旗標。" -#: ../../using/configure.rst:1318 +#: ../../using/configure.rst:1321 msgid "Optimization flags." msgstr "最佳化旗標。" -#: ../../using/configure.rst:1322 +#: ../../using/configure.rst:1325 msgid "Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``." msgstr "" -#: ../../using/configure.rst:1328 +#: ../../using/configure.rst:1331 msgid "Compiler flags used to build a shared library." msgstr "用於建置共享函式庫的編譯器旗標。" -#: ../../using/configure.rst:1330 +#: ../../using/configure.rst:1333 msgid "For example, ``-fPIC`` is used on Linux and on BSD." msgstr "例如說 ``-fPIC`` 被使用於 Linux 與 BSD 上。" -#: ../../using/configure.rst:1334 +#: ../../using/configure.rst:1337 msgid "Extra C flags added for building the interpreter object files." msgstr "用於建置直譯器目的檔的額外 C 旗標。" -#: ../../using/configure.rst:1336 +#: ../../using/configure.rst:1339 msgid "" "Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty " "string otherwise." msgstr "" "預設值:當使用 :option:`--enable-shared` 時為 ``$(CCSHARED)``,否則為空字串。" -#: ../../using/configure.rst:1341 +#: ../../using/configure.rst:1344 msgid "" "Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) " "$(EXTRA_CFLAGS)``." @@ -1953,7 +1956,7 @@ msgstr "" "預設值:``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) " "$(EXTRA_CFLAGS)``。" -#: ../../using/configure.rst:1345 +#: ../../using/configure.rst:1348 msgid "" "Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/" "internal``." @@ -1961,11 +1964,11 @@ msgstr "" "預設值:``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/" "internal``。" -#: ../../using/configure.rst:1351 +#: ../../using/configure.rst:1354 msgid "C flags used for building the interpreter object files." msgstr "用於建置直譯器目的檔的 C 旗標。" -#: ../../using/configure.rst:1353 +#: ../../using/configure.rst:1356 msgid "" "Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) " "$(CFLAGSFORSHARED)``." @@ -1973,126 +1976,126 @@ msgstr "" "預設值:``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) " "$(CFLAGSFORSHARED)``。" -#: ../../using/configure.rst:1359 +#: ../../using/configure.rst:1362 msgid "Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``." msgstr "預設值:``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``。" -#: ../../using/configure.rst:1365 +#: ../../using/configure.rst:1368 msgid "" "Compiler flags to build a standard library extension module as a built-in " "module, like the :mod:`posix` module." msgstr "" -#: ../../using/configure.rst:1368 +#: ../../using/configure.rst:1371 msgid "Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``." msgstr "預設值:``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``。" -#: ../../using/configure.rst:1374 +#: ../../using/configure.rst:1377 msgid "Purify command. Purify is a memory debugger program." msgstr "" -#: ../../using/configure.rst:1376 +#: ../../using/configure.rst:1379 msgid "Default: empty string (not used)." msgstr "預設值:空字串(未使用)。" -#: ../../using/configure.rst:1380 +#: ../../using/configure.rst:1383 msgid "Linker flags" msgstr "" -#: ../../using/configure.rst:1384 +#: ../../using/configure.rst:1387 msgid "" "Linker command used to build programs like ``python`` and ``_testembed``." msgstr "" -#: ../../using/configure.rst:1386 +#: ../../using/configure.rst:1389 msgid "Default: ``$(PURIFY) $(CC)``." msgstr "預設值:``$(PURIFY) $(CC)``。" -#: ../../using/configure.rst:1390 +#: ../../using/configure.rst:1393 msgid "" "Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script." msgstr "" -#: ../../using/configure.rst:1392 +#: ../../using/configure.rst:1395 msgid "" "Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use " "them on the command line to append to these values without stomping the pre-" "set values." msgstr "" -#: ../../using/configure.rst:1400 +#: ../../using/configure.rst:1403 msgid "" ":envvar:`LDFLAGS_NODIST` is used in the same manner as :envvar:" "`CFLAGS_NODIST`. Use it when a linker flag should *not* be part of :envvar:" "`LDFLAGS` once Python is installed (:gh:`65320`)." msgstr "" -#: ../../using/configure.rst:1404 +#: ../../using/configure.rst:1407 msgid "In particular, :envvar:`LDFLAGS` should not contain:" msgstr "" -#: ../../using/configure.rst:1406 +#: ../../using/configure.rst:1409 msgid "" "the compiler flag ``-L`` (for setting the search path for libraries). The ``-" "L`` flags are processed from left to right, and any flags in :envvar:" "`LDFLAGS` would take precedence over user- and package-supplied ``-L`` flags." msgstr "" -#: ../../using/configure.rst:1413 +#: ../../using/configure.rst:1416 msgid "" "Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure`` " "script." msgstr "" -#: ../../using/configure.rst:1420 +#: ../../using/configure.rst:1423 msgid "" "Linker flags, e.g. :samp:`-L{lib_dir}` if you have libraries in a " "nonstandard directory *lib_dir*." msgstr "" -#: ../../using/configure.rst:1429 +#: ../../using/configure.rst:1432 msgid "" "Linker flags to pass libraries to the linker when linking the Python " "executable." msgstr "" -#: ../../using/configure.rst:1432 +#: ../../using/configure.rst:1435 msgid "Example: ``-lrt``." msgstr "範例:``-lrt``。" -#: ../../using/configure.rst:1436 +#: ../../using/configure.rst:1439 msgid "Command to build a shared library." msgstr "建置共享函式庫的指令。" -#: ../../using/configure.rst:1438 +#: ../../using/configure.rst:1441 msgid "Default: ``@LDSHARED@ $(PY_LDFLAGS)``." msgstr "預設值:``@LDSHARED@ $(PY_LDFLAGS)``。" -#: ../../using/configure.rst:1442 +#: ../../using/configure.rst:1445 msgid "Command to build ``libpython`` shared library." msgstr "建置 ``libpython`` 共享函式庫的指令。" -#: ../../using/configure.rst:1444 +#: ../../using/configure.rst:1447 msgid "Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``." msgstr "預設值:``@BLDSHARED@ $(PY_CORE_LDFLAGS)``。" -#: ../../using/configure.rst:1448 +#: ../../using/configure.rst:1451 msgid "Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``." msgstr "預設值:``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``。" -#: ../../using/configure.rst:1452 +#: ../../using/configure.rst:1455 msgid "Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``." msgstr "預設值:``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``。" -#: ../../using/configure.rst:1458 +#: ../../using/configure.rst:1461 msgid "Linker flags used for building the interpreter object files." msgstr "" -#: ../../using/configure.rst:1464 +#: ../../using/configure.rst:1467 msgid "Footnotes" msgstr "註腳" -#: ../../using/configure.rst:1465 +#: ../../using/configure.rst:1468 msgid "" "``git clean -fdx`` is an even more extreme way to \"clean\" your checkout. " "It removes all files not known to Git. When bug hunting using ``git " @@ -2101,3 +2104,7 @@ msgid "" "clean build. **Use with care**, as it will delete all files not checked into " "Git, including your new, uncommitted work." msgstr "" + +#~ msgid "" +#~ "Enable AddressSanitizer memory error detector, ``asan`` (default is no)." +#~ msgstr "啟用 AddressSanitizer 記憶體錯誤偵測器 ``asan``\\ (預設不啟用)。"