Make merge (#1695)
* Make merge * FIX: spelling for pospell. * Uniformisation des entêtes po.
This commit is contained in:
parent 0086ed1f76
commit 17d5f9cebe
257 changed files with 43019 additions and 31747 deletions
| | @ -5,7 +5,7 @@ msgid "" | |||
msgstr "" | ||||
"Project-Id-Version: Python 3\n" | ||||
"Report-Msgid-Bugs-To: \n" | ||||
"POT-Creation-Date: 2020-08-24 09:01+0200\n" | ||||
"POT-Creation-Date: 2021-09-23 16:16+0200\n" | ||||
"PO-Revision-Date: 2021-02-07 22:27+0100\n" | ||||
"Last-Translator: Julien Palard <julien@palard.fr>\n" | ||||
"Language-Team: FRENCH <traductions@lists.afpy.org>\n" | ||||
| | @ -1177,18 +1177,14 @@ msgid "" | |||
"The cycle detector is able to detect garbage cycles and can reclaim them. " | ||||
"The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." | ||||
"collect` function), as well as configuration interfaces and the ability to " | ||||
"disable the detector at runtime. The cycle detector is considered an " | ||||
"optional component; though it is included by default, it can be disabled at " | ||||
"build time using the :option:`!--without-cycle-gc` option to the :program:" | ||||
"`configure` script on Unix platforms (including Mac OS X). If the cycle " | ||||
"detector is disabled in this way, the :mod:`gc` module will not be available." | ||||
"disable the detector at runtime." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:925 | ||||
#: extending/extending.rst:920 | ||||
msgid "Reference Counting in Python" | ||||
msgstr "Comptage de références en Python" | ||||
| ||||
#: extending/extending.rst:927 | ||||
#: extending/extending.rst:922 | ||||
msgid "" | ||||
"There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " | ||||
"the incrementing and decrementing of the reference count. :c:func:" | ||||
| | @ -1206,7 +1202,7 @@ msgstr "" | |||
"objet` de l'objet. À cette fin (et pour d'autres), chaque objet contient " | ||||
"également un pointeur vers son objet type." | ||||
| ||||
#: extending/extending.rst:934 | ||||
#: extending/extending.rst:929 | ||||
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 " | ||||
| | @ -1229,7 +1225,7 @@ msgstr "" | |||
"c:func:`Py_DECREF`. Oublier de se débarrasser d'une référence crée une fuite " | ||||
"de mémoire." | ||||
| ||||
#: extending/extending.rst:943 | ||||
#: extending/extending.rst:938 | ||||
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 " | ||||
| | @ -1238,7 +1234,7 @@ msgid "" | |||
"risks using freed memory and should be avoided completely [#]_." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:949 | ||||
#: extending/extending.rst:944 | ||||
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 " | ||||
| | @ -1257,7 +1253,7 @@ msgstr "" | |||
"correct, une référence empruntée peut être utilisée après que le " | ||||
"propriétaire auquel elle a été empruntée l'a en fait éliminée." | ||||
| ||||
#: extending/extending.rst:957 | ||||
#: extending/extending.rst:952 | ||||
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 " | ||||
| | @ -1266,11 +1262,11 @@ msgid "" | |||
"properly, as well as the previous owner)." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:967 | ||||
#: extending/extending.rst:962 | ||||
msgid "Ownership Rules" | ||||
msgstr "Règles concernant la propriété de références" | ||||
| ||||
#: extending/extending.rst:969 | ||||
#: extending/extending.rst:964 | ||||
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 " | ||||
| | @ -1281,7 +1277,7 @@ msgstr "" | |||
"l'interface de la fonction, peu importe que la propriété soit transférée " | ||||
"avec la référence ou non." | ||||
| ||||
#: extending/extending.rst:973 | ||||
#: extending/extending.rst:968 | ||||
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 " | ||||
| | @ -1292,7 +1288,7 @@ msgid "" | |||
"reference to a cached item." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:981 | ||||
#: extending/extending.rst:976 | ||||
msgid "" | ||||
"Many functions that extract objects from other objects also transfer " | ||||
"ownership with the reference, for instance :c:func:" | ||||
| | @ -1303,14 +1299,14 @@ msgid "" | |||
"list or dictionary." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:988 | ||||
#: extending/extending.rst:983 | ||||
msgid "" | ||||
"The function :c:func:`PyImport_AddModule` also returns a borrowed reference, " | ||||
"even though it may actually create the object it returns: this is possible " | ||||
"because an owned reference to the object is stored in ``sys.modules``." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:992 | ||||
#: extending/extending.rst:987 | ||||
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 " | ||||
| | @ -1321,7 +1317,7 @@ msgid "" | |||
"don't take over ownership --- they are \"normal.\")" | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1000 | ||||
#: extending/extending.rst:995 | ||||
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 " | ||||
| | @ -1330,18 +1326,18 @@ msgid "" | |||
"turned into an owned reference by calling :c:func:`Py_INCREF`." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1006 | ||||
#: extending/extending.rst:1001 | ||||
msgid "" | ||||
"The object reference returned from a C function that is called from Python " | ||||
"must be an owned reference --- ownership is transferred from the function to " | ||||
"its caller." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1014 | ||||
#: extending/extending.rst:1009 | ||||
msgid "Thin Ice" | ||||
msgstr "Terrain dangereux" | ||||
| ||||
#: extending/extending.rst:1016 | ||||
#: extending/extending.rst:1011 | ||||
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 " | ||||
| | @ -1353,7 +1349,7 @@ msgstr "" | |||
"lien avec des invocations implicites de l’interpréteur, et peuvent amener le " | ||||
"propriétaire d'une référence à s'en défaire." | ||||
| ||||
#: extending/extending.rst:1020 | ||||
#: extending/extending.rst:1015 | ||||
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 " | ||||
| | @ -1363,7 +1359,7 @@ msgstr "" | |||
"de :c:func:`Py_DECREF` à un objet non relié, tout en empruntant une " | ||||
"référence à un élément de liste. Par exemple ::" | ||||
| ||||
#: extending/extending.rst:1032 | ||||
#: extending/extending.rst:1027 | ||||
msgid "" | ||||
"This function first borrows a reference to ``list[0]``, then replaces " | ||||
"``list[1]`` with the value ``0``, and finally prints the borrowed reference. " | ||||
| | @ -1373,7 +1369,7 @@ msgstr "" | |||
"``list[1]`` par la valeur ``0``, et enfin affiche la référence empruntée. " | ||||
"Ça a l'air inoffensif, n'est-ce pas ? Mais ce n'est pas le cas !" | ||||
| ||||
#: extending/extending.rst:1036 | ||||
#: extending/extending.rst:1031 | ||||
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 " | ||||
| | @ -1390,7 +1386,7 @@ msgstr "" | |||
"meth:`__del__`. Si l'instance de cette classe a un nombre des références de " | ||||
"1, sa destruction appellera sa méthode :meth:`__del__`." | ||||
| ||||
#: extending/extending.rst:1043 | ||||
#: extending/extending.rst:1038 | ||||
msgid "" | ||||
"Since it is written in Python, the :meth:`__del__` method can execute " | ||||
"arbitrary Python code. Could it perhaps do something to invalidate the " | ||||
| | @ -1408,20 +1404,20 @@ msgstr "" | |||
"supposant que ce soit la dernière référence à cet objet, elle libérerait la " | ||||
"mémoire qui lui est associée, invalidant ainsi ``item``." | ||||
| ||||
#: extending/extending.rst:1051 | ||||
#: extending/extending.rst:1046 | ||||
msgid "" | ||||
"The solution, once you know the source of the problem, is easy: temporarily " | ||||
"increment the reference count. The correct version of the function reads::" | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1065 | ||||
#: extending/extending.rst:1060 | ||||
msgid "" | ||||
"This is a true story. An older version of Python contained variants of this " | ||||
"bug and someone spent a considerable amount of time in a C debugger to " | ||||
"figure out why his :meth:`__del__` methods would fail..." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1069 | ||||
#: extending/extending.rst:1064 | ||||
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 " | ||||
| | @ -1444,11 +1440,11 @@ msgstr "" | |||
"processeur en attendant que les E/S soient terminées. Évidemment, la " | ||||
"fonction suivante a le même problème que la précédente ::" | ||||
| ||||
#: extending/extending.rst:1092 | ||||
#: extending/extending.rst:1087 | ||||
msgid "NULL Pointers" | ||||
msgstr "Pointeurs ``NULL``" | ||||
| ||||
#: extending/extending.rst:1094 | ||||
#: extending/extending.rst:1089 | ||||
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 " | ||||
| | @ -1470,7 +1466,7 @@ msgstr "" | |||
"devait tester pour ``NULL``, il y aurait beaucoup de tests redondants et le " | ||||
"code s'exécuterait plus lentement." | ||||
| ||||
#: extending/extending.rst:1102 | ||||
#: extending/extending.rst:1097 | ||||
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 " | ||||
| | @ -1480,7 +1476,7 @@ msgstr "" | |||
"lorsqu'un pointeur qui peut être ``NULL`` est reçu, par exemple, de :c:func:" | ||||
"`malloc` ou d'une fonction qui peut lever une exception." | ||||
| ||||
#: extending/extending.rst:1106 | ||||
#: extending/extending.rst:1101 | ||||
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:" | ||||
| | @ -1490,7 +1486,7 @@ msgstr "" | |||
"pointeurs ``NULL``. Cependant, leurs variantes :c:func:`Py_XINCREF` et :c:" | ||||
"func:`Py_XDECREF` le font." | ||||
| ||||
#: extending/extending.rst:1110 | ||||
#: extending/extending.rst:1105 | ||||
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 " | ||||
| | @ -1499,7 +1495,7 @@ msgid "" | |||
"variants with ``NULL`` checking." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1116 | ||||
#: extending/extending.rst:1111 | ||||
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 " | ||||
| | @ -1509,7 +1505,7 @@ msgstr "" | |||
"aux fonctions C (``args`` dans les exemples) n'est jamais ``NULL``. En fait, " | ||||
"il garantit qu'il s'agit toujours d'un n-uplet [#]_." | ||||
| ||||
#: extending/extending.rst:1120 | ||||
#: extending/extending.rst:1115 | ||||
msgid "" | ||||
"It is a severe error to ever let a ``NULL`` pointer \"escape\" to the Python " | ||||
"user." | ||||
| | @ -1517,11 +1513,11 @@ msgstr "" | |||
"C'est une grave erreur de laisser un pointeur ``NULL`` \"échapper\" à " | ||||
"l'utilisateur Python." | ||||
| ||||
#: extending/extending.rst:1131 | ||||
#: extending/extending.rst:1126 | ||||
msgid "Writing Extensions in C++" | ||||
msgstr "Écrire des extensions en C++" | ||||
| ||||
#: extending/extending.rst:1133 | ||||
#: extending/extending.rst:1128 | ||||
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 " | ||||
| | @ -1545,11 +1541,11 @@ msgstr "" | |||
"``__cplusplus`` est défini (tous les compilateurs C++ récents définissent ce " | ||||
"symbole)." | ||||
| ||||
#: extending/extending.rst:1147 | ||||
#: extending/extending.rst:1142 | ||||
msgid "Providing a C API for an Extension Module" | ||||
msgstr "Fournir une API en langage C pour un module d'extension" | ||||
| ||||
#: extending/extending.rst:1152 | ||||
#: extending/extending.rst:1147 | ||||
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 " | ||||
| | @ -1569,7 +1565,7 @@ msgstr "" | |||
"collection devrait posséder un ensemble de fonctions C pour une manipulation " | ||||
"directe à partir d'autres modules d'extension." | ||||
| ||||
#: extending/extending.rst:1160 | ||||
#: extending/extending.rst:1155 | ||||
msgid "" | ||||
"At first sight this seems easy: just write the functions (without declaring " | ||||
"them ``static``, of course), provide an appropriate header file, and " | ||||
| | @ -1599,7 +1595,7 @@ msgstr "" | |||
"*Unix*). Et même si les symboles sont globalement visibles, le module dont " | ||||
"on souhaite appeler les fonctions n'est peut-être pas encore chargé !" | ||||
| ||||
#: extending/extending.rst:1172 | ||||
#: extending/extending.rst:1167 | ||||
msgid "" | ||||
"Portability therefore requires not to make any assumptions about symbol " | ||||
"visibility. This means that all symbols in extension modules should be " | ||||
| | @ -1617,7 +1613,7 @@ msgstr "" | |||
"accessibles à partir d'autres modules d'extension doivent être exportés " | ||||
"d'une manière différente." | ||||
| ||||
#: extending/extending.rst:1179 | ||||
#: extending/extending.rst:1174 | ||||
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 " | ||||
| | @ -1629,7 +1625,7 @@ msgid "" | |||
"the Capsule." | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1187 | ||||
#: extending/extending.rst:1182 | ||||
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 " | ||||
| | @ -1646,7 +1642,7 @@ msgstr "" | |||
"différentes manières entre le module fournissant le code et les modules " | ||||
"clients." | ||||
| ||||
#: extending/extending.rst:1193 | ||||
#: extending/extending.rst:1188 | ||||
#, fuzzy | ||||
msgid "" | ||||
"Whichever method you choose, it's important to name your Capsules properly. " | ||||
| | @ -1664,13 +1660,13 @@ msgstr "" | |||
"concernant un éventuel conflit de types, car il n'y a pas de moyen de " | ||||
"distinguer deux ou plusieurs Capsules non nommée entre elles." | ||||
| ||||
#: extending/extending.rst:1200 | ||||
#: extending/extending.rst:1195 | ||||
msgid "" | ||||
"In particular, Capsules used to expose C APIs should be given a name " | ||||
"following this convention::" | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1205 | ||||
#: extending/extending.rst:1200 | ||||
#, fuzzy | ||||
msgid "" | ||||
"The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " | ||||
| | @ -1684,7 +1680,7 @@ msgstr "" | |||
"utilisateurs d'API C un degré élevé de certitude que la Capsule qu'ils " | ||||
"chargent contient l'API C correcte." | ||||
| ||||
#: extending/extending.rst:1210 | ||||
#: extending/extending.rst:1205 | ||||
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 " | ||||
| | @ -1703,7 +1699,7 @@ msgstr "" | |||
"le module et de récupérer ses pointeurs d'API C. Les modules clients n'ont " | ||||
"qu'à appeler cette macro avant d'accéder à l'API C." | ||||
| ||||
#: extending/extending.rst:1218 | ||||
#: extending/extending.rst:1213 | ||||
msgid "" | ||||
"The exporting module is a modification of the :mod:`spam` module from " | ||||
"section :ref:`extending-simpleexample`. The function :func:`spam.system` " | ||||
| | @ -1720,25 +1716,25 @@ msgstr "" | |||
"Cette fonction :c:func:`PySpam_System` est également exportée vers d'autres " | ||||
"modules d'extension." | ||||
| ||||
#: extending/extending.rst:1225 | ||||
#: extending/extending.rst:1220 | ||||
msgid "" | ||||
"The function :c:func:`PySpam_System` is a plain C function, declared " | ||||
"``static`` like everything else::" | ||||
msgstr "" | ||||
| ||||
#: extending/extending.rst:1234 | ||||
#: extending/extending.rst:1229 | ||||
msgid "The function :c:func:`spam_system` is modified in a trivial way::" | ||||
msgstr "La fonction :c:func:`spam_system` est modifiée de manière simple ::" | ||||
| ||||
#: extending/extending.rst:1248 | ||||
#: extending/extending.rst:1243 | ||||
msgid "In the beginning of the module, right after the line ::" | ||||
msgstr "Au début du module, immédiatement après la ligne ::" | ||||
| ||||
#: extending/extending.rst:1252 | ||||
#: extending/extending.rst:1247 | ||||
msgid "two more lines must be added::" | ||||
msgstr "on doit ajouter deux lignes supplémentaires ::" | ||||
| ||||
#: extending/extending.rst:1257 | ||||
#: extending/extending.rst:1252 | ||||
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 " | ||||
| | @ -1750,7 +1746,7 @@ msgstr "" | |||
"Enfin, la fonction d'initialisation du module doit prendre en charge " | ||||
"l'initialisation du tableau de pointeurs de l'API C ::" | ||||
| ||||
#: extending/extending.rst:1287 | ||||
#: extending/extending.rst:1282 | ||||
msgid "" | ||||
"Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " | ||||
"would disappear when :func:`PyInit_spam` terminates!" | ||||
| | @ -1758,7 +1754,7 @@ msgstr "" | |||
"Notez que ``PySpam_API`` est déclaré ``static`` ; sinon le tableau de " | ||||
"pointeurs disparaîtrait lorsque :func:`PyInit_spam`` se finit !" | ||||
| ||||
#: extending/extending.rst:1290 | ||||
#: extending/extending.rst:1285 | ||||
msgid "" | ||||
"The bulk of the work is in the header file :file:`spammodule.h`, which looks " | ||||
"like this::" | ||||
| | @ -1766,7 +1762,7 @@ msgstr "" | |||
"L'essentiel du travail se trouve dans le fichier d'en-tête :file:`spammodule." | ||||
"h`, qui ressemble à ceci ::" | ||||
| ||||
#: extending/extending.rst:1341 | ||||
#: extending/extending.rst:1336 | ||||
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:" | ||||
| | @ -1776,7 +1772,7 @@ msgstr "" | |||
"func:`PySpam_System` est d'appeler la fonction (ou plutôt la macro) :c:func:" | ||||
"`import_spam` dans sa fonction d'initialisation ::" | ||||
| ||||
#: extending/extending.rst:1359 | ||||
#: extending/extending.rst:1354 | ||||
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 " | ||||
| | @ -1787,7 +1783,7 @@ msgstr "" | |||
"même pour chaque fonction exportée, ce qui fait qu'elle ne doit être apprise " | ||||
"qu'une seule fois." | ||||
| ||||
#: extending/extending.rst:1363 | ||||
#: extending/extending.rst:1358 | ||||
msgid "" | ||||
"Finally it should be mentioned that Capsules offer additional functionality, " | ||||
"which is especially useful for memory allocation and deallocation of the " | ||||
| | @ -1804,11 +1800,11 @@ msgstr "" | |||
"file:`Include/pycapsule.h` et :file:`Objects/pycapsule.c` dans la " | ||||
"distribution du code source Python)." | ||||
| ||||
#: extending/extending.rst:1371 | ||||
#: extending/extending.rst:1366 | ||||
msgid "Footnotes" | ||||
msgstr "Notes" | ||||
| ||||
#: extending/extending.rst:1372 | ||||
#: extending/extending.rst:1367 | ||||
msgid "" | ||||
"An interface for this function already exists in the standard module :mod:" | ||||
"`os` --- it was chosen as a simple and straightforward example." | ||||
| | @ -1816,7 +1812,7 @@ msgstr "" | |||
"Une interface pour cette fonction existe déjà dans le module standard :mod:" | ||||
"`os`, elle a été choisie comme un exemple simple et direct." | ||||
| ||||
#: extending/extending.rst:1375 | ||||
#: extending/extending.rst:1370 | ||||
msgid "" | ||||
"The metaphor of \"borrowing\" a reference is not completely correct: the " | ||||
"owner still has a copy of the reference." | ||||
| | @ -1824,7 +1820,7 @@ msgstr "" | |||
"L'expression « emprunter une référence » n'est pas tout à fait correcte, car " | ||||
"le propriétaire a toujours une copie de la référence." | ||||
| ||||
#: extending/extending.rst:1378 | ||||
#: extending/extending.rst:1373 | ||||
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 " | ||||
| | @ -1834,7 +1830,7 @@ msgstr "" | |||
"pas**, le compte de référence lui-même pourrait être en mémoire libérée et " | ||||
"peut donc être réutilisé pour un autre objet !" | ||||
| ||||
#: extending/extending.rst:1382 | ||||
#: extending/extending.rst:1377 | ||||
msgid "" | ||||
"These guarantees don't hold when you use the \"old\" style calling " | ||||
"convention --- this is still found in much existing code." | ||||
| | | |||
| | @ -5,7 +5,7 @@ msgid "" | |||
msgstr "" | ||||
"Project-Id-Version: Python 3\n" | ||||
"Report-Msgid-Bugs-To: \n" | ||||
"POT-Creation-Date: 2021-02-24 17:33+0100\n" | ||||
"POT-Creation-Date: 2021-09-23 16:16+0200\n" | ||||
"PO-Revision-Date: 2021-02-07 20:03+0100\n" | ||||
"Last-Translator: \n" | ||||
"Language-Team: FRENCH <traductions@lists.afpy.org>\n" | ||||
| | @ -28,7 +28,7 @@ msgstr "" | |||
#: extending/newtypes.rst:14 | ||||
msgid "" | ||||
"Here is the definition of :c:type:`PyTypeObject`, with some fields only used " | ||||
"in debug builds omitted:" | ||||
"in :ref:`debug builds <debug-build>` omitted:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:20 | ||||
| | @ -311,30 +311,25 @@ msgid "Never writable." | |||
msgstr "Jamais disponible en écriture." | ||||
| ||||
#: extending/newtypes.rst:290 | ||||
msgid ":const:`READ_RESTRICTED`" | ||||
msgstr ":const:`READ_RESTRICTED`" | ||||
#, fuzzy | ||||
msgid ":const:`PY_AUDIT_READ`" | ||||
msgstr ":const:`READONLY`" | ||||
| ||||
#: extending/newtypes.rst:290 | ||||
msgid "Not readable in restricted mode." | ||||
msgstr "Non disponible en lecture, dans le mode restreint." | ||||
msgid "" | ||||
"Emit an ``object.__getattr__`` :ref:`audit events <audit-events>` before " | ||||
"reading." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:292 | ||||
msgid ":const:`WRITE_RESTRICTED`" | ||||
msgstr ":const:`WRITE_RESTRICTED`" | ||||
#: extending/newtypes.rst:295 | ||||
msgid "" | ||||
":const:`RESTRICTED`, :const:`READ_RESTRICTED` and :const:`WRITE_RESTRICTED` " | ||||
"are deprecated. However, :const:`READ_RESTRICTED` is an alias for :const:" | ||||
"`PY_AUDIT_READ`, so fields that specify either :const:`RESTRICTED` or :const:" | ||||
"`READ_RESTRICTED` will also raise an audit event." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:292 | ||||
msgid "Not writable in restricted mode." | ||||
msgstr "Non disponible en écriture dans le mode restreint." | ||||
| ||||
#: extending/newtypes.rst:294 | ||||
msgid ":const:`RESTRICTED`" | ||||
msgstr ":const:`RESTRICTED`" | ||||
| ||||
#: extending/newtypes.rst:294 | ||||
msgid "Not readable or writable in restricted mode." | ||||
msgstr "Non disponible en lecture ou écriture, en mode restreint." | ||||
| ||||
#: extending/newtypes.rst:303 | ||||
#: extending/newtypes.rst:308 | ||||
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 " | ||||
| | @ -351,17 +346,17 @@ msgstr "" | |||
"descripteur de l'objet de classe, et utiliser son attribut :attr:`__doc__` " | ||||
"pour renvoyer le *docstring*." | ||||
| ||||
#: extending/newtypes.rst:309 | ||||
#: extending/newtypes.rst:314 | ||||
msgid "" | ||||
"As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry " | ||||
"with a :attr:`name` value of ``NULL`` is required." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:323 | ||||
#: extending/newtypes.rst:328 | ||||
msgid "Type-specific Attribute Management" | ||||
msgstr "Gestion des attributs de type spécifiques" | ||||
| ||||
#: extending/newtypes.rst:325 | ||||
#: extending/newtypes.rst:330 | ||||
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:" | ||||
| | @ -372,18 +367,18 @@ msgid "" | |||
"functionality, you'll understand what needs to be done." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:333 | ||||
#: extending/newtypes.rst:338 | ||||
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 "" | ||||
| ||||
#: extending/newtypes.rst:337 | ||||
#: extending/newtypes.rst:342 | ||||
msgid "Here is an example::" | ||||
msgstr "Voici un exemple ::" | ||||
| ||||
#: extending/newtypes.rst:353 | ||||
#: extending/newtypes.rst:358 | ||||
msgid "" | ||||
"The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:" | ||||
"`__setattr__` or :meth:`__delattr__` method of a class instance would be " | ||||
| | @ -393,11 +388,11 @@ msgid "" | |||
"should be set to ``NULL``. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:367 | ||||
#: extending/newtypes.rst:372 | ||||
msgid "Object Comparison" | ||||
msgstr "Comparaison des objets" | ||||
| ||||
#: extending/newtypes.rst:373 | ||||
#: extending/newtypes.rst:378 | ||||
msgid "" | ||||
"The :c:member:`~PyTypeObject.tp_richcompare` handler is called when " | ||||
"comparisons are needed. It is analogous to the :ref:`rich comparison " | ||||
| | @ -405,7 +400,7 @@ msgid "" | |||
"`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:378 | ||||
#: extending/newtypes.rst:383 | ||||
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``, " | ||||
| | @ -416,23 +411,23 @@ msgid "" | |||
"should be tried, or ``NULL`` if an exception was set." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:386 | ||||
#: extending/newtypes.rst:391 | ||||
msgid "" | ||||
"Here is a sample implementation, for a datatype that is considered equal if " | ||||
"the size of an internal pointer is equal::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:416 | ||||
#: extending/newtypes.rst:421 | ||||
msgid "Abstract Protocol Support" | ||||
msgstr "Support pour le protocole abstrait" | ||||
| ||||
#: extending/newtypes.rst:418 | ||||
#: extending/newtypes.rst:423 | ||||
msgid "" | ||||
"Python supports a variety of *abstract* 'protocols;' the specific interfaces " | ||||
"provided to use these interfaces are documented in :ref:`abstract`." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:422 | ||||
#: extending/newtypes.rst:427 | ||||
msgid "" | ||||
"A number of these abstract interfaces were defined early in the development " | ||||
"of the Python implementation. In particular, the number, mapping, and " | ||||
| | @ -447,7 +442,7 @@ msgid "" | |||
"slot, but a slot may still be unfilled.) ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:437 | ||||
#: extending/newtypes.rst:442 | ||||
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 " | ||||
| | @ -458,13 +453,13 @@ msgid "" | |||
"distribution. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:446 | ||||
#: extending/newtypes.rst:451 | ||||
msgid "" | ||||
"This function, if you choose to provide it, should return a hash number for " | ||||
"an instance of your data type. Here is a simple example::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:459 | ||||
#: extending/newtypes.rst:464 | ||||
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, " | ||||
| | @ -472,7 +467,7 @@ msgid "" | |||
"computation is successful, as seen above." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:468 | ||||
#: extending/newtypes.rst:473 | ||||
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 " | ||||
| | @ -480,23 +475,23 @@ msgid "" | |||
"handler is invoked." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:472 | ||||
#: extending/newtypes.rst:477 | ||||
msgid "This function takes three arguments:" | ||||
msgstr "Cette fonction prend trois arguments :" | ||||
| ||||
#: extending/newtypes.rst:474 | ||||
#: extending/newtypes.rst:479 | ||||
msgid "" | ||||
"*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 "" | ||||
| ||||
#: extending/newtypes.rst:477 | ||||
#: extending/newtypes.rst:482 | ||||
msgid "" | ||||
"*args* is a tuple containing the arguments to the call. You can use :c:func:" | ||||
"`PyArg_ParseTuple` to extract the arguments." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:480 | ||||
#: extending/newtypes.rst:485 | ||||
msgid "" | ||||
"*kwds* is a dictionary of keyword arguments that were passed. If this is non-" | ||||
"``NULL`` and you support keyword arguments, use :c:func:" | ||||
| | @ -505,11 +500,11 @@ msgid "" | |||
"`TypeError` with a message saying that keyword arguments are not supported." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:486 | ||||
#: extending/newtypes.rst:491 | ||||
msgid "Here is a toy ``tp_call`` implementation::" | ||||
msgstr "Ceci est une implémentation ``tp_call`` très simple ::" | ||||
| ||||
#: extending/newtypes.rst:512 | ||||
#: extending/newtypes.rst:517 | ||||
msgid "" | ||||
"These functions provide support for the iterator protocol. Both handlers " | ||||
"take exactly one parameter, the instance for which they are being called, " | ||||
| | @ -520,7 +515,7 @@ msgid "" | |||
"__next__` method." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:519 | ||||
#: extending/newtypes.rst:524 | ||||
msgid "" | ||||
"Any :term:`iterable` object must implement the :c:member:`~PyTypeObject." | ||||
"tp_iter` handler, which must return an :term:`iterator` object. Here the " | ||||
| | @ -531,7 +526,7 @@ msgstr "" | |||
"`iterator`. Ici, les mêmes directives s'appliquent de la même façon que " | ||||
"pour les classes *Python* :" | ||||
| ||||
#: extending/newtypes.rst:523 | ||||
#: extending/newtypes.rst:528 | ||||
msgid "" | ||||
"For collections (such as lists and tuples) which can support multiple " | ||||
"independent iterators, a new iterator should be created and returned by each " | ||||
| | @ -541,7 +536,7 @@ msgstr "" | |||
"implémenter plusieurs itérateurs indépendants, un nouvel itérateur doit être " | ||||
"créé et renvoyé par chaque appel de type :c:member:`~PyTypeObject.tp_iter`." | ||||
| ||||
#: extending/newtypes.rst:526 | ||||
#: extending/newtypes.rst:531 | ||||
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." | ||||
| | @ -549,7 +544,7 @@ msgid "" | |||
"therefore implement the :c:member:`~PyTypeObject.tp_iternext` handler." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:531 | ||||
#: extending/newtypes.rst:536 | ||||
msgid "" | ||||
"Any :term:`iterator` object should implement both :c:member:`~PyTypeObject." | ||||
"tp_iter` and :c:member:`~PyTypeObject.tp_iternext`. An iterator's :c:member:" | ||||
| | @ -564,11 +559,11 @@ msgid "" | |||
"``NULL``." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes.rst:547 | ||||
#: extending/newtypes.rst:552 | ||||
msgid "Weak Reference Support" | ||||
msgstr "Prise en charge de la référence faible" | ||||
| ||||
#: extending/newtypes.rst:549 | ||||
#: extending/newtypes.rst:554 | ||||
msgid "" | ||||
"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 " | ||||
| | @ -579,11 +574,11 @@ msgstr "" | |||
"faible sans avoir à supporter le surcoût de la performance critique des " | ||||
"certains objets, tels que les nombres." | ||||
| ||||
#: extending/newtypes.rst:554 | ||||
#: extending/newtypes.rst:559 | ||||
msgid "Documentation for the :mod:`weakref` module." | ||||
msgstr "Documentation pour le module :mod:`weakref`." | ||||
| ||||
#: extending/newtypes.rst:556 | ||||
#: extending/newtypes.rst:561 | ||||
msgid "" | ||||
"For an object to be weakly referencable, the extension type must do two " | ||||
"things:" | ||||
| | @ -591,7 +586,7 @@ msgstr "" | |||
"Pour qu'un objet soit faiblement référençable, le type d'extension doit " | ||||
"faire deux choses :" | ||||
| ||||
#: extending/newtypes.rst:558 | ||||
#: extending/newtypes.rst:563 | ||||
msgid "" | ||||
"Include a :c:type:`PyObject\\*` field in the C object structure dedicated to " | ||||
"the weak reference mechanism. The object's constructor should leave it " | ||||
| | @ -603,7 +598,7 @@ msgstr "" | |||
"la valeur ``NULL`` (ce qui est automatique lorsque l'on utilise le champ par " | ||||
"défaut :c:member:`~PyTypeObject.tp_alloc`)." | ||||
| ||||
#: extending/newtypes.rst:563 | ||||
#: extending/newtypes.rst:568 | ||||
msgid "" | ||||
"Set the :c:member:`~PyTypeObject.tp_weaklistoffset` type member to the " | ||||
"offset of the aforementioned field in the C object structure, so that the " | ||||
| | @ -614,7 +609,7 @@ msgstr "" | |||
"l'objet *C*, afin que l'interpréteur sache comment accéder à ce champ et le " | ||||
"modifier." | ||||
| ||||
#: extending/newtypes.rst:567 | ||||
#: extending/newtypes.rst:572 | ||||
msgid "" | ||||
"Concretely, here is how a trivial object structure would be augmented with " | ||||
"the required field::" | ||||
| | @ -622,12 +617,12 @@ msgstr "" | |||
"Concrètement, voici comment une structure d'objet simple serait complétée " | ||||
"par le champ requis ::" | ||||
| ||||
#: extending/newtypes.rst:575 | ||||
#: extending/newtypes.rst:580 | ||||
msgid "And the corresponding member in the statically-declared type object::" | ||||
msgstr "" | ||||
"Et le membre correspondant dans l'objet de type déclaré statiquement ::" | ||||
| ||||
#: extending/newtypes.rst:583 | ||||
#: extending/newtypes.rst:588 | ||||
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-" | ||||
| | @ -637,11 +632,11 @@ msgstr "" | |||
"référence faible (en appelant :c:func:`PyObject_ClearWeakRefs`) si le champ " | ||||
"est non ``NULL`` ::" | ||||
| ||||
#: extending/newtypes.rst:599 | ||||
#: extending/newtypes.rst:604 | ||||
msgid "More Suggestions" | ||||
msgstr "Plus de suggestions" | ||||
| ||||
#: extending/newtypes.rst:601 | ||||
#: extending/newtypes.rst:606 | ||||
msgid "" | ||||
"In order to learn how to implement any specific method for your new data " | ||||
"type, get the :term:`CPython` source code. Go to the :file:`Objects` " | ||||
| | @ -656,7 +651,7 @@ msgstr "" | |||
"``tp_richcompare``). Vous trouverez des exemples de la fonction que vous " | ||||
"voulez implémenter." | ||||
| ||||
#: extending/newtypes.rst:607 | ||||
#: extending/newtypes.rst:612 | ||||
msgid "" | ||||
"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 " | ||||
| | @ -666,20 +661,38 @@ msgstr "" | |||
"du type que vous implémentez, utilisez la fonction :c:func:" | ||||
"`PyObject_TypeCheck`. Voici un exemple de son utilisation ::" | ||||
| ||||
#: extending/newtypes.rst:618 | ||||
#: extending/newtypes.rst:623 | ||||
msgid "Download CPython source releases." | ||||
msgstr "Télécharger les versions sources de *CPython*." | ||||
| ||||
#: extending/newtypes.rst:618 | ||||
#: extending/newtypes.rst:623 | ||||
msgid "https://www.python.org/downloads/source/" | ||||
msgstr "https://www.python.org/downloads/source/" | ||||
| ||||
#: extending/newtypes.rst:620 | ||||
#: extending/newtypes.rst:625 | ||||
msgid "" | ||||
"The CPython project on GitHub, where the CPython source code is developed." | ||||
msgstr "" | ||||
"Le projet *CPython* sur *GitHub*, où se trouve le code source *CPython*." | ||||
| ||||
#: extending/newtypes.rst:621 | ||||
#: extending/newtypes.rst:626 | ||||
msgid "https://github.com/python/cpython" | ||||
msgstr "https://github.com/python/cpython" | ||||
| ||||
#~ msgid ":const:`READ_RESTRICTED`" | ||||
#~ msgstr ":const:`READ_RESTRICTED`" | ||||
| ||||
#~ msgid "Not readable in restricted mode." | ||||
#~ msgstr "Non disponible en lecture, dans le mode restreint." | ||||
| ||||
#~ msgid ":const:`WRITE_RESTRICTED`" | ||||
#~ msgstr ":const:`WRITE_RESTRICTED`" | ||||
| ||||
#~ msgid "Not writable in restricted mode." | ||||
#~ msgstr "Non disponible en écriture dans le mode restreint." | ||||
| ||||
#~ msgid ":const:`RESTRICTED`" | ||||
#~ msgstr ":const:`RESTRICTED`" | ||||
| ||||
#~ msgid "Not readable or writable in restricted mode." | ||||
#~ msgstr "Non disponible en lecture ou écriture, en mode restreint." | ||||
| | | |||
| | @ -5,7 +5,7 @@ msgid "" | |||
msgstr "" | ||||
"Project-Id-Version: Python 3\n" | ||||
"Report-Msgid-Bugs-To: \n" | ||||
"POT-Creation-Date: 2020-08-24 09:01+0200\n" | ||||
"POT-Creation-Date: 2021-09-23 16:16+0200\n" | ||||
"PO-Revision-Date: 2018-06-17 10:15+0200\n" | ||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||||
"Language-Team: FRENCH <traductions@lists.afpy.org>\n" | ||||
| | @ -100,34 +100,35 @@ msgid "" | |||
"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." | ||||
"abstract away the layout and to enable additional fields in :ref:`debug " | ||||
"builds <debug-build>`." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:75 | ||||
#: extending/newtypes_tutorial.rst:76 | ||||
msgid "" | ||||
"There is no semicolon above after the :c:macro:`PyObject_HEAD` macro. Be " | ||||
"wary of adding one by accident: some compilers will complain." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:78 | ||||
#: extending/newtypes_tutorial.rst:79 | ||||
msgid "" | ||||
"Of course, objects generally store additional data besides the standard " | ||||
"``PyObject_HEAD`` boilerplate; for example, here is the definition for " | ||||
"standard Python floats::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:87 | ||||
#: extending/newtypes_tutorial.rst:88 | ||||
msgid "The second bit is the definition of the type object. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:100 | ||||
#: extending/newtypes_tutorial.rst:101 | ||||
msgid "" | ||||
"We recommend using C99-style designated initializers as above, to avoid " | ||||
"listing all the :c:type:`PyTypeObject` fields that you don't care about and " | ||||
"also to avoid caring about the fields' declaration order." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:104 | ||||
#: extending/newtypes_tutorial.rst:105 | ||||
msgid "" | ||||
"The actual definition of :c:type:`PyTypeObject` in :file:`object.h` has many " | ||||
"more :ref:`fields <type-structs>` than the definition above. The remaining " | ||||
| | @ -135,23 +136,23 @@ msgid "" | |||
"to not specify them explicitly unless you need them." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:109 | ||||
#: extending/newtypes_tutorial.rst:110 | ||||
msgid "We're going to pick it apart, one field at a time::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:113 | ||||
#: extending/newtypes_tutorial.rst:114 | ||||
msgid "" | ||||
"This line is mandatory boilerplate to initialize the ``ob_base`` field " | ||||
"mentioned above. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:118 | ||||
#: extending/newtypes_tutorial.rst:119 | ||||
msgid "" | ||||
"The name of our type. This will appear in the default textual " | ||||
"representation of our objects and in some error messages, for example:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:128 | ||||
#: extending/newtypes_tutorial.rst:129 | ||||
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:" | ||||
| | @ -160,14 +161,14 @@ msgid "" | |||
"type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:137 | ||||
#: extending/newtypes_tutorial.rst:138 | ||||
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 "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:143 | ||||
#: extending/newtypes_tutorial.rst:144 | ||||
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 " | ||||
| | @ -181,23 +182,23 @@ msgid "" | |||
"your base type, and therefore increasing its size." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:153 | ||||
#: extending/newtypes_tutorial.rst:154 | ||||
msgid "We set the class flags to :const:`Py_TPFLAGS_DEFAULT`. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:157 | ||||
#: extending/newtypes_tutorial.rst:158 | ||||
msgid "" | ||||
"All types should include this constant in their flags. It enables all of " | ||||
"the members defined until at least Python 3.3. If you need further members, " | ||||
"you will need to OR the corresponding flags." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:161 | ||||
#: extending/newtypes_tutorial.rst:162 | ||||
msgid "" | ||||
"We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:165 | ||||
#: extending/newtypes_tutorial.rst:166 | ||||
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:" | ||||
| | @ -206,53 +207,53 @@ msgid "" | |||
"`PyType_GenericNew`. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:172 | ||||
#: extending/newtypes_tutorial.rst:173 | ||||
msgid "" | ||||
"Everything else in the file should be familiar, except for some code in :c:" | ||||
"func:`PyInit_custom`::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:178 | ||||
#: extending/newtypes_tutorial.rst:179 | ||||
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 "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:189 | ||||
#: extending/newtypes_tutorial.rst:190 | ||||
msgid "" | ||||
"This adds the type to the module dictionary. This allows us to create :" | ||||
"class:`Custom` instances by calling the :class:`Custom` class:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:197 | ||||
#: extending/newtypes_tutorial.rst:198 | ||||
msgid "" | ||||
"That's it! All that remains is to build it; put the above code in a file " | ||||
"called :file:`custom.c` and:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:206 | ||||
#: extending/newtypes_tutorial.rst:207 | ||||
msgid "in a file called :file:`setup.py`; then typing" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:212 | ||||
#: extending/newtypes_tutorial.rst:213 | ||||
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 "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:216 | ||||
#: extending/newtypes_tutorial.rst:217 | ||||
msgid "That wasn't so hard, was it?" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:218 | ||||
#: extending/newtypes_tutorial.rst:219 | ||||
msgid "" | ||||
"Of course, the current Custom type is pretty uninteresting. It has no data " | ||||
"and doesn't do anything. It can't even be subclassed." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:222 | ||||
#: extending/newtypes_tutorial.rst:223 | ||||
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 " | ||||
| | @ -262,32 +263,32 @@ msgid "" | |||
"packages/>`_." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:230 | ||||
#: extending/newtypes_tutorial.rst:231 | ||||
msgid "Adding data and methods to the Basic example" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:232 | ||||
#: extending/newtypes_tutorial.rst:233 | ||||
msgid "" | ||||
"Let's extend the basic example to add some data and methods. Let's also " | ||||
"make the type usable as a base class. We'll create a new module, :mod:" | ||||
"`custom2` that adds these capabilities:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:239 | ||||
#: extending/newtypes_tutorial.rst:240 | ||||
msgid "This version of the module has a number of changes." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:241 | ||||
#: extending/newtypes_tutorial.rst:242 | ||||
msgid "We've added an extra include::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:245 | ||||
#: extending/newtypes_tutorial.rst:246 | ||||
msgid "" | ||||
"This include provides declarations that we use to handle attributes, as " | ||||
"described a bit later." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:248 | ||||
#: extending/newtypes_tutorial.rst:249 | ||||
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 " | ||||
| | @ -295,21 +296,21 @@ msgid "" | |||
"integer." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:252 | ||||
#: extending/newtypes_tutorial.rst:253 | ||||
msgid "The object structure is updated accordingly::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:261 | ||||
#: extending/newtypes_tutorial.rst:262 | ||||
msgid "" | ||||
"Because we now have data to manage, we have to be more careful about object " | ||||
"allocation and deallocation. At a minimum, we need a deallocation method::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:272 | ||||
#: extending/newtypes_tutorial.rst:273 | ||||
msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:276 | ||||
#: extending/newtypes_tutorial.rst:277 | ||||
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 " | ||||
| | @ -320,7 +321,7 @@ msgid "" | |||
"instance of a subclass." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:285 | ||||
#: extending/newtypes_tutorial.rst:286 | ||||
msgid "" | ||||
"The explicit cast to ``destructor`` above is needed because we defined " | ||||
"``Custom_dealloc`` to take a ``CustomObject *`` argument, but the " | ||||
| | @ -329,17 +330,17 @@ msgid "" | |||
"oriented polymorphism, in C!" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:291 | ||||
#: extending/newtypes_tutorial.rst:292 | ||||
msgid "" | ||||
"We want to make sure that the first and last names are initialized to empty " | ||||
"strings, so we provide a ``tp_new`` implementation::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:315 | ||||
#: extending/newtypes_tutorial.rst:316 | ||||
msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:319 | ||||
#: extending/newtypes_tutorial.rst:320 | ||||
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:" | ||||
| | @ -350,7 +351,7 @@ msgid "" | |||
"attributes to non-``NULL`` default values." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:327 | ||||
#: extending/newtypes_tutorial.rst:328 | ||||
msgid "" | ||||
"``tp_new`` is passed the type being instantiated (not necessarily " | ||||
"``CustomType``, if a subclass is instantiated) and any arguments passed when " | ||||
| | @ -360,25 +361,25 @@ msgid "" | |||
"k.a. ``tp_init`` in C or ``__init__`` in Python) methods." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:335 | ||||
#: extending/newtypes_tutorial.rst:336 | ||||
msgid "" | ||||
"``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do " | ||||
"it itself." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:338 | ||||
#: extending/newtypes_tutorial.rst:339 | ||||
msgid "" | ||||
"The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` " | ||||
"slot to allocate memory::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:343 | ||||
#: extending/newtypes_tutorial.rst:344 | ||||
msgid "" | ||||
"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject." | ||||
"tp_alloc` result against ``NULL`` before proceeding." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:347 | ||||
#: extending/newtypes_tutorial.rst:348 | ||||
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 " | ||||
| | @ -386,7 +387,7 @@ msgid "" | |||
"allocation strategy." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:353 | ||||
#: extending/newtypes_tutorial.rst:354 | ||||
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:" | ||||
| | @ -399,17 +400,17 @@ msgid "" | |||
"subclasses without getting a :exc:`TypeError`.)" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:363 | ||||
#: extending/newtypes_tutorial.rst:364 | ||||
msgid "" | ||||
"We also define an initialization function which accepts arguments to provide " | ||||
"initial values for our instance::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:392 | ||||
#: extending/newtypes_tutorial.rst:393 | ||||
msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:396 | ||||
#: extending/newtypes_tutorial.rst:397 | ||||
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. " | ||||
| | @ -417,7 +418,7 @@ msgid "" | |||
"return either ``0`` on success or ``-1`` on error." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:401 | ||||
#: extending/newtypes_tutorial.rst:402 | ||||
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 " | ||||
| | @ -428,7 +429,7 @@ msgid "" | |||
"``first`` member like this::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:415 | ||||
#: extending/newtypes_tutorial.rst:416 | ||||
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 " | ||||
| | @ -438,49 +439,49 @@ msgid "" | |||
"accesses and modifies our object." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:422 | ||||
#: extending/newtypes_tutorial.rst:423 | ||||
msgid "" | ||||
"To be paranoid and protect ourselves against this possibility, we almost " | ||||
"always reassign members before decrementing their reference counts. When " | ||||
"don't we have to do this?" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:426 | ||||
#: extending/newtypes_tutorial.rst:427 | ||||
msgid "when we absolutely know that the reference count is greater than 1;" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:428 | ||||
#: extending/newtypes_tutorial.rst:429 | ||||
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 "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:431 | ||||
#: extending/newtypes_tutorial.rst:432 | ||||
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 "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:434 | ||||
#: extending/newtypes_tutorial.rst:435 | ||||
msgid "" | ||||
"We want to expose our instance variables as attributes. There are a number " | ||||
"of ways to do that. The simplest way is to define member definitions::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:447 | ||||
#: extending/newtypes_tutorial.rst:448 | ||||
msgid "" | ||||
"and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:451 | ||||
#: extending/newtypes_tutorial.rst:452 | ||||
msgid "" | ||||
"Each member definition has a member name, type, offset, access flags and " | ||||
"documentation string. See the :ref:`Generic-Attribute-Management` section " | ||||
"below for details." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:455 | ||||
#: extending/newtypes_tutorial.rst:456 | ||||
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 " | ||||
| | @ -491,13 +492,13 @@ msgid "" | |||
"deleted." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:462 | ||||
#: extending/newtypes_tutorial.rst:463 | ||||
msgid "" | ||||
"We define a single method, :meth:`Custom.name()`, that outputs the objects " | ||||
"name as the concatenation of the first and last names. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:479 | ||||
#: extending/newtypes_tutorial.rst:480 | ||||
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 " | ||||
| | @ -507,7 +508,7 @@ msgid "" | |||
"method is equivalent to the Python method:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:491 | ||||
#: extending/newtypes_tutorial.rst:492 | ||||
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 " | ||||
| | @ -516,23 +517,23 @@ msgid "" | |||
"We'll see how to do that in the next section." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:497 | ||||
#: extending/newtypes_tutorial.rst:498 | ||||
msgid "" | ||||
"Now that we've defined the method, we need to create an array of method " | ||||
"definitions::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:507 | ||||
#: extending/newtypes_tutorial.rst:508 | ||||
msgid "" | ||||
"(note that we used the :const:`METH_NOARGS` flag to indicate that the method " | ||||
"is expecting no arguments other than *self*)" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:510 | ||||
#: extending/newtypes_tutorial.rst:511 | ||||
msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:514 | ||||
#: extending/newtypes_tutorial.rst:515 | ||||
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 " | ||||
| | @ -540,22 +541,22 @@ msgid "" | |||
"to add the :const:`Py_TPFLAGS_BASETYPE` to our class flag definition::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:521 | ||||
#: extending/newtypes_tutorial.rst:522 | ||||
msgid "" | ||||
"We rename :c:func:`PyInit_custom` to :c:func:`PyInit_custom2`, update the " | ||||
"module name in the :c:type:`PyModuleDef` struct, and update the full class " | ||||
"name in the :c:type:`PyTypeObject` struct." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:525 | ||||
#: extending/newtypes_tutorial.rst:526 | ||||
msgid "Finally, we update our :file:`setup.py` file to build the new module:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:538 | ||||
#: extending/newtypes_tutorial.rst:539 | ||||
msgid "Providing finer control over data attributes" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:540 | ||||
#: extending/newtypes_tutorial.rst:541 | ||||
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 " | ||||
| | @ -564,14 +565,14 @@ msgid "" | |||
"make sure that these attributes always contain strings." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:549 | ||||
#: extending/newtypes_tutorial.rst:550 | ||||
msgid "" | ||||
"To provide greater control, over the :attr:`first` and :attr:`last` " | ||||
"attributes, we'll use custom getter and setter functions. Here are the " | ||||
"functions for getting and setting the :attr:`first` attribute::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:580 | ||||
#: extending/newtypes_tutorial.rst:581 | ||||
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 " | ||||
| | @ -581,7 +582,7 @@ msgid "" | |||
"data in the closure.)" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:586 | ||||
#: extending/newtypes_tutorial.rst:587 | ||||
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 " | ||||
| | @ -589,32 +590,32 @@ msgid "" | |||
"or if its new value is not a string." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:591 | ||||
#: extending/newtypes_tutorial.rst:592 | ||||
msgid "We create an array of :c:type:`PyGetSetDef` structures::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:601 | ||||
#: extending/newtypes_tutorial.rst:602 | ||||
msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:605 | ||||
#: extending/newtypes_tutorial.rst:606 | ||||
msgid "" | ||||
"The last item in a :c:type:`PyGetSetDef` structure is the \"closure\" " | ||||
"mentioned above. In this case, we aren't using a closure, so we just pass " | ||||
"``NULL``." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:608 | ||||
#: extending/newtypes_tutorial.rst:609 | ||||
msgid "We also remove the member definitions for these attributes::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:616 | ||||
#: extending/newtypes_tutorial.rst:617 | ||||
msgid "" | ||||
"We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " | ||||
"allow strings [#]_ to be passed::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:645 | ||||
#: extending/newtypes_tutorial.rst:646 | ||||
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 " | ||||
| | @ -624,25 +625,25 @@ msgid "" | |||
"possibility that the initialization of these members failed in ``tp_new``." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:652 | ||||
#: extending/newtypes_tutorial.rst:653 | ||||
msgid "" | ||||
"We also rename the module initialization function and module name in the " | ||||
"initialization function, as we did before, and we add an extra definition to " | ||||
"the :file:`setup.py` file." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:658 | ||||
#: extending/newtypes_tutorial.rst:659 | ||||
msgid "Supporting cyclic garbage collection" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:660 | ||||
#: extending/newtypes_tutorial.rst:661 | ||||
msgid "" | ||||
"Python has a :term:`cyclic garbage collector (GC) <garbage collection>` that " | ||||
"can identify unneeded objects even when their reference counts are not zero. " | ||||
"This can happen when objects are involved in cycles. For example, consider:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:670 | ||||
#: extending/newtypes_tutorial.rst:671 | ||||
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 " | ||||
| | @ -650,7 +651,7 @@ msgid "" | |||
"out that the list is garbage and free it." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:675 | ||||
#: extending/newtypes_tutorial.rst:676 | ||||
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 [#]_. " | ||||
| | @ -659,7 +660,7 @@ msgid "" | |||
"reasons, :class:`Custom` objects can participate in cycles:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:689 | ||||
#: extending/newtypes_tutorial.rst:690 | ||||
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 " | ||||
| | @ -667,13 +668,13 @@ msgid "" | |||
"slots:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:696 | ||||
#: extending/newtypes_tutorial.rst:697 | ||||
msgid "" | ||||
"First, the traversal method lets the cyclic GC know about subobjects that " | ||||
"could participate in cycles::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:716 | ||||
#: extending/newtypes_tutorial.rst:717 | ||||
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:" | ||||
| | @ -682,26 +683,26 @@ msgid "" | |||
"be returned if it is non-zero." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:722 | ||||
#: extending/newtypes_tutorial.rst:723 | ||||
msgid "" | ||||
"Python provides a :c:func:`Py_VISIT` macro that automates calling visit " | ||||
"functions. With :c:func:`Py_VISIT`, we can minimize the amount of " | ||||
"boilerplate in ``Custom_traverse``::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:735 | ||||
#: extending/newtypes_tutorial.rst:736 | ||||
msgid "" | ||||
"The :c:member:`~PyTypeObject.tp_traverse` implementation must name its " | ||||
"arguments exactly *visit* and *arg* in order to use :c:func:`Py_VISIT`." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:738 | ||||
#: extending/newtypes_tutorial.rst:739 | ||||
msgid "" | ||||
"Second, we need to provide a method for clearing any subobjects that can " | ||||
"participate in cycles::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:749 | ||||
#: extending/newtypes_tutorial.rst:750 | ||||
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 " | ||||
| | @ -711,18 +712,18 @@ msgid "" | |||
"again (*especially* if there is a reference cycle)." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:757 | ||||
#: extending/newtypes_tutorial.rst:758 | ||||
msgid "You could emulate :c:func:`Py_CLEAR` by writing::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:764 | ||||
#: extending/newtypes_tutorial.rst:765 | ||||
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 "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:768 | ||||
#: extending/newtypes_tutorial.rst:769 | ||||
msgid "" | ||||
"The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " | ||||
"attributes. It means the circular GC can be triggered inside the function. " | ||||
| | @ -732,12 +733,12 @@ msgid "" | |||
"`PyObject_GC_UnTrack` and ``Custom_clear``::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:783 | ||||
#: extending/newtypes_tutorial.rst:784 | ||||
msgid "" | ||||
"Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:787 | ||||
#: extending/newtypes_tutorial.rst:788 | ||||
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 " | ||||
| | @ -745,11 +746,11 @@ msgid "" | |||
"automatically provided." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:793 | ||||
#: extending/newtypes_tutorial.rst:794 | ||||
msgid "Subclassing other types" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:795 | ||||
#: extending/newtypes_tutorial.rst:796 | ||||
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 " | ||||
| | @ -757,7 +758,7 @@ msgid "" | |||
"share these :c:type:`PyTypeObject` structures between extension modules." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:800 | ||||
#: extending/newtypes_tutorial.rst:801 | ||||
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 " | ||||
| | @ -765,34 +766,34 @@ msgid "" | |||
"that increases an internal counter:" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:820 | ||||
#: extending/newtypes_tutorial.rst:821 | ||||
msgid "" | ||||
"As you can see, the source code closely resembles the :class:`Custom` " | ||||
"examples in previous sections. We will break down the main differences " | ||||
"between them. ::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:828 | ||||
#: extending/newtypes_tutorial.rst:829 | ||||
msgid "" | ||||
"The primary difference for derived type objects is that the base type's " | ||||
"object structure must be the first value. The base type will already " | ||||
"include the :c:func:`PyObject_HEAD` at the beginning of its structure." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:832 | ||||
#: extending/newtypes_tutorial.rst:833 | ||||
msgid "" | ||||
"When a Python object is a :class:`SubList` instance, its ``PyObject *`` " | ||||
"pointer can be safely cast to both ``PyListObject *`` and ``SubListObject " | ||||
"*``::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:844 | ||||
#: extending/newtypes_tutorial.rst:845 | ||||
msgid "" | ||||
"We see above how to call through to the :attr:`__init__` method of the base " | ||||
"type." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:847 | ||||
#: extending/newtypes_tutorial.rst:848 | ||||
msgid "" | ||||
"This pattern is important when writing a type with custom :c:member:" | ||||
"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " | ||||
| | @ -801,7 +802,7 @@ msgid "" | |||
"the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:853 | ||||
#: extending/newtypes_tutorial.rst:854 | ||||
msgid "" | ||||
"The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." | ||||
"tp_base` specifying the type's concrete base class. Due to cross-platform " | ||||
| | @ -810,7 +811,7 @@ msgid "" | |||
"function::" | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:881 | ||||
#: extending/newtypes_tutorial.rst:882 | ||||
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 " | ||||
| | @ -819,29 +820,29 @@ msgid "" | |||
"from the base type will be inherited." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:887 | ||||
#: extending/newtypes_tutorial.rst:888 | ||||
msgid "" | ||||
"After that, calling :c:func:`PyType_Ready` and adding the type object to the " | ||||
"module is the same as with the basic :class:`Custom` examples." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:892 | ||||
#: extending/newtypes_tutorial.rst:893 | ||||
msgid "Footnotes" | ||||
msgstr "Notes" | ||||
| ||||
#: extending/newtypes_tutorial.rst:893 | ||||
#: extending/newtypes_tutorial.rst:894 | ||||
msgid "" | ||||
"This is true when we know that the object is a basic type, like a string or " | ||||
"a float." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:896 | ||||
#: extending/newtypes_tutorial.rst:897 | ||||
msgid "" | ||||
"We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " | ||||
"this example, because our type doesn't support garbage collection." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:899 | ||||
#: extending/newtypes_tutorial.rst:900 | ||||
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 " | ||||
| | @ -851,7 +852,7 @@ msgid "" | |||
"objects." | ||||
msgstr "" | ||||
| ||||
#: extending/newtypes_tutorial.rst:905 | ||||
#: extending/newtypes_tutorial.rst:906 | ||||
msgid "" | ||||
"Also, even with our attributes restricted to strings instances, the user " | ||||
"could pass arbitrary :class:`str` subclasses and therefore still create " | ||||
| | | |||
Loading…
Add table
Add a link
Reference in a new issue