diff --git a/c-api/arg.po b/c-api/arg.po index d97d4f7c..1cf2cec6 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-05-27 19:40+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: 2018-02-15 00:29+0100\n" "Last-Translator: Julien Palard \n" "Language-Team: \n" @@ -295,7 +295,7 @@ msgid "" "`PyObject\\*`." msgstr "" -#: ../Doc/c-api/arg.rst:152 ../Doc/c-api/arg.rst:557 +#: ../Doc/c-api/arg.rst:156 msgid "``u`` (:class:`str`) [Py_UNICODE \\*]" msgstr "``u`` (:class:`str`) [Py_UNICODE \\*]" @@ -310,22 +310,29 @@ msgid "" "`ValueError` exception is raised." msgstr "" -#: ../Doc/c-api/arg.rst:157 ../Doc/c-api/arg.rst:562 +#: ../Doc/c-api/arg.rst:157 ../Doc/c-api/arg.rst:166 ../Doc/c-api/arg.rst:174 +#: ../Doc/c-api/arg.rst:182 +msgid "" +"Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using :c:" +"func:`PyUnicode_AsWideCharString`." +msgstr "" + +#: ../Doc/c-api/arg.rst:165 msgid "``u#`` (:class:`str`) [Py_UNICODE \\*, int]" msgstr "``u#`` (:class:`str`) [Py_UNICODE \\*, int]" -#: ../Doc/c-api/arg.rst:155 +#: ../Doc/c-api/arg.rst:159 msgid "" "This variant on ``u`` stores into two C variables, the first one a pointer " "to a Unicode data buffer, the second one its length. This variant allows " "null code points." msgstr "" -#: ../Doc/c-api/arg.rst:161 +#: ../Doc/c-api/arg.rst:173 msgid "``Z`` (:class:`str` or ``None``) [Py_UNICODE \\*]" msgstr "``Z`` (:class:`str` ou ``None``) [Py_UNICODE \\*]" -#: ../Doc/c-api/arg.rst:160 +#: ../Doc/c-api/arg.rst:168 msgid "" "Like ``u``, but the Python object may also be ``None``, in which case the :c:" "type:`Py_UNICODE` pointer is set to *NULL*." @@ -333,11 +340,11 @@ msgstr "" "Comme ``u``, mais l'objet Python peut aussi être ``None``, auquel cas le " "pointeur :c:type:`Py_UNICODE` vaut *NULL*." -#: ../Doc/c-api/arg.rst:165 +#: ../Doc/c-api/arg.rst:181 msgid "``Z#`` (:class:`str` or ``None``) [Py_UNICODE \\*, int]" msgstr "``Z#`` (:class:`str` ou ``None``) [Py_UNICODE \\*, int]" -#: ../Doc/c-api/arg.rst:164 +#: ../Doc/c-api/arg.rst:176 msgid "" "Like ``u#``, but the Python object may also be ``None``, in which case the :" "c:type:`Py_UNICODE` pointer is set to *NULL*." @@ -345,22 +352,22 @@ msgstr "" "Comme ``u#``, mais l'objet Python peut également être ``None``, auquel cas " "le pointeur :c:type:`Py_UNICODE` vaut *NULL*." -#: ../Doc/c-api/arg.rst:170 +#: ../Doc/c-api/arg.rst:186 msgid "``U`` (:class:`str`) [PyObject \\*]" msgstr "``U`` (:class:`str`) [PyObject \\*]" -#: ../Doc/c-api/arg.rst:168 +#: ../Doc/c-api/arg.rst:184 msgid "" "Requires that the Python object is a Unicode object, without attempting any " "conversion. Raises :exc:`TypeError` if the object is not a Unicode object. " "The C variable may also be declared as :c:type:`PyObject\\*`." msgstr "" -#: ../Doc/c-api/arg.rst:176 +#: ../Doc/c-api/arg.rst:192 msgid "``w*`` (read-write :term:`bytes-like object`) [Py_buffer]" msgstr "``w*`` (read-write :term:`bytes-like object`) [Py_buffer]" -#: ../Doc/c-api/arg.rst:173 +#: ../Doc/c-api/arg.rst:189 msgid "" "This format accepts any object which implements the read-write buffer " "interface. It fills a :c:type:`Py_buffer` structure provided by the caller. " @@ -368,17 +375,17 @@ msgid "" "`PyBuffer_Release` when it is done with the buffer." msgstr "" -#: ../Doc/c-api/arg.rst:193 +#: ../Doc/c-api/arg.rst:209 msgid "``es`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer]" msgstr "" -#: ../Doc/c-api/arg.rst:179 +#: ../Doc/c-api/arg.rst:195 msgid "" "This variant on ``s`` is used for encoding Unicode into a character buffer. " "It only works for encoded data without embedded NUL bytes." msgstr "" -#: ../Doc/c-api/arg.rst:182 +#: ../Doc/c-api/arg.rst:198 msgid "" "This format requires two arguments. The first is only used as input, and " "must be a :c:type:`const char\\*` which points to the name of an encoding as " @@ -390,7 +397,7 @@ msgid "" "argument." msgstr "" -#: ../Doc/c-api/arg.rst:190 +#: ../Doc/c-api/arg.rst:206 msgid "" ":c:func:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy " "the encoded data into this buffer and adjust *\\*buffer* to reference the " @@ -398,33 +405,33 @@ msgid "" "`PyMem_Free` to free the allocated buffer after use." msgstr "" -#: ../Doc/c-api/arg.rst:198 +#: ../Doc/c-api/arg.rst:214 msgid "" "``et`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char " "\\*encoding, char \\*\\*buffer]" msgstr "" -#: ../Doc/c-api/arg.rst:196 +#: ../Doc/c-api/arg.rst:212 msgid "" "Same as ``es`` except that byte string objects are passed through without " "recoding them. Instead, the implementation assumes that the byte string " "object uses the encoding passed in as parameter." msgstr "" -#: ../Doc/c-api/arg.rst:229 +#: ../Doc/c-api/arg.rst:245 msgid "" "``es#`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer, int " "\\*buffer_length]" msgstr "" -#: ../Doc/c-api/arg.rst:201 +#: ../Doc/c-api/arg.rst:217 msgid "" "This variant on ``s#`` is used for encoding Unicode into a character buffer. " "Unlike the ``es`` format, this variant allows input data which contains NUL " "characters." msgstr "" -#: ../Doc/c-api/arg.rst:205 +#: ../Doc/c-api/arg.rst:221 msgid "" "It requires three arguments. The first is only used as input, and must be " "a :c:type:`const char\\*` which points to the name of an encoding as a NUL-" @@ -437,11 +444,11 @@ msgid "" "will be set to the number of bytes in the output buffer." msgstr "" -#: ../Doc/c-api/arg.rst:215 +#: ../Doc/c-api/arg.rst:231 msgid "There are two modes of operation:" msgstr "Il existe deux modes de fonctionnement :" -#: ../Doc/c-api/arg.rst:217 +#: ../Doc/c-api/arg.rst:233 msgid "" "If *\\*buffer* points a *NULL* pointer, the function will allocate a buffer " "of the needed size, copy the encoded data into this buffer and set *" @@ -450,7 +457,7 @@ msgid "" "after usage." msgstr "" -#: ../Doc/c-api/arg.rst:222 +#: ../Doc/c-api/arg.rst:238 msgid "" "If *\\*buffer* points to a non-*NULL* pointer (an already allocated " "buffer), :c:func:`PyArg_ParseTuple` will use this location as the buffer and " @@ -459,7 +466,7 @@ msgid "" "the buffer is not large enough, a :exc:`ValueError` will be set." msgstr "" -#: ../Doc/c-api/arg.rst:228 +#: ../Doc/c-api/arg.rst:244 msgid "" "In both cases, *\\*buffer_length* is set to the length of the encoded data " "without the trailing NUL byte." @@ -467,28 +474,28 @@ msgstr "" "Dans les deux cas, *\\*buffer_length* est la longueur des données encodées, " "sans l'octet NUL de fin." -#: ../Doc/c-api/arg.rst:234 +#: ../Doc/c-api/arg.rst:250 msgid "" "``et#`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char " "\\*encoding, char \\*\\*buffer, int \\*buffer_length]" msgstr "" -#: ../Doc/c-api/arg.rst:232 +#: ../Doc/c-api/arg.rst:248 msgid "" "Same as ``es#`` except that byte string objects are passed through without " "recoding them. Instead, the implementation assumes that the byte string " "object uses the encoding passed in as parameter." msgstr "" -#: ../Doc/c-api/arg.rst:237 +#: ../Doc/c-api/arg.rst:253 msgid "Numbers" msgstr "Les nombres" -#: ../Doc/c-api/arg.rst:241 +#: ../Doc/c-api/arg.rst:257 msgid "``b`` (:class:`int`) [unsigned char]" msgstr "``b`` (:class:`int`) [unsigned char]" -#: ../Doc/c-api/arg.rst:240 +#: ../Doc/c-api/arg.rst:256 msgid "" "Convert a nonnegative Python integer to an unsigned tiny int, stored in a C :" "c:type:`unsigned char`." @@ -496,11 +503,11 @@ msgstr "" "Convertit un entier Python positif ou nul en un unsigned tiny int, stocké " "dans un :c:type:`unsigned char` C." -#: ../Doc/c-api/arg.rst:245 ../Doc/c-api/arg.rst:583 +#: ../Doc/c-api/arg.rst:261 ../Doc/c-api/arg.rst:600 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "``B`` (:class:`int`) [unsigned char]" -#: ../Doc/c-api/arg.rst:244 +#: ../Doc/c-api/arg.rst:260 msgid "" "Convert a Python integer to a tiny int without overflow checking, stored in " "a C :c:type:`unsigned char`." @@ -508,19 +515,19 @@ msgstr "" "Convertit un entier Python en un tiny int sans vérifier le débordement, " "stocké dans un :c:type:`unsigned char` C." -#: ../Doc/c-api/arg.rst:248 ../Doc/c-api/arg.rst:577 +#: ../Doc/c-api/arg.rst:264 ../Doc/c-api/arg.rst:594 msgid "``h`` (:class:`int`) [short int]" msgstr "``h`` (:class:`int`) [short int]" -#: ../Doc/c-api/arg.rst:248 +#: ../Doc/c-api/arg.rst:264 msgid "Convert a Python integer to a C :c:type:`short int`." msgstr "Convertit un entier Python en un :c:type:`short int` C." -#: ../Doc/c-api/arg.rst:252 ../Doc/c-api/arg.rst:586 +#: ../Doc/c-api/arg.rst:268 ../Doc/c-api/arg.rst:603 msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "``H`` (:class:`int`) [unsigned short int]" -#: ../Doc/c-api/arg.rst:251 +#: ../Doc/c-api/arg.rst:267 msgid "" "Convert a Python integer to a C :c:type:`unsigned short int`, without " "overflow checking." @@ -528,19 +535,19 @@ msgstr "" "Convertit un entier Python en un :c:type:`unsigned short int` C, sans " "contrôle de débordement." -#: ../Doc/c-api/arg.rst:255 ../Doc/c-api/arg.rst:571 +#: ../Doc/c-api/arg.rst:271 ../Doc/c-api/arg.rst:588 msgid "``i`` (:class:`int`) [int]" msgstr "``i`` (:class:`int`) [int]" -#: ../Doc/c-api/arg.rst:255 +#: ../Doc/c-api/arg.rst:271 msgid "Convert a Python integer to a plain C :c:type:`int`." msgstr "Convertit un entier Python en un :c:type:`int` C." -#: ../Doc/c-api/arg.rst:259 ../Doc/c-api/arg.rst:589 +#: ../Doc/c-api/arg.rst:275 ../Doc/c-api/arg.rst:606 msgid "``I`` (:class:`int`) [unsigned int]" msgstr "``I`` (:class:`int`) [unsigned int]" -#: ../Doc/c-api/arg.rst:258 +#: ../Doc/c-api/arg.rst:274 msgid "" "Convert a Python integer to a C :c:type:`unsigned int`, without overflow " "checking." @@ -548,19 +555,19 @@ msgstr "" "Convertit un entier Python en un :c:type:`unsigned int` C, sans contrôle de " "le débordement." -#: ../Doc/c-api/arg.rst:262 ../Doc/c-api/arg.rst:580 +#: ../Doc/c-api/arg.rst:278 ../Doc/c-api/arg.rst:597 msgid "``l`` (:class:`int`) [long int]" msgstr "``l`` (:class:`int`) [long int]" -#: ../Doc/c-api/arg.rst:262 +#: ../Doc/c-api/arg.rst:278 msgid "Convert a Python integer to a C :c:type:`long int`." msgstr "Convertit un entier Python en un :c:type:`long int`." -#: ../Doc/c-api/arg.rst:266 ../Doc/c-api/arg.rst:592 +#: ../Doc/c-api/arg.rst:282 ../Doc/c-api/arg.rst:609 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "``k`` (:class:`int`) [unsigned long]" -#: ../Doc/c-api/arg.rst:265 +#: ../Doc/c-api/arg.rst:281 msgid "" "Convert a Python integer to a C :c:type:`unsigned long` without overflow " "checking." @@ -568,37 +575,37 @@ msgstr "" "Convertit un entier Python en un :c:type:`unsigned long` C sans en vérifier " "le débordement." -#: ../Doc/c-api/arg.rst:269 ../Doc/c-api/arg.rst:595 +#: ../Doc/c-api/arg.rst:285 ../Doc/c-api/arg.rst:612 msgid "``L`` (:class:`int`) [long long]" msgstr "``L`` (:class:`int`) [long long]" -#: ../Doc/c-api/arg.rst:269 +#: ../Doc/c-api/arg.rst:285 msgid "Convert a Python integer to a C :c:type:`long long`." msgstr "" -#: ../Doc/c-api/arg.rst:273 ../Doc/c-api/arg.rst:598 +#: ../Doc/c-api/arg.rst:289 ../Doc/c-api/arg.rst:615 msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "``K`` (:class:`int`) [unsigned long long]" -#: ../Doc/c-api/arg.rst:272 +#: ../Doc/c-api/arg.rst:288 msgid "" "Convert a Python integer to a C :c:type:`unsigned long long` without " "overflow checking." msgstr "" -#: ../Doc/c-api/arg.rst:276 ../Doc/c-api/arg.rst:601 +#: ../Doc/c-api/arg.rst:292 ../Doc/c-api/arg.rst:618 msgid "``n`` (:class:`int`) [Py_ssize_t]" msgstr "``n`` (:class:`int`) [Py_ssize_t]" -#: ../Doc/c-api/arg.rst:276 +#: ../Doc/c-api/arg.rst:292 msgid "Convert a Python integer to a C :c:type:`Py_ssize_t`." msgstr "Convertit un entier Python en un :c:type:`short int` C." -#: ../Doc/c-api/arg.rst:283 +#: ../Doc/c-api/arg.rst:299 msgid "``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]" msgstr "``c`` (:class:`bytes` ou :class:`bytearray` of length 1) [char]" -#: ../Doc/c-api/arg.rst:279 +#: ../Doc/c-api/arg.rst:295 msgid "" "Convert a Python byte, represented as a :class:`bytes` or :class:`bytearray` " "object of length 1, to a C :c:type:`char`." @@ -606,15 +613,15 @@ msgstr "" "Convertit un octet Python, représenté comme un objet :class:`bytes` ou :" "class:`bytearray` de longueur 1, en un :c:type:`char` C." -#: ../Doc/c-api/arg.rst:282 +#: ../Doc/c-api/arg.rst:298 msgid "Allow :class:`bytearray` objects." msgstr "" -#: ../Doc/c-api/arg.rst:287 ../Doc/c-api/arg.rst:609 +#: ../Doc/c-api/arg.rst:303 ../Doc/c-api/arg.rst:626 msgid "``C`` (:class:`str` of length 1) [int]" msgstr "``C`` (:class:`str` of length 1) [int]" -#: ../Doc/c-api/arg.rst:286 +#: ../Doc/c-api/arg.rst:302 msgid "" "Convert a Python character, represented as a :class:`str` object of length " "1, to a C :c:type:`int`." @@ -622,41 +629,41 @@ msgstr "" "Convertit un caractère Python, représenté comme un objet :class:`str` de " "longueur 1, en un :c:type:`int` C." -#: ../Doc/c-api/arg.rst:290 ../Doc/c-api/arg.rst:615 +#: ../Doc/c-api/arg.rst:306 ../Doc/c-api/arg.rst:632 msgid "``f`` (:class:`float`) [float]" msgstr "``f`` (:class:`float`) [float]" -#: ../Doc/c-api/arg.rst:290 +#: ../Doc/c-api/arg.rst:306 msgid "Convert a Python floating point number to a C :c:type:`float`." msgstr "Convertit un nombre flottant Python vers un :c:type:`float`." -#: ../Doc/c-api/arg.rst:293 ../Doc/c-api/arg.rst:612 +#: ../Doc/c-api/arg.rst:309 ../Doc/c-api/arg.rst:629 msgid "``d`` (:class:`float`) [double]" msgstr "``d`` (:class:`float`) [double]" -#: ../Doc/c-api/arg.rst:293 +#: ../Doc/c-api/arg.rst:309 msgid "Convert a Python floating point number to a C :c:type:`double`." msgstr "Convertit un nombre flottant Python vers un :c:type:`double` C." -#: ../Doc/c-api/arg.rst:296 +#: ../Doc/c-api/arg.rst:312 msgid "``D`` (:class:`complex`) [Py_complex]" msgstr "``D`` (:class:`complex`) [Py_complex]" -#: ../Doc/c-api/arg.rst:296 +#: ../Doc/c-api/arg.rst:312 msgid "Convert a Python complex number to a C :c:type:`Py_complex` structure." msgstr "" "Convertit un nombre complexe Python vers une structure :c:type:`Py_complex` " "C." -#: ../Doc/c-api/arg.rst:299 +#: ../Doc/c-api/arg.rst:315 msgid "Other objects" msgstr "Autres objets" -#: ../Doc/c-api/arg.rst:304 ../Doc/c-api/arg.rst:626 +#: ../Doc/c-api/arg.rst:320 ../Doc/c-api/arg.rst:643 msgid "``O`` (object) [PyObject \\*]" msgstr "``O`` (object) [PyObject \\*]" -#: ../Doc/c-api/arg.rst:302 +#: ../Doc/c-api/arg.rst:318 msgid "" "Store a Python object (without any conversion) in a C object pointer. The C " "program thus receives the actual object that was passed. The object's " @@ -667,11 +674,11 @@ msgstr "" "référence sur l'objet n'est pas incrémenté. Le pointeur stocké n'est pas " "*NULL*." -#: ../Doc/c-api/arg.rst:311 +#: ../Doc/c-api/arg.rst:327 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" msgstr "``O!`` (object) [*typeobject*, PyObject \\*]" -#: ../Doc/c-api/arg.rst:307 +#: ../Doc/c-api/arg.rst:323 msgid "" "Store a Python object in a C object pointer. This is similar to ``O``, but " "takes two C arguments: the first is the address of a Python type object, the " @@ -680,11 +687,11 @@ msgid "" "required type, :exc:`TypeError` is raised." msgstr "" -#: ../Doc/c-api/arg.rst:336 ../Doc/c-api/arg.rst:640 +#: ../Doc/c-api/arg.rst:352 ../Doc/c-api/arg.rst:657 msgid "``O&`` (object) [*converter*, *anything*]" msgstr "``O&`` (object) [*converter*, *anything*]" -#: ../Doc/c-api/arg.rst:316 +#: ../Doc/c-api/arg.rst:332 msgid "" "Convert a Python object to a C variable through a *converter* function. " "This takes two arguments: the first is a function, the second is the address " @@ -692,7 +699,7 @@ msgid "" "*converter* function in turn is called as follows::" msgstr "" -#: ../Doc/c-api/arg.rst:323 +#: ../Doc/c-api/arg.rst:339 msgid "" "where *object* is the Python object to be converted and *address* is the :c:" "type:`void\\*` argument that was passed to the :c:func:`PyArg_Parse\\*` " @@ -702,7 +709,7 @@ msgid "" "*address* unmodified." msgstr "" -#: ../Doc/c-api/arg.rst:329 +#: ../Doc/c-api/arg.rst:345 msgid "" "If the *converter* returns ``Py_CLEANUP_SUPPORTED``, it may get called a " "second time if the argument parsing eventually fails, giving the converter a " @@ -711,15 +718,15 @@ msgid "" "value as in the original call." msgstr "" -#: ../Doc/c-api/arg.rst:335 +#: ../Doc/c-api/arg.rst:351 msgid "``Py_CLEANUP_SUPPORTED`` was added." msgstr "``Py_CLEANUP_SUPPORTED`` à été ajouté." -#: ../Doc/c-api/arg.rst:345 +#: ../Doc/c-api/arg.rst:361 msgid "``p`` (:class:`bool`) [int]" msgstr "``p`` (:class:`bool`) [int]" -#: ../Doc/c-api/arg.rst:339 +#: ../Doc/c-api/arg.rst:355 msgid "" "Tests the value passed in for truth (a boolean **p**\\ redicate) and " "converts the result to its equivalent C true/false integer value. Sets the " @@ -728,11 +735,11 @@ msgid "" "how Python tests values for truth." msgstr "" -#: ../Doc/c-api/arg.rst:350 ../Doc/c-api/arg.rst:643 +#: ../Doc/c-api/arg.rst:366 ../Doc/c-api/arg.rst:660 msgid "``(items)`` (:class:`tuple`) [*matching-items*]" msgstr "``(items)`` (:class:`tuple`) [*matching-items*]" -#: ../Doc/c-api/arg.rst:348 +#: ../Doc/c-api/arg.rst:364 msgid "" "The object must be a Python sequence whose length is the number of format " "units in *items*. The C arguments must correspond to the individual format " @@ -743,7 +750,7 @@ msgstr "" "chaque unité de format particulière dans *articles*. Les unités de formats " "pour les séquences peuvent être imbriquées." -#: ../Doc/c-api/arg.rst:352 +#: ../Doc/c-api/arg.rst:368 msgid "" "It is possible to pass \"long\" integers (integers whose value exceeds the " "platform's :const:`LONG_MAX`) however no proper range checking is done --- " @@ -752,7 +759,7 @@ msgid "" "downcasts in C --- your mileage may vary)." msgstr "" -#: ../Doc/c-api/arg.rst:358 +#: ../Doc/c-api/arg.rst:374 msgid "" "A few other characters have a meaning in a format string. These may not " "occur inside nested parentheses. They are:" @@ -760,11 +767,11 @@ msgstr "" "Quelques autres caractères ont un sens dans une chaîne de format. On ne doit " "pas les trouvées dans des parenthèses imbriquées. Ce sont :" -#: ../Doc/c-api/arg.rst:366 +#: ../Doc/c-api/arg.rst:382 msgid "``|``" msgstr "" -#: ../Doc/c-api/arg.rst:362 +#: ../Doc/c-api/arg.rst:378 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -773,11 +780,11 @@ msgid "" "corresponding C variable(s)." msgstr "" -#: ../Doc/c-api/arg.rst:375 +#: ../Doc/c-api/arg.rst:391 msgid "``$``" msgstr "" -#: ../Doc/c-api/arg.rst:369 +#: ../Doc/c-api/arg.rst:385 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. Currently, all " @@ -785,22 +792,22 @@ msgid "" "be specified before ``$`` in the format string." msgstr "" -#: ../Doc/c-api/arg.rst:380 +#: ../Doc/c-api/arg.rst:396 msgid "``:``" msgstr "" -#: ../Doc/c-api/arg.rst:378 +#: ../Doc/c-api/arg.rst:394 msgid "" "The list of format units ends here; the string after the colon is used as " "the function name in error messages (the \"associated value\" of the " "exception that :c:func:`PyArg_ParseTuple` raises)." msgstr "" -#: ../Doc/c-api/arg.rst:385 +#: ../Doc/c-api/arg.rst:401 msgid "``;``" msgstr "" -#: ../Doc/c-api/arg.rst:383 +#: ../Doc/c-api/arg.rst:399 msgid "" "The list of format units ends here; the string after the semicolon is used " "as the error message *instead* of the default error message. ``:`` and ``;" @@ -810,7 +817,7 @@ msgstr "" "virgule est utilise comme message d'erreur *au lieu* du message d'erreur par " "défaut. ``:`` et ``;`` sont mutuellement exclusifs." -#: ../Doc/c-api/arg.rst:387 +#: ../Doc/c-api/arg.rst:403 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" @@ -819,7 +826,7 @@ msgstr "" "à l'appelant sont des références *empruntées* ; ne décrémentez pas leur " "compteur de références !" -#: ../Doc/c-api/arg.rst:390 +#: ../Doc/c-api/arg.rst:406 msgid "" "Additional arguments passed to these functions must be addresses of " "variables whose type is determined by the format string; these are used to " @@ -836,7 +843,7 @@ msgstr "" "devraient correspondre à ce qui est spécifié pour l'unité de format " "correspondante." -#: ../Doc/c-api/arg.rst:396 +#: ../Doc/c-api/arg.rst:412 msgid "" "For the conversion to succeed, the *arg* object must match the format and " "the format must be exhausted. On success, the :c:func:`PyArg_Parse\\*` " @@ -847,24 +854,24 @@ msgid "" "untouched." msgstr "" -#: ../Doc/c-api/arg.rst:405 +#: ../Doc/c-api/arg.rst:421 msgid "API Functions" msgstr "Fonction de l'API" -#: ../Doc/c-api/arg.rst:409 +#: ../Doc/c-api/arg.rst:425 msgid "" "Parse the parameters of a function that takes only positional parameters " "into local variables. Returns true on success; on failure, it returns false " "and raises the appropriate exception." msgstr "" -#: ../Doc/c-api/arg.rst:416 +#: ../Doc/c-api/arg.rst:432 msgid "" "Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list " "rather than a variable number of arguments." msgstr "" -#: ../Doc/c-api/arg.rst:422 +#: ../Doc/c-api/arg.rst:438 msgid "" "Parse the parameters of a function that takes both positional and keyword " "parameters into local variables. The *keywords* argument is a *NULL*-" @@ -873,26 +880,26 @@ msgid "" "success; on failure, it returns false and raises the appropriate exception." msgstr "" -#: ../Doc/c-api/arg.rst:429 +#: ../Doc/c-api/arg.rst:445 msgid "" "Added support for :ref:`positional-only parameters `." msgstr "" -#: ../Doc/c-api/arg.rst:436 +#: ../Doc/c-api/arg.rst:452 msgid "" "Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a " "va_list rather than a variable number of arguments." msgstr "" -#: ../Doc/c-api/arg.rst:442 +#: ../Doc/c-api/arg.rst:458 msgid "" "Ensure that the keys in the keywords argument dictionary are strings. This " "is only needed if :c:func:`PyArg_ParseTupleAndKeywords` is not used, since " "the latter already does this check." msgstr "" -#: ../Doc/c-api/arg.rst:452 +#: ../Doc/c-api/arg.rst:468 msgid "" "Function used to deconstruct the argument lists of \"old-style\" functions " "--- these are functions which use the :const:`METH_OLDARGS` parameter " @@ -903,7 +910,7 @@ msgid "" "continue to be used for that purpose." msgstr "" -#: ../Doc/c-api/arg.rst:463 +#: ../Doc/c-api/arg.rst:479 msgid "" "A simpler form of parameter retrieval which does not use a format string to " "specify the types of the arguments. Functions which use this method to " @@ -921,23 +928,23 @@ msgid "" "a failure." msgstr "" -#: ../Doc/c-api/arg.rst:477 +#: ../Doc/c-api/arg.rst:493 msgid "" "This is an example of the use of this function, taken from the sources for " "the :mod:`_weakref` helper module for weak references::" msgstr "" -#: ../Doc/c-api/arg.rst:493 +#: ../Doc/c-api/arg.rst:509 msgid "" "The call to :c:func:`PyArg_UnpackTuple` in this example is entirely " "equivalent to this call to :c:func:`PyArg_ParseTuple`::" msgstr "" -#: ../Doc/c-api/arg.rst:501 +#: ../Doc/c-api/arg.rst:517 msgid "Building values" msgstr "Construction des valeurs" -#: ../Doc/c-api/arg.rst:505 +#: ../Doc/c-api/arg.rst:521 msgid "" "Create a new value based on a format string similar to those accepted by " "the :c:func:`PyArg_Parse\\*` family of functions and a sequence of values. " @@ -945,7 +952,7 @@ msgid "" "raised if *NULL* is returned." msgstr "" -#: ../Doc/c-api/arg.rst:510 +#: ../Doc/c-api/arg.rst:526 msgid "" ":c:func:`Py_BuildValue` does not always build a tuple. It builds a tuple " "only if its format string contains two or more format units. If the format " @@ -954,7 +961,7 @@ msgid "" "it to return a tuple of size 0 or one, parenthesize the format string." msgstr "" -#: ../Doc/c-api/arg.rst:516 +#: ../Doc/c-api/arg.rst:532 msgid "" "When memory buffers are passed as parameters to supply data to build " "objects, as for the ``s`` and ``s#`` formats, the required data is copied. " @@ -965,7 +972,7 @@ msgid "" "`Py_BuildValue` returns." msgstr "" -#: ../Doc/c-api/arg.rst:524 +#: ../Doc/c-api/arg.rst:540 msgid "" "In the following description, the quoted form is the format unit; the entry " "in (round) parentheses is the Python object type that the format unit will " @@ -973,173 +980,183 @@ msgid "" "be passed." msgstr "" -#: ../Doc/c-api/arg.rst:528 +#: ../Doc/c-api/arg.rst:544 msgid "" "The characters space, tab, colon and comma are ignored in format strings " "(but not within format units such as ``s#``). This can be used to make long " "format strings a tad more readable." msgstr "" -#: ../Doc/c-api/arg.rst:534 +#: ../Doc/c-api/arg.rst:550 msgid "``s`` (:class:`str` or ``None``) [char \\*]" msgstr "``s`` (:class:`str` ou ``None``) [char \\*]" -#: ../Doc/c-api/arg.rst:533 +#: ../Doc/c-api/arg.rst:549 msgid "" "Convert a null-terminated C string to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is *NULL*, ``None`` is used." msgstr "" -#: ../Doc/c-api/arg.rst:539 +#: ../Doc/c-api/arg.rst:555 msgid "``s#`` (:class:`str` or ``None``) [char \\*, int]" msgstr "``s#`` (:class:`str` ou ``None``) [char \\*, int]" -#: ../Doc/c-api/arg.rst:537 +#: ../Doc/c-api/arg.rst:553 msgid "" "Convert a C string and its length to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is *NULL*, the length is " "ignored and ``None`` is returned." msgstr "" -#: ../Doc/c-api/arg.rst:543 +#: ../Doc/c-api/arg.rst:559 msgid "``y`` (:class:`bytes`) [char \\*]" msgstr "``y`` (:class:`bytes`) [char \\*]" -#: ../Doc/c-api/arg.rst:542 +#: ../Doc/c-api/arg.rst:558 msgid "" "This converts a C string to a Python :class:`bytes` object. If the C string " "pointer is *NULL*, ``None`` is returned." msgstr "" -#: ../Doc/c-api/arg.rst:547 +#: ../Doc/c-api/arg.rst:563 msgid "``y#`` (:class:`bytes`) [char \\*, int]" msgstr "``y#`` (:class:`bytes`) [char \\*, int]" -#: ../Doc/c-api/arg.rst:546 +#: ../Doc/c-api/arg.rst:562 msgid "" "This converts a C string and its lengths to a Python object. If the C " "string pointer is *NULL*, ``None`` is returned." msgstr "" -#: ../Doc/c-api/arg.rst:550 +#: ../Doc/c-api/arg.rst:566 msgid "``z`` (:class:`str` or ``None``) [char \\*]" msgstr "``z`` (:class:`str` ou ``None``) [char \\*]" -#: ../Doc/c-api/arg.rst:550 ../Doc/c-api/arg.rst:565 +#: ../Doc/c-api/arg.rst:566 ../Doc/c-api/arg.rst:582 msgid "Same as ``s``." msgstr "" -#: ../Doc/c-api/arg.rst:553 +#: ../Doc/c-api/arg.rst:569 msgid "``z#`` (:class:`str` or ``None``) [char \\*, int]" msgstr "``z#`` (:class:`str` ou ``None``) [char \\*, int]" -#: ../Doc/c-api/arg.rst:553 ../Doc/c-api/arg.rst:568 +#: ../Doc/c-api/arg.rst:569 ../Doc/c-api/arg.rst:585 msgid "Same as ``s#``." msgstr "" -#: ../Doc/c-api/arg.rst:556 +#: ../Doc/c-api/arg.rst:574 +#, fuzzy +msgid "``u`` (:class:`str`) [wchar_t \\*]" +msgstr "``s`` (:class:`str`) [const char \\*]" + +#: ../Doc/c-api/arg.rst:572 msgid "" -"Convert a null-terminated buffer of Unicode (UCS-2 or UCS-4) data to a " -"Python Unicode object. If the Unicode buffer pointer is *NULL*, ``None`` is " -"returned." +"Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or " +"UCS-4) data to a Python Unicode object. If the Unicode buffer pointer is " +"*NULL*, ``None`` is returned." msgstr "" -#: ../Doc/c-api/arg.rst:560 +#: ../Doc/c-api/arg.rst:579 +#, fuzzy +msgid "``u#`` (:class:`str`) [wchar_t \\*, int]" +msgstr "``y#`` (:class:`bytes`) [char \\*, int]" + +#: ../Doc/c-api/arg.rst:577 msgid "" -"Convert a Unicode (UCS-2 or UCS-4) data buffer and its length to a Python " +"Convert a Unicode (UTF-16 or UCS-4) data buffer and its length to a Python " "Unicode object. If the Unicode buffer pointer is *NULL*, the length is " "ignored and ``None`` is returned." msgstr "" -#: ../Doc/c-api/arg.rst:565 +#: ../Doc/c-api/arg.rst:582 msgid "``U`` (:class:`str` or ``None``) [char \\*]" msgstr "``U`` (:class:`str` ou ``None``) [char \\*]" -#: ../Doc/c-api/arg.rst:568 +#: ../Doc/c-api/arg.rst:585 msgid "``U#`` (:class:`str` or ``None``) [char \\*, int]" msgstr "``U#`` (:class:`str` ou ``None``) [char \\*, int]" -#: ../Doc/c-api/arg.rst:571 +#: ../Doc/c-api/arg.rst:588 msgid "Convert a plain C :c:type:`int` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:574 +#: ../Doc/c-api/arg.rst:591 msgid "``b`` (:class:`int`) [char]" msgstr "``b`` (:class:`int`) [char]" -#: ../Doc/c-api/arg.rst:574 +#: ../Doc/c-api/arg.rst:591 msgid "Convert a plain C :c:type:`char` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:577 +#: ../Doc/c-api/arg.rst:594 msgid "Convert a plain C :c:type:`short int` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:580 +#: ../Doc/c-api/arg.rst:597 msgid "Convert a C :c:type:`long int` to a Python integer object." msgstr "Convertit un :c:type:`long int` en un int Python." -#: ../Doc/c-api/arg.rst:583 +#: ../Doc/c-api/arg.rst:600 msgid "Convert a C :c:type:`unsigned char` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:586 +#: ../Doc/c-api/arg.rst:603 msgid "Convert a C :c:type:`unsigned short int` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:589 +#: ../Doc/c-api/arg.rst:606 msgid "Convert a C :c:type:`unsigned int` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:592 +#: ../Doc/c-api/arg.rst:609 msgid "Convert a C :c:type:`unsigned long` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:595 +#: ../Doc/c-api/arg.rst:612 msgid "Convert a C :c:type:`long long` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:598 +#: ../Doc/c-api/arg.rst:615 msgid "Convert a C :c:type:`unsigned long long` to a Python integer object." msgstr "" -#: ../Doc/c-api/arg.rst:601 +#: ../Doc/c-api/arg.rst:618 msgid "Convert a C :c:type:`Py_ssize_t` to a Python integer." msgstr "" -#: ../Doc/c-api/arg.rst:605 +#: ../Doc/c-api/arg.rst:622 msgid "``c`` (:class:`bytes` of length 1) [char]" msgstr "``c`` (:class:`bytes` de taille 1) [char]" -#: ../Doc/c-api/arg.rst:604 +#: ../Doc/c-api/arg.rst:621 msgid "" "Convert a C :c:type:`int` representing a byte to a Python :class:`bytes` " "object of length 1." msgstr "" -#: ../Doc/c-api/arg.rst:608 +#: ../Doc/c-api/arg.rst:625 msgid "" "Convert a C :c:type:`int` representing a character to Python :class:`str` " "object of length 1." msgstr "" -#: ../Doc/c-api/arg.rst:612 +#: ../Doc/c-api/arg.rst:629 msgid "Convert a C :c:type:`double` to a Python floating point number." msgstr "" -#: ../Doc/c-api/arg.rst:615 +#: ../Doc/c-api/arg.rst:632 msgid "Convert a C :c:type:`float` to a Python floating point number." msgstr "" -#: ../Doc/c-api/arg.rst:618 +#: ../Doc/c-api/arg.rst:635 msgid "``D`` (:class:`complex`) [Py_complex \\*]" msgstr "``D`` (:class:`complex`) [Py_complex \\*]" -#: ../Doc/c-api/arg.rst:618 +#: ../Doc/c-api/arg.rst:635 msgid "Convert a C :c:type:`Py_complex` structure to a Python complex number." msgstr "" -#: ../Doc/c-api/arg.rst:621 +#: ../Doc/c-api/arg.rst:638 msgid "" "Pass a Python object untouched (except for its reference count, which is " "incremented by one). If the object passed in is a *NULL* pointer, it is " @@ -1149,26 +1166,26 @@ msgid "" "yet, :exc:`SystemError` is set." msgstr "" -#: ../Doc/c-api/arg.rst:629 +#: ../Doc/c-api/arg.rst:646 msgid "``S`` (object) [PyObject \\*]" msgstr "``S`` (object) [PyObject \\*]" -#: ../Doc/c-api/arg.rst:629 +#: ../Doc/c-api/arg.rst:646 msgid "Same as ``O``." msgstr "" -#: ../Doc/c-api/arg.rst:634 +#: ../Doc/c-api/arg.rst:651 msgid "``N`` (object) [PyObject \\*]" msgstr "``N`` (object) [PyObject \\*]" -#: ../Doc/c-api/arg.rst:632 +#: ../Doc/c-api/arg.rst:649 msgid "" "Same as ``O``, except it doesn't increment the reference count on the " "object. Useful when the object is created by a call to an object constructor " "in the argument list." msgstr "" -#: ../Doc/c-api/arg.rst:637 +#: ../Doc/c-api/arg.rst:654 msgid "" "Convert *anything* to a Python object through a *converter* function. The " "function is called with *anything* (which should be compatible with :c:type:" @@ -1176,40 +1193,40 @@ msgid "" "*NULL* if an error occurred." msgstr "" -#: ../Doc/c-api/arg.rst:643 +#: ../Doc/c-api/arg.rst:660 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." msgstr "" -#: ../Doc/c-api/arg.rst:646 +#: ../Doc/c-api/arg.rst:663 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "``[items]`` (:class:`list`) [*matching-items*]" -#: ../Doc/c-api/arg.rst:646 +#: ../Doc/c-api/arg.rst:663 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." msgstr "" -#: ../Doc/c-api/arg.rst:651 +#: ../Doc/c-api/arg.rst:668 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "``{items}`` (:class:`dict`) [*matching-items*]" -#: ../Doc/c-api/arg.rst:649 +#: ../Doc/c-api/arg.rst:666 msgid "" "Convert a sequence of C values to a Python dictionary. Each pair of " "consecutive C values adds one item to the dictionary, serving as key and " "value, respectively." msgstr "" -#: ../Doc/c-api/arg.rst:653 +#: ../Doc/c-api/arg.rst:670 msgid "" "If there is an error in the format string, the :exc:`SystemError` exception " "is set and *NULL* returned." msgstr "" -#: ../Doc/c-api/arg.rst:658 +#: ../Doc/c-api/arg.rst:675 msgid "" "Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list " "rather than a variable number of arguments." diff --git a/c-api/buffer.po b/c-api/buffer.po index 969f47aa..d4326596 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-02 22:11+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -622,33 +622,44 @@ msgstr "" #: ../Doc/c-api/buffer.rst:478 msgid "" +"Copy *len* bytes from *src* to its contiguous representation in *buf*. " +"*order* can be ``'C'`` or ``'F'`` (for C-style or Fortran-style ordering). " +"``0`` is returned on success, ``-1`` on error." +msgstr "" + +#: ../Doc/c-api/buffer.rst:482 +msgid "This function fails if *len* != *src->len*." +msgstr "" + +#: ../Doc/c-api/buffer.rst:487 +msgid "" "Fill the *strides* array with byte-strides of a :term:`contiguous` (C-style " "if *order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the " "given shape with the given number of bytes per element." msgstr "" -#: ../Doc/c-api/buffer.rst:485 +#: ../Doc/c-api/buffer.rst:494 msgid "" "Handle buffer requests for an exporter that wants to expose *buf* of size " "*len* with writability set according to *readonly*. *buf* is interpreted as " "a sequence of unsigned bytes." msgstr "" -#: ../Doc/c-api/buffer.rst:489 +#: ../Doc/c-api/buffer.rst:498 msgid "" "The *flags* argument indicates the request type. This function always fills " "in *view* as specified by flags, unless *buf* has been designated as read-" "only and :c:macro:`PyBUF_WRITABLE` is set in *flags*." msgstr "" -#: ../Doc/c-api/buffer.rst:493 +#: ../Doc/c-api/buffer.rst:502 msgid "" "On success, set :c:member:`view->obj` to a new reference to *exporter* and " "return 0. Otherwise, raise :c:data:`PyExc_BufferError`, set :c:member:`view-" ">obj` to *NULL* and return ``-1``;" msgstr "" -#: ../Doc/c-api/buffer.rst:497 +#: ../Doc/c-api/buffer.rst:506 msgid "" "If this function is used as part of a :ref:`getbufferproc `, " "*exporter* MUST be set to the exporting object and *flags* must be passed " diff --git a/distutils/configfile.po b/distutils/configfile.po index e05e3e94..2daae7c8 100644 --- a/distutils/configfile.po +++ b/distutils/configfile.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-10 00:49+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -64,10 +64,10 @@ msgid "" msgstr "" #: ../Doc/distutils/configfile.rst:39 -msgid "The basic syntax of the configuration file is simple::" +msgid "The basic syntax of the configuration file is simple:" msgstr "" -#: ../Doc/distutils/configfile.rst:45 +#: ../Doc/distutils/configfile.rst:47 msgid "" "where *command* is one of the Distutils commands (e.g. :command:`build_py`, :" "command:`install`), and *option* is one of the options that command " @@ -78,37 +78,37 @@ msgid "" "by indenting the continuation lines." msgstr "" -#: ../Doc/distutils/configfile.rst:53 +#: ../Doc/distutils/configfile.rst:55 msgid "" "You can find out the list of options supported by a particular command with " -"the universal :option:`!--help` option, e.g. ::" +"the universal :option:`!--help` option, e.g." msgstr "" -#: ../Doc/distutils/configfile.rst:69 +#: ../Doc/distutils/configfile.rst:73 msgid "" "Note that an option spelled :option:`!--foo-bar` on the command-line is " "spelled ``foo_bar`` in configuration files." msgstr "" -#: ../Doc/distutils/configfile.rst:74 +#: ../Doc/distutils/configfile.rst:78 msgid "" "For example, say you want your extensions to be built \"in-place\"---that " "is, you have an extension :mod:`pkg.ext`, and you want the compiled " "extension file (:file:`ext.so` on Unix, say) to be put in the same source " "directory as your pure Python modules :mod:`pkg.mod1` and :mod:`pkg.mod2`. " "You can always use the :option:`!--inplace` option on the command-line to " -"ensure this::" +"ensure this:" msgstr "" -#: ../Doc/distutils/configfile.rst:82 +#: ../Doc/distutils/configfile.rst:88 msgid "" "But this requires that you always specify the :command:`build_ext` command " "explicitly, and remember to provide :option:`!--inplace`. An easier way is " "to \"set and forget\" this option, by encoding it in :file:`setup.cfg`, the " -"configuration file for this distribution::" +"configuration file for this distribution:" msgstr "" -#: ../Doc/distutils/configfile.rst:90 +#: ../Doc/distutils/configfile.rst:98 msgid "" "This will affect all builds of this module distribution, whether or not you " "explicitly specify :command:`build_ext`. If you include :file:`setup.cfg` " @@ -121,7 +121,7 @@ msgid "" "always a bad idea, though.)" msgstr "" -#: ../Doc/distutils/configfile.rst:99 +#: ../Doc/distutils/configfile.rst:107 msgid "" "Another example: certain commands take a lot of options that don't change " "from run to run; for example, :command:`bdist_rpm` needs to know everything " @@ -130,30 +130,30 @@ msgid "" "generated by the Distutils (such as the list of files installed). But some " "of it has to be supplied as options to :command:`bdist_rpm`, which would be " "very tedious to do on the command-line for every run. Hence, here is a " -"snippet from the Distutils' own :file:`setup.cfg`::" +"snippet from the Distutils' own :file:`setup.cfg`:" msgstr "" -#: ../Doc/distutils/configfile.rst:117 +#: ../Doc/distutils/configfile.rst:127 msgid "" "Note that the ``doc_files`` option is simply a whitespace-separated string " "split across multiple lines for readability." msgstr "" -#: ../Doc/distutils/configfile.rst:124 +#: ../Doc/distutils/configfile.rst:134 msgid ":ref:`inst-config-syntax` in \"Installing Python Modules\"" msgstr "" -#: ../Doc/distutils/configfile.rst:124 +#: ../Doc/distutils/configfile.rst:134 msgid "" "More information on the configuration files is available in the manual for " "system administrators." msgstr "" -#: ../Doc/distutils/configfile.rst:129 +#: ../Doc/distutils/configfile.rst:139 msgid "Footnotes" msgstr "Notes" -#: ../Doc/distutils/configfile.rst:130 +#: ../Doc/distutils/configfile.rst:140 msgid "" "This ideal probably won't be achieved until auto-configuration is fully " "supported by the Distutils." diff --git a/distutils/introduction.po b/distutils/introduction.po index feac01af..0dba419d 100644 --- a/distutils/introduction.po +++ b/distutils/introduction.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-02 22:11+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -298,10 +298,9 @@ msgstr "" msgid "" "a collection of Python modules distributed together as a single downloadable " "resource and meant to be installed *en masse*. Examples of some well-known " -"module distributions are NumPy, SciPy, PIL (the Python Imaging Library), or " -"mxBase. (This would be called a *package*, except that term is already " -"taken in the Python context: a single module distribution may contain zero, " -"one, or many Python packages.)" +"module distributions are NumPy, SciPy, Pillow, or mxBase. (This would be " +"called a *package*, except that term is already taken in the Python context: " +"a single module distribution may contain zero, one, or many Python packages.)" msgstr "" #: ../Doc/distutils/introduction.rst:203 diff --git a/distutils/packageindex.po b/distutils/packageindex.po index 3a8afaa7..15f2c05e 100644 --- a/distutils/packageindex.po +++ b/distutils/packageindex.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-10 00:49+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -214,96 +214,96 @@ msgid "" "existence of a :file:`.pypirc` file at the location :file:`$HOME/.pypirc`. " "If this file exists, the command uses the username, password, and repository " "URL configured in the file. The format of a :file:`.pypirc` file is as " -"follows::" +"follows:" msgstr "" -#: ../Doc/distutils/packageindex.rst:170 +#: ../Doc/distutils/packageindex.rst:172 msgid "" "The *distutils* section defines an *index-servers* variable that lists the " "name of all sections describing a repository." msgstr "" -#: ../Doc/distutils/packageindex.rst:173 +#: ../Doc/distutils/packageindex.rst:175 msgid "Each section describing a repository defines three variables:" msgstr "" -#: ../Doc/distutils/packageindex.rst:175 +#: ../Doc/distutils/packageindex.rst:177 msgid "*repository*, that defines the url of the PyPI server. Defaults to" msgstr "" -#: ../Doc/distutils/packageindex.rst:176 +#: ../Doc/distutils/packageindex.rst:178 msgid "``https://upload.pypi.org/legacy/``." msgstr "" -#: ../Doc/distutils/packageindex.rst:177 +#: ../Doc/distutils/packageindex.rst:179 msgid "*username*, which is the registered username on the PyPI server." msgstr "" -#: ../Doc/distutils/packageindex.rst:179 +#: ../Doc/distutils/packageindex.rst:181 msgid "*password*, that will be used to authenticate. If omitted the user" msgstr "" -#: ../Doc/distutils/packageindex.rst:179 +#: ../Doc/distutils/packageindex.rst:181 msgid "will be prompt to type it when needed." msgstr "" -#: ../Doc/distutils/packageindex.rst:181 +#: ../Doc/distutils/packageindex.rst:183 msgid "" "If you want to define another server a new section can be created and listed " -"in the *index-servers* variable::" +"in the *index-servers* variable:" msgstr "" -#: ../Doc/distutils/packageindex.rst:199 +#: ../Doc/distutils/packageindex.rst:203 msgid "" "This allows the :command:`register` and :command:`upload` commands to be " "called with the ``--repository`` option as described in :ref:`package-" "cmdoptions`." msgstr "" -#: ../Doc/distutils/packageindex.rst:203 +#: ../Doc/distutils/packageindex.rst:207 msgid "" "Specifically, you might want to add the `PyPI Test Repository `_ to your ``.pypirc`` to facilitate testing before " "doing your first upload to ``PyPI`` itself." msgstr "" -#: ../Doc/distutils/packageindex.rst:211 +#: ../Doc/distutils/packageindex.rst:215 msgid "PyPI package display" msgstr "" -#: ../Doc/distutils/packageindex.rst:213 +#: ../Doc/distutils/packageindex.rst:217 msgid "" "The ``long_description`` field plays a special role at PyPI. It is used by " "the server to display a home page for the registered package." msgstr "" -#: ../Doc/distutils/packageindex.rst:216 +#: ../Doc/distutils/packageindex.rst:220 msgid "" "If you use the `reStructuredText `_ syntax for this field, PyPI will parse it and display an HTML output " "for the package home page." msgstr "" -#: ../Doc/distutils/packageindex.rst:220 +#: ../Doc/distutils/packageindex.rst:224 msgid "" "The ``long_description`` field can be attached to a text file located in the " "package::" msgstr "" -#: ../Doc/distutils/packageindex.rst:231 +#: ../Doc/distutils/packageindex.rst:235 msgid "" "In that case, :file:`README.txt` is a regular reStructuredText text file " "located in the root of the package besides :file:`setup.py`." msgstr "" -#: ../Doc/distutils/packageindex.rst:234 +#: ../Doc/distutils/packageindex.rst:238 msgid "" "To prevent registering broken reStructuredText content, you can use the :" "program:`rst2html` program that is provided by the :mod:`docutils` package " "and check the ``long_description`` from the command line:" msgstr "" -#: ../Doc/distutils/packageindex.rst:242 +#: ../Doc/distutils/packageindex.rst:246 msgid "" ":mod:`docutils` will display a warning if there's something wrong with your " "syntax. Because PyPI applies additional checks (e.g. by passing ``--no-" diff --git a/extending/extending.po b/extending/extending.po index 60dbfeb5..8bc9177f 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-12-01 07:43+0100\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: 2018-02-15 00:36+0100\n" "Last-Translator: \n" "Language-Team: \n" @@ -84,12 +84,13 @@ msgid "A Simple Example" msgstr "Un exemple simple" #: ../Doc/extending/extending.rst:41 +#, fuzzy msgid "" "Let's create an extension module called ``spam`` (the favorite food of Monty " "Python fans...) and let's say we want to create a Python interface to the C " "library function :c:func:`system` [#]_. This function takes a null-" "terminated character string as argument and returns an integer. We want " -"this function to be callable from Python as follows::" +"this function to be callable from Python as follows:" msgstr "" "Créons un module d'extension appelé ``spam`` (la nourriture préférée de fans " "des Monty Python ...) et disons que nous voulons créer une interface Python " @@ -98,7 +99,7 @@ msgstr "" "un entier. Nous voulons que cette fonction soit appelable à partir de Python " "comme suit : ::" -#: ../Doc/extending/extending.rst:50 +#: ../Doc/extending/extending.rst:52 msgid "" "Begin by creating a file :file:`spammodule.c`. (Historically, if a module " "is called ``spam``, the C file containing its implementation is called :file:" @@ -110,11 +111,11 @@ msgstr "" "appelé :file:`spammodule.c`. Si le nom du module est très long, comme " "``spammify``, le nom du module peut être juste :file:`spammify.c`.)" -#: ../Doc/extending/extending.rst:55 +#: ../Doc/extending/extending.rst:57 msgid "The first line of our file can be::" msgstr "La première ligne de notre fichier peut être : ::" -#: ../Doc/extending/extending.rst:59 +#: ../Doc/extending/extending.rst:61 msgid "" "which pulls in the Python API (you can add a comment describing the purpose " "of the module and a copyright notice if you like)." @@ -122,7 +123,7 @@ msgstr "" "qui récupère l'API Python (vous pouvez ajouter un commentaire décrivant le " "but du module et un avis de droit d'auteur si vous le souhaitez)." -#: ../Doc/extending/extending.rst:64 +#: ../Doc/extending/extending.rst:66 msgid "" "Since Python may define some pre-processor definitions which affect the " "standard headers on some systems, you *must* include :file:`Python.h` before " @@ -132,7 +133,7 @@ msgstr "" "les têtes standard sur certains systèmes, vous *devez* inclure :file:`Python." "h` avant les en-têtes standards." -#: ../Doc/extending/extending.rst:68 +#: ../Doc/extending/extending.rst:70 msgid "" "All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` " "or ``PY``, except those defined in standard header files. For convenience, " @@ -150,7 +151,7 @@ msgstr "" "sur votre système, il déclare les fonctions :c:func:`malloc`, :c:func:`free` " "et :c:func:`realloc` directement." -#: ../Doc/extending/extending.rst:76 +#: ../Doc/extending/extending.rst:78 msgid "" "The next thing we add to our module file is the C function that will be " "called when the Python expression ``spam.system(string)`` is evaluated " @@ -161,7 +162,7 @@ msgstr "" "system(chaîne)`` sera évaluée (nous verrons bientôt comment elle finit par " "être appelée) ::" -#: ../Doc/extending/extending.rst:92 +#: ../Doc/extending/extending.rst:94 msgid "" "There is a straightforward translation from the argument list in Python (for " "example, the single expression ``\"ls -l\"``) to the arguments passed to the " @@ -173,7 +174,7 @@ msgstr "" "La fonction C a toujours deux arguments, appelés par convention *self* et " "*args*." -#: ../Doc/extending/extending.rst:97 +#: ../Doc/extending/extending.rst:99 msgid "" "The *self* argument points to the module object for module-level functions; " "for a method it would point to the object instance." @@ -181,7 +182,7 @@ msgstr "" "Pour les fonctions au niveau du module, l'argument *self* pointe sur l'objet " "module, pour une méthode, il pointe sur l'instance de l'objet." -#: ../Doc/extending/extending.rst:100 +#: ../Doc/extending/extending.rst:102 msgid "" "The *args* argument will be a pointer to a Python tuple object containing " "the arguments. Each item of the tuple corresponds to an argument in the " @@ -202,7 +203,7 @@ msgstr "" "ainsi que les types de variables C dans lequel stocker les valeurs " "converties. Nous en verront plus, plus tard." -#: ../Doc/extending/extending.rst:109 +#: ../Doc/extending/extending.rst:111 msgid "" ":c:func:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the " "right type and its components have been stored in the variables whose " @@ -218,11 +219,11 @@ msgstr "" "exception appropriée de sorte que la fonction d'appel puisse renvoyer *NULL* " "immédiatement (comme nous l'avons vu dans l'exemple)." -#: ../Doc/extending/extending.rst:119 +#: ../Doc/extending/extending.rst:121 msgid "Intermezzo: Errors and Exceptions" msgstr "Intermezzo: Les erreurs et exceptions" -#: ../Doc/extending/extending.rst:121 +#: ../Doc/extending/extending.rst:123 msgid "" "An important convention throughout the Python interpreter is the following: " "when a function fails, it should set an exception condition and return an " @@ -249,7 +250,7 @@ msgstr "" "Reference*). Il est important de les connaître pour comprendre comment les " "erreurs sont propagées." -#: ../Doc/extending/extending.rst:132 +#: ../Doc/extending/extending.rst:134 msgid "" "The Python API defines a number of functions to set various types of " "exceptions." @@ -257,7 +258,7 @@ msgstr "" "L'API Python définit un certain nombre de fonctions pour créer différents " "types d'exceptions." -#: ../Doc/extending/extending.rst:134 +#: ../Doc/extending/extending.rst:136 msgid "" "The most common one is :c:func:`PyErr_SetString`. Its arguments are an " "exception object and a C string. The exception object is usually a " @@ -271,7 +272,7 @@ msgstr "" "cause de l'erreur et est convertie en une chaîne Python puis stockée en tant " "que \"valeur associée\" à l'exception." -#: ../Doc/extending/extending.rst:140 +#: ../Doc/extending/extending.rst:142 msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " @@ -286,7 +287,7 @@ msgstr "" "arguments: l'exception et sa valeur associée. Vous ne devez pas appliquer :c:" "func:`Py_INCREF` aux objets transmis à ces fonctions." -#: ../Doc/extending/extending.rst:147 +#: ../Doc/extending/extending.rst:149 msgid "" "You can test non-destructively whether an exception has been set with :c:" "func:`PyErr_Occurred`. This returns the current exception object, or *NULL* " @@ -301,7 +302,7 @@ msgstr "" "survenue durant l'appel d'une fonction, puisque vous devriez être en mesure " "de le déterminer à partir de la valeur de retour." -#: ../Doc/extending/extending.rst:153 +#: ../Doc/extending/extending.rst:155 msgid "" "When a function *f* that calls another function *g* detects that the latter " "fails, *f* should itself return an error value (usually *NULL* or ``-1``). " @@ -326,7 +327,7 @@ msgstr "" "d'exécution et essaie de trouver un gestionnaire d'exception spécifié par le " "développeur Python." -#: ../Doc/extending/extending.rst:163 +#: ../Doc/extending/extending.rst:165 msgid "" "(There are situations where a module can actually give a more detailed error " "message by calling another :c:func:`PyErr_\\*` function, and in such cases " @@ -341,7 +342,7 @@ msgstr "" "sur la cause de l'erreur: la plupart des opérations peuvent échouer pour " "tout un tas de raisons)." -#: ../Doc/extending/extending.rst:169 +#: ../Doc/extending/extending.rst:171 msgid "" "To ignore an exception set by a function call that failed, the exception " "condition must be cleared explicitly by calling :c:func:`PyErr_Clear`. The " @@ -356,7 +357,7 @@ msgstr "" "l'interpréteur, mais souhaite la gérer lui-même (peut-être en essayant " "quelque chose d'autre, ou en prétendant que rien n'a mal tourné)." -#: ../Doc/extending/extending.rst:175 +#: ../Doc/extending/extending.rst:177 msgid "" "Every failing :c:func:`malloc` call must be turned into an exception --- the " "direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call :c:func:" @@ -371,7 +372,7 @@ msgstr "" "`PyLong_FromLong`) le font déjà, donc cette note ne concerne que ceux qui " "appellent :c:func:`malloc` directement." -#: ../Doc/extending/extending.rst:181 +#: ../Doc/extending/extending.rst:183 msgid "" "Also note that, with the important exception of :c:func:`PyArg_ParseTuple` " "and friends, functions that return an integer status usually return a " @@ -383,7 +384,7 @@ msgstr "" "donnent généralement une valeur positive ou zéro en cas de succès et ``-1`` " "en cas d'échec, comme les appels du système Unix." -#: ../Doc/extending/extending.rst:185 +#: ../Doc/extending/extending.rst:187 msgid "" "Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or :" "c:func:`Py_DECREF` calls for objects you have already created) when you " @@ -393,7 +394,7 @@ msgstr "" "de nettoyage (en appelant :c:func:`Py_XDECREF` ou :c:func:`Py_DECREF` avec " "les objets que vous auriez déjà créés) !" -#: ../Doc/extending/extending.rst:189 +#: ../Doc/extending/extending.rst:191 msgid "" "The choice of which exception to raise is entirely yours. There are " "predeclared C objects corresponding to all built-in Python exceptions, such " @@ -417,7 +418,7 @@ msgstr "" "qui doit satisfaire d'autres conditions, :c:data:`PyExc_ValueError` sera " "plus appropriée." -#: ../Doc/extending/extending.rst:199 +#: ../Doc/extending/extending.rst:201 msgid "" "You can also define a new exception that is unique to your module. For this, " "you usually declare a static object variable at the beginning of your file::" @@ -426,7 +427,7 @@ msgstr "" "cela, déclarez simplement une variable statique au début de votre " "fichier : ::" -#: ../Doc/extending/extending.rst:204 +#: ../Doc/extending/extending.rst:206 msgid "" "and initialize it in your module's initialization function (:c:func:" "`PyInit_spam`) with an exception object (leaving out the error checking for " @@ -436,7 +437,7 @@ msgstr "" "`PyInit_spam`) avec un objet exception (Passons, pour le moment, la " "vérification des codes d'erreur) ::" -#: ../Doc/extending/extending.rst:222 +#: ../Doc/extending/extending.rst:224 msgid "" "Note that the Python name for the exception object is :exc:`spam.error`. " "The :c:func:`PyErr_NewException` function may create a class with the base " @@ -448,7 +449,7 @@ msgstr "" "`Exception` (à moins qu'une autre classe ne lui soit fournie à la place de " "*NULL*), voir :ref:`bltin-exceptions`." -#: ../Doc/extending/extending.rst:227 +#: ../Doc/extending/extending.rst:229 msgid "" "Note also that the :c:data:`SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -466,7 +467,7 @@ msgstr "" "code qui soulèvel'exception peut engendrer un rejet central ou des effets " "secondaires innatendus." -#: ../Doc/extending/extending.rst:234 +#: ../Doc/extending/extending.rst:236 msgid "" "We discuss the use of ``PyMODINIT_FUNC`` as a function return type later in " "this sample." @@ -474,7 +475,7 @@ msgstr "" "Nous traiterons de l'utilisation de ``PyMODINIT_FUNC`` comme un type de " "retour de fonction plus tard dans cette section." -#: ../Doc/extending/extending.rst:237 +#: ../Doc/extending/extending.rst:239 msgid "" "The :exc:`spam.error` exception can be raised in your extension module using " "a call to :c:func:`PyErr_SetString` as shown below::" @@ -482,11 +483,11 @@ msgstr "" "L'exception :exc:`spam.error` peut être levée dans votre module d'extension " "en appelant :c:func:`PyErr_SetString` comme montré ci-dessous ::" -#: ../Doc/extending/extending.rst:260 +#: ../Doc/extending/extending.rst:262 msgid "Back to the Example" msgstr "Retour vers l'exemple" -#: ../Doc/extending/extending.rst:262 +#: ../Doc/extending/extending.rst:264 msgid "" "Going back to our example function, you should now be able to understand " "this statement::" @@ -494,7 +495,7 @@ msgstr "" "En revenant vers notre fonction exemple, vous devriez maintenant être " "capable de comprendre cette affirmation ::" -#: ../Doc/extending/extending.rst:268 +#: ../Doc/extending/extending.rst:270 msgid "" "It returns *NULL* (the error indicator for functions returning object " "pointers) if an error is detected in the argument list, relying on the " @@ -513,7 +514,7 @@ msgstr "" "la variable :c:data:`command` doit être clairement déclarée comme ``const " "char *command``)." -#: ../Doc/extending/extending.rst:276 +#: ../Doc/extending/extending.rst:278 msgid "" "The next statement is a call to the Unix function :c:func:`system`, passing " "it the string we just got from :c:func:`PyArg_ParseTuple`::" @@ -522,7 +523,7 @@ msgstr "" "en lui passant la chaîne que nous venons d'obtenir à partir de :c:func:" "`PyArg_ParseTuple` ::" -#: ../Doc/extending/extending.rst:281 +#: ../Doc/extending/extending.rst:283 msgid "" "Our :func:`spam.system` function must return the value of :c:data:`sts` as a " "Python object. This is done using the function :c:func:`PyLong_FromLong`. ::" @@ -531,7 +532,7 @@ msgstr "" "comme un objet Python. Cela est effectué par l'utilisation de la fonction :c:" "func:`PyLong_FromLong`. ::" -#: ../Doc/extending/extending.rst:286 +#: ../Doc/extending/extending.rst:288 msgid "" "In this case, it will return an integer object. (Yes, even integers are " "objects on the heap in Python!)" @@ -539,7 +540,7 @@ msgstr "" "Dans ce cas, elle renvoyera un objet entier. (Oui, même les entiers sont des " "objets dans le tas en Python!)" -#: ../Doc/extending/extending.rst:289 +#: ../Doc/extending/extending.rst:291 msgid "" "If you have a C function that returns no useful argument (a function " "returning :c:type:`void`), the corresponding Python function must return " @@ -551,7 +552,7 @@ msgstr "" "renvoyer ``None``. Vous aurez besoin de cette locution pour cela (qui est " "implémentée par la macro :c:macro:`Py_RETURN_NONE`) ::" -#: ../Doc/extending/extending.rst:297 +#: ../Doc/extending/extending.rst:299 msgid "" ":c:data:`Py_None` is the C name for the special Python object ``None``. It " "is a genuine Python object rather than a *NULL* pointer, which means \"error" @@ -561,17 +562,17 @@ msgstr "" "un authentique objet Python plutôt qu'un pointeur *NULL*, qui signifie " "\"error\" dans la plupart des situations, comme nous l'avons vu." -#: ../Doc/extending/extending.rst:305 +#: ../Doc/extending/extending.rst:307 msgid "The Module's Method Table and Initialization Function" msgstr "" -#: ../Doc/extending/extending.rst:307 +#: ../Doc/extending/extending.rst:309 msgid "" "I promised to show how :c:func:`spam_system` is called from Python programs. " "First, we need to list its name and address in a \"method table\"::" msgstr "" -#: ../Doc/extending/extending.rst:318 +#: ../Doc/extending/extending.rst:320 msgid "" "Note the third entry (``METH_VARARGS``). This is a flag telling the " "interpreter the calling convention to be used for the C function. It should " @@ -580,14 +581,14 @@ msgid "" "is used." msgstr "" -#: ../Doc/extending/extending.rst:323 +#: ../Doc/extending/extending.rst:325 msgid "" "When using only ``METH_VARARGS``, the function should expect the Python-" "level parameters to be passed in as a tuple acceptable for parsing via :c:" "func:`PyArg_ParseTuple`; more information on this function is provided below." msgstr "" -#: ../Doc/extending/extending.rst:327 +#: ../Doc/extending/extending.rst:329 msgid "" "The :const:`METH_KEYWORDS` bit may be set in the third field if keyword " "arguments should be passed to the function. In this case, the C function " @@ -596,12 +597,12 @@ msgid "" "to such a function." msgstr "" -#: ../Doc/extending/extending.rst:333 +#: ../Doc/extending/extending.rst:335 msgid "" "The method table must be referenced in the module definition structure::" msgstr "" -#: ../Doc/extending/extending.rst:344 +#: ../Doc/extending/extending.rst:346 msgid "" "This structure, in turn, must be passed to the interpreter in the module's " "initialization function. The initialization function must be named :c:func:" @@ -609,14 +610,14 @@ msgid "" "only non-\\ ``static`` item defined in the module file::" msgstr "" -#: ../Doc/extending/extending.rst:355 +#: ../Doc/extending/extending.rst:357 msgid "" "Note that PyMODINIT_FUNC declares the function as ``PyObject *`` return " "type, declares any special linkage declarations required by the platform, " "and for C++ declares the function as ``extern \"C\"``." msgstr "" -#: ../Doc/extending/extending.rst:359 +#: ../Doc/extending/extending.rst:361 msgid "" "When the Python program imports module :mod:`spam` for the first time, :c:" "func:`PyInit_spam` is called. (See below for comments about embedding " @@ -630,7 +631,7 @@ msgid "" "gets inserted into ``sys.modules``." msgstr "" -#: ../Doc/extending/extending.rst:370 +#: ../Doc/extending/extending.rst:372 msgid "" "When embedding Python, the :c:func:`PyInit_spam` function is not called " "automatically unless there's an entry in the :c:data:`PyImport_Inittab` " @@ -638,7 +639,7 @@ msgid "" "`PyImport_AppendInittab`, optionally followed by an import of the module::" msgstr "" -#: ../Doc/extending/extending.rst:406 +#: ../Doc/extending/extending.rst:408 msgid "" "Removing entries from ``sys.modules`` or importing compiled modules into " "multiple interpreters within a process (or following a :c:func:`fork` " @@ -647,14 +648,14 @@ msgid "" "initializing internal data structures." msgstr "" -#: ../Doc/extending/extending.rst:412 +#: ../Doc/extending/extending.rst:414 msgid "" "A more substantial example module is included in the Python source " "distribution as :file:`Modules/xxmodule.c`. This file may be used as a " "template or simply read as an example." msgstr "" -#: ../Doc/extending/extending.rst:418 +#: ../Doc/extending/extending.rst:420 msgid "" "Unlike our ``spam`` example, ``xxmodule`` uses *multi-phase initialization* " "(new in Python 3.5), where a PyModuleDef structure is returned from " @@ -662,11 +663,11 @@ msgid "" "For details on multi-phase initialization, see :PEP:`489`." msgstr "" -#: ../Doc/extending/extending.rst:427 +#: ../Doc/extending/extending.rst:429 msgid "Compilation and Linkage" msgstr "" -#: ../Doc/extending/extending.rst:429 +#: ../Doc/extending/extending.rst:431 msgid "" "There are two more things to do before you can use your new extension: " "compiling and linking it with the Python system. If you use dynamic " @@ -676,17 +677,17 @@ msgid "" "Windows (chapter :ref:`building-on-windows`) for more information about this." msgstr "" -#: ../Doc/extending/extending.rst:436 +#: ../Doc/extending/extending.rst:438 msgid "" "If you can't use dynamic loading, or if you want to make your module a " "permanent part of the Python interpreter, you will have to change the " "configuration setup and rebuild the interpreter. Luckily, this is very " "simple on Unix: just place your file (:file:`spammodule.c` for example) in " "the :file:`Modules/` directory of an unpacked source distribution, add a " -"line to the file :file:`Modules/Setup.local` describing your file::" +"line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" -#: ../Doc/extending/extending.rst:445 +#: ../Doc/extending/extending.rst:449 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " "directory. You can also run :program:`make` in the :file:`Modules/` " @@ -695,17 +696,17 @@ msgid "" "the :file:`Setup` file.)" msgstr "" -#: ../Doc/extending/extending.rst:451 +#: ../Doc/extending/extending.rst:455 msgid "" "If your module requires additional libraries to link with, these can be " -"listed on the line in the configuration file as well, for instance::" +"listed on the line in the configuration file as well, for instance:" msgstr "" -#: ../Doc/extending/extending.rst:460 +#: ../Doc/extending/extending.rst:466 msgid "Calling Python Functions from C" msgstr "" -#: ../Doc/extending/extending.rst:462 +#: ../Doc/extending/extending.rst:468 msgid "" "So far we have concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " @@ -716,7 +717,7 @@ msgid "" "uses are also imaginable." msgstr "" -#: ../Doc/extending/extending.rst:470 +#: ../Doc/extending/extending.rst:476 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (I won't dwell on how to " @@ -725,7 +726,7 @@ msgid "" "line option in :file:`Modules/main.c` from the Python source code.)" msgstr "" -#: ../Doc/extending/extending.rst:476 +#: ../Doc/extending/extending.rst:482 msgid "" "Calling a Python function is easy. First, the Python program must somehow " "pass you the Python function object. You should provide a function (or some " @@ -735,7 +736,7 @@ msgid "" "function might be part of a module definition::" msgstr "" -#: ../Doc/extending/extending.rst:506 +#: ../Doc/extending/extending.rst:512 msgid "" "This function must be registered with the interpreter using the :const:" "`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" @@ -743,7 +744,7 @@ msgid "" "section :ref:`parsetuple`." msgstr "" -#: ../Doc/extending/extending.rst:511 +#: ../Doc/extending/extending.rst:517 msgid "" "The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement " "the reference count of an object and are safe in the presence of *NULL* " @@ -751,7 +752,7 @@ msgid "" "info on them in section :ref:`refcounts`." msgstr "" -#: ../Doc/extending/extending.rst:518 +#: ../Doc/extending/extending.rst:524 msgid "" "Later, when it is time to call the function, you call the C function :c:func:" "`PyObject_CallObject`. This function has two arguments, both pointers to " @@ -763,7 +764,7 @@ msgid "" "or more format codes between parentheses. For example::" msgstr "" -#: ../Doc/extending/extending.rst:538 +#: ../Doc/extending/extending.rst:544 msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " @@ -772,7 +773,7 @@ msgid "" "`Py_DECREF`\\ -ed immediately after the :c:func:`PyObject_CallObject` call." msgstr "" -#: ../Doc/extending/extending.rst:544 +#: ../Doc/extending/extending.rst:550 msgid "" "The return value of :c:func:`PyObject_CallObject` is \"new\": either it is a " "brand new object, or it is an existing object whose reference count has been " @@ -781,7 +782,7 @@ msgid "" "not interested in its value." msgstr "" -#: ../Doc/extending/extending.rst:550 +#: ../Doc/extending/extending.rst:556 msgid "" "Before you do this, however, it is important to check that the return value " "isn't *NULL*. If it is, the Python function terminated by raising an " @@ -792,7 +793,7 @@ msgid "" "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" -#: ../Doc/extending/extending.rst:563 +#: ../Doc/extending/extending.rst:569 msgid "" "Depending on the desired interface to the Python callback function, you may " "also have to provide an argument list to :c:func:`PyObject_CallObject`. In " @@ -804,7 +805,7 @@ msgid "" "you want to pass an integral event code, you might use the following code::" msgstr "" -#: ../Doc/extending/extending.rst:582 +#: ../Doc/extending/extending.rst:588 msgid "" "Note the placement of ``Py_DECREF(arglist)`` immediately after the call, " "before the error check! Also note that strictly speaking this code is not " @@ -812,22 +813,22 @@ msgid "" "checked." msgstr "" -#: ../Doc/extending/extending.rst:586 +#: ../Doc/extending/extending.rst:592 msgid "" "You may also call a function with keyword arguments by using :c:func:" "`PyObject_Call`, which supports arguments and keyword arguments. As in the " "above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" msgstr "" -#: ../Doc/extending/extending.rst:604 +#: ../Doc/extending/extending.rst:610 msgid "Extracting Parameters in Extension Functions" msgstr "" -#: ../Doc/extending/extending.rst:608 +#: ../Doc/extending/extending.rst:614 msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" msgstr "" -#: ../Doc/extending/extending.rst:612 +#: ../Doc/extending/extending.rst:618 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " "from Python to a C function. The *format* argument must be a format string, " @@ -836,7 +837,7 @@ msgid "" "whose type is determined by the format string." msgstr "" -#: ../Doc/extending/extending.rst:618 +#: ../Doc/extending/extending.rst:624 msgid "" "Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments " "have the required types, it cannot check the validity of the addresses of C " @@ -844,7 +845,7 @@ msgid "" "probably crash or at least overwrite random bits in memory. So be careful!" msgstr "" -#: ../Doc/extending/extending.rst:623 +#: ../Doc/extending/extending.rst:629 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" @@ -853,20 +854,20 @@ msgstr "" "à l'appelant sont des références *empruntées* ; ne décrémentez pas leur " "compteur de références !" -#: ../Doc/extending/extending.rst:626 +#: ../Doc/extending/extending.rst:632 msgid "Some example calls::" msgstr "" -#: ../Doc/extending/extending.rst:696 +#: ../Doc/extending/extending.rst:702 msgid "Keyword Parameters for Extension Functions" msgstr "" -#: ../Doc/extending/extending.rst:700 +#: ../Doc/extending/extending.rst:706 msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr "" -#: ../Doc/extending/extending.rst:705 +#: ../Doc/extending/extending.rst:711 msgid "" "The *arg* and *format* parameters are identical to those of the :c:func:" "`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " @@ -877,30 +878,30 @@ msgid "" "returns true, otherwise it returns false and raises an appropriate exception." msgstr "" -#: ../Doc/extending/extending.rst:715 +#: ../Doc/extending/extending.rst:721 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " "parameters passed in which are not present in the *kwlist* will cause :exc:" "`TypeError` to be raised." msgstr "" -#: ../Doc/extending/extending.rst:721 +#: ../Doc/extending/extending.rst:727 msgid "" "Here is an example module which uses keywords, based on an example by Geoff " "Philbrick (philbrick@hks.com)::" msgstr "" -#: ../Doc/extending/extending.rst:775 +#: ../Doc/extending/extending.rst:781 msgid "Building Arbitrary Values" msgstr "" -#: ../Doc/extending/extending.rst:777 +#: ../Doc/extending/extending.rst:783 msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "" -#: ../Doc/extending/extending.rst:782 +#: ../Doc/extending/extending.rst:788 msgid "" "It recognizes a set of format units similar to the ones recognized by :c:" "func:`PyArg_ParseTuple`, but the arguments (which are input to the function, " @@ -908,7 +909,7 @@ msgid "" "object, suitable for returning from a C function called from Python." msgstr "" -#: ../Doc/extending/extending.rst:787 +#: ../Doc/extending/extending.rst:793 msgid "" "One difference with :c:func:`PyArg_ParseTuple`: while the latter requires " "its first argument to be a tuple (since Python argument lists are always " @@ -920,16 +921,16 @@ msgid "" "parenthesize the format string." msgstr "" -#: ../Doc/extending/extending.rst:795 +#: ../Doc/extending/extending.rst:801 msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "" -#: ../Doc/extending/extending.rst:821 +#: ../Doc/extending/extending.rst:827 msgid "Reference Counts" msgstr "" -#: ../Doc/extending/extending.rst:823 +#: ../Doc/extending/extending.rst:829 msgid "" "In languages like C or C++, the programmer is responsible for dynamic " "allocation and deallocation of memory on the heap. In C, this is done using " @@ -938,7 +939,7 @@ msgid "" "restrict the following discussion to the C case." msgstr "" -#: ../Doc/extending/extending.rst:829 +#: ../Doc/extending/extending.rst:835 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " "returned to the pool of available memory by exactly one call to :c:func:" @@ -953,7 +954,7 @@ msgid "" "crashes." msgstr "" -#: ../Doc/extending/extending.rst:840 +#: ../Doc/extending/extending.rst:846 msgid "" "Common causes of memory leaks are unusual paths through the code. For " "instance, a function may allocate a block of memory, do some calculation, " @@ -970,7 +971,7 @@ msgid "" "of errors." msgstr "" -#: ../Doc/extending/extending.rst:853 +#: ../Doc/extending/extending.rst:859 msgid "" "Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it " "needs a strategy to avoid memory leaks as well as the use of freed memory. " @@ -981,7 +982,7 @@ msgid "" "reference to the object has been deleted and the object is freed." msgstr "" -#: ../Doc/extending/extending.rst:861 +#: ../Doc/extending/extending.rst:867 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -997,7 +998,7 @@ msgid "" "with reference counts." msgstr "" -#: ../Doc/extending/extending.rst:873 +#: ../Doc/extending/extending.rst:879 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1011,7 +1012,7 @@ msgid "" "though there are no further references to the cycle itself." msgstr "" -#: ../Doc/extending/extending.rst:884 +#: ../Doc/extending/extending.rst:890 msgid "" "The cycle detector is able to detect garbage cycles and can reclaim them. " "The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." @@ -1023,11 +1024,11 @@ msgid "" "detector is disabled in this way, the :mod:`gc` module will not be available." msgstr "" -#: ../Doc/extending/extending.rst:898 +#: ../Doc/extending/extending.rst:904 msgid "Reference Counting in Python" msgstr "" -#: ../Doc/extending/extending.rst:900 +#: ../Doc/extending/extending.rst:906 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " "the incrementing and decrementing of the reference count. :c:func:" @@ -1038,7 +1039,7 @@ msgid "" "object." msgstr "" -#: ../Doc/extending/extending.rst:907 +#: ../Doc/extending/extending.rst:913 msgid "" "The big question now remains: when to use ``Py_INCREF(x)`` and " "``Py_DECREF(x)``? Let's first introduce some terms. Nobody \"owns\" an " @@ -1051,7 +1052,7 @@ msgid "" "reference creates a memory leak." msgstr "" -#: ../Doc/extending/extending.rst:916 +#: ../Doc/extending/extending.rst:922 msgid "" "It is also possible to :dfn:`borrow` [#]_ a reference to an object. The " "borrower of a reference should not call :c:func:`Py_DECREF`. The borrower " @@ -1060,7 +1061,7 @@ msgid "" "risks using freed memory and should be avoided completely [#]_." msgstr "" -#: ../Doc/extending/extending.rst:922 +#: ../Doc/extending/extending.rst:928 msgid "" "The advantage of borrowing over owning a reference is that you don't need to " "take care of disposing of the reference on all possible paths through the " @@ -1071,7 +1072,7 @@ msgid "" "borrowed has in fact disposed of it." msgstr "" -#: ../Doc/extending/extending.rst:930 +#: ../Doc/extending/extending.rst:936 msgid "" "A borrowed reference can be changed into an owned reference by calling :c:" "func:`Py_INCREF`. This does not affect the status of the owner from which " @@ -1080,18 +1081,18 @@ msgid "" "properly, as well as the previous owner)." msgstr "" -#: ../Doc/extending/extending.rst:940 +#: ../Doc/extending/extending.rst:946 msgid "Ownership Rules" msgstr "" -#: ../Doc/extending/extending.rst:942 +#: ../Doc/extending/extending.rst:948 msgid "" "Whenever an object reference is passed into or out of a function, it is part " "of the function's interface specification whether ownership is transferred " "with the reference or not." msgstr "" -#: ../Doc/extending/extending.rst:946 +#: ../Doc/extending/extending.rst:952 msgid "" "Most functions that return a reference to an object pass on ownership with " "the reference. In particular, all functions whose function it is to create " @@ -1102,7 +1103,7 @@ msgid "" "reference to a cached item." msgstr "" -#: ../Doc/extending/extending.rst:954 +#: ../Doc/extending/extending.rst:960 msgid "" "Many functions that extract objects from other objects also transfer " "ownership with the reference, for instance :c:func:" @@ -1113,14 +1114,14 @@ msgid "" "list or dictionary." msgstr "" -#: ../Doc/extending/extending.rst:961 +#: ../Doc/extending/extending.rst:967 msgid "" "The function :c:func:`PyImport_AddModule` also returns a borrowed reference, " "even though it may actually create the object it returns: this is possible " "because an owned reference to the object is stored in ``sys.modules``." msgstr "" -#: ../Doc/extending/extending.rst:965 +#: ../Doc/extending/extending.rst:971 msgid "" "When you pass an object reference into another function, in general, the " "function borrows the reference from you --- if it needs to store it, it will " @@ -1131,7 +1132,7 @@ msgid "" "don't take over ownership --- they are \"normal.\")" msgstr "" -#: ../Doc/extending/extending.rst:973 +#: ../Doc/extending/extending.rst:979 msgid "" "When a C function is called from Python, it borrows references to its " "arguments from the caller. The caller owns a reference to the object, so " @@ -1140,18 +1141,18 @@ msgid "" "turned into an owned reference by calling :c:func:`Py_INCREF`." msgstr "" -#: ../Doc/extending/extending.rst:979 +#: ../Doc/extending/extending.rst:985 msgid "" "The object reference returned from a C function that is called from Python " "must be an owned reference --- ownership is transferred from the function to " "its caller." msgstr "" -#: ../Doc/extending/extending.rst:987 +#: ../Doc/extending/extending.rst:993 msgid "Thin Ice" msgstr "" -#: ../Doc/extending/extending.rst:989 +#: ../Doc/extending/extending.rst:995 msgid "" "There are a few situations where seemingly harmless use of a borrowed " "reference can lead to problems. These all have to do with implicit " @@ -1159,21 +1160,21 @@ msgid "" "dispose of it." msgstr "" -#: ../Doc/extending/extending.rst:993 +#: ../Doc/extending/extending.rst:999 msgid "" "The first and most important case to know about is using :c:func:`Py_DECREF` " "on an unrelated object while borrowing a reference to a list item. For " "instance::" msgstr "" -#: ../Doc/extending/extending.rst:1005 +#: ../Doc/extending/extending.rst:1011 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " "``list[1]`` with the value ``0``, and finally prints the borrowed reference. " "Looks harmless, right? But it's not!" msgstr "" -#: ../Doc/extending/extending.rst:1009 +#: ../Doc/extending/extending.rst:1015 msgid "" "Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns " "references to all its items, so when item 1 is replaced, it has to dispose " @@ -1183,7 +1184,7 @@ msgid "" "count of 1, disposing of it will call its :meth:`__del__` method." msgstr "" -#: ../Doc/extending/extending.rst:1016 +#: ../Doc/extending/extending.rst:1022 msgid "" "Since it is written in Python, the :meth:`__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -1194,20 +1195,20 @@ msgid "" "associated with it, thereby invalidating ``item``." msgstr "" -#: ../Doc/extending/extending.rst:1024 +#: ../Doc/extending/extending.rst:1030 msgid "" "The solution, once you know the source of the problem, is easy: temporarily " "increment the reference count. The correct version of the function reads::" msgstr "" -#: ../Doc/extending/extending.rst:1038 +#: ../Doc/extending/extending.rst:1044 msgid "" "This is a true story. An older version of Python contained variants of this " "bug and someone spent a considerable amount of time in a C debugger to " "figure out why his :meth:`__del__` methods would fail..." msgstr "" -#: ../Doc/extending/extending.rst:1042 +#: ../Doc/extending/extending.rst:1048 msgid "" "The second case of problems with a borrowed reference is a variant involving " "threads. Normally, multiple threads in the Python interpreter can't get in " @@ -1220,11 +1221,11 @@ msgid "" "previous one::" msgstr "" -#: ../Doc/extending/extending.rst:1065 +#: ../Doc/extending/extending.rst:1071 msgid "NULL Pointers" msgstr "" -#: ../Doc/extending/extending.rst:1067 +#: ../Doc/extending/extending.rst:1073 msgid "" "In general, functions that take object references as arguments do not expect " "you to pass them *NULL* pointers, and will dump core (or cause later core " @@ -1236,21 +1237,21 @@ msgid "" "slowly." msgstr "" -#: ../Doc/extending/extending.rst:1075 +#: ../Doc/extending/extending.rst:1081 msgid "" "It is better to test for *NULL* only at the \"source:\" when a pointer that " "may be *NULL* is received, for example, from :c:func:`malloc` or from a " "function that may raise an exception." msgstr "" -#: ../Doc/extending/extending.rst:1079 +#: ../Doc/extending/extending.rst:1085 msgid "" "The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for " "*NULL* pointers --- however, their variants :c:func:`Py_XINCREF` and :c:func:" "`Py_XDECREF` do." msgstr "" -#: ../Doc/extending/extending.rst:1083 +#: ../Doc/extending/extending.rst:1089 msgid "" "The macros for checking for a particular object type (``Pytype_Check()``) " "don't check for *NULL* pointers --- again, there is much code that calls " @@ -1259,24 +1260,24 @@ msgid "" "variants with *NULL* checking." msgstr "" -#: ../Doc/extending/extending.rst:1089 +#: ../Doc/extending/extending.rst:1095 msgid "" "The C function calling mechanism guarantees that the argument list passed to " "C functions (``args`` in the examples) is never *NULL* --- in fact it " "guarantees that it is always a tuple [#]_." msgstr "" -#: ../Doc/extending/extending.rst:1093 +#: ../Doc/extending/extending.rst:1099 msgid "" "It is a severe error to ever let a *NULL* pointer \"escape\" to the Python " "user." msgstr "" -#: ../Doc/extending/extending.rst:1104 +#: ../Doc/extending/extending.rst:1110 msgid "Writing Extensions in C++" msgstr "" -#: ../Doc/extending/extending.rst:1106 +#: ../Doc/extending/extending.rst:1112 msgid "" "It is possible to write extension modules in C++. Some restrictions apply. " "If the main program (the Python interpreter) is compiled and linked by the C " @@ -1289,11 +1290,11 @@ msgid "" "(all recent C++ compilers define this symbol)." msgstr "" -#: ../Doc/extending/extending.rst:1120 +#: ../Doc/extending/extending.rst:1126 msgid "Providing a C API for an Extension Module" msgstr "" -#: ../Doc/extending/extending.rst:1125 +#: ../Doc/extending/extending.rst:1131 msgid "" "Many extension modules just provide new functions and types to be used from " "Python, but sometimes the code in an extension module can be useful for " @@ -1304,7 +1305,7 @@ msgid "" "functions for direct manipulation from other extension modules." msgstr "" -#: ../Doc/extending/extending.rst:1133 +#: ../Doc/extending/extending.rst:1139 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -1320,7 +1321,7 @@ msgid "" "call might not have been loaded yet!" msgstr "" -#: ../Doc/extending/extending.rst:1145 +#: ../Doc/extending/extending.rst:1151 msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " @@ -1330,7 +1331,7 @@ msgid "" "accessible from other extension modules must be exported in a different way." msgstr "" -#: ../Doc/extending/extending.rst:1152 +#: ../Doc/extending/extending.rst:1158 msgid "" "Python provides a special mechanism to pass C-level information (pointers) " "from one extension module to another one: Capsules. A Capsule is a Python " @@ -1342,7 +1343,7 @@ msgid "" "the Capsule." msgstr "" -#: ../Doc/extending/extending.rst:1160 +#: ../Doc/extending/extending.rst:1166 msgid "" "There are many ways in which Capsules can be used to export the C API of an " "extension module. Each function could get its own Capsule, or all C API " @@ -1352,7 +1353,7 @@ msgid "" "client modules." msgstr "" -#: ../Doc/extending/extending.rst:1166 +#: ../Doc/extending/extending.rst:1172 msgid "" "Whichever method you choose, it's important to name your Capsules properly. " "The function :c:func:`PyCapsule_New` takes a name parameter (:c:type:`const " @@ -1362,13 +1363,13 @@ msgid "" "from another." msgstr "" -#: ../Doc/extending/extending.rst:1173 +#: ../Doc/extending/extending.rst:1179 msgid "" "In particular, Capsules used to expose C APIs should be given a name " "following this convention::" msgstr "" -#: ../Doc/extending/extending.rst:1178 +#: ../Doc/extending/extending.rst:1184 msgid "" "The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " "C API provided via a Capsule, but only if the Capsule's name matches this " @@ -1376,7 +1377,7 @@ msgid "" "the Capsule they load contains the correct C API." msgstr "" -#: ../Doc/extending/extending.rst:1183 +#: ../Doc/extending/extending.rst:1189 msgid "" "The following example demonstrates an approach that puts most of the burden " "on the writer of the exporting module, which is appropriate for commonly " @@ -1387,7 +1388,7 @@ msgid "" "modules only have to call this macro before accessing the C API." msgstr "" -#: ../Doc/extending/extending.rst:1191 +#: ../Doc/extending/extending.rst:1197 msgid "" "The exporting module is a modification of the :mod:`spam` module from " "section :ref:`extending-simpleexample`. The function :func:`spam.system` " @@ -1397,25 +1398,25 @@ msgid "" "function :c:func:`PySpam_System` is also exported to other extension modules." msgstr "" -#: ../Doc/extending/extending.rst:1198 +#: ../Doc/extending/extending.rst:1204 msgid "" "The function :c:func:`PySpam_System` is a plain C function, declared " "``static`` like everything else::" msgstr "" -#: ../Doc/extending/extending.rst:1207 +#: ../Doc/extending/extending.rst:1213 msgid "The function :c:func:`spam_system` is modified in a trivial way::" msgstr "" -#: ../Doc/extending/extending.rst:1221 +#: ../Doc/extending/extending.rst:1227 msgid "In the beginning of the module, right after the line ::" msgstr "" -#: ../Doc/extending/extending.rst:1225 +#: ../Doc/extending/extending.rst:1231 msgid "two more lines must be added::" msgstr "" -#: ../Doc/extending/extending.rst:1230 +#: ../Doc/extending/extending.rst:1236 msgid "" "The ``#define`` is used to tell the header file that it is being included in " "the exporting module, not a client module. Finally, the module's " @@ -1423,33 +1424,33 @@ msgid "" "array::" msgstr "" -#: ../Doc/extending/extending.rst:1256 +#: ../Doc/extending/extending.rst:1262 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " "would disappear when :func:`PyInit_spam` terminates!" msgstr "" -#: ../Doc/extending/extending.rst:1259 +#: ../Doc/extending/extending.rst:1265 msgid "" "The bulk of the work is in the header file :file:`spammodule.h`, which looks " "like this::" msgstr "" -#: ../Doc/extending/extending.rst:1310 +#: ../Doc/extending/extending.rst:1316 msgid "" "All that a client module must do in order to have access to the function :c:" "func:`PySpam_System` is to call the function (or rather macro) :c:func:" "`import_spam` in its initialization function::" msgstr "" -#: ../Doc/extending/extending.rst:1328 +#: ../Doc/extending/extending.rst:1334 msgid "" "The main disadvantage of this approach is that the file :file:`spammodule.h` " "is rather complicated. However, the basic structure is the same for each " "function that is exported, so it has to be learned only once." msgstr "" -#: ../Doc/extending/extending.rst:1332 +#: ../Doc/extending/extending.rst:1338 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -1459,30 +1460,30 @@ msgid "" "in the Python source code distribution)." msgstr "" -#: ../Doc/extending/extending.rst:1340 +#: ../Doc/extending/extending.rst:1346 msgid "Footnotes" msgstr "Notes" -#: ../Doc/extending/extending.rst:1341 +#: ../Doc/extending/extending.rst:1347 msgid "" "An interface for this function already exists in the standard module :mod:" "`os` --- it was chosen as a simple and straightforward example." msgstr "" -#: ../Doc/extending/extending.rst:1344 +#: ../Doc/extending/extending.rst:1350 msgid "" "The metaphor of \"borrowing\" a reference is not completely correct: the " "owner still has a copy of the reference." msgstr "" -#: ../Doc/extending/extending.rst:1347 +#: ../Doc/extending/extending.rst:1353 msgid "" "Checking that the reference count is at least 1 **does not work** --- the " "reference count itself could be in freed memory and may thus be reused for " "another object!" msgstr "" -#: ../Doc/extending/extending.rst:1351 +#: ../Doc/extending/extending.rst:1357 msgid "" "These guarantees don't hold when you use the \"old\" style calling " "convention --- this is still found in much existing code." diff --git a/extending/index.po b/extending/index.po index d6231934..4392e89b 100644 --- a/extending/index.po +++ b/extending/index.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-05-27 19:40+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: 2017-11-22 10:45+0100\n" "Last-Translator: Julien Palard \n" "Language-Team: \n" @@ -69,18 +69,20 @@ msgid "Recommended third party tools" msgstr "Les outils tiers recommandés" #: ../Doc/extending/index.rst:28 +#, fuzzy msgid "" "This guide only covers the basic tools for creating extensions provided as " -"part of this version of CPython. Third party tools like Cython, ``cffi``, " -"SWIG and Numba offer both simpler and more sophisticated approaches to " -"creating C and C++ extensions for Python." +"part of this version of CPython. Third party tools like `Cython `_, `cffi `_, `SWIG `_ and `Numba `_ offer both simpler and " +"more sophisticated approaches to creating C and C++ extensions for Python." msgstr "" "Ce guide ne couvre que les outils basiques permettant de créer des " "extensions fournies dans cette version de CPython. Les outils tiers tels que " "Cython, ``cffi``, SWIG et Numba offrent des approches plus simples et plus " "élaborées pour créer des extensions C et C++ pour Python." -#: ../Doc/extending/index.rst:38 +#: ../Doc/extending/index.rst:40 msgid "" "`Python Packaging User Guide: Binary Extensions `_" @@ -88,7 +90,7 @@ msgstr "" "`Guide d'utilisation de l'empaquetage Python : Extensions binaires `_" -#: ../Doc/extending/index.rst:36 +#: ../Doc/extending/index.rst:38 msgid "" "The Python Packaging User Guide not only covers several available tools that " "simplify the creation of binary extensions, but also discusses the various " @@ -99,11 +101,11 @@ msgstr "" "binaires, mais aborde aussi les différentes raisons pour lesquelles créer un " "module d'extension peut être souhaitable d'entrée." -#: ../Doc/extending/index.rst:43 +#: ../Doc/extending/index.rst:45 msgid "Creating extensions without third party tools" msgstr "Création d'extensions sans outils tiers" -#: ../Doc/extending/index.rst:45 +#: ../Doc/extending/index.rst:47 msgid "" "This section of the guide covers creating C and C++ extensions without " "assistance from third party tools. It is intended primarily for creators of " @@ -115,11 +117,11 @@ msgstr "" "ces outils, plus que d'être une méthode recommandée pour créer votre propre " "extension C." -#: ../Doc/extending/index.rst:60 +#: ../Doc/extending/index.rst:63 msgid "Embedding the CPython runtime in a larger application" msgstr "Intégrer l'interpréteur CPython dans une plus grande application" -#: ../Doc/extending/index.rst:62 +#: ../Doc/extending/index.rst:65 msgid "" "Sometimes, rather than creating an extension that runs inside the Python " "interpreter as the main application, it is desirable to instead embed the " diff --git a/extending/newtypes.po b/extending/newtypes.po index f2c7ed20..262eef35 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-23 09:03+0100\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,846 +17,72 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../Doc/extending/newtypes.rst:8 -msgid "Defining New Types" +#: ../Doc/extending/newtypes.rst:5 +msgid "Defining Extension Types: Assorted Topics" msgstr "" -#: ../Doc/extending/newtypes.rst:15 -msgid "" -"As mentioned in the last chapter, Python allows the writer of an extension " -"module to define new types that can be manipulated from Python code, much " -"like strings and lists in core Python." -msgstr "" - -#: ../Doc/extending/newtypes.rst:19 -msgid "" -"This is not hard; the code for all extension types follows a pattern, but " -"there are some details that you need to understand before you can get " -"started." -msgstr "" - -#: ../Doc/extending/newtypes.rst:26 -msgid "The Basics" -msgstr "" - -#: ../Doc/extending/newtypes.rst:28 -msgid "" -"The Python runtime sees all Python objects as variables of type :c:type:" -"`PyObject\\*`, which serves as a \"base type\" for all Python objects. :c:" -"type:`PyObject` itself only contains the refcount and a pointer to the " -"object's \"type object\". This is where the action is; the type object " -"determines which (C) functions get called when, for instance, an attribute " -"gets looked up on an object or it is multiplied by another object. These C " -"functions are called \"type methods\"." -msgstr "" - -#: ../Doc/extending/newtypes.rst:36 -msgid "" -"So, if you want to define a new object type, you need to create a new type " -"object." -msgstr "" - -#: ../Doc/extending/newtypes.rst:39 -msgid "" -"This sort of thing can only be explained by example, so here's a minimal, " -"but complete, module that defines a new type:" -msgstr "" - -#: ../Doc/extending/newtypes.rst:45 -msgid "" -"Now that's quite a bit to take in at once, but hopefully bits will seem " -"familiar from the last chapter." -msgstr "" - -#: ../Doc/extending/newtypes.rst:48 -msgid "The first bit that will be new is::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:54 -msgid "" -"This is what a Noddy object will contain---in this case, nothing more than " -"what every Python object contains---a field called ``ob_base`` of type :c:" -"type:`PyObject`. :c:type:`PyObject` in turn, contains an ``ob_refcnt`` " -"field and a pointer to a type object. These can be accessed using the " -"macros :c:macro:`Py_REFCNT` and :c:macro:`Py_TYPE` respectively. These are " -"the fields the :c:macro:`PyObject_HEAD` macro brings in. The reason for the " -"macro is to standardize the layout and to enable special debugging fields in " -"debug builds." -msgstr "" - -#: ../Doc/extending/newtypes.rst:62 -msgid "" -"Note that there is no semicolon after the :c:macro:`PyObject_HEAD` macro; " -"one is included in the macro definition. Be wary of adding one by accident; " -"it's easy to do from habit, and your compiler might not complain, but " -"someone else's probably will! (On Windows, MSVC is known to call this an " -"error and refuse to compile the code.)" -msgstr "" - -#: ../Doc/extending/newtypes.rst:68 -msgid "" -"For contrast, let's take a look at the corresponding definition for standard " -"Python floats::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:76 -msgid "Moving on, we come to the crunch --- the type object. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:102 -msgid "" -"Now if you go and look up the definition of :c:type:`PyTypeObject` in :file:" -"`object.h` you'll see that it has many more fields that the definition " -"above. The remaining fields will be filled with zeros by the C compiler, " -"and it's common practice to not specify them explicitly unless you need them." -msgstr "" - -#: ../Doc/extending/newtypes.rst:107 -msgid "" -"This is so important that we're going to pick the top of it apart still " -"further::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:112 -msgid "This line is a bit of a wart; what we'd like to write is::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:116 -msgid "" -"as the type of a type object is \"type\", but this isn't strictly conforming " -"C and some compilers complain. Fortunately, this member will be filled in " -"for us by :c:func:`PyType_Ready`. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:122 -msgid "" -"The name of our type. This will appear in the default textual " -"representation of our objects and in some error messages, for example::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:130 -msgid "" -"Note that the name is a dotted name that includes both the module name and " -"the name of the type within the module. The module in this case is :mod:" -"`noddy` and the type is :class:`Noddy`, so we set the type name to :class:" -"`noddy.Noddy`. One side effect of using an undotted name is that the pydoc " -"documentation tool will not list the new type in the module documentation. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:138 -msgid "" -"This is so that Python knows how much memory to allocate when you call :c:" -"func:`PyObject_New`." -msgstr "" - -#: ../Doc/extending/newtypes.rst:143 -msgid "" -"If you want your type to be subclassable from Python, and your type has the " -"same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " -"problems with multiple inheritance. A Python subclass of your type will " -"have to list your type first in its :attr:`~class.__bases__`, or else it " -"will not be able to call your type's :meth:`__new__` method without getting " -"an error. You can avoid this problem by ensuring that your type has a " -"larger value for :c:member:`~PyTypeObject.tp_basicsize` than its base type " -"does. Most of the time, this will be true anyway, because either your base " -"type will be :class:`object`, or else you will be adding data members to " -"your base type, and therefore increasing its size." -msgstr "" - -#: ../Doc/extending/newtypes.rst:157 -msgid "" -"This has to do with variable length objects like lists and strings. Ignore " -"this for now." -msgstr "" - -#: ../Doc/extending/newtypes.rst:160 -msgid "" -"Skipping a number of type methods that we don't provide, we set the class " -"flags to :const:`Py_TPFLAGS_DEFAULT`. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:165 -msgid "" -"All types should include this constant in their flags. It enables all of " -"the members defined until at least Python 3.3. If you need further members, " -"you will need to OR the corresponding flags." -msgstr "" - -#: ../Doc/extending/newtypes.rst:169 -msgid "" -"We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:173 -msgid "" -"Now we get into the type methods, the things that make your objects " -"different from the others. We aren't going to implement any of these in " -"this version of the module. We'll expand this example later to have more " -"interesting behavior." -msgstr "" - -#: ../Doc/extending/newtypes.rst:177 -msgid "" -"For now, all we want to be able to do is to create new :class:`Noddy` " -"objects. To enable object creation, we have to provide a :c:member:" -"`~PyTypeObject.tp_new` implementation. In this case, we can just use the " -"default implementation provided by the API function :c:func:" -"`PyType_GenericNew`. We'd like to just assign this to the :c:member:" -"`~PyTypeObject.tp_new` slot, but we can't, for portability sake, On some " -"platforms or compilers, we can't statically initialize a structure member " -"with a function defined in another C module, so, instead, we'll assign the :" -"c:member:`~PyTypeObject.tp_new` slot in the module initialization function " -"just before calling :c:func:`PyType_Ready`::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:191 -msgid "" -"All the other type methods are *NULL*, so we'll go over them later --- " -"that's for a later section!" -msgstr "" - -#: ../Doc/extending/newtypes.rst:194 -msgid "" -"Everything else in the file should be familiar, except for some code in :c:" -"func:`PyInit_noddy`::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:200 -msgid "" -"This initializes the :class:`Noddy` type, filing in a number of members, " -"including :attr:`ob_type` that we initially set to *NULL*. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:205 -msgid "" -"This adds the type to the module dictionary. This allows us to create :" -"class:`Noddy` instances by calling the :class:`Noddy` class::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:211 -msgid "" -"That's it! All that remains is to build it; put the above code in a file " -"called :file:`noddy.c` and ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:218 -msgid "in a file called :file:`setup.py`; then typing" -msgstr "" - -#: ../Doc/extending/newtypes.rst:224 -msgid "" -"at a shell should produce a file :file:`noddy.so` in a subdirectory; move to " -"that directory and fire up Python --- you should be able to ``import noddy`` " -"and play around with Noddy objects." -msgstr "" - -#: ../Doc/extending/newtypes.rst:228 -msgid "That wasn't so hard, was it?" -msgstr "" - -#: ../Doc/extending/newtypes.rst:230 -msgid "" -"Of course, the current Noddy type is pretty uninteresting. It has no data " -"and doesn't do anything. It can't even be subclassed." -msgstr "" - -#: ../Doc/extending/newtypes.rst:235 -msgid "Adding data and methods to the Basic example" -msgstr "" - -#: ../Doc/extending/newtypes.rst:237 -msgid "" -"Let's extend the basic example to add some data and methods. Let's also " -"make the type usable as a base class. We'll create a new module, :mod:" -"`noddy2` that adds these capabilities:" -msgstr "" - -#: ../Doc/extending/newtypes.rst:244 -msgid "This version of the module has a number of changes." -msgstr "" - -#: ../Doc/extending/newtypes.rst:246 -msgid "We've added an extra include::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:250 -msgid "" -"This include provides declarations that we use to handle attributes, as " -"described a bit later." -msgstr "" - -#: ../Doc/extending/newtypes.rst:253 -msgid "" -"The name of the :class:`Noddy` object structure has been shortened to :class:" -"`Noddy`. The type object name has been shortened to :class:`NoddyType`." -msgstr "" - -#: ../Doc/extending/newtypes.rst:256 -msgid "" -"The :class:`Noddy` type now has three data attributes, *first*, *last*, and " -"*number*. The *first* and *last* variables are Python strings containing " -"first and last names. The *number* attribute is an integer." -msgstr "" - -#: ../Doc/extending/newtypes.rst:260 -msgid "The object structure is updated accordingly::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:269 -msgid "" -"Because we now have data to manage, we have to be more careful about object " -"allocation and deallocation. At a minimum, we need a deallocation method::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:280 -msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:284 -msgid "" -"This method decrements the reference counts of the two Python attributes. We " -"use :c:func:`Py_XDECREF` here because the :attr:`first` and :attr:`last` " -"members could be *NULL*. It then calls the :c:member:`~PyTypeObject." -"tp_free` member of the object's type to free the object's memory. Note that " -"the object's type might not be :class:`NoddyType`, because the object may be " -"an instance of a subclass." -msgstr "" - -#: ../Doc/extending/newtypes.rst:290 -msgid "" -"We want to make sure that the first and last names are initialized to empty " -"strings, so we provide a new method::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:318 -msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:322 -msgid "" -"The new member is responsible for creating (as opposed to initializing) " -"objects of the type. It is exposed in Python as the :meth:`__new__` " -"method. See the paper titled \"Unifying types and classes in Python\" for a " -"detailed discussion of the :meth:`__new__` method. One reason to implement " -"a new method is to assure the initial values of instance variables. In this " -"case, we use the new method to make sure that the initial values of the " -"members :attr:`first` and :attr:`last` are not *NULL*. If we didn't care " -"whether the initial values were *NULL*, we could have used :c:func:" -"`PyType_GenericNew` as our new method, as we did before. :c:func:" -"`PyType_GenericNew` initializes all of the instance variable members to " -"*NULL*." -msgstr "" - -#: ../Doc/extending/newtypes.rst:333 -msgid "" -"The new method is a static method that is passed the type being instantiated " -"and any arguments passed when the type was called, and that returns the new " -"object created. New methods always accept positional and keyword arguments, " -"but they often ignore the arguments, leaving the argument handling to " -"initializer methods. Note that if the type supports subclassing, the type " -"passed may not be the type being defined. The new method calls the :c:" -"member:`~PyTypeObject.tp_alloc` slot to allocate memory. We don't fill the :" -"c:member:`~PyTypeObject.tp_alloc` slot ourselves. Rather :c:func:" -"`PyType_Ready` fills it for us by inheriting it from our base class, which " -"is :class:`object` by default. Most types use the default allocation." -msgstr "" - -#: ../Doc/extending/newtypes.rst:345 -msgid "" -"If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one " -"that calls a base type's :c:member:`~PyTypeObject.tp_new` or :meth:" -"`__new__`), you must *not* try to determine what method to call using method " -"resolution order at runtime. Always statically determine what type you are " -"going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or " -"via ``type->tp_base->tp_new``. If you do not do this, Python subclasses of " -"your type that also inherit from other Python-defined classes may not work " -"correctly. (Specifically, you may not be able to create instances of such " -"subclasses without getting a :exc:`TypeError`.)" -msgstr "" - -#: ../Doc/extending/newtypes.rst:354 -msgid "We provide an initialization function::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:385 -msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:389 -msgid "" -"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:" -"`__init__` method. It is used to initialize an object after it's created. " -"Unlike the new method, we can't guarantee that the initializer is called. " -"The initializer isn't called when unpickling objects and it can be " -"overridden. Our initializer accepts arguments to provide initial values for " -"our instance. Initializers always accept positional and keyword arguments. " -"Initializers should return either ``0`` on success or ``-1`` on error." -msgstr "" - -#: ../Doc/extending/newtypes.rst:397 -msgid "" -"Initializers can be called multiple times. Anyone can call the :meth:" -"`__init__` method on our objects. For this reason, we have to be extra " -"careful when assigning the new values. We might be tempted, for example to " -"assign the :attr:`first` member like this::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:408 -msgid "" -"But this would be risky. Our type doesn't restrict the type of the :attr:" -"`first` member, so it could be any kind of object. It could have a " -"destructor that causes code to be executed that tries to access the :attr:" -"`first` member. To be paranoid and protect ourselves against this " -"possibility, we almost always reassign members before decrementing their " -"reference counts. When don't we have to do this?" -msgstr "" - -#: ../Doc/extending/newtypes.rst:415 -msgid "when we absolutely know that the reference count is greater than 1" -msgstr "" - -#: ../Doc/extending/newtypes.rst:417 -msgid "" -"when we know that deallocation of the object [#]_ will not cause any calls " -"back into our type's code" -msgstr "" - -#: ../Doc/extending/newtypes.rst:420 -msgid "" -"when decrementing a reference count in a :c:member:`~PyTypeObject." -"tp_dealloc` handler when garbage-collections is not supported [#]_" -msgstr "" - -#: ../Doc/extending/newtypes.rst:423 -msgid "" -"We want to expose our instance variables as attributes. There are a number " -"of ways to do that. The simplest way is to define member definitions::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:436 -msgid "" -"and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:440 -msgid "" -"Each member definition has a member name, type, offset, access flags and " -"documentation string. See the :ref:`Generic-Attribute-Management` section " -"below for details." -msgstr "" - -#: ../Doc/extending/newtypes.rst:444 -msgid "" -"A disadvantage of this approach is that it doesn't provide a way to restrict " -"the types of objects that can be assigned to the Python attributes. We " -"expect the first and last names to be strings, but any Python objects can be " -"assigned. Further, the attributes can be deleted, setting the C pointers to " -"*NULL*. Even though we can make sure the members are initialized to non-" -"*NULL* values, the members can be set to *NULL* if the attributes are " -"deleted." -msgstr "" - -#: ../Doc/extending/newtypes.rst:451 -msgid "" -"We define a single method, :meth:`name`, that outputs the objects name as " -"the concatenation of the first and last names. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:470 -msgid "" -"The method is implemented as a C function that takes a :class:`Noddy` (or :" -"class:`Noddy` subclass) instance as the first argument. Methods always take " -"an instance as the first argument. Methods often take positional and keyword " -"arguments as well, but in this case we don't take any and don't need to " -"accept a positional argument tuple or keyword argument dictionary. This " -"method is equivalent to the Python method::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:480 -msgid "" -"Note that we have to check for the possibility that our :attr:`first` and :" -"attr:`last` members are *NULL*. This is because they can be deleted, in " -"which case they are set to *NULL*. It would be better to prevent deletion " -"of these attributes and to restrict the attribute values to be strings. " -"We'll see how to do that in the next section." -msgstr "" - -#: ../Doc/extending/newtypes.rst:486 -msgid "" -"Now that we've defined the method, we need to create an array of method " -"definitions::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:496 -msgid "and assign them to the :c:member:`~PyTypeObject.tp_methods` slot::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:500 -msgid "" -"Note that we used the :const:`METH_NOARGS` flag to indicate that the method " -"is passed no arguments." -msgstr "" - -#: ../Doc/extending/newtypes.rst:503 -msgid "" -"Finally, we'll make our type usable as a base class. We've written our " -"methods carefully so far so that they don't make any assumptions about the " -"type of the object being created or used, so all we need to do is to add " -"the :const:`Py_TPFLAGS_BASETYPE` to our class flag definition::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:510 -msgid "" -"We rename :c:func:`PyInit_noddy` to :c:func:`PyInit_noddy2` and update the " -"module name in the :c:type:`PyModuleDef` struct." -msgstr "" - -#: ../Doc/extending/newtypes.rst:513 -msgid "Finally, we update our :file:`setup.py` file to build the new module::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:524 -msgid "Providing finer control over data attributes" -msgstr "" - -#: ../Doc/extending/newtypes.rst:526 -msgid "" -"In this section, we'll provide finer control over how the :attr:`first` and :" -"attr:`last` attributes are set in the :class:`Noddy` example. In the " -"previous version of our module, the instance variables :attr:`first` and :" -"attr:`last` could be set to non-string values or even deleted. We want to " -"make sure that these attributes always contain strings." -msgstr "" - -#: ../Doc/extending/newtypes.rst:535 -msgid "" -"To provide greater control, over the :attr:`first` and :attr:`last` " -"attributes, we'll use custom getter and setter functions. Here are the " -"functions for getting and setting the :attr:`first` attribute::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:566 -msgid "" -"The getter function is passed a :class:`Noddy` object and a \"closure\", " -"which is void pointer. In this case, the closure is ignored. (The closure " -"supports an advanced usage in which definition data is passed to the getter " -"and setter. This could, for example, be used to allow a single set of getter " -"and setter functions that decide the attribute to get or set based on data " -"in the closure.)" -msgstr "" - -#: ../Doc/extending/newtypes.rst:572 -msgid "" -"The setter function is passed the :class:`Noddy` object, the new value, and " -"the closure. The new value may be *NULL*, in which case the attribute is " -"being deleted. In our setter, we raise an error if the attribute is deleted " -"or if the attribute value is not a string." -msgstr "" - -#: ../Doc/extending/newtypes.rst:577 -msgid "We create an array of :c:type:`PyGetSetDef` structures::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:591 -msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:595 -msgid "to register our attribute getters and setters." -msgstr "" - -#: ../Doc/extending/newtypes.rst:597 -msgid "" -"The last item in a :c:type:`PyGetSetDef` structure is the closure mentioned " -"above. In this case, we aren't using the closure, so we just pass *NULL*." -msgstr "" - -#: ../Doc/extending/newtypes.rst:600 -msgid "We also remove the member definitions for these attributes::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:608 -msgid "" -"We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " -"allow strings [#]_ to be passed::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:640 -msgid "" -"With these changes, we can assure that the :attr:`first` and :attr:`last` " -"members are never *NULL* so we can remove checks for *NULL* values in almost " -"all cases. This means that most of the :c:func:`Py_XDECREF` calls can be " -"converted to :c:func:`Py_DECREF` calls. The only place we can't change these " -"calls is in the deallocator, where there is the possibility that the " -"initialization of these members failed in the constructor." -msgstr "" - -#: ../Doc/extending/newtypes.rst:647 -msgid "" -"We also rename the module initialization function and module name in the " -"initialization function, as we did before, and we add an extra definition to " -"the :file:`setup.py` file." -msgstr "" - -#: ../Doc/extending/newtypes.rst:653 -msgid "Supporting cyclic garbage collection" -msgstr "" - -#: ../Doc/extending/newtypes.rst:655 -msgid "" -"Python has a cyclic-garbage collector that can identify unneeded objects " -"even when their reference counts are not zero. This can happen when objects " -"are involved in cycles. For example, consider::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:663 -msgid "" -"In this example, we create a list that contains itself. When we delete it, " -"it still has a reference from itself. Its reference count doesn't drop to " -"zero. Fortunately, Python's cyclic-garbage collector will eventually figure " -"out that the list is garbage and free it." -msgstr "" - -#: ../Doc/extending/newtypes.rst:668 -msgid "" -"In the second version of the :class:`Noddy` example, we allowed any kind of " -"object to be stored in the :attr:`first` or :attr:`last` attributes [#]_. " -"This means that :class:`Noddy` objects can participate in cycles::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:677 -msgid "" -"This is pretty silly, but it gives us an excuse to add support for the " -"cyclic-garbage collector to the :class:`Noddy` example. To support cyclic " -"garbage collection, types need to fill two slots and set a class flag that " -"enables these slots:" -msgstr "" - -#: ../Doc/extending/newtypes.rst:685 -msgid "" -"The traversal method provides access to subobjects that could participate in " -"cycles::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:707 -msgid "" -"For each subobject that can participate in cycles, we need to call the :c:" -"func:`visit` function, which is passed to the traversal method. The :c:func:" -"`visit` function takes as arguments the subobject and the extra argument " -"*arg* passed to the traversal method. It returns an integer value that must " -"be returned if it is non-zero." -msgstr "" - -#: ../Doc/extending/newtypes.rst:713 -msgid "" -"Python provides a :c:func:`Py_VISIT` macro that automates calling visit " -"functions. With :c:func:`Py_VISIT`, :c:func:`Noddy_traverse` can be " -"simplified::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:726 -msgid "" -"Note that the :c:member:`~PyTypeObject.tp_traverse` implementation must name " -"its arguments exactly *visit* and *arg* in order to use :c:func:`Py_VISIT`. " -"This is to encourage uniformity across these boring implementations." -msgstr "" - -#: ../Doc/extending/newtypes.rst:730 -msgid "" -"We also need to provide a method for clearing any subobjects that can " -"participate in cycles." -msgstr "" - -#: ../Doc/extending/newtypes.rst:751 -msgid "" -"Notice the use of a temporary variable in :c:func:`Noddy_clear`. We use the " -"temporary variable so that we can set each member to *NULL* before " -"decrementing its reference count. We do this because, as was discussed " -"earlier, if the reference count drops to zero, we might cause code to run " -"that calls back into the object. In addition, because we now support " -"garbage collection, we also have to worry about code being run that triggers " -"garbage collection. If garbage collection is run, our :c:member:" -"`~PyTypeObject.tp_traverse` handler could get called. We can't take a chance " -"of having :c:func:`Noddy_traverse` called when a member's reference count " -"has dropped to zero and its value hasn't been set to *NULL*." -msgstr "" - -#: ../Doc/extending/newtypes.rst:761 -msgid "" -"Python provides a :c:func:`Py_CLEAR` that automates the careful decrementing " -"of reference counts. With :c:func:`Py_CLEAR`, the :c:func:`Noddy_clear` " -"function can be simplified::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:773 -msgid "" -"Note that :c:func:`Noddy_dealloc` may call arbitrary functions through " -"``__del__`` method or weakref callback. It means circular GC can be " -"triggered inside the function. Since GC assumes reference count is not " -"zero, we need to untrack the object from GC by calling :c:func:" -"`PyObject_GC_UnTrack` before clearing members. Here is reimplemented " -"deallocator which uses :c:func:`PyObject_GC_UnTrack` and :c:func:" -"`Noddy_clear`." -msgstr "" - -#: ../Doc/extending/newtypes.rst:790 -msgid "" -"Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:794 -msgid "" -"That's pretty much it. If we had written custom :c:member:`~PyTypeObject." -"tp_alloc` or :c:member:`~PyTypeObject.tp_free` slots, we'd need to modify " -"them for cyclic-garbage collection. Most extensions will use the versions " -"automatically provided." -msgstr "" - -#: ../Doc/extending/newtypes.rst:800 -msgid "Subclassing other types" -msgstr "" - -#: ../Doc/extending/newtypes.rst:802 -msgid "" -"It is possible to create new extension types that are derived from existing " -"types. It is easiest to inherit from the built in types, since an extension " -"can easily use the :class:`PyTypeObject` it needs. It can be difficult to " -"share these :class:`PyTypeObject` structures between extension modules." -msgstr "" - -#: ../Doc/extending/newtypes.rst:807 -msgid "" -"In this example we will create a :class:`Shoddy` type that inherits from the " -"built-in :class:`list` type. The new type will be completely compatible with " -"regular lists, but will have an additional :meth:`increment` method that " -"increases an internal counter. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:825 -msgid "" -"As you can see, the source code closely resembles the :class:`Noddy` " -"examples in previous sections. We will break down the main differences " -"between them. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:833 -msgid "" -"The primary difference for derived type objects is that the base type's " -"object structure must be the first value. The base type will already include " -"the :c:func:`PyObject_HEAD` at the beginning of its structure." -msgstr "" - -#: ../Doc/extending/newtypes.rst:837 -msgid "" -"When a Python object is a :class:`Shoddy` instance, its *PyObject\\** " -"pointer can be safely cast to both *PyListObject\\** and *Shoddy\\**. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:849 -msgid "" -"In the :attr:`__init__` method for our type, we can see how to call through " -"to the :attr:`__init__` method of the base type." -msgstr "" - -#: ../Doc/extending/newtypes.rst:852 -msgid "" -"This pattern is important when writing a type with custom :attr:`new` and :" -"attr:`dealloc` methods. The :attr:`new` method should not actually create " -"the memory for the object with :c:member:`~PyTypeObject.tp_alloc`, that will " -"be handled by the base class when calling its :c:member:`~PyTypeObject." -"tp_new`." -msgstr "" - -#: ../Doc/extending/newtypes.rst:857 -msgid "" -"When filling out the :c:func:`PyTypeObject` for the :class:`Shoddy` type, " -"you see a slot for :c:func:`tp_base`. Due to cross platform compiler issues, " -"you can't fill that field directly with the :c:func:`PyList_Type`; it can be " -"done later in the module's :c:func:`init` function. ::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:880 -msgid "" -"Before calling :c:func:`PyType_Ready`, the type structure must have the :c:" -"member:`~PyTypeObject.tp_base` slot filled in. When we are deriving a new " -"type, it is not necessary to fill out the :c:member:`~PyTypeObject.tp_alloc` " -"slot with :c:func:`PyType_GenericNew` -- the allocate function from the base " -"type will be inherited." -msgstr "" - -#: ../Doc/extending/newtypes.rst:885 -msgid "" -"After that, calling :c:func:`PyType_Ready` and adding the type object to the " -"module is the same as with the basic :class:`Noddy` examples." -msgstr "" - -#: ../Doc/extending/newtypes.rst:892 -msgid "Type Methods" -msgstr "" - -#: ../Doc/extending/newtypes.rst:894 +#: ../Doc/extending/newtypes.rst:9 msgid "" "This section aims to give a quick fly-by on the various type methods you can " "implement and what they do." msgstr "" -#: ../Doc/extending/newtypes.rst:897 +#: ../Doc/extending/newtypes.rst:12 msgid "" "Here is the definition of :c:type:`PyTypeObject`, with some fields only used " "in debug builds omitted:" msgstr "" -#: ../Doc/extending/newtypes.rst:903 +#: ../Doc/extending/newtypes.rst:18 msgid "" -"Now that's a *lot* of methods. Don't worry too much though - if you have a " +"Now that's a *lot* of methods. Don't worry too much though -- if you have a " "type you want to define, the chances are very good that you will only " "implement a handful of these." msgstr "" -#: ../Doc/extending/newtypes.rst:907 +#: ../Doc/extending/newtypes.rst:22 msgid "" "As you probably expect by now, we're going to go over this and give more " "information about the various handlers. We won't go in the order they are " "defined in the structure, because there is a lot of historical baggage that " -"impacts the ordering of the fields; be sure your type initialization keeps " -"the fields in the right order! It's often easiest to find an example that " -"includes all the fields you need (even if they're initialized to ``0``) and " -"then change the values to suit your new type. ::" +"impacts the ordering of the fields. It's often easiest to find an example " +"that includes the fields you need and then change the values to suit your " +"new type. ::" msgstr "" -#: ../Doc/extending/newtypes.rst:917 +#: ../Doc/extending/newtypes.rst:31 msgid "" -"The name of the type - as mentioned in the last section, this will appear in " -"various places, almost entirely for diagnostic purposes. Try to choose " -"something that will be helpful in such a situation! ::" +"The name of the type -- as mentioned in the previous chapter, this will " +"appear in various places, almost entirely for diagnostic purposes. Try to " +"choose something that will be helpful in such a situation! ::" msgstr "" -#: ../Doc/extending/newtypes.rst:923 +#: ../Doc/extending/newtypes.rst:37 msgid "" "These fields tell the runtime how much memory to allocate when new objects " "of this type are created. Python has some built-in support for variable " -"length structures (think: strings, lists) which is where the :c:member:" +"length structures (think: strings, tuples) which is where the :c:member:" "`~PyTypeObject.tp_itemsize` field comes in. This will be dealt with " "later. ::" msgstr "" -#: ../Doc/extending/newtypes.rst:930 +#: ../Doc/extending/newtypes.rst:44 msgid "" "Here you can put a string (or its address) that you want returned when the " "Python script references ``obj.__doc__`` to retrieve the doc string." msgstr "" -#: ../Doc/extending/newtypes.rst:933 +#: ../Doc/extending/newtypes.rst:47 msgid "" -"Now we come to the basic type methods---the ones most extension types will " +"Now we come to the basic type methods -- the ones most extension types will " "implement." msgstr "" -#: ../Doc/extending/newtypes.rst:938 +#: ../Doc/extending/newtypes.rst:52 msgid "Finalization and De-allocation" msgstr "" -#: ../Doc/extending/newtypes.rst:950 +#: ../Doc/extending/newtypes.rst:64 msgid "" "This function is called when the reference count of the instance of your " "type is reduced to zero and the Python interpreter wants to reclaim it. If " @@ -865,7 +91,7 @@ msgid "" "of this function::" msgstr "" -#: ../Doc/extending/newtypes.rst:967 +#: ../Doc/extending/newtypes.rst:81 msgid "" "One important requirement of the deallocator function is that it leaves any " "pending exceptions alone. This is important since deallocators are " @@ -880,7 +106,7 @@ msgid "" "c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` functions::" msgstr "" -#: ../Doc/extending/newtypes.rst:1006 +#: ../Doc/extending/newtypes.rst:120 msgid "" "There are limitations to what you can safely do in a deallocator function. " "First, if your type supports garbage collection (using :c:member:" @@ -893,43 +119,43 @@ msgid "" "tp_dealloc` again, causing a double free and a crash." msgstr "" -#: ../Doc/extending/newtypes.rst:1015 +#: ../Doc/extending/newtypes.rst:129 msgid "" "Starting with Python 3.4, it is recommended not to put any complex " "finalization code in :c:member:`~PyTypeObject.tp_dealloc`, and instead use " "the new :c:member:`~PyTypeObject.tp_finalize` type method." msgstr "" -#: ../Doc/extending/newtypes.rst:1020 +#: ../Doc/extending/newtypes.rst:134 msgid ":pep:`442` explains the new finalization scheme." msgstr "" -#: ../Doc/extending/newtypes.rst:1027 +#: ../Doc/extending/newtypes.rst:141 msgid "Object Presentation" msgstr "" -#: ../Doc/extending/newtypes.rst:1029 +#: ../Doc/extending/newtypes.rst:143 msgid "" "In Python, there are two ways to generate a textual representation of an " "object: the :func:`repr` function, and the :func:`str` function. (The :func:" "`print` function just calls :func:`str`.) These handlers are both optional." msgstr "" -#: ../Doc/extending/newtypes.rst:1038 +#: ../Doc/extending/newtypes.rst:152 msgid "" "The :c:member:`~PyTypeObject.tp_repr` handler should return a string object " "containing a representation of the instance for which it is called. Here is " "a simple example::" msgstr "" -#: ../Doc/extending/newtypes.rst:1049 +#: ../Doc/extending/newtypes.rst:163 msgid "" "If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the " "interpreter will supply a representation that uses the type's :c:member:" "`~PyTypeObject.tp_name` and a uniquely-identifying value for the object." msgstr "" -#: ../Doc/extending/newtypes.rst:1053 +#: ../Doc/extending/newtypes.rst:167 msgid "" "The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:" "member:`~PyTypeObject.tp_repr` handler described above is to :func:`repr`; " @@ -940,15 +166,15 @@ msgid "" "the :c:member:`~PyTypeObject.tp_repr` handler is used instead." msgstr "" -#: ../Doc/extending/newtypes.rst:1060 +#: ../Doc/extending/newtypes.rst:174 msgid "Here is a simple example::" msgstr "" -#: ../Doc/extending/newtypes.rst:1072 +#: ../Doc/extending/newtypes.rst:186 msgid "Attribute Management" msgstr "" -#: ../Doc/extending/newtypes.rst:1074 +#: ../Doc/extending/newtypes.rst:188 msgid "" "For every object which can support attributes, the corresponding type must " "provide the functions that control how the attributes are resolved. There " @@ -958,7 +184,7 @@ msgid "" "handler is *NULL*." msgstr "" -#: ../Doc/extending/newtypes.rst:1080 +#: ../Doc/extending/newtypes.rst:194 msgid "" "Python supports two pairs of attribute handlers; a type that supports " "attributes only needs to implement the functions for one pair. The " @@ -967,7 +193,7 @@ msgid "" "use whichever pair makes more sense for the implementation's convenience. ::" msgstr "" -#: ../Doc/extending/newtypes.rst:1092 +#: ../Doc/extending/newtypes.rst:206 msgid "" "If accessing attributes of an object is always a simple operation (this will " "be explained shortly), there are generic implementations which can be used " @@ -978,35 +204,35 @@ msgid "" "mechanism that is available." msgstr "" -#: ../Doc/extending/newtypes.rst:1103 +#: ../Doc/extending/newtypes.rst:217 msgid "Generic Attribute Management" msgstr "" -#: ../Doc/extending/newtypes.rst:1105 +#: ../Doc/extending/newtypes.rst:219 msgid "" "Most extension types only use *simple* attributes. So, what makes the " "attributes simple? There are only a couple of conditions that must be met:" msgstr "" -#: ../Doc/extending/newtypes.rst:1108 +#: ../Doc/extending/newtypes.rst:222 msgid "" "The name of the attributes must be known when :c:func:`PyType_Ready` is " "called." msgstr "" -#: ../Doc/extending/newtypes.rst:1111 +#: ../Doc/extending/newtypes.rst:225 msgid "" "No special processing is needed to record that an attribute was looked up or " "set, nor do actions need to be taken based on the value." msgstr "" -#: ../Doc/extending/newtypes.rst:1114 +#: ../Doc/extending/newtypes.rst:228 msgid "" "Note that this list does not place any restrictions on the values of the " "attributes, when the values are computed, or how relevant data is stored." msgstr "" -#: ../Doc/extending/newtypes.rst:1117 +#: ../Doc/extending/newtypes.rst:231 msgid "" "When :c:func:`PyType_Ready` is called, it uses three tables referenced by " "the type object to create :term:`descriptor`\\s which are placed in the " @@ -1018,18 +244,18 @@ msgid "" "*NULL* as well, allowing the base type to handle attributes." msgstr "" -#: ../Doc/extending/newtypes.rst:1125 +#: ../Doc/extending/newtypes.rst:239 msgid "The tables are declared as three fields of the type object::" msgstr "" -#: ../Doc/extending/newtypes.rst:1131 +#: ../Doc/extending/newtypes.rst:245 msgid "" "If :c:member:`~PyTypeObject.tp_methods` is not *NULL*, it must refer to an " "array of :c:type:`PyMethodDef` structures. Each entry in the table is an " "instance of this structure::" msgstr "" -#: ../Doc/extending/newtypes.rst:1142 +#: ../Doc/extending/newtypes.rst:256 msgid "" "One entry should be defined for each method provided by the type; no entries " "are needed for methods inherited from a base type. One additional entry is " @@ -1037,7 +263,7 @@ msgid "" "attr:`ml_name` field of the sentinel must be *NULL*." msgstr "" -#: ../Doc/extending/newtypes.rst:1147 +#: ../Doc/extending/newtypes.rst:261 msgid "" "The second table is used to define attributes which map directly to data " "stored in the instance. A variety of primitive C types are supported, and " @@ -1045,7 +271,7 @@ msgid "" "defined as::" msgstr "" -#: ../Doc/extending/newtypes.rst:1159 +#: ../Doc/extending/newtypes.rst:273 msgid "" "For each entry in the table, a :term:`descriptor` will be constructed and " "added to the type which will be able to extract a value from the instance " @@ -1056,53 +282,53 @@ msgid "" "accessed." msgstr "" -#: ../Doc/extending/newtypes.rst:1166 +#: ../Doc/extending/newtypes.rst:280 msgid "" "The following flag constants are defined in :file:`structmember.h`; they may " "be combined using bitwise-OR." msgstr "" -#: ../Doc/extending/newtypes.rst:1170 +#: ../Doc/extending/newtypes.rst:284 msgid "Constant" msgstr "Constante" -#: ../Doc/extending/newtypes.rst:1170 +#: ../Doc/extending/newtypes.rst:284 msgid "Meaning" msgstr "Signification" -#: ../Doc/extending/newtypes.rst:1172 +#: ../Doc/extending/newtypes.rst:286 msgid ":const:`READONLY`" msgstr "" -#: ../Doc/extending/newtypes.rst:1172 +#: ../Doc/extending/newtypes.rst:286 msgid "Never writable." msgstr "" -#: ../Doc/extending/newtypes.rst:1174 +#: ../Doc/extending/newtypes.rst:288 msgid ":const:`READ_RESTRICTED`" msgstr "" -#: ../Doc/extending/newtypes.rst:1174 +#: ../Doc/extending/newtypes.rst:288 msgid "Not readable in restricted mode." msgstr "" -#: ../Doc/extending/newtypes.rst:1176 +#: ../Doc/extending/newtypes.rst:290 msgid ":const:`WRITE_RESTRICTED`" msgstr "" -#: ../Doc/extending/newtypes.rst:1176 +#: ../Doc/extending/newtypes.rst:290 msgid "Not writable in restricted mode." msgstr "" -#: ../Doc/extending/newtypes.rst:1178 +#: ../Doc/extending/newtypes.rst:292 msgid ":const:`RESTRICTED`" msgstr "" -#: ../Doc/extending/newtypes.rst:1178 +#: ../Doc/extending/newtypes.rst:292 msgid "Not readable or writable in restricted mode." msgstr "" -#: ../Doc/extending/newtypes.rst:1187 +#: ../Doc/extending/newtypes.rst:301 msgid "" "An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` " "table to build descriptors that are used at runtime is that any attribute " @@ -1112,17 +338,17 @@ msgid "" "`__doc__` attribute." msgstr "" -#: ../Doc/extending/newtypes.rst:1193 +#: ../Doc/extending/newtypes.rst:307 msgid "" "As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry " "with a :attr:`name` value of *NULL* is required." msgstr "" -#: ../Doc/extending/newtypes.rst:1207 +#: ../Doc/extending/newtypes.rst:321 msgid "Type-specific Attribute Management" msgstr "" -#: ../Doc/extending/newtypes.rst:1209 +#: ../Doc/extending/newtypes.rst:323 msgid "" "For simplicity, only the :c:type:`char\\*` version will be demonstrated " "here; the type of the name parameter is the only difference between the :c:" @@ -1133,18 +359,18 @@ msgid "" "functionality, you'll understand what needs to be done." msgstr "" -#: ../Doc/extending/newtypes.rst:1217 +#: ../Doc/extending/newtypes.rst:331 msgid "" "The :c:member:`~PyTypeObject.tp_getattr` handler is called when the object " "requires an attribute look-up. It is called in the same situations where " "the :meth:`__getattr__` method of a class would be called." msgstr "" -#: ../Doc/extending/newtypes.rst:1221 +#: ../Doc/extending/newtypes.rst:335 msgid "Here is an example::" msgstr "Voici un exemple : ::" -#: ../Doc/extending/newtypes.rst:1237 +#: ../Doc/extending/newtypes.rst:351 msgid "" "The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:" "`__setattr__` or :meth:`__delattr__` method of a class instance would be " @@ -1154,11 +380,11 @@ msgid "" "should be set to *NULL*. ::" msgstr "" -#: ../Doc/extending/newtypes.rst:1251 +#: ../Doc/extending/newtypes.rst:365 msgid "Object Comparison" msgstr "" -#: ../Doc/extending/newtypes.rst:1257 +#: ../Doc/extending/newtypes.rst:371 msgid "" "The :c:member:`~PyTypeObject.tp_richcompare` handler is called when " "comparisons are needed. It is analogous to the :ref:`rich comparison " @@ -1166,7 +392,7 @@ msgid "" "`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." msgstr "" -#: ../Doc/extending/newtypes.rst:1262 +#: ../Doc/extending/newtypes.rst:376 msgid "" "This function is called with two Python objects and the operator as " "arguments, where the operator is one of ``Py_EQ``, ``Py_NE``, ``Py_LE``, " @@ -1177,23 +403,23 @@ msgid "" "should be tried, or *NULL* if an exception was set." msgstr "" -#: ../Doc/extending/newtypes.rst:1270 +#: ../Doc/extending/newtypes.rst:384 msgid "" "Here is a sample implementation, for a datatype that is considered equal if " "the size of an internal pointer is equal::" msgstr "" -#: ../Doc/extending/newtypes.rst:1300 +#: ../Doc/extending/newtypes.rst:414 msgid "Abstract Protocol Support" msgstr "" -#: ../Doc/extending/newtypes.rst:1302 +#: ../Doc/extending/newtypes.rst:416 msgid "" "Python supports a variety of *abstract* 'protocols;' the specific interfaces " "provided to use these interfaces are documented in :ref:`abstract`." msgstr "" -#: ../Doc/extending/newtypes.rst:1306 +#: ../Doc/extending/newtypes.rst:420 msgid "" "A number of these abstract interfaces were defined early in the development " "of the Python implementation. In particular, the number, mapping, and " @@ -1208,7 +434,7 @@ msgid "" "slot, but a slot may still be unfilled.) ::" msgstr "" -#: ../Doc/extending/newtypes.rst:1321 +#: ../Doc/extending/newtypes.rst:435 msgid "" "If you wish your object to be able to act like a number, a sequence, or a " "mapping object, then you place the address of a structure that implements " @@ -1219,13 +445,21 @@ msgid "" "distribution. ::" msgstr "" -#: ../Doc/extending/newtypes.rst:1330 +#: ../Doc/extending/newtypes.rst:444 msgid "" "This function, if you choose to provide it, should return a hash number for " -"an instance of your data type. Here is a moderately pointless example::" +"an instance of your data type. Here is a simple example::" msgstr "" -#: ../Doc/extending/newtypes.rst:1346 +#: ../Doc/extending/newtypes.rst:457 +msgid "" +":c:type:`Py_hash_t` is a signed integer type with a platform-varying width. " +"Returning ``-1`` from :c:member:`~PyTypeObject.tp_hash` indicates an error, " +"which is why you should be careful to avoid returning it when hash " +"computation is successful, as seen above." +msgstr "" + +#: ../Doc/extending/newtypes.rst:466 msgid "" "This function is called when an instance of your data type is \"called\", " "for example, if ``obj1`` is an instance of your data type and the Python " @@ -1233,173 +467,170 @@ msgid "" "handler is invoked." msgstr "" -#: ../Doc/extending/newtypes.rst:1350 +#: ../Doc/extending/newtypes.rst:470 msgid "This function takes three arguments:" msgstr "" -#: ../Doc/extending/newtypes.rst:1352 +#: ../Doc/extending/newtypes.rst:472 msgid "" -"*arg1* is the instance of the data type which is the subject of the call. If " -"the call is ``obj1('hello')``, then *arg1* is ``obj1``." +"*self* is the instance of the data type which is the subject of the call. If " +"the call is ``obj1('hello')``, then *self* is ``obj1``." msgstr "" -#: ../Doc/extending/newtypes.rst:1355 +#: ../Doc/extending/newtypes.rst:475 msgid "" -"*arg2* is a tuple containing the arguments to the call. You can use :c:func:" +"*args* is a tuple containing the arguments to the call. You can use :c:func:" "`PyArg_ParseTuple` to extract the arguments." msgstr "" -#: ../Doc/extending/newtypes.rst:1358 +#: ../Doc/extending/newtypes.rst:478 msgid "" -"*arg3* is a dictionary of keyword arguments that were passed. If this is non-" +"*kwds* is a dictionary of keyword arguments that were passed. If this is non-" "*NULL* and you support keyword arguments, use :c:func:" "`PyArg_ParseTupleAndKeywords` to extract the arguments. If you do not want " "to support keyword arguments and this is non-*NULL*, raise a :exc:" "`TypeError` with a message saying that keyword arguments are not supported." msgstr "" -#: ../Doc/extending/newtypes.rst:1364 -msgid "" -"Here is a desultory example of the implementation of the call function. ::" +#: ../Doc/extending/newtypes.rst:484 +msgid "Here is a toy ``tp_call`` implementation::" msgstr "" -#: ../Doc/extending/newtypes.rst:1395 +#: ../Doc/extending/newtypes.rst:510 msgid "" -"These functions provide support for the iterator protocol. Any object which " -"wishes to support iteration over its contents (which may be generated during " -"iteration) must implement the ``tp_iter`` handler. Objects which are " -"returned by a ``tp_iter`` handler must implement both the ``tp_iter`` and " -"``tp_iternext`` handlers. Both handlers take exactly one parameter, the " -"instance for which they are being called, and return a new reference. In " -"the case of an error, they should set an exception and return *NULL*." +"These functions provide support for the iterator protocol. Both handlers " +"take exactly one parameter, the instance for which they are being called, " +"and return a new reference. In the case of an error, they should set an " +"exception and return *NULL*. :c:member:`~PyTypeObject.tp_iter` corresponds " +"to the Python :meth:`__iter__` method, while :c:member:`~PyTypeObject." +"tp_iternext` corresponds to the Python :meth:`~iterator.__next__` method." msgstr "" -#: ../Doc/extending/newtypes.rst:1403 +#: ../Doc/extending/newtypes.rst:517 msgid "" -"For an object which represents an iterable collection, the ``tp_iter`` " -"handler must return an iterator object. The iterator object is responsible " -"for maintaining the state of the iteration. For collections which can " -"support multiple iterators which do not interfere with each other (as lists " -"and tuples do), a new iterator should be created and returned. Objects " -"which can only be iterated over once (usually due to side effects of " -"iteration) should implement this handler by returning a new reference to " -"themselves, and should also implement the ``tp_iternext`` handler. File " -"objects are an example of such an iterator." +"Any :term:`iterable` object must implement the :c:member:`~PyTypeObject." +"tp_iter` handler, which must return an :term:`iterator` object. Here the " +"same guidelines apply as for Python classes:" msgstr "" -#: ../Doc/extending/newtypes.rst:1413 +#: ../Doc/extending/newtypes.rst:521 msgid "" -"Iterator objects should implement both handlers. The ``tp_iter`` handler " -"should return a new reference to the iterator (this is the same as the " -"``tp_iter`` handler for objects which can only be iterated over " -"destructively). The ``tp_iternext`` handler should return a new reference " -"to the next object in the iteration if there is one. If the iteration has " -"reached the end, it may return *NULL* without setting an exception or it may " -"set :exc:`StopIteration`; avoiding the exception can yield slightly better " -"performance. If an actual error occurs, it should set an exception and " -"return *NULL*." +"For collections (such as lists and tuples) which can support multiple " +"independent iterators, a new iterator should be created and returned by each " +"call to :c:member:`~PyTypeObject.tp_iter`." msgstr "" -#: ../Doc/extending/newtypes.rst:1426 +#: ../Doc/extending/newtypes.rst:524 +msgid "" +"Objects which can only be iterated over once (usually due to side effects of " +"iteration, such as file objects) can implement :c:member:`~PyTypeObject." +"tp_iter` by returning a new reference to themselves -- and should also " +"therefore implement the :c:member:`~PyTypeObject.tp_iternext` handler." +msgstr "" + +#: ../Doc/extending/newtypes.rst:529 +msgid "" +"Any :term:`iterator` object should implement both :c:member:`~PyTypeObject." +"tp_iter` and :c:member:`~PyTypeObject.tp_iternext`. An iterator's :c:member:" +"`~PyTypeObject.tp_iter` handler should return a new reference to the " +"iterator. Its :c:member:`~PyTypeObject.tp_iternext` handler should return a " +"new reference to the next object in the iteration, if there is one. If the " +"iteration has reached the end, :c:member:`~PyTypeObject.tp_iternext` may " +"return *NULL* without setting an exception, or it may set :exc:" +"`StopIteration` *in addition* to returning *NULL*; avoiding the exception " +"can yield slightly better performance. If an actual error occurs, :c:member:" +"`~PyTypeObject.tp_iternext` should always set an exception and return *NULL*." +msgstr "" + +#: ../Doc/extending/newtypes.rst:545 msgid "Weak Reference Support" msgstr "" -#: ../Doc/extending/newtypes.rst:1428 +#: ../Doc/extending/newtypes.rst:547 msgid "" -"One of the goals of Python's weak-reference implementation is to allow any " +"One of the goals of Python's weak reference implementation is to allow any " "type to participate in the weak reference mechanism without incurring the " -"overhead on those objects which do not benefit by weak referencing (such as " -"numbers)." +"overhead on performance-critical objects (such as numbers)." msgstr "" -#: ../Doc/extending/newtypes.rst:1432 +#: ../Doc/extending/newtypes.rst:552 +msgid "Documentation for the :mod:`weakref` module." +msgstr "" + +#: ../Doc/extending/newtypes.rst:554 msgid "" -"For an object to be weakly referencable, the extension must include a :c:" -"type:`PyObject\\*` field in the instance structure for the use of the weak " -"reference mechanism; it must be initialized to *NULL* by the object's " -"constructor. It must also set the :c:member:`~PyTypeObject." -"tp_weaklistoffset` field of the corresponding type object to the offset of " -"the field. For example, the instance type is defined with the following " -"structure::" +"For an object to be weakly referencable, the extension type must do two " +"things:" msgstr "" -#: ../Doc/extending/newtypes.rst:1446 -msgid "The statically-declared type object for instances is defined this way::" -msgstr "" - -#: ../Doc/extending/newtypes.rst:1463 +#: ../Doc/extending/newtypes.rst:556 msgid "" -"The type constructor is responsible for initializing the weak reference list " -"to *NULL*::" +"Include a :c:type:`PyObject\\*` field in the C object structure dedicated to " +"the weak reference mechanism. The object's constructor should leave it " +"*NULL* (which is automatic when using the default :c:member:`~PyTypeObject." +"tp_alloc`)." msgstr "" -#: ../Doc/extending/newtypes.rst:1475 +#: ../Doc/extending/newtypes.rst:561 msgid "" -"The only further addition is that the destructor needs to call the weak " -"reference manager to clear any weak references. This is only required if " -"the weak reference list is non-*NULL*::" +"Set the :c:member:`~PyTypeObject.tp_weaklistoffset` type member to the " +"offset of the aforementioned field in the C object structure, so that the " +"interpreter knows how to access and modify that field." msgstr "" -#: ../Doc/extending/newtypes.rst:1494 +#: ../Doc/extending/newtypes.rst:565 +msgid "" +"Concretely, here is how a trivial object structure would be augmented with " +"the required field::" +msgstr "" + +#: ../Doc/extending/newtypes.rst:573 +msgid "And the corresponding member in the statically-declared type object::" +msgstr "" + +#: ../Doc/extending/newtypes.rst:581 +msgid "" +"The only further addition is that ``tp_dealloc`` needs to clear any weak " +"references (by calling :c:func:`PyObject_ClearWeakRefs`) if the field is non-" +"*NULL*::" +msgstr "" + +#: ../Doc/extending/newtypes.rst:597 msgid "More Suggestions" msgstr "" -#: ../Doc/extending/newtypes.rst:1496 -msgid "" -"Remember that you can omit most of these functions, in which case you " -"provide ``0`` as a value. There are type definitions for each of the " -"functions you must provide. They are in :file:`object.h` in the Python " -"include directory that comes with the source distribution of Python." -msgstr "" - -#: ../Doc/extending/newtypes.rst:1501 +#: ../Doc/extending/newtypes.rst:599 msgid "" "In order to learn how to implement any specific method for your new data " -"type, do the following: Download and unpack the Python source distribution. " -"Go to the :file:`Objects` directory, then search the C source files for " -"``tp_`` plus the function you want (for example, ``tp_richcompare``). You " -"will find examples of the function you want to implement." +"type, get the :term:`CPython` source code. Go to the :file:`Objects` " +"directory, then search the C source files for ``tp_`` plus the function you " +"want (for example, ``tp_richcompare``). You will find examples of the " +"function you want to implement." msgstr "" -#: ../Doc/extending/newtypes.rst:1507 +#: ../Doc/extending/newtypes.rst:605 msgid "" -"When you need to verify that an object is an instance of the type you are " -"implementing, use the :c:func:`PyObject_TypeCheck` function. A sample of its " -"use might be something like the following::" +"When you need to verify that an object is a concrete instance of the type " +"you are implementing, use the :c:func:`PyObject_TypeCheck` function. A " +"sample of its use might be something like the following::" msgstr "" -#: ../Doc/extending/newtypes.rst:1517 -msgid "Footnotes" -msgstr "Notes" +#: ../Doc/extending/newtypes.rst:616 +msgid "Download CPython source releases." +msgstr "" -#: ../Doc/extending/newtypes.rst:1518 +#: ../Doc/extending/newtypes.rst:616 +msgid "https://www.python.org/downloads/source/" +msgstr "" + +#: ../Doc/extending/newtypes.rst:618 msgid "" -"This is true when we know that the object is a basic type, like a string or " -"a float." +"The CPython project on GitHub, where the CPython source code is developed." msgstr "" -#: ../Doc/extending/newtypes.rst:1521 -msgid "" -"We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " -"this example, because our type doesn't support garbage collection. Even if a " -"type supports garbage collection, there are calls that can be made to " -"\"untrack\" the object from garbage collection, however, these calls are " -"advanced and not covered here." +#: ../Doc/extending/newtypes.rst:619 +msgid "https://github.com/python/cpython" msgstr "" -#: ../Doc/extending/newtypes.rst:1526 -msgid "" -"We now know that the first and last members are strings, so perhaps we could " -"be less careful about decrementing their reference counts, however, we " -"accept instances of string subclasses. Even though deallocating normal " -"strings won't call back into our objects, we can't guarantee that " -"deallocating an instance of a string subclass won't call back into our " -"objects." -msgstr "" - -#: ../Doc/extending/newtypes.rst:1532 -msgid "" -"Even in the third version, we aren't guaranteed to avoid cycles. Instances " -"of string subclasses are allowed and string subclasses could allow cycles " -"even if normal strings don't." -msgstr "" +#~ msgid "Footnotes" +#~ msgstr "Notes" diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po new file mode 100644 index 00000000..fc307303 --- /dev/null +++ b/extending/newtypes_tutorial.po @@ -0,0 +1,861 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2018, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.6\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../Doc/extending/newtypes_tutorial.rst:7 +msgid "Defining Extension Types: Tutorial" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:14 +msgid "" +"Python allows the writer of a C extension module to define new types that " +"can be manipulated from Python code, much like the built-in :class:`str` " +"and :class:`list` types. The code for all extension types follows a " +"pattern, but there are some details that you need to understand before you " +"can get started. This document is a gentle introduction to the topic." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:24 +msgid "The Basics" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:26 +msgid "" +"The :term:`CPython` runtime sees all Python objects as variables of type :c:" +"type:`PyObject\\*`, which serves as a \"base type\" for all Python objects. " +"The :c:type:`PyObject` structure itself only contains the object's :term:" +"`reference count` and a pointer to the object's \"type object\". This is " +"where the action is; the type object determines which (C) functions get " +"called by the interpreter when, for instance, an attribute gets looked up on " +"an object, a method called, or it is multiplied by another object. These C " +"functions are called \"type methods\"." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:35 +msgid "" +"So, if you want to define a new extension type, you need to create a new " +"type object." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:38 +msgid "" +"This sort of thing can only be explained by example, so here's a minimal, " +"but complete, module that defines a new type named :class:`Custom` inside a " +"C extension module :mod:`custom`:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:43 +msgid "" +"What we're showing here is the traditional way of defining *static* " +"extension types. It should be adequate for most uses. The C API also " +"allows defining heap-allocated extension types using the :c:func:" +"`PyType_FromSpec` function, which isn't covered in this tutorial." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:50 +msgid "" +"Now that's quite a bit to take in at once, but hopefully bits will seem " +"familiar from the previous chapter. This file defines three things:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:53 +msgid "" +"What a :class:`Custom` **object** contains: this is the ``CustomObject`` " +"struct, which is allocated once for each :class:`Custom` instance." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:55 +msgid "" +"How the :class:`Custom` **type** behaves: this is the ``CustomType`` struct, " +"which defines a set of flags and function pointers that the interpreter " +"inspects when specific operations are requested." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:58 +msgid "" +"How to initialize the :mod:`custom` module: this is the ``PyInit_custom`` " +"function and the associated ``custommodule`` struct." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:61 +msgid "The first bit is::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:67 +msgid "" +"This is what a Custom object will contain. ``PyObject_HEAD`` is mandatory " +"at the start of each object struct and defines a field called ``ob_base`` of " +"type :c:type:`PyObject`, containing a pointer to a type object and a " +"reference count (these can be accessed using the macros :c:macro:`Py_REFCNT` " +"and :c:macro:`Py_TYPE` respectively). The reason for the macro is to " +"abstract away the layout and to enable additional fields in debug builds." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:75 +msgid "" +"There is no semicolon above after the :c:macro:`PyObject_HEAD` macro. Be " +"wary of adding one by accident: some compilers will complain." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:78 +msgid "" +"Of course, objects generally store additional data besides the standard " +"``PyObject_HEAD`` boilerplate; for example, here is the definition for " +"standard Python floats::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:87 +msgid "The second bit is the definition of the type object. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:99 +msgid "" +"We recommend using C99-style designated initializers as above, to avoid " +"listing all the :c:type:`PyTypeObject` fields that you don't care about and " +"also to avoid caring about the fields' declaration order." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:103 +msgid "" +"The actual definition of :c:type:`PyTypeObject` in :file:`object.h` has many " +"more :ref:`fields ` than the definition above. The remaining " +"fields will be filled with zeros by the C compiler, and it's common practice " +"to not specify them explicitly unless you need them." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:108 +msgid "We're going to pick it apart, one field at a time::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:112 +msgid "" +"This line is mandatory boilerplate to initialize the ``ob_base`` field " +"mentioned above. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:117 +msgid "" +"The name of our type. This will appear in the default textual " +"representation of our objects and in some error messages, for example:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:127 +msgid "" +"Note that the name is a dotted name that includes both the module name and " +"the name of the type within the module. The module in this case is :mod:" +"`custom` and the type is :class:`Custom`, so we set the type name to :class:" +"`custom.Custom`. Using the real dotted import path is important to make your " +"type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:136 +msgid "" +"This is so that Python knows how much memory to allocate when creating new :" +"class:`Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is only " +"used for variable-sized objects and should otherwise be zero." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:142 +msgid "" +"If you want your type to be subclassable from Python, and your type has the " +"same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " +"problems with multiple inheritance. A Python subclass of your type will " +"have to list your type first in its :attr:`~class.__bases__`, or else it " +"will not be able to call your type's :meth:`__new__` method without getting " +"an error. You can avoid this problem by ensuring that your type has a " +"larger value for :c:member:`~PyTypeObject.tp_basicsize` than its base type " +"does. Most of the time, this will be true anyway, because either your base " +"type will be :class:`object`, or else you will be adding data members to " +"your base type, and therefore increasing its size." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:152 +msgid "We set the class flags to :const:`Py_TPFLAGS_DEFAULT`. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:156 +msgid "" +"All types should include this constant in their flags. It enables all of " +"the members defined until at least Python 3.3. If you need further members, " +"you will need to OR the corresponding flags." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:160 +msgid "" +"We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:164 +msgid "" +"To enable object creation, we have to provide a :c:member:`~PyTypeObject." +"tp_new` handler. This is the equivalent of the Python method :meth:" +"`__new__`, but has to be specified explicitly. In this case, we can just " +"use the default implementation provided by the API function :c:func:" +"`PyType_GenericNew`. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:171 +msgid "" +"Everything else in the file should be familiar, except for some code in :c:" +"func:`PyInit_custom`::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:177 +msgid "" +"This initializes the :class:`Custom` type, filling in a number of members to " +"the appropriate default values, including :attr:`ob_type` that we initially " +"set to *NULL*. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:183 +msgid "" +"This adds the type to the module dictionary. This allows us to create :" +"class:`Custom` instances by calling the :class:`Custom` class:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:191 +msgid "" +"That's it! All that remains is to build it; put the above code in a file " +"called :file:`custom.c` and:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:200 +msgid "in a file called :file:`setup.py`; then typing" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:206 +msgid "" +"at a shell should produce a file :file:`custom.so` in a subdirectory; move " +"to that directory and fire up Python --- you should be able to ``import " +"custom`` and play around with Custom objects." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:210 +msgid "That wasn't so hard, was it?" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:212 +msgid "" +"Of course, the current Custom type is pretty uninteresting. It has no data " +"and doesn't do anything. It can't even be subclassed." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:216 +msgid "" +"While this documentation showcases the standard :mod:`distutils` module for " +"building C extensions, it is recommended in real-world use cases to use the " +"newer and better-maintained ``setuptools`` library. Documentation on how to " +"do this is out of scope for this document and can be found in the `Python " +"Packaging User's Guide `_." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:224 +msgid "Adding data and methods to the Basic example" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:226 +msgid "" +"Let's extend the basic example to add some data and methods. Let's also " +"make the type usable as a base class. We'll create a new module, :mod:" +"`custom2` that adds these capabilities:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:233 +msgid "This version of the module has a number of changes." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:235 +msgid "We've added an extra include::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:239 +msgid "" +"This include provides declarations that we use to handle attributes, as " +"described a bit later." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:242 +msgid "" +"The :class:`Custom` type now has three data attributes in its C struct, " +"*first*, *last*, and *number*. The *first* and *last* variables are Python " +"strings containing first and last names. The *number* attribute is a C " +"integer." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:246 +msgid "The object structure is updated accordingly::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:255 +msgid "" +"Because we now have data to manage, we have to be more careful about object " +"allocation and deallocation. At a minimum, we need a deallocation method::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:266 +msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:270 +msgid "" +"This method first clears the reference counts of the two Python attributes. :" +"c:func:`Py_XDECREF` correctly handles the case where its argument is *NULL* " +"(which might happen here if ``tp_new`` failed midway). It then calls the :c:" +"member:`~PyTypeObject.tp_free` member of the object's type (computed by " +"``Py_TYPE(self)``) to free the object's memory. Note that the object's type " +"might not be :class:`CustomType`, because the object may be an instance of a " +"subclass." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:279 +msgid "" +"The explicit cast to ``destructor`` above is needed because we defined " +"``Custom_dealloc`` to take a ``CustomObject *`` argument, but the " +"``tp_dealloc`` function pointer expects to receive a ``PyObject *`` " +"argument. Otherwise, the compiler will emit a warning. This is object-" +"oriented polymorphism, in C!" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:285 +msgid "" +"We want to make sure that the first and last names are initialized to empty " +"strings, so we provide a ``tp_new`` implementation::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:309 +msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:313 +msgid "" +"The ``tp_new`` handler is responsible for creating (as opposed to " +"initializing) objects of the type. It is exposed in Python as the :meth:" +"`__new__` method. It is not required to define a ``tp_new`` member, and " +"indeed many extension types will simply reuse :c:func:`PyType_GenericNew` as " +"done in the first version of the ``Custom`` type above. In this case, we " +"use the ``tp_new`` handler to initialize the ``first`` and ``last`` " +"attributes to non-*NULL* default values." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:321 +msgid "" +"``tp_new`` is passed the type being instantiated (not necessarily " +"``CustomType``, if a subclass is instantiated) and any arguments passed when " +"the type was called, and is expected to return the instance created. " +"``tp_new`` handlers always accept positional and keyword arguments, but they " +"often ignore the arguments, leaving the argument handling to initializer (a." +"k.a. ``tp_init`` in C or ``__init__`` in Python) methods." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:329 +msgid "" +"``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do " +"it itself." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:332 +msgid "" +"The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` " +"slot to allocate memory::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:337 +msgid "" +"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject." +"tp_alloc` result against *NULL* before proceeding." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:341 +msgid "" +"We didn't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. " +"Rather :c:func:`PyType_Ready` fills it for us by inheriting it from our base " +"class, which is :class:`object` by default. Most types use the default " +"allocation strategy." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:347 +msgid "" +"If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one " +"that calls a base type's :c:member:`~PyTypeObject.tp_new` or :meth:" +"`__new__`), you must *not* try to determine what method to call using method " +"resolution order at runtime. Always statically determine what type you are " +"going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or " +"via ``type->tp_base->tp_new``. If you do not do this, Python subclasses of " +"your type that also inherit from other Python-defined classes may not work " +"correctly. (Specifically, you may not be able to create instances of such " +"subclasses without getting a :exc:`TypeError`.)" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:357 +msgid "" +"We also define an initialization function which accepts arguments to provide " +"initial values for our instance::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:386 +msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:390 +msgid "" +"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:" +"`__init__` method. It is used to initialize an object after it's created. " +"Initializers always accept positional and keyword arguments, and they should " +"return either ``0`` on success or ``-1`` on error." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:395 +msgid "" +"Unlike the ``tp_new`` handler, there is no guarantee that ``tp_init`` is " +"called at all (for example, the :mod:`pickle` module by default doesn't " +"call :meth:`__init__` on unpickled instances). It can also be called " +"multiple times. Anyone can call the :meth:`__init__` method on our " +"objects. For this reason, we have to be extra careful when assigning the " +"new attribute values. We might be tempted, for example to assign the " +"``first`` member like this::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:409 +msgid "" +"But this would be risky. Our type doesn't restrict the type of the " +"``first`` member, so it could be any kind of object. It could have a " +"destructor that causes code to be executed that tries to access the " +"``first`` member; or that destructor could release the :term:`Global " +"interpreter Lock` and let arbitrary code run in other threads that accesses " +"and modifies our object." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:416 +msgid "" +"To be paranoid and protect ourselves against this possibility, we almost " +"always reassign members before decrementing their reference counts. When " +"don't we have to do this?" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:420 +msgid "when we absolutely know that the reference count is greater than 1;" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:422 +msgid "" +"when we know that deallocation of the object [#]_ will neither release the :" +"term:`GIL` nor cause any calls back into our type's code;" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:425 +msgid "" +"when decrementing a reference count in a :c:member:`~PyTypeObject." +"tp_dealloc` handler on a type which doesn't support cyclic garbage " +"collection [#]_." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:428 +msgid "" +"We want to expose our instance variables as attributes. There are a number " +"of ways to do that. The simplest way is to define member definitions::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:441 +msgid "" +"and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:445 +msgid "" +"Each member definition has a member name, type, offset, access flags and " +"documentation string. See the :ref:`Generic-Attribute-Management` section " +"below for details." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:449 +msgid "" +"A disadvantage of this approach is that it doesn't provide a way to restrict " +"the types of objects that can be assigned to the Python attributes. We " +"expect the first and last names to be strings, but any Python objects can be " +"assigned. Further, the attributes can be deleted, setting the C pointers to " +"*NULL*. Even though we can make sure the members are initialized to non-" +"*NULL* values, the members can be set to *NULL* if the attributes are " +"deleted." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:456 +msgid "" +"We define a single method, :meth:`Custom.name()`, that outputs the objects " +"name as the concatenation of the first and last names. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:473 +msgid "" +"The method is implemented as a C function that takes a :class:`Custom` (or :" +"class:`Custom` subclass) instance as the first argument. Methods always " +"take an instance as the first argument. Methods often take positional and " +"keyword arguments as well, but in this case we don't take any and don't need " +"to accept a positional argument tuple or keyword argument dictionary. This " +"method is equivalent to the Python method:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:485 +msgid "" +"Note that we have to check for the possibility that our :attr:`first` and :" +"attr:`last` members are *NULL*. This is because they can be deleted, in " +"which case they are set to *NULL*. It would be better to prevent deletion " +"of these attributes and to restrict the attribute values to be strings. " +"We'll see how to do that in the next section." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:491 +msgid "" +"Now that we've defined the method, we need to create an array of method " +"definitions::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:501 +msgid "" +"(note that we used the :const:`METH_NOARGS` flag to indicate that the method " +"is expecting no arguments other than *self*)" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:504 +msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:508 +msgid "" +"Finally, we'll make our type usable as a base class for subclassing. We've " +"written our methods carefully so far so that they don't make any assumptions " +"about the type of the object being created or used, so all we need to do is " +"to add the :const:`Py_TPFLAGS_BASETYPE` to our class flag definition::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:515 +msgid "" +"We rename :c:func:`PyInit_custom` to :c:func:`PyInit_custom2`, update the " +"module name in the :c:type:`PyModuleDef` struct, and update the full class " +"name in the :c:type:`PyTypeObject` struct." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:519 +msgid "Finally, we update our :file:`setup.py` file to build the new module:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:532 +msgid "Providing finer control over data attributes" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:534 +msgid "" +"In this section, we'll provide finer control over how the :attr:`first` and :" +"attr:`last` attributes are set in the :class:`Custom` example. In the " +"previous version of our module, the instance variables :attr:`first` and :" +"attr:`last` could be set to non-string values or even deleted. We want to " +"make sure that these attributes always contain strings." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:543 +msgid "" +"To provide greater control, over the :attr:`first` and :attr:`last` " +"attributes, we'll use custom getter and setter functions. Here are the " +"functions for getting and setting the :attr:`first` attribute::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:574 +msgid "" +"The getter function is passed a :class:`Custom` object and a \"closure\", " +"which is a void pointer. In this case, the closure is ignored. (The " +"closure supports an advanced usage in which definition data is passed to the " +"getter and setter. This could, for example, be used to allow a single set of " +"getter and setter functions that decide the attribute to get or set based on " +"data in the closure.)" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:580 +msgid "" +"The setter function is passed the :class:`Custom` object, the new value, and " +"the closure. The new value may be *NULL*, in which case the attribute is " +"being deleted. In our setter, we raise an error if the attribute is deleted " +"or if its new value is not a string." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:585 +msgid "We create an array of :c:type:`PyGetSetDef` structures::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:595 +msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:599 +msgid "" +"The last item in a :c:type:`PyGetSetDef` structure is the \"closure\" " +"mentioned above. In this case, we aren't using a closure, so we just pass " +"*NULL*." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:602 +msgid "We also remove the member definitions for these attributes::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:610 +msgid "" +"We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " +"allow strings [#]_ to be passed::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:639 +msgid "" +"With these changes, we can assure that the ``first`` and ``last`` members " +"are never *NULL* so we can remove checks for *NULL* values in almost all " +"cases. This means that most of the :c:func:`Py_XDECREF` calls can be " +"converted to :c:func:`Py_DECREF` calls. The only place we can't change " +"these calls is in the ``tp_dealloc`` implementation, where there is the " +"possibility that the initialization of these members failed in ``tp_new``." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:646 +msgid "" +"We also rename the module initialization function and module name in the " +"initialization function, as we did before, and we add an extra definition to " +"the :file:`setup.py` file." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:652 +msgid "Supporting cyclic garbage collection" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:654 +msgid "" +"Python has a :term:`cyclic garbage collector (GC) ` that " +"can identify unneeded objects even when their reference counts are not zero. " +"This can happen when objects are involved in cycles. For example, consider:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:664 +msgid "" +"In this example, we create a list that contains itself. When we delete it, " +"it still has a reference from itself. Its reference count doesn't drop to " +"zero. Fortunately, Python's cyclic garbage collector will eventually figure " +"out that the list is garbage and free it." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:669 +msgid "" +"In the second version of the :class:`Custom` example, we allowed any kind of " +"object to be stored in the :attr:`first` or :attr:`last` attributes [#]_. " +"Besides, in the second and third versions, we allowed subclassing :class:" +"`Custom`, and subclasses may add arbitrary attributes. For any of those two " +"reasons, :class:`Custom` objects can participate in cycles:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:683 +msgid "" +"To allow a :class:`Custom` instance participating in a reference cycle to be " +"properly detected and collected by the cyclic GC, our :class:`Custom` type " +"needs to fill two additional slots and to enable a flag that enables these " +"slots:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:690 +msgid "" +"First, the traversal method lets the cyclic GC know about subobjects that " +"could participate in cycles::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:710 +msgid "" +"For each subobject that can participate in cycles, we need to call the :c:" +"func:`visit` function, which is passed to the traversal method. The :c:func:" +"`visit` function takes as arguments the subobject and the extra argument " +"*arg* passed to the traversal method. It returns an integer value that must " +"be returned if it is non-zero." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:716 +msgid "" +"Python provides a :c:func:`Py_VISIT` macro that automates calling visit " +"functions. With :c:func:`Py_VISIT`, we can minimize the amount of " +"boilerplate in ``Custom_traverse``::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:729 +msgid "" +"The :c:member:`~PyTypeObject.tp_traverse` implementation must name its " +"arguments exactly *visit* and *arg* in order to use :c:func:`Py_VISIT`." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:732 +msgid "" +"Second, we need to provide a method for clearing any subobjects that can " +"participate in cycles::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:743 +msgid "" +"Notice the use of the :c:func:`Py_CLEAR` macro. It is the recommended and " +"safe way to clear data attributes of arbitrary types while decrementing " +"their reference counts. If you were to call :c:func:`Py_XDECREF` instead on " +"the attribute before setting it to *NULL*, there is a possibility that the " +"attribute's destructor would call back into code that reads the attribute " +"again (*especially* if there is a reference cycle)." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:751 +msgid "You could emulate :c:func:`Py_CLEAR` by writing::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:758 +msgid "" +"Nevertheless, it is much easier and less error-prone to always use :c:func:" +"`Py_CLEAR` when deleting an attribute. Don't try to micro-optimize at the " +"expense of robustness!" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:762 +msgid "" +"The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " +"attributes. It means the circular GC can be triggered inside the function. " +"Since the GC assumes reference count is not zero, we need to untrack the " +"object from the GC by calling :c:func:`PyObject_GC_UnTrack` before clearing " +"members. Here is our reimplemented deallocator using :c:func:" +"`PyObject_GC_UnTrack` and ``Custom_clear``::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:777 +msgid "" +"Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:781 +msgid "" +"That's pretty much it. If we had written custom :c:member:`~PyTypeObject." +"tp_alloc` or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify " +"them for cyclic garbage collection. Most extensions will use the versions " +"automatically provided." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:787 +msgid "Subclassing other types" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:789 +msgid "" +"It is possible to create new extension types that are derived from existing " +"types. It is easiest to inherit from the built in types, since an extension " +"can easily use the :c:type:`PyTypeObject` it needs. It can be difficult to " +"share these :c:type:`PyTypeObject` structures between extension modules." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:794 +msgid "" +"In this example we will create a :class:`SubList` type that inherits from " +"the built-in :class:`list` type. The new type will be completely compatible " +"with regular lists, but will have an additional :meth:`increment` method " +"that increases an internal counter:" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:814 +msgid "" +"As you can see, the source code closely resembles the :class:`Custom` " +"examples in previous sections. We will break down the main differences " +"between them. ::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:822 +msgid "" +"The primary difference for derived type objects is that the base type's " +"object structure must be the first value. The base type will already " +"include the :c:func:`PyObject_HEAD` at the beginning of its structure." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:826 +msgid "" +"When a Python object is a :class:`SubList` instance, its ``PyObject *`` " +"pointer can be safely cast to both ``PyListObject *`` and ``SubListObject " +"*``::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:838 +msgid "" +"We see above how to call through to the :attr:`__init__` method of the base " +"type." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:841 +msgid "" +"This pattern is important when writing a type with custom :c:member:" +"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " +"The :c:member:`~PyTypeObject.tp_new` handler should not actually create the " +"memory for the object with its :c:member:`~PyTypeObject.tp_alloc`, but let " +"the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:847 +msgid "" +"The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." +"tp_base` specifying the type's concrete base class. Due to cross-platform " +"compiler issues, you can't fill that field directly with a reference to :c:" +"type:`PyList_Type`; it should be done later in the module initialization " +"function::" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:870 +msgid "" +"Before calling :c:func:`PyType_Ready`, the type structure must have the :c:" +"member:`~PyTypeObject.tp_base` slot filled in. When we are deriving an " +"existing type, it is not necessary to fill out the :c:member:`~PyTypeObject." +"tp_alloc` slot with :c:func:`PyType_GenericNew` -- the allocation function " +"from the base type will be inherited." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:876 +msgid "" +"After that, calling :c:func:`PyType_Ready` and adding the type object to the " +"module is the same as with the basic :class:`Custom` examples." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:881 +msgid "Footnotes" +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:882 +msgid "" +"This is true when we know that the object is a basic type, like a string or " +"a float." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:885 +msgid "" +"We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " +"this example, because our type doesn't support garbage collection." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:888 +msgid "" +"We now know that the first and last members are strings, so perhaps we could " +"be less careful about decrementing their reference counts, however, we " +"accept instances of string subclasses. Even though deallocating normal " +"strings won't call back into our objects, we can't guarantee that " +"deallocating an instance of a string subclass won't call back into our " +"objects." +msgstr "" + +#: ../Doc/extending/newtypes_tutorial.rst:894 +msgid "" +"Also, even with our attributes restricted to strings instances, the user " +"could pass arbitrary :class:`str` subclasses and therefore still create " +"reference cycles." +msgstr "" diff --git a/faq/library.po b/faq/library.po index 7a173869..59939541 100644 --- a/faq/library.po +++ b/faq/library.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-02 22:11+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: 2018-02-15 00:37+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -127,20 +127,20 @@ msgstr "" msgid "" "Occasionally, a user's environment is so full that the :program:`/usr/bin/" "env` program fails; or there's no env program at all. In that case, you can " -"try the following hack (due to Alex Rezinsky)::" +"try the following hack (due to Alex Rezinsky):" msgstr "" -#: ../Doc/faq/library.rst:84 +#: ../Doc/faq/library.rst:86 msgid "" "The minor disadvantage is that this defines the script's __doc__ string. " "However, you can fix that by adding ::" msgstr "" -#: ../Doc/faq/library.rst:92 +#: ../Doc/faq/library.rst:94 msgid "Is there a curses/termcap package for Python?" msgstr "" -#: ../Doc/faq/library.rst:96 +#: ../Doc/faq/library.rst:98 msgid "" "For Unix variants: The standard Python source distribution comes with a " "curses module in the :source:`Modules` subdirectory, though it's not " @@ -148,7 +148,7 @@ msgid "" "distribution -- there is no curses module for Windows.)" msgstr "" -#: ../Doc/faq/library.rst:101 +#: ../Doc/faq/library.rst:103 msgid "" "The :mod:`curses` module supports basic curses features as well as many " "additional functions from ncurses and SYSV curses such as colour, " @@ -158,58 +158,58 @@ msgid "" "category." msgstr "" -#: ../Doc/faq/library.rst:107 +#: ../Doc/faq/library.rst:109 msgid "" "For Windows: use `the consolelib module `_." msgstr "" -#: ../Doc/faq/library.rst:112 +#: ../Doc/faq/library.rst:114 msgid "Is there an equivalent to C's onexit() in Python?" msgstr "" -#: ../Doc/faq/library.rst:114 +#: ../Doc/faq/library.rst:116 msgid "" "The :mod:`atexit` module provides a register function that is similar to " "C's :c:func:`onexit`." msgstr "" -#: ../Doc/faq/library.rst:119 +#: ../Doc/faq/library.rst:121 msgid "Why don't my signal handlers work?" msgstr "" -#: ../Doc/faq/library.rst:121 +#: ../Doc/faq/library.rst:123 msgid "" "The most common problem is that the signal handler is declared with the " "wrong argument list. It is called as ::" msgstr "" -#: ../Doc/faq/library.rst:126 +#: ../Doc/faq/library.rst:128 msgid "so it should be declared with two arguments::" msgstr "" -#: ../Doc/faq/library.rst:133 +#: ../Doc/faq/library.rst:135 msgid "Common tasks" msgstr "" -#: ../Doc/faq/library.rst:136 +#: ../Doc/faq/library.rst:138 msgid "How do I test a Python program or component?" msgstr "" -#: ../Doc/faq/library.rst:138 +#: ../Doc/faq/library.rst:140 msgid "" "Python comes with two testing frameworks. The :mod:`doctest` module finds " "examples in the docstrings for a module and runs them, comparing the output " "with the expected output given in the docstring." msgstr "" -#: ../Doc/faq/library.rst:142 +#: ../Doc/faq/library.rst:144 msgid "" "The :mod:`unittest` module is a fancier testing framework modelled on Java " "and Smalltalk testing frameworks." msgstr "" -#: ../Doc/faq/library.rst:145 +#: ../Doc/faq/library.rst:147 msgid "" "To make testing easier, you should use good modular design in your program. " "Your program should have almost all functionality encapsulated in either " @@ -220,15 +220,15 @@ msgid "" "more difficult to do." msgstr "" -#: ../Doc/faq/library.rst:153 +#: ../Doc/faq/library.rst:155 msgid "The \"global main logic\" of your program may be as simple as ::" msgstr "" -#: ../Doc/faq/library.rst:158 +#: ../Doc/faq/library.rst:160 msgid "at the bottom of the main module of your program." msgstr "" -#: ../Doc/faq/library.rst:160 +#: ../Doc/faq/library.rst:162 msgid "" "Once your program is organized as a tractable collection of functions and " "class behaviours you should write test functions that exercise the " @@ -240,24 +240,24 @@ msgid "" "design flaws earlier." msgstr "" -#: ../Doc/faq/library.rst:168 +#: ../Doc/faq/library.rst:170 msgid "" "\"Support modules\" that are not intended to be the main module of a program " "may include a self-test of the module. ::" msgstr "" -#: ../Doc/faq/library.rst:174 +#: ../Doc/faq/library.rst:176 msgid "" "Even programs that interact with complex external interfaces may be tested " "when the external interfaces are unavailable by using \"fake\" interfaces " "implemented in Python." msgstr "" -#: ../Doc/faq/library.rst:180 +#: ../Doc/faq/library.rst:182 msgid "How do I create documentation from doc strings?" msgstr "" -#: ../Doc/faq/library.rst:182 +#: ../Doc/faq/library.rst:184 msgid "" "The :mod:`pydoc` module can create HTML from the doc strings in your Python " "source code. An alternative for creating API documentation purely from " @@ -265,65 +265,65 @@ msgid "" "sphinx-doc.org>`_ can also include docstring content." msgstr "" -#: ../Doc/faq/library.rst:189 +#: ../Doc/faq/library.rst:191 msgid "How do I get a single keypress at a time?" msgstr "" -#: ../Doc/faq/library.rst:191 +#: ../Doc/faq/library.rst:193 msgid "" "For Unix variants there are several solutions. It's straightforward to do " "this using curses, but curses is a fairly large module to learn." msgstr "" -#: ../Doc/faq/library.rst:235 +#: ../Doc/faq/library.rst:237 msgid "Threads" msgstr "" -#: ../Doc/faq/library.rst:238 +#: ../Doc/faq/library.rst:240 msgid "How do I program using threads?" msgstr "" -#: ../Doc/faq/library.rst:240 +#: ../Doc/faq/library.rst:242 msgid "" "Be sure to use the :mod:`threading` module and not the :mod:`_thread` " "module. The :mod:`threading` module builds convenient abstractions on top of " "the low-level primitives provided by the :mod:`_thread` module." msgstr "" -#: ../Doc/faq/library.rst:244 +#: ../Doc/faq/library.rst:246 msgid "" "Aahz has a set of slides from his threading tutorial that are helpful; see " "http://www.pythoncraft.com/OSCON2001/." msgstr "" -#: ../Doc/faq/library.rst:249 +#: ../Doc/faq/library.rst:251 msgid "None of my threads seem to run: why?" msgstr "" -#: ../Doc/faq/library.rst:251 +#: ../Doc/faq/library.rst:253 msgid "" "As soon as the main thread exits, all threads are killed. Your main thread " "is running too quickly, giving the threads no time to do any work." msgstr "" -#: ../Doc/faq/library.rst:254 +#: ../Doc/faq/library.rst:256 msgid "" "A simple fix is to add a sleep to the end of the program that's long enough " "for all the threads to finish::" msgstr "" -#: ../Doc/faq/library.rst:269 +#: ../Doc/faq/library.rst:271 msgid "" "But now (on many platforms) the threads don't run in parallel, but appear to " "run sequentially, one at a time! The reason is that the OS thread scheduler " "doesn't start a new thread until the previous thread is blocked." msgstr "" -#: ../Doc/faq/library.rst:273 +#: ../Doc/faq/library.rst:275 msgid "A simple fix is to add a tiny sleep to the start of the run function::" msgstr "" -#: ../Doc/faq/library.rst:286 +#: ../Doc/faq/library.rst:288 msgid "" "Instead of trying to guess a good delay value for :func:`time.sleep`, it's " "better to use some kind of semaphore mechanism. One idea is to use the :mod:" @@ -332,17 +332,17 @@ msgid "" "the queue as there are threads." msgstr "" -#: ../Doc/faq/library.rst:294 +#: ../Doc/faq/library.rst:296 msgid "How do I parcel out work among a bunch of worker threads?" msgstr "" -#: ../Doc/faq/library.rst:296 +#: ../Doc/faq/library.rst:298 msgid "" "The easiest way is to use the new :mod:`concurrent.futures` module, " "especially the :mod:`~concurrent.futures.ThreadPoolExecutor` class." msgstr "" -#: ../Doc/faq/library.rst:299 +#: ../Doc/faq/library.rst:301 msgid "" "Or, if you want fine control over the dispatching algorithm, you can write " "your own logic manually. Use the :mod:`queue` module to create a queue " @@ -352,25 +352,25 @@ msgid "" "necessary to ensure that each job is handed out exactly once." msgstr "" -#: ../Doc/faq/library.rst:306 +#: ../Doc/faq/library.rst:308 msgid "Here's a trivial example::" msgstr "" -#: ../Doc/faq/library.rst:344 +#: ../Doc/faq/library.rst:346 msgid "When run, this will produce the following output:" msgstr "" -#: ../Doc/faq/library.rst:362 +#: ../Doc/faq/library.rst:364 msgid "" "Consult the module's documentation for more details; the :class:`~queue." "Queue` class provides a featureful interface." msgstr "" -#: ../Doc/faq/library.rst:367 +#: ../Doc/faq/library.rst:369 msgid "What kinds of global value mutation are thread-safe?" msgstr "" -#: ../Doc/faq/library.rst:369 +#: ../Doc/faq/library.rst:371 msgid "" "A :term:`global interpreter lock` (GIL) is used internally to ensure that " "only one thread runs in the Python VM at a time. In general, Python offers " @@ -380,7 +380,7 @@ msgid "" "instruction is therefore atomic from the point of view of a Python program." msgstr "" -#: ../Doc/faq/library.rst:376 +#: ../Doc/faq/library.rst:378 msgid "" "In theory, this means an exact accounting requires an exact understanding of " "the PVM bytecode implementation. In practice, it means that operations on " @@ -388,17 +388,17 @@ msgid "" "\"look atomic\" really are." msgstr "" -#: ../Doc/faq/library.rst:381 +#: ../Doc/faq/library.rst:383 msgid "" "For example, the following operations are all atomic (L, L1, L2 are lists, " "D, D1, D2 are dicts, x, y are objects, i, j are ints)::" msgstr "" -#: ../Doc/faq/library.rst:396 +#: ../Doc/faq/library.rst:398 msgid "These aren't::" msgstr "" -#: ../Doc/faq/library.rst:403 +#: ../Doc/faq/library.rst:405 msgid "" "Operations that replace other objects may invoke those other objects' :meth:" "`__del__` method when their reference count reaches zero, and that can " @@ -406,11 +406,11 @@ msgid "" "and lists. When in doubt, use a mutex!" msgstr "" -#: ../Doc/faq/library.rst:410 +#: ../Doc/faq/library.rst:412 msgid "Can't we get rid of the Global Interpreter Lock?" msgstr "" -#: ../Doc/faq/library.rst:414 +#: ../Doc/faq/library.rst:416 msgid "" "The :term:`global interpreter lock` (GIL) is often seen as a hindrance to " "Python's deployment on high-end multiprocessor server machines, because a " @@ -418,7 +418,7 @@ msgid "" "insistence that (almost) all Python code can only run while the GIL is held." msgstr "" -#: ../Doc/faq/library.rst:419 +#: ../Doc/faq/library.rst:421 msgid "" "Back in the days of Python 1.5, Greg Stein actually implemented a " "comprehensive patch set (the \"free threading\" patches) that removed the " @@ -430,7 +430,7 @@ msgid "" "the GIL." msgstr "" -#: ../Doc/faq/library.rst:427 +#: ../Doc/faq/library.rst:429 msgid "" "This doesn't mean that you can't make good use of Python on multi-CPU " "machines! You just have to be creative with dividing the work up between " @@ -441,7 +441,7 @@ msgid "" "dispatching of tasks." msgstr "" -#: ../Doc/faq/library.rst:435 +#: ../Doc/faq/library.rst:437 msgid "" "Judicious use of C extensions will also help; if you use a C extension to " "perform a time-consuming task, the extension can release the GIL while the " @@ -450,7 +450,7 @@ msgid "" "`hashlib` already do this." msgstr "" -#: ../Doc/faq/library.rst:441 +#: ../Doc/faq/library.rst:443 msgid "" "It has been suggested that the GIL should be a per-interpreter-state lock " "rather than truly global; interpreters then wouldn't be able to share " @@ -462,7 +462,7 @@ msgid "" "the interpreter state. And so on." msgstr "" -#: ../Doc/faq/library.rst:450 +#: ../Doc/faq/library.rst:452 msgid "" "And I doubt that it can even be done in finite time, because the same " "problem exists for 3rd party extensions. It is likely that 3rd party " @@ -470,28 +470,28 @@ msgid "" "store all their global state in the interpreter state." msgstr "" -#: ../Doc/faq/library.rst:455 +#: ../Doc/faq/library.rst:457 msgid "" "And finally, once you have multiple interpreters not sharing any state, what " "have you gained over running each interpreter in a separate process?" msgstr "" -#: ../Doc/faq/library.rst:460 +#: ../Doc/faq/library.rst:462 msgid "Input and Output" msgstr "Les entrées/sorties" -#: ../Doc/faq/library.rst:463 +#: ../Doc/faq/library.rst:465 msgid "How do I delete a file? (And other file questions...)" msgstr "" -#: ../Doc/faq/library.rst:465 +#: ../Doc/faq/library.rst:467 msgid "" "Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, " "see the :mod:`os` module. The two functions are identical; :func:`~os." "unlink` is simply the name of the Unix system call for this function." msgstr "" -#: ../Doc/faq/library.rst:469 +#: ../Doc/faq/library.rst:471 msgid "" "To remove a directory, use :func:`os.rmdir`; use :func:`os.mkdir` to create " "one. ``os.makedirs(path)`` will create any intermediate directories in " @@ -500,11 +500,11 @@ msgid "" "directory tree and its contents, use :func:`shutil.rmtree`." msgstr "" -#: ../Doc/faq/library.rst:475 +#: ../Doc/faq/library.rst:477 msgid "To rename a file, use ``os.rename(old_path, new_path)``." msgstr "" -#: ../Doc/faq/library.rst:477 +#: ../Doc/faq/library.rst:479 msgid "" "To truncate a file, open it using ``f = open(filename, \"rb+\")``, and use " "``f.truncate(offset)``; offset defaults to the current seek position. " @@ -512,54 +512,54 @@ msgid "" "open`, where *fd* is the file descriptor (a small integer)." msgstr "" -#: ../Doc/faq/library.rst:482 +#: ../Doc/faq/library.rst:484 msgid "" "The :mod:`shutil` module also contains a number of functions to work on " "files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and :" "func:`~shutil.rmtree`." msgstr "" -#: ../Doc/faq/library.rst:488 +#: ../Doc/faq/library.rst:490 msgid "How do I copy a file?" msgstr "" -#: ../Doc/faq/library.rst:490 +#: ../Doc/faq/library.rst:492 msgid "" "The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note " "that on MacOS 9 it doesn't copy the resource fork and Finder info." msgstr "" -#: ../Doc/faq/library.rst:495 +#: ../Doc/faq/library.rst:497 msgid "How do I read (or write) binary data?" msgstr "" -#: ../Doc/faq/library.rst:497 +#: ../Doc/faq/library.rst:499 msgid "" "To read or write complex binary data formats, it's best to use the :mod:" "`struct` module. It allows you to take a string containing binary data " "(usually numbers) and convert it to Python objects; and vice versa." msgstr "" -#: ../Doc/faq/library.rst:501 +#: ../Doc/faq/library.rst:503 msgid "" "For example, the following code reads two 2-byte integers and one 4-byte " "integer in big-endian format from a file::" msgstr "" -#: ../Doc/faq/library.rst:510 +#: ../Doc/faq/library.rst:512 msgid "" "The '>' in the format string forces big-endian data; the letter 'h' reads " "one \"short integer\" (2 bytes), and 'l' reads one \"long integer\" (4 " "bytes) from the string." msgstr "" -#: ../Doc/faq/library.rst:514 +#: ../Doc/faq/library.rst:516 msgid "" "For data that is more regular (e.g. a homogeneous list of ints or floats), " "you can also use the :mod:`array` module." msgstr "" -#: ../Doc/faq/library.rst:519 +#: ../Doc/faq/library.rst:521 msgid "" "To read and write binary data, it is mandatory to open the file in binary " "mode (here, passing ``\"rb\"`` to :func:`open`). If you use ``\"r\"`` " @@ -567,11 +567,11 @@ msgid "" "will return :class:`str` objects rather than :class:`bytes` objects." msgstr "" -#: ../Doc/faq/library.rst:527 +#: ../Doc/faq/library.rst:529 msgid "I can't seem to use os.read() on a pipe created with os.popen(); why?" msgstr "" -#: ../Doc/faq/library.rst:529 +#: ../Doc/faq/library.rst:531 msgid "" ":func:`os.read` is a low-level function which takes a file descriptor, a " "small integer representing the opened file. :func:`os.popen` creates a high-" @@ -580,37 +580,37 @@ msgid "" "popen`, you need to use ``p.read(n)``." msgstr "" -#: ../Doc/faq/library.rst:616 +#: ../Doc/faq/library.rst:618 msgid "How do I access the serial (RS232) port?" msgstr "" -#: ../Doc/faq/library.rst:618 +#: ../Doc/faq/library.rst:620 msgid "For Win32, POSIX (Linux, BSD, etc.), Jython:" msgstr "" -#: ../Doc/faq/library.rst:620 +#: ../Doc/faq/library.rst:622 msgid "http://pyserial.sourceforge.net" msgstr "" -#: ../Doc/faq/library.rst:622 +#: ../Doc/faq/library.rst:624 msgid "For Unix, see a Usenet post by Mitch Chapman:" msgstr "" -#: ../Doc/faq/library.rst:624 +#: ../Doc/faq/library.rst:626 msgid "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" msgstr "" -#: ../Doc/faq/library.rst:628 +#: ../Doc/faq/library.rst:630 msgid "Why doesn't closing sys.stdout (stdin, stderr) really close it?" msgstr "" -#: ../Doc/faq/library.rst:630 +#: ../Doc/faq/library.rst:632 msgid "" "Python :term:`file objects ` are a high-level layer of " "abstraction on low-level C file descriptors." msgstr "" -#: ../Doc/faq/library.rst:633 +#: ../Doc/faq/library.rst:635 msgid "" "For most file objects you create in Python via the built-in :func:`open` " "function, ``f.close()`` marks the Python file object as being closed from " @@ -619,7 +619,7 @@ msgid "" "``f`` becomes garbage." msgstr "" -#: ../Doc/faq/library.rst:639 +#: ../Doc/faq/library.rst:641 msgid "" "But stdin, stdout and stderr are treated specially by Python, because of the " "special status also given to them by C. Running ``sys.stdout.close()`` " @@ -627,94 +627,94 @@ msgid "" "associated C file descriptor." msgstr "" -#: ../Doc/faq/library.rst:644 +#: ../Doc/faq/library.rst:646 msgid "" "To close the underlying C file descriptor for one of these three, you should " "first be sure that's what you really want to do (e.g., you may confuse " "extension modules trying to do I/O). If it is, use :func:`os.close`::" msgstr "" -#: ../Doc/faq/library.rst:652 +#: ../Doc/faq/library.rst:654 msgid "Or you can use the numeric constants 0, 1 and 2, respectively." msgstr "" -#: ../Doc/faq/library.rst:656 +#: ../Doc/faq/library.rst:658 msgid "Network/Internet Programming" msgstr "" -#: ../Doc/faq/library.rst:659 +#: ../Doc/faq/library.rst:661 msgid "What WWW tools are there for Python?" msgstr "" -#: ../Doc/faq/library.rst:661 +#: ../Doc/faq/library.rst:663 msgid "" "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library " "Reference Manual. Python has many modules that will help you build server-" "side and client-side web systems." msgstr "" -#: ../Doc/faq/library.rst:667 +#: ../Doc/faq/library.rst:669 msgid "" "A summary of available frameworks is maintained by Paul Boddie at https://" "wiki.python.org/moin/WebProgramming\\ ." msgstr "" -#: ../Doc/faq/library.rst:670 +#: ../Doc/faq/library.rst:672 msgid "" "Cameron Laird maintains a useful set of pages about Python web technologies " "at http://phaseit.net/claird/comp.lang.python/web_python." msgstr "" -#: ../Doc/faq/library.rst:675 +#: ../Doc/faq/library.rst:677 msgid "How can I mimic CGI form submission (METHOD=POST)?" msgstr "" -#: ../Doc/faq/library.rst:677 +#: ../Doc/faq/library.rst:679 msgid "" "I would like to retrieve web pages that are the result of POSTing a form. Is " "there existing code that would let me do this easily?" msgstr "" -#: ../Doc/faq/library.rst:680 +#: ../Doc/faq/library.rst:682 msgid "Yes. Here's a simple example that uses urllib.request::" msgstr "" -#: ../Doc/faq/library.rst:695 +#: ../Doc/faq/library.rst:697 msgid "" "Note that in general for percent-encoded POST operations, query strings must " "be quoted using :func:`urllib.parse.urlencode`. For example, to send " "``name=Guy Steele, Jr.``::" msgstr "" -#: ../Doc/faq/library.rst:703 +#: ../Doc/faq/library.rst:705 msgid ":ref:`urllib-howto` for extensive examples." msgstr "" -#: ../Doc/faq/library.rst:707 +#: ../Doc/faq/library.rst:709 msgid "What module should I use to help with generating HTML?" msgstr "" -#: ../Doc/faq/library.rst:711 +#: ../Doc/faq/library.rst:713 msgid "" "You can find a collection of useful links on the `Web Programming wiki page " "`_." msgstr "" -#: ../Doc/faq/library.rst:716 +#: ../Doc/faq/library.rst:718 msgid "How do I send mail from a Python script?" msgstr "" -#: ../Doc/faq/library.rst:718 +#: ../Doc/faq/library.rst:720 msgid "Use the standard library module :mod:`smtplib`." msgstr "" -#: ../Doc/faq/library.rst:720 +#: ../Doc/faq/library.rst:722 msgid "" "Here's a very simple interactive mail sender that uses it. This method will " "work on any host that supports an SMTP listener. ::" msgstr "" -#: ../Doc/faq/library.rst:740 +#: ../Doc/faq/library.rst:742 msgid "" "A Unix-only alternative uses sendmail. The location of the sendmail program " "varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes ``/" @@ -722,17 +722,17 @@ msgid "" "some sample code::" msgstr "" -#: ../Doc/faq/library.rst:760 +#: ../Doc/faq/library.rst:762 msgid "How do I avoid blocking in the connect() method of a socket?" msgstr "" -#: ../Doc/faq/library.rst:762 +#: ../Doc/faq/library.rst:764 msgid "" "The :mod:`select` module is commonly used to help with asynchronous I/O on " "sockets." msgstr "" -#: ../Doc/faq/library.rst:765 +#: ../Doc/faq/library.rst:767 msgid "" "To prevent the TCP connect from blocking, you can set the socket to non-" "blocking mode. Then when you do the ``connect()``, you will either connect " @@ -742,7 +742,7 @@ msgid "" "values, so you're going to have to check what's returned on your system." msgstr "" -#: ../Doc/faq/library.rst:772 +#: ../Doc/faq/library.rst:774 msgid "" "You can use the ``connect_ex()`` method to avoid creating an exception. It " "will just return the errno value. To poll, you can call ``connect_ex()`` " @@ -750,26 +750,26 @@ msgid "" "or you can pass this socket to select to check if it's writable." msgstr "" -#: ../Doc/faq/library.rst:778 +#: ../Doc/faq/library.rst:780 msgid "" "The :mod:`asyncore` module presents a framework-like approach to the problem " "of writing non-blocking networking code. The third-party `Twisted `_ library is a popular and feature-rich alternative." msgstr "" -#: ../Doc/faq/library.rst:785 +#: ../Doc/faq/library.rst:787 msgid "Databases" msgstr "" -#: ../Doc/faq/library.rst:788 +#: ../Doc/faq/library.rst:790 msgid "Are there any interfaces to database packages in Python?" msgstr "" -#: ../Doc/faq/library.rst:790 +#: ../Doc/faq/library.rst:792 msgid "Yes." msgstr "Oui." -#: ../Doc/faq/library.rst:792 +#: ../Doc/faq/library.rst:794 msgid "" "Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM " "` are also included with standard Python. There is also the :mod:" @@ -777,18 +777,18 @@ msgid "" "database." msgstr "" -#: ../Doc/faq/library.rst:797 +#: ../Doc/faq/library.rst:799 msgid "" "Support for most relational databases is available. See the " "`DatabaseProgramming wiki page `_ for details." msgstr "" -#: ../Doc/faq/library.rst:803 +#: ../Doc/faq/library.rst:805 msgid "How do you implement persistent objects in Python?" msgstr "" -#: ../Doc/faq/library.rst:805 +#: ../Doc/faq/library.rst:807 msgid "" "The :mod:`pickle` library module solves this in a very general way (though " "you still can't store things like open files, sockets or windows), and the :" @@ -796,55 +796,55 @@ msgid "" "mappings containing arbitrary Python objects." msgstr "" -#: ../Doc/faq/library.rst:812 +#: ../Doc/faq/library.rst:814 msgid "Mathematics and Numerics" msgstr "" -#: ../Doc/faq/library.rst:815 +#: ../Doc/faq/library.rst:817 msgid "How do I generate random numbers in Python?" msgstr "" -#: ../Doc/faq/library.rst:817 +#: ../Doc/faq/library.rst:819 msgid "" "The standard module :mod:`random` implements a random number generator. " "Usage is simple::" msgstr "" -#: ../Doc/faq/library.rst:823 +#: ../Doc/faq/library.rst:825 msgid "This returns a random floating point number in the range [0, 1)." msgstr "" -#: ../Doc/faq/library.rst:825 +#: ../Doc/faq/library.rst:827 msgid "" "There are also many other specialized generators in this module, such as:" msgstr "" -#: ../Doc/faq/library.rst:827 +#: ../Doc/faq/library.rst:829 msgid "``randrange(a, b)`` chooses an integer in the range [a, b)." msgstr "" -#: ../Doc/faq/library.rst:828 +#: ../Doc/faq/library.rst:830 msgid "``uniform(a, b)`` chooses a floating point number in the range [a, b)." msgstr "" -#: ../Doc/faq/library.rst:829 +#: ../Doc/faq/library.rst:831 msgid "" "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution." msgstr "" -#: ../Doc/faq/library.rst:831 +#: ../Doc/faq/library.rst:833 msgid "Some higher-level functions operate on sequences directly, such as:" msgstr "" -#: ../Doc/faq/library.rst:833 +#: ../Doc/faq/library.rst:835 msgid "``choice(S)`` chooses random element from a given sequence" msgstr "" -#: ../Doc/faq/library.rst:834 +#: ../Doc/faq/library.rst:836 msgid "``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly" msgstr "" -#: ../Doc/faq/library.rst:836 +#: ../Doc/faq/library.rst:838 msgid "" "There's also a ``Random`` class you can instantiate to create independent " "multiple random number generators." diff --git a/faq/windows.po b/faq/windows.po index 3770f6a7..9f4370bf 100644 --- a/faq/windows.po +++ b/faq/windows.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-10-13 22:28+0200\n" +"POT-Creation-Date: 2018-04-29 00:24+0200\n" "PO-Revision-Date: 2018-01-21 23:08+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,18 +17,18 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../Doc/faq/windows.rst:7 +#: ../Doc/faq/windows.rst:9 msgid "Python on Windows FAQ" msgstr "" "Ce n'est pas forcément une question simple. Si vous êtes déjà familier avec " "le lancement de programmes depuis la ligne de commande de Windows alors tout " "semblera évident; Sinon, vous auriez besoin d'être un peu guidé." -#: ../Doc/faq/windows.rst:18 +#: ../Doc/faq/windows.rst:20 msgid "How do I run a Python program under Windows?" msgstr "Comment exécuter un programme Python sous Windows ?" -#: ../Doc/faq/windows.rst:20 +#: ../Doc/faq/windows.rst:22 msgid "" "This is not necessarily a straightforward question. If you are already " "familiar with running programs from the Windows command line then everything " @@ -38,7 +38,7 @@ msgstr "" "le lancement de programmes depuis la ligne de commande de Windows alors tout " "semblera évident; Sinon, vous auriez besoin d'être un peu guidé." -#: ../Doc/faq/windows.rst:27 +#: ../Doc/faq/windows.rst:29 msgid "" "This series of screencasts aims to get you up and running with Python on " "Windows XP. The knowledge is distilled into 1.5 hours and will get you up " @@ -51,7 +51,8 @@ msgstr "" "votre choix, et de débugger et écrire du code solide accompagné des tests " "unitaires." -#: ../Doc/faq/windows.rst:36 +#: ../Doc/faq/windows.rst:38 +#, fuzzy msgid "" "Unless you use some sort of integrated development environment, you will end " "up *typing* Windows commands into what is variously referred to as a \"DOS " @@ -59,7 +60,7 @@ msgid "" "from your Start menu; under Windows 7 the menu selection is :menuselection:" "`Start --> Programs --> Accessories --> Command Prompt`. You should be able " "to recognize when you have started such a window because you will see a " -"Windows \"command prompt\", which usually looks like this::" +"Windows \"command prompt\", which usually looks like this:" msgstr "" "A moins que vous n'utilisiez quelque environnement de développement, vous " "devrez entrer des commandes Windows dans ce qui est diversement référé comme " @@ -69,15 +70,16 @@ msgstr "" "dans la bonne fenêtre quand vous verrez une fenêtre invite de commande qui " "ressemble normalement à ça ::" -#: ../Doc/faq/windows.rst:46 +#: ../Doc/faq/windows.rst:50 +#, fuzzy msgid "" "The letter may be different, and there might be other things after it, so " -"you might just as easily see something like::" +"you might just as easily see something like:" msgstr "" "La lettre peut être différente, et il peut y avoir d'autres choses à la " "suite, alors il se peut aussi bien que vous voyez quelque chose tel que ::" -#: ../Doc/faq/windows.rst:51 +#: ../Doc/faq/windows.rst:57 msgid "" "depending on how your computer has been set up and what else you have " "recently done with it. Once you have started such a window, you are well on " @@ -87,7 +89,7 @@ msgstr "" "fait avec. Une fois que vous avez ouvert cette fenêtre, vous êtes bien " "partis pour pouvoir lancer des programmes Python." -#: ../Doc/faq/windows.rst:55 +#: ../Doc/faq/windows.rst:61 msgid "" "You need to realize that your Python scripts have to be processed by another " "program called the Python *interpreter*. The interpreter reads your script, " @@ -100,32 +102,33 @@ msgstr "" "programme. Alors, comment faire pour donner votre code Python à " "l'interpréteur ?" -#: ../Doc/faq/windows.rst:60 +#: ../Doc/faq/windows.rst:66 +#, fuzzy msgid "" "First, you need to make sure that your command window recognises the word " "\"python\" as an instruction to start the interpreter. If you have opened a " "command window, you should try entering the command ``python`` and hitting " -"return.::" +"return:" msgstr "" "Tout d'abord, vous devez vous assurer que votre fenêtre d'invite de commande " "reconnaît le mot \"python\" comme une instruction pour démarrer " "l'interpréteur. Si vous avez ouvert une fenêtre de commande, entrez la " "commande ``python``, puis appuyez sur la touche entrée ::" -#: ../Doc/faq/windows.rst:67 -msgid "You should then see something like::" +#: ../Doc/faq/windows.rst:75 +#, fuzzy +msgid "You should then see something like:" msgstr "Vous devez vous trouver face à quelque chose comme ça ::" -#: ../Doc/faq/windows.rst:73 +#: ../Doc/faq/windows.rst:83 msgid "" "You have started the interpreter in \"interactive mode\". That means you can " "enter Python statements or expressions interactively and have them executed " "or evaluated while you wait. This is one of Python's strongest features. " -"Check it by entering a few expressions of your choice and seeing the " -"results::" +"Check it by entering a few expressions of your choice and seeing the results:" msgstr "" -#: ../Doc/faq/windows.rst:83 +#: ../Doc/faq/windows.rst:95 msgid "" "Many people use the interactive mode as a convenient yet highly programmable " "calculator. When you want to end your interactive Python session, hold the :" @@ -133,7 +136,7 @@ msgid "" "\" key to get back to your Windows command prompt." msgstr "" -#: ../Doc/faq/windows.rst:88 +#: ../Doc/faq/windows.rst:100 msgid "" "You may also find that you have a Start-menu entry such as :menuselection:" "`Start --> Programs --> Python 3.3 --> Python (command line)` that results " @@ -143,38 +146,38 @@ msgid "" "the interpreter." msgstr "" -#: ../Doc/faq/windows.rst:94 +#: ../Doc/faq/windows.rst:106 msgid "" "If the ``python`` command, instead of displaying the interpreter prompt " "``>>>``, gives you a message like::" msgstr "" -#: ../Doc/faq/windows.rst:102 +#: ../Doc/faq/windows.rst:114 msgid "" "Python is not added to the DOS path by default. This screencast will walk " "you through the steps to add the correct entry to the `System Path`, " "allowing Python to be executed from the command-line by all users." msgstr "" -#: ../Doc/faq/windows.rst:111 +#: ../Doc/faq/windows.rst:123 msgid "or::" msgstr "ou : ::" -#: ../Doc/faq/windows.rst:115 +#: ../Doc/faq/windows.rst:127 msgid "" "then you need to make sure that your computer knows where to find the Python " "interpreter. To do this you will have to modify a setting called PATH, " "which is a list of directories where Windows will look for programs." msgstr "" -#: ../Doc/faq/windows.rst:119 +#: ../Doc/faq/windows.rst:131 msgid "" "You should arrange for Python's installation directory to be added to the " "PATH of every command window as it starts. If you installed Python fairly " "recently then the command ::" msgstr "" -#: ../Doc/faq/windows.rst:125 +#: ../Doc/faq/windows.rst:137 msgid "" "will probably tell you where it is installed; the usual location is " "something like ``C:\\Python33``. Otherwise you will be reduced to a search " @@ -185,7 +188,7 @@ msgid "" "command ::" msgstr "" -#: ../Doc/faq/windows.rst:134 +#: ../Doc/faq/windows.rst:146 msgid "" "starts up the interpreter as above (and don't forget you'll need a \":kbd:" "`Ctrl-Z`\" and an \":kbd:`Enter`\" to get out of it). Once you have verified " @@ -194,17 +197,17 @@ msgid "" "in the installer as of CPython 3.3." msgstr "" -#: ../Doc/faq/windows.rst:140 +#: ../Doc/faq/windows.rst:152 msgid "" "More information about environment variables can be found on the :ref:`Using " "Python on Windows ` page." msgstr "" -#: ../Doc/faq/windows.rst:144 +#: ../Doc/faq/windows.rst:156 msgid "How do I make Python scripts executable?" msgstr "" -#: ../Doc/faq/windows.rst:146 +#: ../Doc/faq/windows.rst:158 msgid "" "On Windows, the standard Python installer already associates the .py " "extension with a file type (Python.File) and gives that file type an open " @@ -215,11 +218,11 @@ msgid "" "environment variable." msgstr "" -#: ../Doc/faq/windows.rst:154 +#: ../Doc/faq/windows.rst:166 msgid "Why does Python sometimes take so long to start?" msgstr "" -#: ../Doc/faq/windows.rst:156 +#: ../Doc/faq/windows.rst:168 msgid "" "Usually Python starts very quickly on Windows, but occasionally there are " "bug reports that Python suddenly begins to take a long time to start up. " @@ -227,7 +230,7 @@ msgid "" "Windows systems which appear to be configured identically." msgstr "" -#: ../Doc/faq/windows.rst:161 +#: ../Doc/faq/windows.rst:173 msgid "" "The problem may be caused by a misconfiguration of virus checking software " "on the problem machine. Some virus scanners have been known to introduce " @@ -238,11 +241,11 @@ msgid "" "activity, is a particular offender." msgstr "" -#: ../Doc/faq/windows.rst:171 +#: ../Doc/faq/windows.rst:183 msgid "How do I make an executable from a Python script?" msgstr "Comment construire un exécutable depuis un script Python ?" -#: ../Doc/faq/windows.rst:173 +#: ../Doc/faq/windows.rst:185 msgid "" "See http://cx-freeze.sourceforge.net/ for a distutils extension that allows " "you to create console and GUI executables from Python code. `py2exe