diff --git a/c-api/frame.po b/c-api/frame.po index a4ce337b94..eac5123f52 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-15 20:43+0000\n" +"POT-Creation-Date: 2022-11-23 00:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -45,62 +45,83 @@ msgstr "" msgid "See also :ref:`Reflection `." msgstr "" -#: ../../c-api/frame.rst:25 +#: ../../c-api/frame.rst:24 +msgid "" +"The type of frame objects. It is the same object as :py:class:`types." +"FrameType` in the Python layer." +msgstr "" + +#: ../../c-api/frame.rst:29 +msgid "" +"Previously, this type was only available after including ````." +msgstr "" + +#: ../../c-api/frame.rst:34 +msgid "Return non-zero if *obj* is a frame object." +msgstr "" + +#: ../../c-api/frame.rst:38 +msgid "" +"Previously, this function was only available after including ````." +msgstr "" + +#: ../../c-api/frame.rst:43 msgid "Get the *frame* next outer frame." msgstr "" -#: ../../c-api/frame.rst:27 +#: ../../c-api/frame.rst:45 msgid "" "Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer frame." msgstr "" -#: ../../c-api/frame.rst:35 +#: ../../c-api/frame.rst:53 msgid "Get the *frame*'s ``f_builtins`` attribute." msgstr "" -#: ../../c-api/frame.rst:37 ../../c-api/frame.rst:68 +#: ../../c-api/frame.rst:55 ../../c-api/frame.rst:86 msgid "Return a :term:`strong reference`. The result cannot be ``NULL``." msgstr "" -#: ../../c-api/frame.rst:44 +#: ../../c-api/frame.rst:62 msgid "Get the *frame* code." msgstr "" -#: ../../c-api/frame.rst:46 ../../c-api/frame.rst:86 +#: ../../c-api/frame.rst:64 ../../c-api/frame.rst:104 msgid "Return a :term:`strong reference`." msgstr "" -#: ../../c-api/frame.rst:48 +#: ../../c-api/frame.rst:66 msgid "The result (frame code) cannot be ``NULL``." msgstr "" -#: ../../c-api/frame.rst:55 +#: ../../c-api/frame.rst:73 msgid "" "Get the generator, coroutine, or async generator that owns this frame, or " "``NULL`` if this frame is not owned by a generator. Does not raise an " "exception, even if the return value is ``NULL``." msgstr "" -#: ../../c-api/frame.rst:59 +#: ../../c-api/frame.rst:77 msgid "Return a :term:`strong reference`, or ``NULL``." msgstr "" -#: ../../c-api/frame.rst:66 +#: ../../c-api/frame.rst:84 msgid "Get the *frame*'s ``f_globals`` attribute." msgstr "" -#: ../../c-api/frame.rst:75 +#: ../../c-api/frame.rst:93 msgid "Get the *frame*'s ``f_lasti`` attribute." msgstr "" -#: ../../c-api/frame.rst:77 +#: ../../c-api/frame.rst:95 msgid "Returns -1 if ``frame.f_lasti`` is ``None``." msgstr "" -#: ../../c-api/frame.rst:84 +#: ../../c-api/frame.rst:102 msgid "Get the *frame*'s ``f_locals`` attribute (:class:`dict`)." msgstr "" -#: ../../c-api/frame.rst:93 +#: ../../c-api/frame.rst:111 msgid "Return the line number that *frame* is currently executing." msgstr "" diff --git a/c-api/init_config.po b/c-api/init_config.po index 8d85419a05..b64558dbbb 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-15 20:43+0000\n" +"POT-Creation-Date: 2022-11-19 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-" @@ -296,7 +296,7 @@ msgid "Default: ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "預設:\\ ``PYMEM_ALLOCATOR_NOT_SET``\\ 。" #: ../../c-api/init_config.rst:257 -msgid "Set the LC_CTYPE locale to the user preferred locale?" +msgid "Set the LC_CTYPE locale to the user preferred locale." msgstr "" #: ../../c-api/init_config.rst:259 diff --git a/library/argparse.po b/library/argparse.po index 7091fb8bc2..e7aa0d6cdc 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-31 08:13+0000\n" +"POT-Creation-Date: 2022-11-23 00:17+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-" @@ -1686,10 +1686,10 @@ msgstr "" #: ../../library/argparse.rst:1935 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " -"\"positional arguments\" and \"optional arguments\" when displaying help " -"messages. When there is a better conceptual grouping of arguments than this " -"default one, appropriate groups can be created using the :meth:" -"`add_argument_group` method::" +"\"positional arguments\" and \"options\" when displaying help messages. When " +"there is a better conceptual grouping of arguments than this default one, " +"appropriate groups can be created using the :meth:`add_argument_group` " +"method::" msgstr "" #: ../../library/argparse.rst:1952 diff --git a/library/ctypes.po b/library/ctypes.po index c9220486e6..b01e0c505f 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-31 08:13+0000\n" +"POT-Creation-Date: 2022-11-23 00:17+0000\n" "PO-Revision-Date: 2022-10-16 03:20+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -206,7 +206,7 @@ msgid "" "learn more about :mod:`ctypes` data types." msgstr "" -#: ../../library/ctypes.rst:211 ../../library/ctypes.rst:2137 +#: ../../library/ctypes.rst:211 ../../library/ctypes.rst:2157 msgid "Fundamental data types" msgstr "" @@ -487,11 +487,36 @@ msgid "" "so that they can be converted to the required C data type::" msgstr "" -#: ../../library/ctypes.rst:377 +#: ../../library/ctypes.rst:376 +msgid "Calling varadic functions" +msgstr "" + +#: ../../library/ctypes.rst:378 +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 " +"platforms, and in particular ARM64 for Apple Platforms, the calling " +"convention for variadic functions is different than that for regular " +"functions." +msgstr "" + +#: ../../library/ctypes.rst:383 +msgid "" +"On those platforms it is required to specify the *argtypes* attribute for " +"the regular, non-variadic, function arguments:" +msgstr "" + +#: ../../library/ctypes.rst:390 +msgid "" +"Because specifying the attribute does inhibit portability it is adviced to " +"always specify ``argtypes`` for all variadic functions." +msgstr "" + +#: ../../library/ctypes.rst:397 msgid "Calling functions with your own custom data types" msgstr "" -#: ../../library/ctypes.rst:379 +#: ../../library/ctypes.rst:399 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 " @@ -499,24 +524,24 @@ msgid "" "Of course, it must be one of integer, string, or bytes::" msgstr "" -#: ../../library/ctypes.rst:394 +#: ../../library/ctypes.rst:414 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:402 +#: ../../library/ctypes.rst:422 msgid "Specifying the required argument types (function prototypes)" msgstr "" -#: ../../library/ctypes.rst:404 +#: ../../library/ctypes.rst:424 msgid "" "It is possible to specify the required argument types of functions exported " "from DLLs by setting the :attr:`argtypes` attribute." msgstr "" -#: ../../library/ctypes.rst:407 +#: ../../library/ctypes.rst:427 msgid "" ":attr:`argtypes` must be a sequence of C data types (the ``printf`` function " "is probably not a good example here, because it takes a variable number and " @@ -524,14 +549,14 @@ msgid "" "hand this is quite handy to experiment with this feature)::" msgstr "" -#: ../../library/ctypes.rst:418 +#: ../../library/ctypes.rst:438 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:430 +#: ../../library/ctypes.rst:450 msgid "" "If you have defined your own classes which you pass to function calls, you " "have to implement a :meth:`from_param` class method for them to be able to " @@ -544,31 +569,31 @@ msgid "" "an object with an :attr:`_as_parameter_` attribute." msgstr "" -#: ../../library/ctypes.rst:444 +#: ../../library/ctypes.rst:464 msgid "Return types" msgstr "" -#: ../../library/ctypes.rst:446 +#: ../../library/ctypes.rst:466 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " "return types can be specified by setting the :attr:`restype` attribute of " "the function object." msgstr "" -#: ../../library/ctypes.rst:450 +#: ../../library/ctypes.rst:470 msgid "" "Here is a more advanced example, it uses the ``strchr`` function, which " "expects a string pointer and a char, and returns a pointer to a string::" msgstr "" -#: ../../library/ctypes.rst:463 +#: ../../library/ctypes.rst:483 msgid "" "If you want to avoid the ``ord(\"x\")`` calls above, you can set the :attr:" "`argtypes` attribute, and the second argument will be converted from a " "single character Python bytes object into a C char::" msgstr "" -#: ../../library/ctypes.rst:481 +#: ../../library/ctypes.rst:501 msgid "" "You can also use a callable Python object (a function or a class for " "example) as the :attr:`restype` attribute, if the foreign function returns " @@ -578,7 +603,7 @@ msgid "" "automatically raise an exception::" msgstr "" -#: ../../library/ctypes.rst:504 +#: ../../library/ctypes.rst:524 msgid "" "``WinError`` is a function which will call Windows ``FormatMessage()`` api " "to get the string representation of an error code, and *returns* an " @@ -586,17 +611,17 @@ msgid "" "used, it calls :func:`GetLastError` to retrieve it." msgstr "" -#: ../../library/ctypes.rst:509 +#: ../../library/ctypes.rst:529 msgid "" "Please note that a much more powerful error checking mechanism is available " "through the :attr:`errcheck` attribute; see the reference manual for details." msgstr "" -#: ../../library/ctypes.rst:516 +#: ../../library/ctypes.rst:536 msgid "Passing pointers (or: passing parameters by reference)" msgstr "" -#: ../../library/ctypes.rst:518 +#: ../../library/ctypes.rst:538 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 " @@ -604,7 +629,7 @@ msgid "" "reference*." msgstr "" -#: ../../library/ctypes.rst:522 +#: ../../library/ctypes.rst:542 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:" @@ -613,11 +638,11 @@ msgid "" "you don't need the pointer object in Python itself::" msgstr "" -#: ../../library/ctypes.rst:544 +#: ../../library/ctypes.rst:564 msgid "Structures and unions" msgstr "" -#: ../../library/ctypes.rst:546 +#: ../../library/ctypes.rst:566 msgid "" "Structures and unions must derive from the :class:`Structure` and :class:" "`Union` base classes which are defined in the :mod:`ctypes` module. Each " @@ -625,44 +650,44 @@ msgid "" "a list of *2-tuples*, containing a *field name* and a *field type*." msgstr "" -#: ../../library/ctypes.rst:551 +#: ../../library/ctypes.rst:571 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:554 +#: ../../library/ctypes.rst:574 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:574 +#: ../../library/ctypes.rst:594 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:577 +#: ../../library/ctypes.rst:597 msgid "" "Here is a RECT structure which contains two POINTs named *upperleft* and " "*lowerright*::" msgstr "" -#: ../../library/ctypes.rst:591 +#: ../../library/ctypes.rst:611 msgid "" "Nested structures can also be initialized in the constructor in several " "ways::" msgstr "" -#: ../../library/ctypes.rst:596 +#: ../../library/ctypes.rst:616 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:610 +#: ../../library/ctypes.rst:630 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 " @@ -670,11 +695,11 @@ msgid "" "structures with bit-fields should always be passed to functions by pointer." msgstr "" -#: ../../library/ctypes.rst:616 +#: ../../library/ctypes.rst:636 msgid "Structure/union alignment and byte order" msgstr "" -#: ../../library/ctypes.rst:618 +#: ../../library/ctypes.rst:638 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 :" @@ -683,7 +708,7 @@ msgid "" "This is what ``#pragma pack(n)`` also does in MSVC." msgstr "" -#: ../../library/ctypes.rst:624 +#: ../../library/ctypes.rst:644 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:" @@ -692,91 +717,91 @@ msgid "" "classes cannot contain pointer fields." msgstr "" -#: ../../library/ctypes.rst:634 +#: ../../library/ctypes.rst:654 msgid "Bit fields in structures and unions" msgstr "" -#: ../../library/ctypes.rst:636 +#: ../../library/ctypes.rst:656 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:`_fields_` tuples::" msgstr "" -#: ../../library/ctypes.rst:654 +#: ../../library/ctypes.rst:674 msgid "Arrays" msgstr "" -#: ../../library/ctypes.rst:656 +#: ../../library/ctypes.rst:676 msgid "" "Arrays are sequences, containing a fixed number of instances of the same " "type." msgstr "" -#: ../../library/ctypes.rst:658 +#: ../../library/ctypes.rst:678 msgid "" "The recommended way to create array types is by multiplying a data type with " "a positive integer::" msgstr "" -#: ../../library/ctypes.rst:663 +#: ../../library/ctypes.rst:683 msgid "" "Here is an example of a somewhat artificial data type, a structure " "containing 4 POINTs among other stuff::" msgstr "" -#: ../../library/ctypes.rst:679 +#: ../../library/ctypes.rst:699 msgid "Instances are created in the usual way, by calling the class::" msgstr "" -#: ../../library/ctypes.rst:685 +#: ../../library/ctypes.rst:705 msgid "" "The above code print a series of ``0 0`` lines, because the array contents " "is initialized to zeros." msgstr "" -#: ../../library/ctypes.rst:688 +#: ../../library/ctypes.rst:708 msgid "Initializers of the correct type can also be specified::" msgstr "" -#: ../../library/ctypes.rst:704 +#: ../../library/ctypes.rst:724 msgid "Pointers" msgstr "" -#: ../../library/ctypes.rst:706 +#: ../../library/ctypes.rst:726 msgid "" "Pointer instances are created by calling the :func:`pointer` function on a :" "mod:`ctypes` type::" msgstr "" -#: ../../library/ctypes.rst:714 +#: ../../library/ctypes.rst:734 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:721 +#: ../../library/ctypes.rst:741 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:730 +#: ../../library/ctypes.rst:750 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:742 +#: ../../library/ctypes.rst:762 msgid "Pointer instances can also be indexed with integers::" msgstr "" -#: ../../library/ctypes.rst:748 +#: ../../library/ctypes.rst:768 msgid "Assigning to an integer index changes the pointed to value::" msgstr "" -#: ../../library/ctypes.rst:757 +#: ../../library/ctypes.rst:777 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 " @@ -785,7 +810,7 @@ msgid "" "instead of a single item." msgstr "" -#: ../../library/ctypes.rst:763 +#: ../../library/ctypes.rst:783 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 " @@ -793,23 +818,23 @@ msgid "" "returns a new type::" msgstr "" -#: ../../library/ctypes.rst:779 +#: ../../library/ctypes.rst:799 msgid "" "Calling the pointer type without an argument creates a ``NULL`` pointer. " "``NULL`` pointers have a ``False`` boolean value::" msgstr "" -#: ../../library/ctypes.rst:787 +#: ../../library/ctypes.rst:807 msgid "" ":mod:`ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" -#: ../../library/ctypes.rst:806 +#: ../../library/ctypes.rst:826 msgid "Type conversions" msgstr "" -#: ../../library/ctypes.rst:808 +#: ../../library/ctypes.rst:828 msgid "" "Usually, ctypes does strict type checking. This means, if you have " "``POINTER(c_int)`` in the :attr:`argtypes` list of a function or as the type " @@ -820,7 +845,7 @@ msgid "" "accepts an array of c_int::" msgstr "" -#: ../../library/ctypes.rst:829 +#: ../../library/ctypes.rst:849 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " "type (such as ``POINTER(c_int)``) in :attr:`argtypes`, an object of the " @@ -828,11 +853,11 @@ msgid "" "will apply the required :func:`byref` conversion in this case automatically." msgstr "" -#: ../../library/ctypes.rst:834 +#: ../../library/ctypes.rst:854 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" msgstr "" -#: ../../library/ctypes.rst:841 +#: ../../library/ctypes.rst:861 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 " @@ -841,11 +866,11 @@ msgid "" "``values`` field, but not instances of other types::" msgstr "" -#: ../../library/ctypes.rst:853 +#: ../../library/ctypes.rst:873 msgid "For these cases, the :func:`cast` function is handy." msgstr "" -#: ../../library/ctypes.rst:855 +#: ../../library/ctypes.rst:875 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, " @@ -854,60 +879,60 @@ msgid "" "references the same memory block as the first argument::" msgstr "" -#: ../../library/ctypes.rst:866 +#: ../../library/ctypes.rst:886 msgid "" "So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` " "the structure::" msgstr "" -#: ../../library/ctypes.rst:879 +#: ../../library/ctypes.rst:899 msgid "Incomplete Types" msgstr "" -#: ../../library/ctypes.rst:881 +#: ../../library/ctypes.rst:901 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:892 +#: ../../library/ctypes.rst:912 msgid "" "The straightforward translation into ctypes code would be this, but it does " "not work::" msgstr "" -#: ../../library/ctypes.rst:905 +#: ../../library/ctypes.rst:925 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:" "`_fields_` attribute later, after the class statement::" msgstr "" -#: ../../library/ctypes.rst:917 +#: ../../library/ctypes.rst:937 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:938 +#: ../../library/ctypes.rst:958 msgid "Callback functions" msgstr "" -#: ../../library/ctypes.rst:940 +#: ../../library/ctypes.rst:960 msgid "" ":mod:`ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" -#: ../../library/ctypes.rst:943 +#: ../../library/ctypes.rst:963 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:947 +#: ../../library/ctypes.rst:967 msgid "" "The :func:`CFUNCTYPE` factory function creates types for callback functions " "using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` " @@ -915,21 +940,21 @@ msgid "" "calling convention." msgstr "" -#: ../../library/ctypes.rst:952 +#: ../../library/ctypes.rst:972 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:956 +#: ../../library/ctypes.rst:976 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:966 +#: ../../library/ctypes.rst:986 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 " @@ -939,44 +964,44 @@ msgid "" "otherwise." msgstr "" -#: ../../library/ctypes.rst:972 +#: ../../library/ctypes.rst:992 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:978 +#: ../../library/ctypes.rst:998 msgid "" "To get started, here is a simple callback that shows the values it gets " "passed::" msgstr "" -#: ../../library/ctypes.rst:988 +#: ../../library/ctypes.rst:1008 msgid "The result::" msgstr "" -#: ../../library/ctypes.rst:998 +#: ../../library/ctypes.rst:1018 msgid "Now we can actually compare the two items and return a useful result::" msgstr "" -#: ../../library/ctypes.rst:1013 +#: ../../library/ctypes.rst:1033 msgid "As we can easily check, our array is sorted now::" msgstr "" -#: ../../library/ctypes.rst:1020 +#: ../../library/ctypes.rst:1040 msgid "" "The function factories can be used as decorator factories, so we may as well " "write::" msgstr "" -#: ../../library/ctypes.rst:1038 +#: ../../library/ctypes.rst:1058 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:1042 +#: ../../library/ctypes.rst:1062 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 " @@ -986,11 +1011,11 @@ msgid "" "even when those calls are made from the same C thread." msgstr "" -#: ../../library/ctypes.rst:1052 +#: ../../library/ctypes.rst:1072 msgid "Accessing values exported from dlls" msgstr "" -#: ../../library/ctypes.rst:1054 +#: ../../library/ctypes.rst:1074 msgid "" "Some shared libraries not only export functions, they also export variables. " "An example in the Python library itself is the :c:data:`Py_OptimizeFlag`, an " @@ -998,31 +1023,31 @@ msgid "" "flag given on startup." msgstr "" -#: ../../library/ctypes.rst:1059 +#: ../../library/ctypes.rst:1079 msgid "" ":mod:`ctypes` can access values like this with the :meth:`in_dll` class " "methods of the type. *pythonapi* is a predefined symbol giving access to " "the Python C api::" msgstr "" -#: ../../library/ctypes.rst:1068 +#: ../../library/ctypes.rst:1088 msgid "" "If the interpreter would have been started with :option:`-O`, the sample " "would have printed ``c_long(1)``, or ``c_long(2)`` if :option:`-OO` would " "have been specified." msgstr "" -#: ../../library/ctypes.rst:1072 +#: ../../library/ctypes.rst:1092 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:1075 +#: ../../library/ctypes.rst:1095 msgid "Quoting the docs for that value:" msgstr "" -#: ../../library/ctypes.rst:1077 +#: ../../library/ctypes.rst:1097 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 " @@ -1031,19 +1056,19 @@ msgid "" "frozen modules." msgstr "" -#: ../../library/ctypes.rst:1082 +#: ../../library/ctypes.rst:1102 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:1096 +#: ../../library/ctypes.rst:1116 msgid "" "We have defined the :c:struct:`_frozen` data type, so we can get the pointer " "to the table::" msgstr "" -#: ../../library/ctypes.rst:1103 +#: ../../library/ctypes.rst:1123 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 " @@ -1052,34 +1077,34 @@ msgid "" "the loop when we hit the ``NULL`` entry::" msgstr "" -#: ../../library/ctypes.rst:1119 +#: ../../library/ctypes.rst:1139 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:1127 +#: ../../library/ctypes.rst:1147 msgid "Surprises" msgstr "" -#: ../../library/ctypes.rst:1129 +#: ../../library/ctypes.rst:1149 msgid "" "There are some edges in :mod:`ctypes` where you might expect something other " "than what actually happens." msgstr "" -#: ../../library/ctypes.rst:1132 +#: ../../library/ctypes.rst:1152 msgid "Consider the following example::" msgstr "" -#: ../../library/ctypes.rst:1152 +#: ../../library/ctypes.rst:1172 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:1160 +#: ../../library/ctypes.rst:1180 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 " @@ -1088,26 +1113,26 @@ msgid "" "have the expected effect." msgstr "" -#: ../../library/ctypes.rst:1166 +#: ../../library/ctypes.rst:1186 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:1170 +#: ../../library/ctypes.rst:1190 msgid "" "Another example that may behave differently from what one would expect is " "this::" msgstr "" -#: ../../library/ctypes.rst:1182 +#: ../../library/ctypes.rst:1202 msgid "" "Objects instantiated from :class:`c_char_p` can only have their value set to " "bytes or integers." msgstr "" -#: ../../library/ctypes.rst:1185 +#: ../../library/ctypes.rst:1205 msgid "" "Why is it printing ``False``? ctypes instances are objects containing a " "memory block plus some :term:`descriptor`\\s accessing the contents of the " @@ -1116,16 +1141,16 @@ msgid "" "the contents again constructs a new Python object each time!" msgstr "" -#: ../../library/ctypes.rst:1195 +#: ../../library/ctypes.rst:1215 msgid "Variable-sized data types" msgstr "" -#: ../../library/ctypes.rst:1197 +#: ../../library/ctypes.rst:1217 msgid "" ":mod:`ctypes` provides some support for variable-sized arrays and structures." msgstr "" -#: ../../library/ctypes.rst:1199 +#: ../../library/ctypes.rst:1219 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, " @@ -1134,35 +1159,35 @@ msgid "" "objects type, a :exc:`ValueError` is raised if this is tried::" msgstr "" -#: ../../library/ctypes.rst:1219 +#: ../../library/ctypes.rst:1239 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:1231 +#: ../../library/ctypes.rst:1251 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:1239 +#: ../../library/ctypes.rst:1259 msgid "ctypes reference" msgstr "" -#: ../../library/ctypes.rst:1245 +#: ../../library/ctypes.rst:1265 msgid "Finding shared libraries" msgstr "" -#: ../../library/ctypes.rst:1247 +#: ../../library/ctypes.rst:1267 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:1250 +#: ../../library/ctypes.rst:1270 msgid "" "The purpose of the :func:`find_library` function is to locate a library in a " "way similar to what the compiler or runtime loader does (on platforms with " @@ -1171,13 +1196,13 @@ msgid "" "the runtime loader directly." msgstr "" -#: ../../library/ctypes.rst:1256 +#: ../../library/ctypes.rst:1276 msgid "" "The :mod:`ctypes.util` module provides a function which can help to " "determine the library to load." msgstr "" -#: ../../library/ctypes.rst:1264 +#: ../../library/ctypes.rst:1284 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 " @@ -1185,45 +1210,45 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1269 ../../library/ctypes.rst:1912 +#: ../../library/ctypes.rst:1289 ../../library/ctypes.rst:1932 msgid "The exact functionality is system dependent." msgstr "" -#: ../../library/ctypes.rst:1271 +#: ../../library/ctypes.rst:1291 msgid "" "On Linux, :func:`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:1275 +#: ../../library/ctypes.rst:1295 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:1279 +#: ../../library/ctypes.rst:1299 msgid "Here are some examples::" msgstr "" "以下是一些範例:\n" "\n" "::" -#: ../../library/ctypes.rst:1290 +#: ../../library/ctypes.rst:1310 msgid "" "On macOS, :func:`find_library` tries several predefined naming schemes and " "paths to locate the library, and returns a full pathname if successful::" msgstr "" -#: ../../library/ctypes.rst:1304 +#: ../../library/ctypes.rst:1324 msgid "" "On Windows, :func:`find_library` searches along the system search path, and " "returns the full pathname, but since there is no predefined naming scheme a " "call like ``find_library(\"c\")`` will fail and return ``None``." msgstr "" -#: ../../library/ctypes.rst:1308 +#: ../../library/ctypes.rst:1328 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 " @@ -1231,24 +1256,24 @@ msgid "" "library at runtime." msgstr "" -#: ../../library/ctypes.rst:1316 +#: ../../library/ctypes.rst:1336 msgid "Loading shared libraries" msgstr "" -#: ../../library/ctypes.rst:1318 +#: ../../library/ctypes.rst:1338 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:1324 +#: ../../library/ctypes.rst:1344 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:1328 +#: ../../library/ctypes.rst:1348 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:" @@ -1260,13 +1285,13 @@ msgid "" "determine which one is not found using Windows debugging and tracing tools." msgstr "" -#: ../../library/ctypes.rst:1340 +#: ../../library/ctypes.rst:1360 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL dependents." msgstr "" -#: ../../library/ctypes.rst:1346 +#: ../../library/ctypes.rst:1366 msgid "" "Windows only: Instances of this class represent loaded shared libraries, " "functions in these libraries use the ``stdcall`` calling convention, and are " @@ -1276,24 +1301,24 @@ msgid "" "value signals a failure, an :class:`OSError` is automatically raised." msgstr "" -#: ../../library/ctypes.rst:1353 +#: ../../library/ctypes.rst:1373 msgid ":exc:`WindowsError` used to be raised." msgstr "" -#: ../../library/ctypes.rst:1359 +#: ../../library/ctypes.rst:1379 msgid "" "Windows only: Instances of this class represent loaded shared libraries, " "functions in these libraries use the ``stdcall`` calling convention, and are " "assumed to return :c:expr:`int` by default." msgstr "" -#: ../../library/ctypes.rst:1363 +#: ../../library/ctypes.rst:1383 msgid "" "The Python :term:`global interpreter lock` is released before calling any " "function exported by these libraries, and reacquired afterwards." msgstr "" -#: ../../library/ctypes.rst:1369 +#: ../../library/ctypes.rst:1389 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 " @@ -1301,11 +1326,11 @@ msgid "" "set, a Python exception is raised." msgstr "" -#: ../../library/ctypes.rst:1374 +#: ../../library/ctypes.rst:1394 msgid "Thus, this is only useful to call Python C api functions directly." msgstr "" -#: ../../library/ctypes.rst:1376 +#: ../../library/ctypes.rst:1396 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 " @@ -1315,7 +1340,7 @@ msgid "" "to get a handle to it." msgstr "" -#: ../../library/ctypes.rst:1383 +#: ../../library/ctypes.rst:1403 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 " @@ -1323,7 +1348,7 @@ msgid "" "configurable." msgstr "" -#: ../../library/ctypes.rst:1388 +#: ../../library/ctypes.rst:1408 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:" @@ -1333,14 +1358,14 @@ msgid "" "private copy, the same happens immediately after the function call." msgstr "" -#: ../../library/ctypes.rst:1395 +#: ../../library/ctypes.rst:1415 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:1399 +#: ../../library/ctypes.rst:1419 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 :" @@ -1349,7 +1374,7 @@ msgid "" "private copy of the windows error code." msgstr "" -#: ../../library/ctypes.rst:1405 +#: ../../library/ctypes.rst:1425 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 " @@ -1359,29 +1384,29 @@ msgid "" "ensure the correct library and dependencies are loaded." msgstr "" -#: ../../library/ctypes.rst:1412 +#: ../../library/ctypes.rst:1432 msgid "Added *winmode* parameter." msgstr "新增 *winmode* 參數。" -#: ../../library/ctypes.rst:1419 +#: ../../library/ctypes.rst:1439 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:1426 +#: ../../library/ctypes.rst:1446 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:1433 +#: ../../library/ctypes.rst:1453 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:1436 +#: ../../library/ctypes.rst:1456 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 " @@ -1390,21 +1415,21 @@ msgid "" "other hand, accessing it through an index returns a new object each time::" msgstr "" -#: ../../library/ctypes.rst:1449 +#: ../../library/ctypes.rst:1469 msgid "" "The following public attributes are available, their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: ../../library/ctypes.rst:1455 +#: ../../library/ctypes.rst:1475 msgid "The system handle used to access the library." msgstr "" -#: ../../library/ctypes.rst:1460 +#: ../../library/ctypes.rst:1480 msgid "The name of the library passed in the constructor." msgstr "" -#: ../../library/ctypes.rst:1462 +#: ../../library/ctypes.rst:1482 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -1412,52 +1437,52 @@ msgid "" "attribute of the loader instance." msgstr "" -#: ../../library/ctypes.rst:1470 +#: ../../library/ctypes.rst:1490 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:1473 +#: ../../library/ctypes.rst:1493 msgid "" ":meth:`__getattr__` has special behavior: It allows loading a shared library " "by accessing it as attribute of a library loader instance. The result is " "cached, so repeated attribute accesses return the same library each time." msgstr "" -#: ../../library/ctypes.rst:1479 +#: ../../library/ctypes.rst:1499 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:1483 +#: ../../library/ctypes.rst:1503 msgid "These prefabricated library loaders are available:" msgstr "" -#: ../../library/ctypes.rst:1488 +#: ../../library/ctypes.rst:1508 msgid "Creates :class:`CDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1494 +#: ../../library/ctypes.rst:1514 msgid "Windows only: Creates :class:`WinDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1500 +#: ../../library/ctypes.rst:1520 msgid "Windows only: Creates :class:`OleDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1506 +#: ../../library/ctypes.rst:1526 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1509 +#: ../../library/ctypes.rst:1529 msgid "" "For accessing the C Python api directly, a ready-to-use Python shared " "library object is available:" msgstr "" -#: ../../library/ctypes.rst:1515 +#: ../../library/ctypes.rst:1535 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:" @@ -1465,50 +1490,50 @@ msgid "" "correct :attr:`restype` attribute to use these functions." msgstr "" -#: ../../library/ctypes.rst:1520 +#: ../../library/ctypes.rst:1540 msgid "" "Raises an :ref:`auditing event ` ``ctypes.dlopen`` with argument " "``name``." msgstr "" -#: ../../library/ctypes.rst:1522 +#: ../../library/ctypes.rst:1542 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:1526 +#: ../../library/ctypes.rst:1546 msgid "" "Raises an :ref:`auditing event ` ``ctypes.dlsym`` with arguments " "``library``, ``name``." msgstr "" -#: ../../library/ctypes.rst:1528 +#: ../../library/ctypes.rst:1548 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:1532 +#: ../../library/ctypes.rst:1552 msgid "" "Raises an :ref:`auditing event ` ``ctypes.dlsym/handle`` with " "arguments ``handle``, ``name``." msgstr "" -#: ../../library/ctypes.rst:1534 +#: ../../library/ctypes.rst:1554 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:1541 +#: ../../library/ctypes.rst:1561 msgid "Foreign functions" msgstr "" -#: ../../library/ctypes.rst:1543 +#: ../../library/ctypes.rst:1563 msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " @@ -1517,29 +1542,29 @@ msgid "" "library loader. They are instances of a private class:" msgstr "" -#: ../../library/ctypes.rst:1552 +#: ../../library/ctypes.rst:1572 msgid "Base class for C callable foreign functions." msgstr "" -#: ../../library/ctypes.rst:1554 +#: ../../library/ctypes.rst:1574 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: ../../library/ctypes.rst:1557 +#: ../../library/ctypes.rst:1577 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: ../../library/ctypes.rst:1562 +#: ../../library/ctypes.rst:1582 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:1565 +#: ../../library/ctypes.rst:1585 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 " @@ -1549,7 +1574,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: ../../library/ctypes.rst:1574 +#: ../../library/ctypes.rst:1594 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -1558,7 +1583,7 @@ msgid "" "unspecified arguments as well." msgstr "" -#: ../../library/ctypes.rst:1580 +#: ../../library/ctypes.rst:1600 msgid "" "When a foreign function is called, each actual argument is passed to the :" "meth:`from_param` class method of the items in the :attr:`argtypes` tuple, " @@ -1568,7 +1593,7 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1587 +#: ../../library/ctypes.rst:1607 msgid "" "New: It is now possible to put items in argtypes which are not ctypes types, " "but each item must have a :meth:`from_param` method which returns a value " @@ -1576,50 +1601,50 @@ msgid "" "adapters that can adapt custom objects as function parameters." msgstr "" -#: ../../library/ctypes.rst:1594 +#: ../../library/ctypes.rst:1614 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:1601 +#: ../../library/ctypes.rst:1621 msgid "" "*result* is what the foreign function returns, as specified by the :attr:" "`restype` attribute." msgstr "" -#: ../../library/ctypes.rst:1604 +#: ../../library/ctypes.rst:1624 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:1608 +#: ../../library/ctypes.rst:1628 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:1612 +#: ../../library/ctypes.rst:1632 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:1619 +#: ../../library/ctypes.rst:1639 msgid "" "This exception is raised when a foreign function call cannot convert one of " "the passed arguments." msgstr "" -#: ../../library/ctypes.rst:1623 +#: ../../library/ctypes.rst:1643 msgid "" "Raises an :ref:`auditing event ` ``ctypes.seh_exception`` with " "argument ``code``." msgstr "" -#: ../../library/ctypes.rst:1625 +#: ../../library/ctypes.rst:1645 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 " @@ -1628,24 +1653,24 @@ msgid "" "hook to replace the exception with its own." msgstr "" -#: ../../library/ctypes.rst:1631 +#: ../../library/ctypes.rst:1651 msgid "" "Raises an :ref:`auditing event ` ``ctypes.call_function`` with " "arguments ``func_pointer``, ``arguments``." msgstr "" -#: ../../library/ctypes.rst:1633 +#: ../../library/ctypes.rst:1653 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:1639 +#: ../../library/ctypes.rst:1659 msgid "Function prototypes" msgstr "" -#: ../../library/ctypes.rst:1641 +#: ../../library/ctypes.rst:1661 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -1656,7 +1681,7 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: ../../library/ctypes.rst:1652 +#: ../../library/ctypes.rst:1672 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " @@ -1665,37 +1690,37 @@ msgid "" "after the call; *use_last_error* does the same for the Windows error code." msgstr "" -#: ../../library/ctypes.rst:1662 +#: ../../library/ctypes.rst:1682 msgid "" "Windows only: The returned function prototype creates functions that use the " "``stdcall`` calling convention. The function will release the GIL during " "the call. *use_errno* and *use_last_error* have the same meaning as above." msgstr "" -#: ../../library/ctypes.rst:1670 +#: ../../library/ctypes.rst:1690 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:1673 +#: ../../library/ctypes.rst:1693 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:1681 +#: ../../library/ctypes.rst:1701 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: ../../library/ctypes.rst:1688 +#: ../../library/ctypes.rst:1708 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: ../../library/ctypes.rst:1695 +#: ../../library/ctypes.rst:1715 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 " @@ -1703,7 +1728,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: ../../library/ctypes.rst:1705 +#: ../../library/ctypes.rst:1725 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* " @@ -1711,85 +1736,85 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: ../../library/ctypes.rst:1710 +#: ../../library/ctypes.rst:1730 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:1714 +#: ../../library/ctypes.rst:1734 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: ../../library/ctypes.rst:1717 +#: ../../library/ctypes.rst:1737 msgid "*paramflags* must be a tuple of the same length as :attr:`argtypes`." msgstr "" -#: ../../library/ctypes.rst:1719 +#: ../../library/ctypes.rst:1739 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:1722 +#: ../../library/ctypes.rst:1742 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: ../../library/ctypes.rst:1726 +#: ../../library/ctypes.rst:1746 msgid "1" msgstr "1" -#: ../../library/ctypes.rst:1726 +#: ../../library/ctypes.rst:1746 msgid "Specifies an input parameter to the function." msgstr "" -#: ../../library/ctypes.rst:1729 +#: ../../library/ctypes.rst:1749 msgid "2" msgstr "2" -#: ../../library/ctypes.rst:1729 +#: ../../library/ctypes.rst:1749 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: ../../library/ctypes.rst:1732 +#: ../../library/ctypes.rst:1752 msgid "4" msgstr "4" -#: ../../library/ctypes.rst:1732 +#: ../../library/ctypes.rst:1752 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: ../../library/ctypes.rst:1734 +#: ../../library/ctypes.rst:1754 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:1737 +#: ../../library/ctypes.rst:1757 msgid "The optional third item is the default value for this parameter." msgstr "" -#: ../../library/ctypes.rst:1739 +#: ../../library/ctypes.rst:1759 msgid "" "This 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:1750 ../../library/ctypes.rst:1773 +#: ../../library/ctypes.rst:1770 ../../library/ctypes.rst:1793 msgid "Here is the wrapping with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1758 +#: ../../library/ctypes.rst:1778 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: ../../library/ctypes.rst:1764 +#: ../../library/ctypes.rst:1784 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -1797,7 +1822,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:1782 +#: ../../library/ctypes.rst:1802 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -1805,7 +1830,7 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: ../../library/ctypes.rst:1787 +#: ../../library/ctypes.rst:1807 msgid "" "Output parameters can be combined with the :attr:`errcheck` protocol to do " "further output processing and error checking. The win32 ``GetWindowRect`` " @@ -1814,7 +1839,7 @@ msgid "" "call failed::" msgstr "" -#: ../../library/ctypes.rst:1800 +#: ../../library/ctypes.rst:1820 msgid "" "If the :attr:`errcheck` function returns the argument tuple it receives " "unchanged, :mod:`ctypes` continues the normal processing it does on the " @@ -1823,11 +1848,11 @@ msgid "" "and return them instead, the normal processing will no longer take place::" msgstr "" -#: ../../library/ctypes.rst:1819 +#: ../../library/ctypes.rst:1839 msgid "Utility functions" msgstr "" -#: ../../library/ctypes.rst:1823 +#: ../../library/ctypes.rst:1843 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." @@ -1839,30 +1864,30 @@ msgid "" "argument ``obj``." msgstr "" -#: ../../library/ctypes.rst:1831 +#: ../../library/ctypes.rst:1851 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: ../../library/ctypes.rst:1837 +#: ../../library/ctypes.rst:1857 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:1841 +#: ../../library/ctypes.rst:1861 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: ../../library/ctypes.rst:1845 +#: ../../library/ctypes.rst:1865 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:1851 +#: ../../library/ctypes.rst:1871 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* " @@ -1870,19 +1895,19 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:1859 +#: ../../library/ctypes.rst:1879 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:1862 +#: ../../library/ctypes.rst:1882 msgid "" "*init_or_size* must be an integer which specifies the size of the array, or " "a bytes object which will be used to initialize the array items." msgstr "" -#: ../../library/ctypes.rst:1865 +#: ../../library/ctypes.rst:1885 msgid "" "If a bytes object is specified as first argument, the buffer is made one " "item larger than its length so that the last element in the array is a NUL " @@ -1897,19 +1922,19 @@ msgid "" "with arguments ``init``, ``size``." msgstr "" -#: ../../library/ctypes.rst:1875 +#: ../../library/ctypes.rst:1895 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1878 +#: ../../library/ctypes.rst:1898 msgid "" "*init_or_size* must be an integer which specifies the size of the array, or " "a string which will be used to initialize the array items." msgstr "" -#: ../../library/ctypes.rst:1881 +#: ../../library/ctypes.rst:1901 msgid "" "If a string is specified as first argument, the buffer is made one item " "larger than the length of the string so that the last element in the array " @@ -1924,21 +1949,21 @@ msgid "" "with arguments ``init``, ``size``." msgstr "" -#: ../../library/ctypes.rst:1892 +#: ../../library/ctypes.rst:1912 msgid "" "Windows only: This function is a hook which allows implementing in-process " "COM servers with ctypes. It is called from the DllCanUnloadNow function " "that the _ctypes extension dll exports." msgstr "" -#: ../../library/ctypes.rst:1899 +#: ../../library/ctypes.rst:1919 msgid "" "Windows only: This function is a hook which allows implementing in-process " "COM servers with ctypes. It is called from the DllGetClassObject function " "that the ``_ctypes`` extension dll exports." msgstr "" -#: ../../library/ctypes.rst:1907 +#: ../../library/ctypes.rst:1927 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 " @@ -1946,35 +1971,35 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1918 +#: ../../library/ctypes.rst:1938 msgid "" "Windows only: return the filename of the VC runtime library used by Python, " "and by the extension modules. If the name of the library cannot be " "determined, ``None`` is returned." msgstr "" -#: ../../library/ctypes.rst:1922 +#: ../../library/ctypes.rst:1942 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:1929 +#: ../../library/ctypes.rst:1949 msgid "" "Windows only: Returns a textual description of the error code *code*. If no " "error code is specified, the last error code is used by calling the Windows " "api function GetLastError." msgstr "" -#: ../../library/ctypes.rst:1936 +#: ../../library/ctypes.rst:1956 msgid "" "Windows only: Returns the last error code set by Windows in the calling " "thread. This function calls the Windows ``GetLastError()`` function " "directly, it does not return the ctypes-private copy of the error code." msgstr "" -#: ../../library/ctypes.rst:1942 +#: ../../library/ctypes.rst:1962 msgid "" "Returns the current value of the ctypes-private copy of the system :data:" "`errno` variable in the calling thread." @@ -1986,7 +2011,7 @@ msgid "" "arguments." msgstr "" -#: ../../library/ctypes.rst:1949 +#: ../../library/ctypes.rst:1969 msgid "" "Windows only: returns the current value of the ctypes-private copy of the " "system :data:`LastError` variable in the calling thread." @@ -1998,40 +2023,40 @@ msgid "" "arguments." msgstr "" -#: ../../library/ctypes.rst:1956 +#: ../../library/ctypes.rst:1976 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:1963 +#: ../../library/ctypes.rst:1983 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:1970 +#: ../../library/ctypes.rst:1990 msgid "" "This factory function creates and returns 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:1977 +#: ../../library/ctypes.rst:1997 msgid "" "This function creates a new pointer instance, pointing to *obj*. The " "returned object is of the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:1980 +#: ../../library/ctypes.rst:2000 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:1986 +#: ../../library/ctypes.rst:2006 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 " @@ -2039,7 +2064,7 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:1994 +#: ../../library/ctypes.rst:2014 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." @@ -2051,7 +2076,7 @@ msgid "" "argument ``errno``." msgstr "" -#: ../../library/ctypes.rst:2002 +#: ../../library/ctypes.rst:2022 msgid "" "Windows only: set the current value of the ctypes-private copy of the " "system :data:`LastError` variable in the calling thread to *value* and " @@ -2064,13 +2089,13 @@ msgid "" "argument ``error``." msgstr "" -#: ../../library/ctypes.rst:2011 +#: ../../library/ctypes.rst:2031 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:2017 +#: ../../library/ctypes.rst:2037 msgid "" "This function returns the C string starting at memory address *address* as a " "bytes object. If size is specified, it is used as size, otherwise the string " @@ -2083,7 +2108,7 @@ msgid "" "arguments ``address``, ``size``." msgstr "" -#: ../../library/ctypes.rst:2026 +#: ../../library/ctypes.rst:2046 msgid "" "Windows only: this function is probably the worst-named thing in ctypes. It " "creates an instance of OSError. If *code* is not specified, " @@ -2092,11 +2117,11 @@ msgid "" "error." msgstr "" -#: ../../library/ctypes.rst:2032 +#: ../../library/ctypes.rst:2052 msgid "An instance of :exc:`WindowsError` used to be created." msgstr "" -#: ../../library/ctypes.rst:2038 +#: ../../library/ctypes.rst:2058 msgid "" "This function returns the wide character string starting at memory address " "*address* as a string. If *size* is specified, it is used as the number of " @@ -2110,11 +2135,11 @@ msgid "" "arguments ``address``, ``size``." msgstr "" -#: ../../library/ctypes.rst:2049 +#: ../../library/ctypes.rst:2069 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2054 +#: ../../library/ctypes.rst:2074 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 " @@ -2124,13 +2149,13 @@ msgid "" "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2061 +#: ../../library/ctypes.rst:2081 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:2066 +#: ../../library/ctypes.rst:2086 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " @@ -2145,7 +2170,7 @@ msgid "" "arguments ``pointer``, ``size``, ``offset``." msgstr "" -#: ../../library/ctypes.rst:2076 +#: ../../library/ctypes.rst:2096 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -2153,7 +2178,7 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2086 +#: ../../library/ctypes.rst:2106 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." @@ -2165,13 +2190,13 @@ msgid "" "``address``." msgstr "" -#: ../../library/ctypes.rst:2091 +#: ../../library/ctypes.rst:2111 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2097 +#: ../../library/ctypes.rst:2117 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 " @@ -2179,25 +2204,25 @@ msgid "" "be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2102 +#: ../../library/ctypes.rst:2122 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:2108 +#: ../../library/ctypes.rst:2128 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:2112 +#: ../../library/ctypes.rst:2132 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2116 +#: ../../library/ctypes.rst:2136 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:" @@ -2205,13 +2230,13 @@ msgid "" "block." msgstr "" -#: ../../library/ctypes.rst:2123 +#: ../../library/ctypes.rst:2143 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2128 +#: ../../library/ctypes.rst:2148 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. " @@ -2219,7 +2244,7 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2141 +#: ../../library/ctypes.rst:2161 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 " @@ -2228,11 +2253,11 @@ msgid "" "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2147 +#: ../../library/ctypes.rst:2167 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2151 +#: ../../library/ctypes.rst:2171 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 " @@ -2240,7 +2265,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2156 +#: ../../library/ctypes.rst:2176 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -2248,7 +2273,7 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2162 +#: ../../library/ctypes.rst:2182 msgid "" "Fundamental data types, when returned as foreign function call results, or, " "for example, by retrieving structure field members or array items, are " @@ -2257,7 +2282,7 @@ msgid "" "receive a Python bytes object, *not* a :class:`c_char_p` instance." msgstr "" -#: ../../library/ctypes.rst:2170 +#: ../../library/ctypes.rst:2190 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 " @@ -2265,25 +2290,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: ../../library/ctypes.rst:2175 +#: ../../library/ctypes.rst:2195 msgid "These are the fundamental ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2179 +#: ../../library/ctypes.rst:2199 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:2186 +#: ../../library/ctypes.rst:2206 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:2193 +#: ../../library/ctypes.rst:2213 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 " @@ -2291,178 +2316,178 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: ../../library/ctypes.rst:2201 +#: ../../library/ctypes.rst:2221 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2207 +#: ../../library/ctypes.rst:2227 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:2213 +#: ../../library/ctypes.rst:2233 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2219 +#: ../../library/ctypes.rst:2239 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:2226 +#: ../../library/ctypes.rst:2246 msgid "" "Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for :" "class:`c_byte`." msgstr "" -#: ../../library/ctypes.rst:2232 +#: ../../library/ctypes.rst:2252 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: ../../library/ctypes.rst:2238 +#: ../../library/ctypes.rst:2258 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: ../../library/ctypes.rst:2244 +#: ../../library/ctypes.rst:2264 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: ../../library/ctypes.rst:2250 +#: ../../library/ctypes.rst:2270 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:2256 +#: ../../library/ctypes.rst:2276 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:2262 +#: ../../library/ctypes.rst:2282 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:2268 +#: ../../library/ctypes.rst:2288 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2273 +#: ../../library/ctypes.rst:2293 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2280 +#: ../../library/ctypes.rst:2300 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:2287 +#: ../../library/ctypes.rst:2307 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:2294 +#: ../../library/ctypes.rst:2314 msgid "" "Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ubyte`." msgstr "" -#: ../../library/ctypes.rst:2300 +#: ../../library/ctypes.rst:2320 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: ../../library/ctypes.rst:2306 +#: ../../library/ctypes.rst:2326 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: ../../library/ctypes.rst:2312 +#: ../../library/ctypes.rst:2332 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: ../../library/ctypes.rst:2318 +#: ../../library/ctypes.rst:2338 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:2324 +#: ../../library/ctypes.rst:2344 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:2330 +#: ../../library/ctypes.rst:2350 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:2336 +#: ../../library/ctypes.rst:2356 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:2342 +#: ../../library/ctypes.rst:2362 msgid "" "Represents the C :c:expr:`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:2349 +#: ../../library/ctypes.rst:2369 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:2356 +#: ../../library/ctypes.rst:2376 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:2363 +#: ../../library/ctypes.rst:2383 msgid "" "Windows only: Represents a :c:type:`HRESULT` value, which contains success " "or error information for a function or method call." msgstr "" -#: ../../library/ctypes.rst:2369 +#: ../../library/ctypes.rst:2389 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: ../../library/ctypes.rst:2372 +#: ../../library/ctypes.rst:2392 msgid "" "The :mod:`ctypes.wintypes` module provides quite some other Windows specific " "data types, for example :c:type:`HWND`, :c:type:`WPARAM`, or :c:type:" @@ -2470,41 +2495,41 @@ msgid "" "also defined." msgstr "" -#: ../../library/ctypes.rst:2380 +#: ../../library/ctypes.rst:2400 msgid "Structured data types" msgstr "" -#: ../../library/ctypes.rst:2385 +#: ../../library/ctypes.rst:2405 msgid "Abstract base class for unions in native byte order." msgstr "" -#: ../../library/ctypes.rst:2390 +#: ../../library/ctypes.rst:2410 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2396 +#: ../../library/ctypes.rst:2416 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2402 +#: ../../library/ctypes.rst:2422 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2407 +#: ../../library/ctypes.rst:2427 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2409 +#: ../../library/ctypes.rst:2429 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:2415 +#: ../../library/ctypes.rst:2435 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: ../../library/ctypes.rst:2417 +#: ../../library/ctypes.rst:2437 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:" @@ -2512,34 +2537,34 @@ msgid "" "the fields by direct attribute accesses. These are the" msgstr "" -#: ../../library/ctypes.rst:2425 +#: ../../library/ctypes.rst:2445 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:2429 +#: ../../library/ctypes.rst:2449 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:2433 +#: ../../library/ctypes.rst:2453 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:2436 +#: ../../library/ctypes.rst:2456 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:2446 +#: ../../library/ctypes.rst:2466 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, " @@ -2547,28 +2572,28 @@ msgid "" "raise an AttributeError." msgstr "" -#: ../../library/ctypes.rst:2451 +#: ../../library/ctypes.rst:2471 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:2458 +#: ../../library/ctypes.rst:2478 msgid "" "An optional small integer that allows overriding the alignment of structure " "fields in the instance. :attr:`_pack_` must already be defined when :attr:" "`_fields_` is assigned, otherwise it will have no effect." msgstr "" -#: ../../library/ctypes.rst:2465 +#: ../../library/ctypes.rst:2485 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:2469 +#: ../../library/ctypes.rst:2489 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 " @@ -2576,11 +2601,11 @@ msgid "" "structure or union field." msgstr "" -#: ../../library/ctypes.rst:2474 +#: ../../library/ctypes.rst:2494 msgid "Here is an example type (Windows)::" msgstr "" -#: ../../library/ctypes.rst:2487 +#: ../../library/ctypes.rst:2507 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 " @@ -2590,7 +2615,7 @@ msgid "" "temporary union instance::" msgstr "" -#: ../../library/ctypes.rst:2499 +#: ../../library/ctypes.rst:2519 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:" @@ -2598,7 +2623,7 @@ msgid "" "of the base class." msgstr "" -#: ../../library/ctypes.rst:2504 +#: ../../library/ctypes.rst:2524 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -2608,15 +2633,15 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: ../../library/ctypes.rst:2515 +#: ../../library/ctypes.rst:2535 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:2519 +#: ../../library/ctypes.rst:2539 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:2521 +#: ../../library/ctypes.rst:2541 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 " @@ -2626,34 +2651,34 @@ msgid "" "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:2531 +#: ../../library/ctypes.rst:2551 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:2538 +#: ../../library/ctypes.rst:2558 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:2541 +#: ../../library/ctypes.rst:2561 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:2547 +#: ../../library/ctypes.rst:2567 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:2549 +#: ../../library/ctypes.rst:2569 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:2553 +#: ../../library/ctypes.rst:2573 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 :" @@ -2662,11 +2687,11 @@ msgid "" "probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:2563 +#: ../../library/ctypes.rst:2583 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:2567 +#: ../../library/ctypes.rst:2587 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/exceptions.po b/library/exceptions.po index 140e0e27ae..715e2e6fbb 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-15 20:43+0000\n" +"POT-Creation-Date: 2022-11-19 00:18+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1092,10 +1092,17 @@ msgid "" "from it. ::" msgstr "" -#: ../../library/exceptions.rst:972 +#: ../../library/exceptions.rst:968 +msgid "" +"Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " +"is also a subclass of :exc:`Exception` can only wrap instances of :exc:" +"`Exception`." +msgstr "" + +#: ../../library/exceptions.rst:976 msgid "Exception hierarchy" msgstr "" -#: ../../library/exceptions.rst:974 +#: ../../library/exceptions.rst:978 msgid "The class hierarchy for built-in exceptions is:" msgstr "" diff --git a/library/os.po b/library/os.po index add7b9514c..7cfb12b743 100644 --- a/library/os.po +++ b/library/os.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-31 08:13+0000\n" +"POT-Creation-Date: 2022-11-22 00:18+0000\n" "PO-Revision-Date: 2022-10-16 08:11+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2494,8 +2494,8 @@ msgstr "" #: ../../library/os.rst:2328 msgid "" "Remove (delete) the file *path*. If *path* is a directory, an :exc:" -"`IsADirectoryError` is raised. Use :func:`rmdir` to remove directories. If " -"the file does not exist, a :exc:`FileNotFoundError` is raised." +"`OSError` is raised. Use :func:`rmdir` to remove directories. If the file " +"does not exist, a :exc:`FileNotFoundError` is raised." msgstr "" #: ../../library/os.rst:2332 ../../library/os.rst:2443 diff --git a/library/struct.po b/library/struct.po index daa1ba9ce1..7caea91920 100644 --- a/library/struct.po +++ b/library/struct.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-11-04 00:20+0000\n" +"POT-Creation-Date: 2022-11-23 00:17+0000\n" "PO-Revision-Date: 2018-05-23 16:11+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,26 +28,28 @@ msgstr "**原始碼:**\\ :source:`Lib/struct.py`" #: ../../library/struct.rst:15 msgid "" -"This module performs conversions between Python values and C structs " -"represented as Python :class:`bytes` objects. This can be used in handling " -"binary data stored in files or from network connections, among other " -"sources. It uses :ref:`struct-format-strings` as compact descriptions of " -"the layout of the C structs and the intended conversion to/from Python " -"values." +"This module converts between Python values and C structs represented as " +"Python :class:`bytes` objects. Compact :ref:`format strings ` describe the intended conversions to/from Python values. The " +"module's functions and objects can be used for two largely distinct " +"applications, data exchange with external sources (files or network " +"connections), or data transfer between the Python application and the C " +"layer." msgstr "" -#: ../../library/struct.rst:23 +#: ../../library/struct.rst:25 msgid "" -"By default, the result of packing a given C struct includes pad bytes in " -"order to maintain proper alignment for the C types involved; similarly, " -"alignment is taken into account when unpacking. This behavior is chosen so " -"that the bytes of a packed struct correspond exactly to the layout in memory " -"of the corresponding C struct. To handle platform-independent data formats " -"or omit implicit pad bytes, use ``standard`` size and alignment instead of " -"``native`` size and alignment: see :ref:`struct-alignment` for details." +"When no prefix character is given, native mode is the default. It packs or " +"unpacks data based on the platform and compiler on which the Python " +"interpreter was built. The result of packing a given C struct includes pad " +"bytes which maintain proper alignment for the C types involved; similarly, " +"alignment is taken into account when unpacking. In contrast, when " +"communicating data between external sources, the programmer is responsible " +"for defining byte ordering and padding between elements. See :ref:`struct-" +"alignment` for details." msgstr "" -#: ../../library/struct.rst:31 +#: ../../library/struct.rst:35 msgid "" "Several :mod:`struct` functions (and methods of :class:`Struct`) take a " "*buffer* argument. This refers to objects that implement the :ref:" @@ -58,35 +60,35 @@ msgid "" "additional copying from a :class:`bytes` object." msgstr "" -#: ../../library/struct.rst:40 +#: ../../library/struct.rst:44 msgid "Functions and Exceptions" msgstr "函式與例外" -#: ../../library/struct.rst:42 +#: ../../library/struct.rst:46 msgid "The module defines the following exception and functions:" msgstr "" -#: ../../library/struct.rst:47 +#: ../../library/struct.rst:51 msgid "" "Exception raised on various occasions; argument is a string describing what " "is wrong." msgstr "" -#: ../../library/struct.rst:53 +#: ../../library/struct.rst:57 msgid "" "Return a bytes object containing the values *v1*, *v2*, ... packed according " "to the format string *format*. The arguments must match the values required " "by the format exactly." msgstr "" -#: ../../library/struct.rst:60 +#: ../../library/struct.rst:64 msgid "" "Pack the values *v1*, *v2*, ... according to the format string *format* and " "write the packed bytes into the writable buffer *buffer* starting at " "position *offset*. Note that *offset* is a required argument." msgstr "" -#: ../../library/struct.rst:67 +#: ../../library/struct.rst:71 msgid "" "Unpack from the buffer *buffer* (presumably packed by ``pack(format, ...)``) " "according to the format string *format*. The result is a tuple even if it " @@ -94,7 +96,7 @@ msgid "" "required by the format, as reflected by :func:`calcsize`." msgstr "" -#: ../../library/struct.rst:75 +#: ../../library/struct.rst:79 msgid "" "Unpack from *buffer* starting at position *offset*, according to the format " "string *format*. The result is a tuple even if it contains exactly one " @@ -102,7 +104,7 @@ msgid "" "least the size required by the format, as reflected by :func:`calcsize`." msgstr "" -#: ../../library/struct.rst:83 +#: ../../library/struct.rst:87 msgid "" "Iteratively unpack from the buffer *buffer* according to the format string " "*format*. This function returns an iterator which will read equally sized " @@ -111,181 +113,184 @@ msgid "" "format, as reflected by :func:`calcsize`." msgstr "" -#: ../../library/struct.rst:89 +#: ../../library/struct.rst:93 msgid "Each iteration yields a tuple as specified by the format string." msgstr "" -#: ../../library/struct.rst:96 +#: ../../library/struct.rst:100 msgid "" "Return the size of the struct (and hence of the bytes object produced by " "``pack(format, ...)``) corresponding to the format string *format*." msgstr "" -#: ../../library/struct.rst:103 +#: ../../library/struct.rst:107 msgid "Format Strings" msgstr "" -#: ../../library/struct.rst:105 +#: ../../library/struct.rst:109 msgid "" -"Format strings are the mechanism used to specify the expected layout when " -"packing and unpacking data. They are built up from :ref:`format-" -"characters`, which specify the type of data being packed/unpacked. In " -"addition, there are special characters for controlling the :ref:`struct-" -"alignment`." +"Format strings describe the data layout when packing and unpacking data. " +"They are built up from :ref:`format characters`, which " +"specify the type of data being packed/unpacked. In addition, special " +"characters control the :ref:`byte order, size and alignment`. Each format string consists of an optional prefix character " +"which describes the overall properties of the data and one or more format " +"characters which describe the actual data values and padding." msgstr "" -#: ../../library/struct.rst:114 +#: ../../library/struct.rst:121 msgid "Byte Order, Size, and Alignment" msgstr "" -#: ../../library/struct.rst:116 +#: ../../library/struct.rst:123 msgid "" "By default, C types are represented in the machine's native format and byte " "order, and properly aligned by skipping pad bytes if necessary (according to " -"the rules used by the C compiler)." +"the rules used by the C compiler). This behavior is chosen so that the bytes " +"of a packed struct correspond exactly to the memory layout of the " +"corresponding C struct. Whether to use native byte ordering and padding or " +"standard formats depends on the application." msgstr "" -#: ../../library/struct.rst:127 +#: ../../library/struct.rst:139 msgid "" "Alternatively, the first character of the format string can be used to " "indicate the byte order, size and alignment of the packed data, according to " "the following table:" msgstr "" -#: ../../library/struct.rst:132 +#: ../../library/struct.rst:144 msgid "Character" msgstr "" -#: ../../library/struct.rst:132 +#: ../../library/struct.rst:144 msgid "Byte order" msgstr "" -#: ../../library/struct.rst:132 +#: ../../library/struct.rst:144 msgid "Size" msgstr "" -#: ../../library/struct.rst:132 +#: ../../library/struct.rst:144 msgid "Alignment" msgstr "" -#: ../../library/struct.rst:134 +#: ../../library/struct.rst:146 msgid "``@``" msgstr "``@``" -#: ../../library/struct.rst:134 ../../library/struct.rst:136 +#: ../../library/struct.rst:146 ../../library/struct.rst:148 msgid "native" msgstr "" -#: ../../library/struct.rst:136 +#: ../../library/struct.rst:148 msgid "``=``" msgstr "``=``" -#: ../../library/struct.rst:136 ../../library/struct.rst:138 -#: ../../library/struct.rst:140 ../../library/struct.rst:142 +#: ../../library/struct.rst:148 ../../library/struct.rst:150 +#: ../../library/struct.rst:152 ../../library/struct.rst:154 msgid "standard" msgstr "" -#: ../../library/struct.rst:136 ../../library/struct.rst:138 -#: ../../library/struct.rst:140 ../../library/struct.rst:142 +#: ../../library/struct.rst:148 ../../library/struct.rst:150 +#: ../../library/struct.rst:152 ../../library/struct.rst:154 msgid "none" msgstr "" -#: ../../library/struct.rst:138 +#: ../../library/struct.rst:150 msgid "``<``" msgstr "``<``" -#: ../../library/struct.rst:138 +#: ../../library/struct.rst:150 msgid "little-endian" msgstr "" -#: ../../library/struct.rst:140 +#: ../../library/struct.rst:152 msgid "``>``" msgstr "``>``" -#: ../../library/struct.rst:140 +#: ../../library/struct.rst:152 msgid "big-endian" msgstr "" -#: ../../library/struct.rst:142 +#: ../../library/struct.rst:154 msgid "``!``" msgstr "``!``" -#: ../../library/struct.rst:142 +#: ../../library/struct.rst:154 msgid "network (= big-endian)" msgstr "" -#: ../../library/struct.rst:145 +#: ../../library/struct.rst:157 msgid "If the first character is not one of these, ``'@'`` is assumed." msgstr "" -#: ../../library/struct.rst:147 +#: ../../library/struct.rst:159 msgid "" "Native byte order is big-endian or little-endian, depending on the host " -"system. For example, Intel x86 and AMD64 (x86-64) are little-endian; IBM z " -"and most legacy architectures are big-endian; and ARM, RISC-V and IBM Power " -"feature switchable endianness (bi-endian, though the former two are nearly " -"always little-endian in practice). Use ``sys.byteorder`` to check the " -"endianness of your system." +"system. For example, Intel x86, AMD64 (x86-64), and Apple M1 are little-" +"endian; IBM z and many legacy architectures are big-endian. Use :data:`sys." +"byteorder` to check the endianness of your system." msgstr "" -#: ../../library/struct.rst:154 +#: ../../library/struct.rst:164 msgid "" "Native size and alignment are determined using the C compiler's ``sizeof`` " "expression. This is always combined with native byte order." msgstr "" -#: ../../library/struct.rst:157 +#: ../../library/struct.rst:167 msgid "" "Standard size depends only on the format character; see the table in the :" "ref:`format-characters` section." msgstr "" -#: ../../library/struct.rst:160 +#: ../../library/struct.rst:170 msgid "" "Note the difference between ``'@'`` and ``'='``: both use native byte order, " "but the size and alignment of the latter is standardized." msgstr "" -#: ../../library/struct.rst:163 +#: ../../library/struct.rst:173 msgid "" "The form ``'!'`` represents the network byte order which is always big-" "endian as defined in `IETF RFC 1700 `_." msgstr "" -#: ../../library/struct.rst:166 +#: ../../library/struct.rst:176 msgid "" "There is no way to indicate non-native byte order (force byte-swapping); use " "the appropriate choice of ``'<'`` or ``'>'``." msgstr "" -#: ../../library/struct.rst:169 ../../library/struct.rst:248 +#: ../../library/struct.rst:179 ../../library/struct.rst:258 msgid "Notes:" msgstr "註解:" -#: ../../library/struct.rst:171 +#: ../../library/struct.rst:181 msgid "" "Padding is only automatically added between successive structure members. No " "padding is added at the beginning or the end of the encoded struct." msgstr "" -#: ../../library/struct.rst:174 +#: ../../library/struct.rst:184 msgid "" "No padding is added when using non-native size and alignment, e.g. with '<', " "'>', '=', and '!'." msgstr "" -#: ../../library/struct.rst:177 +#: ../../library/struct.rst:187 msgid "" "To align the end of a structure to the alignment requirement of a particular " "type, end the format with the code for that type with a repeat count of " "zero. See :ref:`struct-examples`." msgstr "" -#: ../../library/struct.rst:185 +#: ../../library/struct.rst:195 msgid "Format Characters" msgstr "" -#: ../../library/struct.rst:187 +#: ../../library/struct.rst:197 msgid "" "Format characters have the following meaning; the conversion between C and " "Python values should be obvious given their types. The 'Standard size' " @@ -295,302 +300,310 @@ msgid "" "platform-dependent." msgstr "" -#: ../../library/struct.rst:195 +#: ../../library/struct.rst:205 msgid "Format" msgstr "" -#: ../../library/struct.rst:195 +#: ../../library/struct.rst:205 msgid "C Type" msgstr "C Type" -#: ../../library/struct.rst:195 +#: ../../library/struct.rst:205 msgid "Python type" msgstr "" -#: ../../library/struct.rst:195 +#: ../../library/struct.rst:205 msgid "Standard size" msgstr "" -#: ../../library/struct.rst:195 +#: ../../library/struct.rst:205 msgid "Notes" msgstr "註解" -#: ../../library/struct.rst:197 +#: ../../library/struct.rst:207 msgid "``x``" msgstr "``x``" -#: ../../library/struct.rst:197 +#: ../../library/struct.rst:207 msgid "pad byte" msgstr "" -#: ../../library/struct.rst:197 +#: ../../library/struct.rst:207 msgid "no value" msgstr "" -#: ../../library/struct.rst:197 +#: ../../library/struct.rst:207 msgid "\\(7)" msgstr "" -#: ../../library/struct.rst:199 +#: ../../library/struct.rst:209 msgid "``c``" msgstr "``c``" -#: ../../library/struct.rst:199 +#: ../../library/struct.rst:209 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../library/struct.rst:199 +#: ../../library/struct.rst:209 msgid "bytes of length 1" msgstr "" -#: ../../library/struct.rst:199 ../../library/struct.rst:201 -#: ../../library/struct.rst:203 ../../library/struct.rst:205 +#: ../../library/struct.rst:209 ../../library/struct.rst:211 +#: ../../library/struct.rst:213 ../../library/struct.rst:215 msgid "1" msgstr "1" -#: ../../library/struct.rst:201 +#: ../../library/struct.rst:211 msgid "``b``" msgstr "``b``" -#: ../../library/struct.rst:201 +#: ../../library/struct.rst:211 msgid ":c:expr:`signed char`" msgstr ":c:expr:`signed char`" -#: ../../library/struct.rst:201 ../../library/struct.rst:203 -#: ../../library/struct.rst:207 ../../library/struct.rst:209 #: ../../library/struct.rst:211 ../../library/struct.rst:213 -#: ../../library/struct.rst:215 ../../library/struct.rst:217 -#: ../../library/struct.rst:219 ../../library/struct.rst:221 -#: ../../library/struct.rst:224 ../../library/struct.rst:226 -#: ../../library/struct.rst:238 +#: ../../library/struct.rst:217 ../../library/struct.rst:219 +#: ../../library/struct.rst:221 ../../library/struct.rst:223 +#: ../../library/struct.rst:225 ../../library/struct.rst:227 +#: ../../library/struct.rst:229 ../../library/struct.rst:231 +#: ../../library/struct.rst:234 ../../library/struct.rst:236 +#: ../../library/struct.rst:248 msgid "integer" msgstr "" -#: ../../library/struct.rst:201 +#: ../../library/struct.rst:211 msgid "\\(1), \\(2)" msgstr "\\(1), \\(2)" -#: ../../library/struct.rst:203 +#: ../../library/struct.rst:213 msgid "``B``" msgstr "``B``" -#: ../../library/struct.rst:203 +#: ../../library/struct.rst:213 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../library/struct.rst:203 ../../library/struct.rst:207 -#: ../../library/struct.rst:209 ../../library/struct.rst:211 -#: ../../library/struct.rst:213 ../../library/struct.rst:215 -#: ../../library/struct.rst:217 ../../library/struct.rst:219 -#: ../../library/struct.rst:221 +#: ../../library/struct.rst:213 ../../library/struct.rst:217 +#: ../../library/struct.rst:219 ../../library/struct.rst:221 +#: ../../library/struct.rst:223 ../../library/struct.rst:225 +#: ../../library/struct.rst:227 ../../library/struct.rst:229 +#: ../../library/struct.rst:231 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/struct.rst:205 +#: ../../library/struct.rst:215 msgid "``?``" msgstr "``?``" -#: ../../library/struct.rst:205 +#: ../../library/struct.rst:215 msgid ":c:expr:`_Bool`" msgstr ":c:expr:`_Bool`" -#: ../../library/struct.rst:205 +#: ../../library/struct.rst:215 msgid "bool" msgstr "bool" -#: ../../library/struct.rst:205 +#: ../../library/struct.rst:215 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/struct.rst:207 +#: ../../library/struct.rst:217 msgid "``h``" msgstr "``h``" -#: ../../library/struct.rst:207 +#: ../../library/struct.rst:217 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../library/struct.rst:207 ../../library/struct.rst:209 -#: ../../library/struct.rst:228 +#: ../../library/struct.rst:217 ../../library/struct.rst:219 +#: ../../library/struct.rst:238 msgid "2" msgstr "2" -#: ../../library/struct.rst:209 +#: ../../library/struct.rst:219 msgid "``H``" msgstr "``H``" -#: ../../library/struct.rst:209 +#: ../../library/struct.rst:219 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../library/struct.rst:211 +#: ../../library/struct.rst:221 msgid "``i``" msgstr "``i``" -#: ../../library/struct.rst:211 +#: ../../library/struct.rst:221 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../library/struct.rst:211 ../../library/struct.rst:213 -#: ../../library/struct.rst:215 ../../library/struct.rst:217 -#: ../../library/struct.rst:230 +#: ../../library/struct.rst:221 ../../library/struct.rst:223 +#: ../../library/struct.rst:225 ../../library/struct.rst:227 +#: ../../library/struct.rst:240 msgid "4" msgstr "4" -#: ../../library/struct.rst:213 +#: ../../library/struct.rst:223 msgid "``I``" msgstr "``I``" -#: ../../library/struct.rst:213 +#: ../../library/struct.rst:223 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../library/struct.rst:215 +#: ../../library/struct.rst:225 msgid "``l``" msgstr "``l``" -#: ../../library/struct.rst:215 +#: ../../library/struct.rst:225 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../library/struct.rst:217 +#: ../../library/struct.rst:227 msgid "``L``" msgstr "``L``" -#: ../../library/struct.rst:217 +#: ../../library/struct.rst:227 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../library/struct.rst:219 +#: ../../library/struct.rst:229 msgid "``q``" msgstr "``q``" -#: ../../library/struct.rst:219 +#: ../../library/struct.rst:229 msgid ":c:expr:`long long`" msgstr ":c:expr:`long long`" -#: ../../library/struct.rst:219 ../../library/struct.rst:221 -#: ../../library/struct.rst:232 +#: ../../library/struct.rst:229 ../../library/struct.rst:231 +#: ../../library/struct.rst:242 msgid "8" msgstr "8" -#: ../../library/struct.rst:221 +#: ../../library/struct.rst:231 msgid "``Q``" msgstr "``Q``" -#: ../../library/struct.rst:221 +#: ../../library/struct.rst:231 msgid ":c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned long long`" -#: ../../library/struct.rst:224 +#: ../../library/struct.rst:234 msgid "``n``" msgstr "``n``" -#: ../../library/struct.rst:224 +#: ../../library/struct.rst:234 msgid ":c:expr:`ssize_t`" msgstr ":c:expr:`ssize_t`" -#: ../../library/struct.rst:224 ../../library/struct.rst:226 +#: ../../library/struct.rst:234 ../../library/struct.rst:236 msgid "\\(3)" msgstr "\\(3)" -#: ../../library/struct.rst:226 +#: ../../library/struct.rst:236 msgid "``N``" msgstr "``N``" -#: ../../library/struct.rst:226 +#: ../../library/struct.rst:236 msgid ":c:expr:`size_t`" msgstr ":c:expr:`size_t`" -#: ../../library/struct.rst:228 +#: ../../library/struct.rst:238 msgid "``e``" msgstr "``e``" -#: ../../library/struct.rst:228 +#: ../../library/struct.rst:238 msgid "\\(6)" msgstr "\\(6)" -#: ../../library/struct.rst:228 ../../library/struct.rst:230 -#: ../../library/struct.rst:232 +#: ../../library/struct.rst:238 ../../library/struct.rst:240 +#: ../../library/struct.rst:242 msgid "float" msgstr "float" -#: ../../library/struct.rst:228 ../../library/struct.rst:230 -#: ../../library/struct.rst:232 +#: ../../library/struct.rst:238 ../../library/struct.rst:240 +#: ../../library/struct.rst:242 msgid "\\(4)" msgstr "\\(4)" -#: ../../library/struct.rst:230 +#: ../../library/struct.rst:240 msgid "``f``" msgstr "``f``" -#: ../../library/struct.rst:230 +#: ../../library/struct.rst:240 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../library/struct.rst:232 +#: ../../library/struct.rst:242 msgid "``d``" msgstr "``d``" -#: ../../library/struct.rst:232 +#: ../../library/struct.rst:242 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../library/struct.rst:234 +#: ../../library/struct.rst:244 msgid "``s``" msgstr "``s``" -#: ../../library/struct.rst:234 ../../library/struct.rst:236 +#: ../../library/struct.rst:244 ../../library/struct.rst:246 msgid ":c:expr:`char[]`" msgstr ":c:expr:`char[]`" -#: ../../library/struct.rst:234 ../../library/struct.rst:236 +#: ../../library/struct.rst:244 ../../library/struct.rst:246 msgid "bytes" msgstr "" -#: ../../library/struct.rst:236 +#: ../../library/struct.rst:244 +msgid "\\(9)" +msgstr "" + +#: ../../library/struct.rst:246 msgid "``p``" msgstr "``p``" -#: ../../library/struct.rst:238 +#: ../../library/struct.rst:246 +msgid "\\(8)" +msgstr "" + +#: ../../library/struct.rst:248 msgid "``P``" msgstr "``P``" -#: ../../library/struct.rst:238 +#: ../../library/struct.rst:248 msgid ":c:expr:`void \\*`" msgstr ":c:expr:`void \\*`" -#: ../../library/struct.rst:238 +#: ../../library/struct.rst:248 msgid "\\(5)" msgstr "\\(5)" -#: ../../library/struct.rst:241 +#: ../../library/struct.rst:251 msgid "Added support for the ``'n'`` and ``'N'`` formats." msgstr "新增 ``'n'`` 與 ``'N'`` 格式的支援。" -#: ../../library/struct.rst:244 +#: ../../library/struct.rst:254 msgid "Added support for the ``'e'`` format." msgstr "新增 ``'e'`` 格式的支援。" -#: ../../library/struct.rst:253 +#: ../../library/struct.rst:263 msgid "" "The ``'?'`` conversion code corresponds to the :c:expr:`_Bool` type defined " "by C99. If this type is not available, it is simulated using a :c:expr:" "`char`. In standard mode, it is always represented by one byte." msgstr "" -#: ../../library/struct.rst:258 +#: ../../library/struct.rst:268 msgid "" "When attempting to pack a non-integer using any of the integer conversion " "codes, if the non-integer has a :meth:`__index__` method then that method is " "called to convert the argument to an integer before packing." msgstr "" -#: ../../library/struct.rst:262 +#: ../../library/struct.rst:272 msgid "Added use of the :meth:`__index__` method for non-integers." msgstr "" -#: ../../library/struct.rst:266 +#: ../../library/struct.rst:276 msgid "" "The ``'n'`` and ``'N'`` conversion codes are only available for the native " "size (selected as the default or with the ``'@'`` byte order character). For " @@ -598,7 +611,7 @@ msgid "" "your application." msgstr "" -#: ../../library/struct.rst:272 +#: ../../library/struct.rst:282 msgid "" "For the ``'f'``, ``'d'`` and ``'e'`` conversion codes, the packed " "representation uses the IEEE 754 binary32, binary64 or binary16 format (for " @@ -606,7 +619,7 @@ msgid "" "format used by the platform." msgstr "" -#: ../../library/struct.rst:278 +#: ../../library/struct.rst:288 msgid "" "The ``'P'`` format character is only available for the native byte ordering " "(selected as the default or with the ``'@'`` byte order character). The byte " @@ -615,7 +628,7 @@ msgid "" "ordering, so the ``'P'`` format is not available." msgstr "" -#: ../../library/struct.rst:285 +#: ../../library/struct.rst:295 msgid "" "The IEEE 754 binary16 \"half precision\" type was introduced in the 2008 " "revision of the `IEEE 754 standard `_. It has a sign " @@ -627,35 +640,52 @@ msgid "" "format `_ for more information." msgstr "" -#: ../../library/struct.rst:295 -msgid "For padding, ``x`` inserts null bytes." -msgstr "" - -#: ../../library/struct.rst:298 -msgid "" -"A format character may be preceded by an integral repeat count. For " -"example, the format string ``'4h'`` means exactly the same as ``'hhhh'``." +#: ../../library/struct.rst:305 +msgid "When packing, ``'x'`` inserts one NUL byte." msgstr "" -#: ../../library/struct.rst:301 +#: ../../library/struct.rst:308 msgid "" -"Whitespace characters between formats are ignored; a count and its format " -"must not contain whitespace though." +"The ``'p'`` format character encodes a \"Pascal string\", meaning a short " +"variable-length string stored in a *fixed number of bytes*, given by the " +"count. The first byte stored is the length of the string, or 255, whichever " +"is smaller. The bytes of the string follow. If the string passed in to :" +"func:`pack` is too long (longer than the count minus 1), only the leading " +"``count-1`` bytes of the string are stored. If the string is shorter than " +"``count-1``, it is padded with null bytes so that exactly count bytes in all " +"are used. Note that for :func:`unpack`, the ``'p'`` format character " +"consumes ``count`` bytes, but that the string returned can never contain " +"more than 255 bytes." msgstr "" -#: ../../library/struct.rst:304 +#: ../../library/struct.rst:320 msgid "" "For the ``'s'`` format character, the count is interpreted as the length of " "the bytes, not a repeat count like for the other format characters; for " -"example, ``'10s'`` means a single 10-byte string, while ``'10c'`` means 10 " -"characters. If a count is not given, it defaults to 1. For packing, the " +"example, ``'10s'`` means a single 10-byte string mapping to or from a single " +"Python byte string, while ``'10c'`` means 10 separate one byte character " +"elements (e.g., ``cccccccccc``) mapping to or from ten different Python byte " +"objects. (See :ref:`struct-examples` for a concrete demonstration of the " +"difference.) If a count is not given, it defaults to 1. For packing, the " "string is truncated or padded with null bytes as appropriate to make it fit. " "For unpacking, the resulting bytes object always has exactly the specified " "number of bytes. As a special case, ``'0s'`` means a single, empty string " "(while ``'0c'`` means 0 characters)." msgstr "" -#: ../../library/struct.rst:313 +#: ../../library/struct.rst:333 +msgid "" +"A format character may be preceded by an integral repeat count. For " +"example, the format string ``'4h'`` means exactly the same as ``'hhhh'``." +msgstr "" + +#: ../../library/struct.rst:336 +msgid "" +"Whitespace characters between formats are ignored; a count and its format " +"must not contain whitespace though." +msgstr "" + +#: ../../library/struct.rst:339 msgid "" "When packing a value ``x`` using one of the integer formats (``'b'``, " "``'B'``, ``'h'``, ``'H'``, ``'i'``, ``'I'``, ``'l'``, ``'L'``, ``'q'``, " @@ -663,27 +693,13 @@ msgid "" "`struct.error` is raised." msgstr "" -#: ../../library/struct.rst:318 +#: ../../library/struct.rst:344 msgid "" "Previously, some of the integer formats wrapped out-of-range values and " "raised :exc:`DeprecationWarning` instead of :exc:`struct.error`." msgstr "" -#: ../../library/struct.rst:322 -msgid "" -"The ``'p'`` format character encodes a \"Pascal string\", meaning a short " -"variable-length string stored in a *fixed number of bytes*, given by the " -"count. The first byte stored is the length of the string, or 255, whichever " -"is smaller. The bytes of the string follow. If the string passed in to :" -"func:`pack` is too long (longer than the count minus 1), only the leading " -"``count-1`` bytes of the string are stored. If the string is shorter than " -"``count-1``, it is padded with null bytes so that exactly count bytes in all " -"are used. Note that for :func:`unpack`, the ``'p'`` format character " -"consumes ``count`` bytes, but that the string returned can never contain " -"more than 255 bytes." -msgstr "" - -#: ../../library/struct.rst:335 +#: ../../library/struct.rst:350 msgid "" "For the ``'?'`` format character, the return value is either :const:`True` " "or :const:`False`. When packing, the truth value of the argument object is " @@ -691,77 +707,173 @@ msgid "" "packed, and any non-zero value will be ``True`` when unpacking." msgstr "" -#: ../../library/struct.rst:345 +#: ../../library/struct.rst:360 msgid "Examples" msgstr "範例" -#: ../../library/struct.rst:348 +#: ../../library/struct.rst:363 +msgid "" +"Native byte order examples (designated by the ``'@'`` format prefix or lack " +"of any prefix character) may not match what the reader's machine produces as " +"that depends on the platform and compiler." +msgstr "" + +#: ../../library/struct.rst:368 msgid "" -"All examples assume a native byte order, size, and alignment with a big-" -"endian machine." +"Pack and unpack integers of three different sizes, using big endian " +"ordering::" msgstr "" -#: ../../library/struct.rst:351 -msgid "A basic example of packing/unpacking three integers::" +#: ../../library/struct.rst:379 +msgid "Attempt to pack an integer which is too large for the defined field::" msgstr "" -#: ../../library/struct.rst:361 +#: ../../library/struct.rst:386 msgid "" -"Unpacked fields can be named by assigning them to variables or by wrapping " -"the result in a named tuple::" +"Demonstrate the difference between ``'s'`` and ``'c'`` format characters::" msgstr "" -#: ../../library/struct.rst:372 +#: ../../library/struct.rst:394 msgid "" -"The ordering of format characters may have an impact on size since the " -"padding needed to satisfy alignment requirements is different::" +"Unpacked fields can be named by assigning them to variables or by wrapping " +"the result in a named tuple::" msgstr "" -#: ../../library/struct.rst:384 +#: ../../library/struct.rst:405 msgid "" -"The following format ``'llh0l'`` specifies two pad bytes at the end, " -"assuming longs are aligned on 4-byte boundaries::" +"The ordering of format characters may have an impact on size in native mode " +"since padding is implicit. In standard mode, the user is responsible for " +"inserting any desired padding. Note in the first ``pack`` call below that " +"three NUL bytes were added after the packed ``'#'`` to align the following " +"integer on a four-byte boundary. In this example, the output was produced on " +"a little endian machine::" msgstr "" -#: ../../library/struct.rst:390 +#: ../../library/struct.rst:422 msgid "" -"This only works when native size and alignment are in effect; standard size " -"and alignment does not enforce any alignment." +"The following format ``'llh0l'`` results in two pad bytes being added at the " +"end, assuming the platform's longs are aligned on 4-byte boundaries::" msgstr "" -#: ../../library/struct.rst:397 +#: ../../library/struct.rst:432 msgid "Module :mod:`array`" msgstr ":mod:`array` 模組" -#: ../../library/struct.rst:397 +#: ../../library/struct.rst:432 msgid "Packed binary storage of homogeneous data." msgstr "" -#: ../../library/struct.rst:399 -msgid "Module :mod:`xdrlib`" -msgstr ":mod:`xdrlib` 模組" +#: ../../library/struct.rst:435 +msgid "Module :mod:`json`" +msgstr ":mod:`json` 模組" + +#: ../../library/struct.rst:435 +msgid "JSON encoder and decoder." +msgstr "" + +#: ../../library/struct.rst:437 +msgid "Module :mod:`pickle`" +msgstr ":mod:`pickle` 模組" + +#: ../../library/struct.rst:438 +msgid "Python object serialization." +msgstr "" + +#: ../../library/struct.rst:444 +msgid "Applications" +msgstr "" + +#: ../../library/struct.rst:446 +msgid "" +"Two main applications for the :mod:`struct` module exist, data interchange " +"between Python and C code within an application or another application " +"compiled using the same compiler (:ref:`native formats`), and data interchange between applications using agreed upon data " +"layout (:ref:`standard formats`). Generally " +"speaking, the format strings constructed for these two domains are distinct." +msgstr "" + +#: ../../library/struct.rst:457 +msgid "Native Formats" +msgstr "" + +#: ../../library/struct.rst:459 +msgid "" +"When constructing format strings which mimic native layouts, the compiler " +"and machine architecture determine byte ordering and padding. In such cases, " +"the ``@`` format character should be used to specify native byte ordering " +"and data sizes. Internal pad bytes are normally inserted automatically. It " +"is possible that a zero-repeat format code will be needed at the end of a " +"format string to round up to the correct byte boundary for proper alignment " +"of consective chunks of data." +msgstr "" + +#: ../../library/struct.rst:467 +msgid "" +"Consider these two simple examples (on a 64-bit, little-endian machine)::" +msgstr "" + +#: ../../library/struct.rst:475 +msgid "" +"Data is not padded to an 8-byte boundary at the end of the second format " +"string without the use of extra padding. A zero-repeat format code solves " +"that problem::" +msgstr "" + +#: ../../library/struct.rst:482 +msgid "" +"The ``'x'`` format code can be used to specify the repeat, but for native " +"formats it is better to use a zero-repeat format like ``'0l'``." +msgstr "" -#: ../../library/struct.rst:400 -msgid "Packing and unpacking of XDR data." +#: ../../library/struct.rst:485 +msgid "" +"By default, native byte ordering and alignment is used, but it is better to " +"be explicit and use the ``'@'`` prefix character." +msgstr "" + +#: ../../library/struct.rst:492 +msgid "Standard Formats" +msgstr "" + +#: ../../library/struct.rst:494 +msgid "" +"When exchanging data beyond your process such as networking or storage, be " +"precise. Specify the exact byte order, size, and alignment. Do not assume " +"they match the native order of a particular machine. For example, network " +"byte order is big-endian, while many popular CPUs are little-endian. By " +"defining this explicitly, the user need not care about the specifics of the " +"platform their code is running on. The first character should typically be " +"``<`` or ``>`` (or ``!``). Padding is the responsibility of the " +"programmer. The zero-repeat format character won't work. Instead, the user " +"must explicitly add ``'x'`` pad bytes where needed. Revisiting the examples " +"from the previous section, we have::" msgstr "" -#: ../../library/struct.rst:406 +#: ../../library/struct.rst:521 +msgid "" +"The above results (executed on a 64-bit machine) aren't guaranteed to match " +"when executed on different machines. For example, the examples below were " +"executed on a 32-bit machine::" +msgstr "" + +#: ../../library/struct.rst:536 msgid "Classes" msgstr "" -#: ../../library/struct.rst:408 +#: ../../library/struct.rst:538 msgid "The :mod:`struct` module also defines the following type:" msgstr "" -#: ../../library/struct.rst:413 +#: ../../library/struct.rst:543 msgid "" "Return a new Struct object which writes and reads binary data according to " -"the format string *format*. Creating a Struct object once and calling its " -"methods is more efficient than calling the :mod:`struct` functions with the " -"same format since the format string only needs to be compiled once." +"the format string *format*. Creating a ``Struct`` object once and calling " +"its methods is more efficient than calling module-level functions with the " +"same format since the format string is only compiled once." msgstr "" -#: ../../library/struct.rst:420 +#: ../../library/struct.rst:550 msgid "" "The compiled versions of the most recent format strings passed to :class:" "`Struct` and the module-level functions are cached, so programs that use " @@ -769,48 +881,48 @@ msgid "" "`Struct` instance." msgstr "" -#: ../../library/struct.rst:425 +#: ../../library/struct.rst:555 msgid "Compiled Struct objects support the following methods and attributes:" msgstr "" -#: ../../library/struct.rst:429 +#: ../../library/struct.rst:559 msgid "" "Identical to the :func:`pack` function, using the compiled format. " "(``len(result)`` will equal :attr:`size`.)" msgstr "" -#: ../../library/struct.rst:435 +#: ../../library/struct.rst:565 msgid "Identical to the :func:`pack_into` function, using the compiled format." msgstr "" -#: ../../library/struct.rst:440 +#: ../../library/struct.rst:570 msgid "" "Identical to the :func:`unpack` function, using the compiled format. The " "buffer's size in bytes must equal :attr:`size`." msgstr "" -#: ../../library/struct.rst:446 +#: ../../library/struct.rst:576 msgid "" "Identical to the :func:`unpack_from` function, using the compiled format. " "The buffer's size in bytes, starting at position *offset*, must be at least :" "attr:`size`." msgstr "" -#: ../../library/struct.rst:453 +#: ../../library/struct.rst:583 msgid "" "Identical to the :func:`iter_unpack` function, using the compiled format. " "The buffer's size in bytes must be a multiple of :attr:`size`." msgstr "" -#: ../../library/struct.rst:460 +#: ../../library/struct.rst:590 msgid "The format string used to construct this Struct object." msgstr "" -#: ../../library/struct.rst:462 +#: ../../library/struct.rst:592 msgid "The format string type is now :class:`str` instead of :class:`bytes`." msgstr "" -#: ../../library/struct.rst:467 +#: ../../library/struct.rst:597 msgid "" "The calculated size of the struct (and hence of the bytes object produced by " "the :meth:`pack` method) corresponding to :attr:`format`." diff --git a/library/typing.po b/library/typing.po index cc5a107d63..3012ab56ec 100644 --- a/library/typing.po +++ b/library/typing.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-11-04 00:20+0000\n" +"POT-Creation-Date: 2022-11-23 00:17+0000\n" "PO-Revision-Date: 2018-05-23 16:14+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1311,7 +1311,7 @@ msgstr "" #: ../../library/typing.rst:1341 msgid "" "Type variable tuples must *always* be unpacked. This helps distinguish type " -"variable types from normal type variables::" +"variable tuples from normal type variables::" msgstr "" #: ../../library/typing.rst:1348 @@ -2807,4 +2807,3 @@ msgstr "3.11" #: ../../library/typing.rst:2871 msgid ":gh:`92332`" msgstr ":gh:`92332`" -