Uniformisation et simplification des chemins.

This commit is contained in:
Julien Palard 2020-07-20 10:45:25 +02:00
commit a5123415bb

View file

@ -15,11 +15,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.3\n"
#: ../Doc/extending/building.rst:7
#: extending/building.rst:7
msgid "Building C and C++ Extensions"
msgstr "Construire des extensions C et C++"
#: ../Doc/extending/building.rst:9
#: extending/building.rst:9
msgid ""
"A C extension for CPython is a shared library (e.g. a ``.so`` file on Linux, "
"``.pyd`` on Windows), which exports an *initialization function*."
@ -27,7 +27,7 @@ msgstr ""
"Une extension C pour CPython est une bibliothèque partagée (Un ``.so`` sur "
"Linux, un ``.pyd`` sur Windows), qui expose une *fonction d'initialisation*."
#: ../Doc/extending/building.rst:12
#: extending/building.rst:12
msgid ""
"To be importable, the shared library must be available on :envvar:"
"`PYTHONPATH`, and must be named after the module name, with an appropriate "
@ -39,11 +39,11 @@ msgstr ""
"l'extension appropriée. En utilisant *distutils*, le nom est généré "
"automatiquement."
#: ../Doc/extending/building.rst:16
#: extending/building.rst:16
msgid "The initialization function has the signature:"
msgstr "La fonction d'initialisation doit avoir le prototype :"
#: ../Doc/extending/building.rst:20
#: extending/building.rst:20
msgid ""
"It returns either a fully-initialized module, or a :c:type:`PyModuleDef` "
"instance. See :ref:`initializing-modules` for details."
@ -52,7 +52,7 @@ msgstr ""
"de :c:type:`PyModuleDef`. Voir :ref:`initializing-modules` pour plus de "
"détails."
#: ../Doc/extending/building.rst:25
#: extending/building.rst:25
msgid ""
"For modules with ASCII-only names, the function must be named "
"``PyInit_<modulename>``, with ``<modulename>`` replaced by the name of the "
@ -70,7 +70,7 @@ msgstr ""
"*punyencode* de Python, dont les tirets sont remplacés par des tirets-bas. "
"En Python ça donne ::"
#: ../Doc/extending/building.rst:39
#: extending/building.rst:39
msgid ""
"It is possible to export multiple modules from a single shared library by "
"defining multiple initialization functions. However, importing them requires "
@ -85,11 +85,11 @@ msgstr ""
"au nom du fichier est cherchée. Voir le chapitre *\"Multiple modules in one "
"library\"* dans la :pep:`489` pour plus d'informations."
#: ../Doc/extending/building.rst:49
#: extending/building.rst:49
msgid "Building C and C++ Extensions with distutils"
msgstr "Construire les extensions C et C++ avec *distutils*"
#: ../Doc/extending/building.rst:53
#: extending/building.rst:53
msgid ""
"Extension modules can be built using distutils, which is included in "
"Python. Since distutils also supports creation of binary packages, users "
@ -100,7 +100,7 @@ msgstr ""
"binaires, les utilisateurs n'auront pas nécessairement besoin ni d'un "
"compilateur ni de *distutils* pour installer l'extension."
#: ../Doc/extending/building.rst:57
#: extending/building.rst:57
msgid ""
"A distutils package contains a driver script, :file:`setup.py`. This is a "
"plain Python file, which, in the most simple case, could look like this:"
@ -108,11 +108,11 @@ msgstr ""
"Un paquet *distutils* contient un script :file:`setup.py`. C'est un simple "
"fichier Python, ressemblant dans la plupart des cas à :"
#: ../Doc/extending/building.rst:73
#: extending/building.rst:73
msgid "With this :file:`setup.py`, and a file :file:`demo.c`, running ::"
msgstr "Avec ce :file:`setup.py` et un fichier :file:`demo.c`, lancer ::"
#: ../Doc/extending/building.rst:77
#: extending/building.rst:77
msgid ""
"will compile :file:`demo.c`, and produce an extension module named ``demo`` "
"in the :file:`build` directory. Depending on the system, the module file "
@ -124,7 +124,7 @@ msgstr ""
"peut se retrouver dans :file:`build/lib.system`, et son nom peut être :file:"
"`demo.py` ou :file:`demo.pyd`."
#: ../Doc/extending/building.rst:82
#: extending/building.rst:82
msgid ""
"In the :file:`setup.py`, all execution is performed by calling the ``setup`` "
"function. This takes a variable number of keyword arguments, of which the "
@ -145,7 +145,7 @@ msgstr ""
"fonctionnalités de *distutils*. Cette section n'explique que la construction "
"de modules d'extension."
#: ../Doc/extending/building.rst:91
#: extending/building.rst:91
msgid ""
"It is common to pre-compute arguments to :func:`setup`, to better structure "
"the driver script. In the example above, the ``ext_modules`` argument to :"
@ -162,7 +162,7 @@ msgstr ""
"nommée ``demo`` construite par la compilation d'un seul fichier source :file:"
"`demo.c`."
#: ../Doc/extending/building.rst:99
#: extending/building.rst:99
msgid ""
"In many cases, building an extension is more complex, since additional "
"preprocessor defines and libraries may be needed. This is demonstrated in "
@ -172,7 +172,7 @@ msgstr ""
"des bibliothèques et définitions de préprocesseurs dont la compilation "
"pourrait dépendre. C'est ce qu'on remarque dans l'exemple plus bas."
#: ../Doc/extending/building.rst:127
#: extending/building.rst:127
msgid ""
"In this example, :func:`~distutils.core.setup` is called with additional "
"meta-information, which is recommended when distribution packages have to be "
@ -188,7 +188,7 @@ msgstr ""
"compilateur, *distutils* peut donner ces informations de manière différente. "
"Par exemple, sur Unix, ça peut ressembler aux commandes ::"
#: ../Doc/extending/building.rst:139
#: extending/building.rst:139
msgid ""
"These lines are for demonstration purposes only; distutils users should "
"trust that distutils gets the invocations right."
@ -196,11 +196,11 @@ msgstr ""
"Ces lignes ne sont qu'à titre d'exemple, les utilisateurs de *distutils* "
"doivent avoir confiance en *distutils* qui fera les appels correctement."
#: ../Doc/extending/building.rst:146
#: extending/building.rst:146
msgid "Distributing your extension modules"
msgstr "Distribuer vos modules d'extension"
#: ../Doc/extending/building.rst:148
#: extending/building.rst:148
msgid ""
"When an extension has been successfully built, there are three ways to use "
"it."
@ -208,21 +208,21 @@ msgstr ""
"Lorsqu'une extension a été construite avec succès, il existe trois moyens de "
"l'utiliser."
#: ../Doc/extending/building.rst:150
#: extending/building.rst:150
msgid ""
"End-users will typically want to install the module, they do so by running ::"
msgstr ""
"Typiquement, les utilisateurs vont vouloir installer le module, ils le font "
"en exécutant ::"
#: ../Doc/extending/building.rst:154
#: extending/building.rst:154
msgid ""
"Module maintainers should produce source packages; to do so, they run ::"
msgstr ""
"Les mainteneurs de modules voudront produire des paquets source, pour ce "
"faire ils exécuteront ::"
#: ../Doc/extending/building.rst:158
#: extending/building.rst:158
msgid ""
"In some cases, additional files need to be included in a source "
"distribution; this is done through a :file:`MANIFEST.in` file; see :ref:"
@ -232,7 +232,7 @@ msgstr ""
"distribution source : c'est possible via un fichier :file:`MANIFEST.in`, c."
"f. :ref:`manifest`."
#: ../Doc/extending/building.rst:161
#: extending/building.rst:161
msgid ""
"If the source distribution has been built successfully, maintainers can also "
"create binary distributions. Depending on the platform, one of the following "

View file

@ -15,11 +15,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
#: ../Doc/extending/embedding.rst:8
#: extending/embedding.rst:8
msgid "Embedding Python in Another Application"
msgstr "Intégrer Python dans une autre application"
#: ../Doc/extending/embedding.rst:10
#: extending/embedding.rst:10
msgid ""
"The previous chapters discussed how to extend Python, that is, how to extend "
"the functionality of Python by attaching a library of C functions to it. It "
@ -41,7 +41,7 @@ msgstr ""
"écrivant des scripts Python. Vous pouvez aussi l'utiliser vous même si "
"certaines fonctionnalités peuvent être rédigées plus facilement en Python."
#: ../Doc/extending/embedding.rst:20
#: extending/embedding.rst:20
msgid ""
"Embedding Python is similar to extending it, but not quite. The difference "
"is that when you extend Python, the main program of the application is still "
@ -55,7 +55,7 @@ msgstr ""
"voir avec Python. C'est simplement quelques parties du programme qui "
"appellent l'interpréteur Python pour exécuter un peu de code Python."
#: ../Doc/extending/embedding.rst:26
#: extending/embedding.rst:26
msgid ""
"So if you are embedding Python, you are providing your own main program. "
"One of the things this main program has to do is initialize the Python "
@ -70,7 +70,7 @@ msgstr ""
"de passer des options à Python. Ensuite vous pourrez appeler l'interpréteur "
"depuis n'importe quelle partie de votre programme."
#: ../Doc/extending/embedding.rst:32
#: extending/embedding.rst:32
msgid ""
"There are several different ways to call the interpreter: you can pass a "
"string containing Python statements to :c:func:`PyRun_SimpleString`, or you "
@ -86,11 +86,11 @@ msgstr ""
"pouvez aussi appeler les API de bas niveau décrites dans les chapitres "
"précédents pour construire et utiliser des objets Python."
#: ../Doc/extending/embedding.rst:42
#: extending/embedding.rst:42
msgid ":ref:`c-api-index`"
msgstr ":ref:`c-api-index`"
#: ../Doc/extending/embedding.rst:42
#: extending/embedding.rst:42
msgid ""
"The details of Python's C interface are given in this manual. A great deal "
"of necessary information can be found here."
@ -98,11 +98,11 @@ msgstr ""
"Les détails sur l'interface entre Python et le C sont donnés dans ce manuel. "
"Pléthore informations s'y trouvent."
#: ../Doc/extending/embedding.rst:49
#: extending/embedding.rst:49
msgid "Very High Level Embedding"
msgstr "Intégration de très haut niveau"
#: ../Doc/extending/embedding.rst:51
#: extending/embedding.rst:51
msgid ""
"The simplest form of embedding Python is the use of the very high level "
"interface. This interface is intended to execute a Python script without "
@ -114,7 +114,7 @@ msgstr ""
"sans avoir à interagir avec directement. C'est utile, par exemple, pour "
"effectuer une opération sur un fichier. ::"
#: ../Doc/extending/embedding.rst:78
#: extending/embedding.rst:78
msgid ""
"The :c:func:`Py_SetProgramName` function should be called before :c:func:"
"`Py_Initialize` to inform the interpreter about paths to Python run-time "
@ -140,11 +140,11 @@ msgstr ""
"`PyRun_SimplFile`, qui vous économise le travail d'allouer de la mémoire et "
"de charger le contenu du fichier."
#: ../Doc/extending/embedding.rst:93
#: extending/embedding.rst:93
msgid "Beyond Very High Level Embedding: An overview"
msgstr "Au-delà de l'intégration de haut niveau : survol"
#: ../Doc/extending/embedding.rst:95
#: extending/embedding.rst:95
msgid ""
"The high level interface gives you the ability to execute arbitrary pieces "
"of Python code from your application, but exchanging data values is quite "
@ -158,7 +158,7 @@ msgstr ""
"appels de niveau plus bas. Il vous en coûtera plus de lignes de C à écrire, "
"mais vous pourrez presque tout faire."
#: ../Doc/extending/embedding.rst:100
#: extending/embedding.rst:100
msgid ""
"It should be noted that extending Python and embedding Python is quite the "
"same activity, despite the different intent. Most topics discussed in the "
@ -170,27 +170,27 @@ msgstr ""
"dans les chapitres précédents sont toujours valides. Pour le prouver, "
"regardez ce qu'un code d'extension de Python vers C fait réellement :"
#: ../Doc/extending/embedding.rst:105
#: extending/embedding.rst:105
msgid "Convert data values from Python to C,"
msgstr "Convertir des valeurs de Python vers le C,"
#: ../Doc/extending/embedding.rst:107
#: extending/embedding.rst:107
msgid "Perform a function call to a C routine using the converted values, and"
msgstr "Appeler une fonction C en utilisant les valeurs converties, et"
#: ../Doc/extending/embedding.rst:109
#: extending/embedding.rst:109
msgid "Convert the data values from the call from C to Python."
msgstr "Convertir les résultats de l'appel à la fonction C pour Python."
#: ../Doc/extending/embedding.rst:111
#: extending/embedding.rst:111
msgid "When embedding Python, the interface code does:"
msgstr "Lors de l'intégration de Python, le code de l'interface fait :"
#: ../Doc/extending/embedding.rst:113
#: extending/embedding.rst:113
msgid "Convert data values from C to Python,"
msgstr "Convertir les valeurs depuis le C vers Python,"
#: ../Doc/extending/embedding.rst:115
#: extending/embedding.rst:115
msgid ""
"Perform a function call to a Python interface routine using the converted "
"values, and"
@ -198,11 +198,11 @@ msgstr ""
"Effectuer un appel de fonction de l'interface Python en utilisant les "
"valeurs converties, et"
#: ../Doc/extending/embedding.rst:118
#: extending/embedding.rst:118
msgid "Convert the data values from the call from Python to C."
msgstr "Convertir les valeurs de l'appel Python pour le C."
#: ../Doc/extending/embedding.rst:120
#: extending/embedding.rst:120
msgid ""
"As you can see, the data conversion steps are simply swapped to accommodate "
"the different direction of the cross-language transfer. The only difference "
@ -215,7 +215,7 @@ msgstr ""
"données. Lors de l'extension, vous appelez une fonction C, lors de "
"l'intégration vous appelez une fonction Python."
#: ../Doc/extending/embedding.rst:125
#: extending/embedding.rst:125
msgid ""
"This chapter will not discuss how to convert data from Python to C and vice "
"versa. Also, proper use of references and dealing with errors is assumed to "
@ -228,11 +228,11 @@ msgstr ""
"l'extension de l'interpréteur, vous pouvez vous référer aux chapitres "
"précédents."
#: ../Doc/extending/embedding.rst:134
#: extending/embedding.rst:134
msgid "Pure Embedding"
msgstr "Intégration pure"
#: ../Doc/extending/embedding.rst:136
#: extending/embedding.rst:136
msgid ""
"The first program aims to execute a function in a Python script. Like in the "
"section about the very high level interface, the Python interpreter does not "
@ -244,11 +244,11 @@ msgstr ""
"l'interpréteur n'interagit pas directement avec l'application (mais le fera "
"dans la section suivante)."
#: ../Doc/extending/embedding.rst:141
#: extending/embedding.rst:141
msgid "The code to run a function defined in a Python script is:"
msgstr "Le code pour appeler une fonction définie dans un script Python est :"
#: ../Doc/extending/embedding.rst:146
#: extending/embedding.rst:146
msgid ""
"This code loads a Python script using ``argv[1]``, and calls the function "
"named in ``argv[2]``. Its integer arguments are the other values of the "
@ -262,11 +262,11 @@ msgstr ""
"programme (appelons l'exécutable :program:`call`), et l'appelez pour "
"exécuter un script Python, tel que :"
#: ../Doc/extending/embedding.rst:161
#: extending/embedding.rst:161
msgid "then the result should be:"
msgstr "alors, le résultat sera :"
#: ../Doc/extending/embedding.rst:169
#: extending/embedding.rst:169
msgid ""
"Although the program is quite large for its functionality, most of the code "
"is for data conversion between Python and C, and for error reporting. The "
@ -277,7 +277,7 @@ msgstr ""
"rapporter les erreurs. La partie intéressante, qui concerne l'intégration de "
"Python débute par ::"
#: ../Doc/extending/embedding.rst:178
#: extending/embedding.rst:178
msgid ""
"After initializing the interpreter, the script is loaded using :c:func:"
"`PyImport_Import`. This routine needs a Python string as its argument, "
@ -289,7 +289,7 @@ msgstr ""
"argument, elle-même construite en utilisant la fonction de conversion :c:"
"func:`PyUnicode_FromString`. ::"
#: ../Doc/extending/embedding.rst:191
#: extending/embedding.rst:191
msgid ""
"Once the script is loaded, the name we're looking for is retrieved using :c:"
"func:`PyObject_GetAttrString`. If the name exists, and the object returned "
@ -303,7 +303,7 @@ msgstr ""
"programme continue, classiquement, par la construction de n-uplet "
"d'arguments. L'appel à la fonction Python est alors effectué avec ::"
#: ../Doc/extending/embedding.rst:199
#: extending/embedding.rst:199
msgid ""
"Upon return of the function, ``pValue`` is either ``NULL`` or it contains a "
"reference to the return value of the function. Be sure to release the "
@ -313,11 +313,11 @@ msgstr ""
"référence sur la valeur donnée par la fonction. Assurez-vous de libérer la "
"référence après avoir utilisé la valeur."
#: ../Doc/extending/embedding.rst:207
#: extending/embedding.rst:207
msgid "Extending Embedded Python"
msgstr "Étendre un Python intégré"
#: ../Doc/extending/embedding.rst:209
#: extending/embedding.rst:209
msgid ""
"Until now, the embedded Python interpreter had no access to functionality "
"from the application itself. The Python API allows this by extending the "
@ -338,7 +338,7 @@ msgstr ""
"à Python, tout comme vous écririez une extension Python normale. Par "
"exemple ::"
#: ../Doc/extending/embedding.rst:246
#: extending/embedding.rst:246
msgid ""
"Insert the above code just above the :c:func:`main` function. Also, insert "
"the following two statements before the call to :c:func:`Py_Initialize`::"
@ -347,7 +347,7 @@ msgstr ""
"aussi les deux instructions suivantes avant l'appel à :c:func:"
"`Py_Initialize` ::"
#: ../Doc/extending/embedding.rst:252
#: extending/embedding.rst:252
msgid ""
"These two lines initialize the ``numargs`` variable, and make the :func:`emb."
"numargs` function accessible to the embedded Python interpreter. With these "
@ -357,7 +357,7 @@ msgstr ""
"func:`emb.numargs` accessible à l'interpréteur intégré. Avec ces ajouts, le "
"script Python petit maintenant faire des choses comme"
#: ../Doc/extending/embedding.rst:261
#: extending/embedding.rst:261
msgid ""
"In a real application, the methods will expose an API of the application to "
"Python."
@ -365,11 +365,11 @@ msgstr ""
"Dans un cas réel, les méthodes exposeraient une API de l'application à "
"Python."
#: ../Doc/extending/embedding.rst:271
#: extending/embedding.rst:271
msgid "Embedding Python in C++"
msgstr "Intégrer Python dans du C++"
#: ../Doc/extending/embedding.rst:273
#: extending/embedding.rst:273
msgid ""
"It is also possible to embed Python in a C++ program; precisely how this is "
"done will depend on the details of the C++ system used; in general you will "
@ -383,11 +383,11 @@ msgstr ""
"compilateur C++ pour compiler et lier votre programme. Il n'y a pas besoin "
"de recompiler Python en utilisant C++."
#: ../Doc/extending/embedding.rst:282
#: extending/embedding.rst:282
msgid "Compiling and Linking under Unix-like systems"
msgstr "Compiler et Lier en environnement Unix ou similaire"
#: ../Doc/extending/embedding.rst:284
#: extending/embedding.rst:284
msgid ""
"It is not necessarily trivial to find the right flags to pass to your "
"compiler (and linker) in order to embed the Python interpreter into your "
@ -399,7 +399,7 @@ msgstr ""
"Python ayant besoin de charger des extensions sous forme de bibliothèques "
"dynamiques en C (des :file:`.so`) pour se lier avec."
#: ../Doc/extending/embedding.rst:290
#: extending/embedding.rst:290
msgid ""
"To find out the required compiler and linker flags, you can execute the :"
"file:`python{X.Y}-config` script which is generated as part of the "
@ -412,7 +412,7 @@ msgstr ""
"(un script :file:`python3-config` peut aussi être disponible). Ce script a "
"quelques options, celles-ci vous seront utiles :"
#: ../Doc/extending/embedding.rst:296
#: extending/embedding.rst:296
msgid ""
"``pythonX.Y-config --cflags`` will give you the recommended flags when "
"compiling:"
@ -420,7 +420,7 @@ msgstr ""
"``pythonX.Y-config --cflags`` vous donnera les options recommandées pour "
"compiler :"
#: ../Doc/extending/embedding.rst:304
#: extending/embedding.rst:304
msgid ""
"``pythonX.Y-config --ldflags`` will give you the recommended flags when "
"linking:"
@ -428,7 +428,7 @@ msgstr ""
"``pythonX.Y-config --ldflags`` vous donnera les drapeaux recommandés lors de "
"l'édition de lien :"
#: ../Doc/extending/embedding.rst:313
#: extending/embedding.rst:313
msgid ""
"To avoid confusion between several Python installations (and especially "
"between the system Python and your own compiled Python), it is recommended "
@ -440,7 +440,7 @@ msgstr ""
"recommandé d'utiliser un chemin absolu vers :file:`python{X.Y}-config`, "
"comme dans l'exemple précédent."
#: ../Doc/extending/embedding.rst:318
#: extending/embedding.rst:318
msgid ""
"If this procedure doesn't work for you (it is not guaranteed to work for all "
"Unix-like platforms; however, we welcome :ref:`bug reports <reporting-"

File diff suppressed because it is too large Load diff

View file

@ -15,11 +15,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.4\n"
#: ../Doc/extending/index.rst:5
#: extending/index.rst:5
msgid "Extending and Embedding the Python Interpreter"
msgstr "Extension et intégration de l'interpréteur Python"
#: ../Doc/extending/index.rst:7
#: extending/index.rst:7
msgid ""
"This document describes how to write modules in C or C++ to extend the "
"Python interpreter with new modules. Those modules can not only define new "
@ -39,7 +39,7 @@ msgstr ""
"dans l'interpréteur, si le système d'exploitation sous-jacent supporte cette "
"fonctionnalité."
#: ../Doc/extending/index.rst:15
#: extending/index.rst:15
msgid ""
"This document assumes basic knowledge about Python. For an informal "
"introduction to the language, see :ref:`tutorial-index`. :ref:`reference-"
@ -54,7 +54,7 @@ msgstr ""
"(tous intégrés et écrits en Python) qui donnent au langage sa large gamme "
"d'applications."
#: ../Doc/extending/index.rst:21
#: extending/index.rst:21
msgid ""
"For a detailed description of the whole Python/C API, see the separate :ref:"
"`c-api-index`."
@ -62,11 +62,11 @@ msgstr ""
"Pour une description dans sa totalité de l'API Python/C, voir :ref:`c-api-"
"index`."
#: ../Doc/extending/index.rst:26
#: extending/index.rst:26
msgid "Recommended third party tools"
msgstr "Les outils tiers recommandés"
#: ../Doc/extending/index.rst:28
#: extending/index.rst:28
msgid ""
"This guide only covers the basic tools for creating extensions provided as "
"part of this version of CPython. Third party tools like `Cython <http://"
@ -81,7 +81,7 @@ msgstr ""
"approches plus simples et plus élaborées pour créer des extensions C et C++ "
"pour Python."
#: ../Doc/extending/index.rst:40
#: extending/index.rst:40
msgid ""
"`Python Packaging User Guide: Binary Extensions <https://packaging.python."
"org/guides/packaging-binary-extensions/>`_"
@ -89,7 +89,7 @@ msgstr ""
"`Guide d'utilisation de l'empaquetage Python : Extensions binaires <https://"
"packaging.python.org/guides/packaging-binary-extensions/>`_"
#: ../Doc/extending/index.rst:38
#: 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 "
@ -100,11 +100,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:45
#: extending/index.rst:45
msgid "Creating extensions without third party tools"
msgstr "Création d'extensions sans outils tiers"
#: ../Doc/extending/index.rst:47
#: 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 "
@ -116,11 +116,11 @@ msgstr ""
"ces outils, plus que d'être une méthode recommandée pour créer votre propre "
"extension C."
#: ../Doc/extending/index.rst:63
#: 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:65
#: 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 "

View file

@ -14,30 +14,30 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../Doc/extending/newtypes.rst:7
#: extending/newtypes.rst:7
msgid "Defining Extension Types: Assorted Topics"
msgstr ""
#: ../Doc/extending/newtypes.rst:11
#: extending/newtypes.rst:11
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:14
#: extending/newtypes.rst:14
msgid ""
"Here is the definition of :c:type:`PyTypeObject`, with some fields only used "
"in debug builds omitted:"
msgstr ""
#: ../Doc/extending/newtypes.rst:20
#: extending/newtypes.rst:20
msgid ""
"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:24
#: extending/newtypes.rst:24
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 "
@ -47,14 +47,14 @@ msgid ""
"new type. ::"
msgstr ""
#: ../Doc/extending/newtypes.rst:33
#: extending/newtypes.rst:33
msgid ""
"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:39
#: extending/newtypes.rst:39
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 "
@ -63,23 +63,23 @@ msgid ""
"later. ::"
msgstr ""
#: ../Doc/extending/newtypes.rst:46
#: extending/newtypes.rst:46
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:49
#: extending/newtypes.rst:49
msgid ""
"Now we come to the basic type methods -- the ones most extension types will "
"implement."
msgstr ""
#: ../Doc/extending/newtypes.rst:54
#: extending/newtypes.rst:54
msgid "Finalization and De-allocation"
msgstr ""
#: ../Doc/extending/newtypes.rst:66
#: extending/newtypes.rst:66
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 "
@ -88,7 +88,7 @@ msgid ""
"of this function::"
msgstr ""
#: ../Doc/extending/newtypes.rst:83
#: extending/newtypes.rst:83
msgid ""
"One important requirement of the deallocator function is that it leaves any "
"pending exceptions alone. This is important since deallocators are "
@ -103,7 +103,7 @@ msgid ""
"c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` functions::"
msgstr ""
#: ../Doc/extending/newtypes.rst:122
#: extending/newtypes.rst:122
msgid ""
"There are limitations to what you can safely do in a deallocator function. "
"First, if your type supports garbage collection (using :c:member:"
@ -116,43 +116,43 @@ msgid ""
"tp_dealloc` again, causing a double free and a crash."
msgstr ""
#: ../Doc/extending/newtypes.rst:131
#: extending/newtypes.rst:131
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:136
#: extending/newtypes.rst:136
msgid ":pep:`442` explains the new finalization scheme."
msgstr ""
#: ../Doc/extending/newtypes.rst:143
#: extending/newtypes.rst:143
msgid "Object Presentation"
msgstr ""
#: ../Doc/extending/newtypes.rst:145
#: extending/newtypes.rst:145
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:154
#: extending/newtypes.rst:154
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:165
#: extending/newtypes.rst:165
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:169
#: extending/newtypes.rst:169
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`; "
@ -163,15 +163,15 @@ msgid ""
"the :c:member:`~PyTypeObject.tp_repr` handler is used instead."
msgstr ""
#: ../Doc/extending/newtypes.rst:176
#: extending/newtypes.rst:176
msgid "Here is a simple example::"
msgstr ""
#: ../Doc/extending/newtypes.rst:188
#: extending/newtypes.rst:188
msgid "Attribute Management"
msgstr ""
#: ../Doc/extending/newtypes.rst:190
#: extending/newtypes.rst:190
msgid ""
"For every object which can support attributes, the corresponding type must "
"provide the functions that control how the attributes are resolved. There "
@ -181,7 +181,7 @@ msgid ""
"handler is ``NULL``."
msgstr ""
#: ../Doc/extending/newtypes.rst:196
#: extending/newtypes.rst:196
msgid ""
"Python supports two pairs of attribute handlers; a type that supports "
"attributes only needs to implement the functions for one pair. The "
@ -190,7 +190,7 @@ msgid ""
"use whichever pair makes more sense for the implementation's convenience. ::"
msgstr ""
#: ../Doc/extending/newtypes.rst:208
#: extending/newtypes.rst:208
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 "
@ -201,35 +201,35 @@ msgid ""
"mechanism that is available."
msgstr ""
#: ../Doc/extending/newtypes.rst:219
#: extending/newtypes.rst:219
msgid "Generic Attribute Management"
msgstr ""
#: ../Doc/extending/newtypes.rst:221
#: extending/newtypes.rst:221
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:224
#: extending/newtypes.rst:224
msgid ""
"The name of the attributes must be known when :c:func:`PyType_Ready` is "
"called."
msgstr ""
#: ../Doc/extending/newtypes.rst:227
#: extending/newtypes.rst:227
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:230
#: extending/newtypes.rst:230
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:233
#: extending/newtypes.rst:233
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 "
@ -241,18 +241,18 @@ msgid ""
"``NULL`` as well, allowing the base type to handle attributes."
msgstr ""
#: ../Doc/extending/newtypes.rst:241
#: extending/newtypes.rst:241
msgid "The tables are declared as three fields of the type object::"
msgstr ""
#: ../Doc/extending/newtypes.rst:247
#: extending/newtypes.rst:247
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:258
#: extending/newtypes.rst:258
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 "
@ -260,7 +260,7 @@ msgid ""
"attr:`ml_name` field of the sentinel must be ``NULL``."
msgstr ""
#: ../Doc/extending/newtypes.rst:263
#: extending/newtypes.rst:263
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 "
@ -268,7 +268,7 @@ msgid ""
"defined as::"
msgstr ""
#: ../Doc/extending/newtypes.rst:275
#: extending/newtypes.rst:275
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 "
@ -279,53 +279,53 @@ msgid ""
"accessed."
msgstr ""
#: ../Doc/extending/newtypes.rst:282
#: extending/newtypes.rst:282
msgid ""
"The following flag constants are defined in :file:`structmember.h`; they may "
"be combined using bitwise-OR."
msgstr ""
#: ../Doc/extending/newtypes.rst:286
#: extending/newtypes.rst:286
msgid "Constant"
msgstr "Constante"
#: ../Doc/extending/newtypes.rst:286
#: extending/newtypes.rst:286
msgid "Meaning"
msgstr "Signification"
#: ../Doc/extending/newtypes.rst:288
#: extending/newtypes.rst:288
msgid ":const:`READONLY`"
msgstr ""
#: ../Doc/extending/newtypes.rst:288
#: extending/newtypes.rst:288
msgid "Never writable."
msgstr ""
#: ../Doc/extending/newtypes.rst:290
#: extending/newtypes.rst:290
msgid ":const:`READ_RESTRICTED`"
msgstr ""
#: ../Doc/extending/newtypes.rst:290
#: extending/newtypes.rst:290
msgid "Not readable in restricted mode."
msgstr ""
#: ../Doc/extending/newtypes.rst:292
#: extending/newtypes.rst:292
msgid ":const:`WRITE_RESTRICTED`"
msgstr ""
#: ../Doc/extending/newtypes.rst:292
#: extending/newtypes.rst:292
msgid "Not writable in restricted mode."
msgstr ""
#: ../Doc/extending/newtypes.rst:294
#: extending/newtypes.rst:294
msgid ":const:`RESTRICTED`"
msgstr ""
#: ../Doc/extending/newtypes.rst:294
#: extending/newtypes.rst:294
msgid "Not readable or writable in restricted mode."
msgstr ""
#: ../Doc/extending/newtypes.rst:303
#: extending/newtypes.rst:303
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 "
@ -335,17 +335,17 @@ msgid ""
"`__doc__` attribute."
msgstr ""
#: ../Doc/extending/newtypes.rst:309
#: extending/newtypes.rst:309
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:323
#: extending/newtypes.rst:323
msgid "Type-specific Attribute Management"
msgstr ""
#: ../Doc/extending/newtypes.rst:325
#: extending/newtypes.rst:325
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:"
@ -356,18 +356,18 @@ msgid ""
"functionality, you'll understand what needs to be done."
msgstr ""
#: ../Doc/extending/newtypes.rst:333
#: extending/newtypes.rst:333
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:337
#: extending/newtypes.rst:337
msgid "Here is an example::"
msgstr "Voici un exemple ::"
#: ../Doc/extending/newtypes.rst:353
#: extending/newtypes.rst:353
msgid ""
"The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:"
"`__setattr__` or :meth:`__delattr__` method of a class instance would be "
@ -377,11 +377,11 @@ msgid ""
"should be set to ``NULL``. ::"
msgstr ""
#: ../Doc/extending/newtypes.rst:367
#: extending/newtypes.rst:367
msgid "Object Comparison"
msgstr ""
#: ../Doc/extending/newtypes.rst:373
#: extending/newtypes.rst:373
msgid ""
"The :c:member:`~PyTypeObject.tp_richcompare` handler is called when "
"comparisons are needed. It is analogous to the :ref:`rich comparison "
@ -389,7 +389,7 @@ msgid ""
"`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`."
msgstr ""
#: ../Doc/extending/newtypes.rst:378
#: extending/newtypes.rst:378
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``, "
@ -400,23 +400,23 @@ msgid ""
"should be tried, or ``NULL`` if an exception was set."
msgstr ""
#: ../Doc/extending/newtypes.rst:386
#: extending/newtypes.rst:386
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:416
#: extending/newtypes.rst:416
msgid "Abstract Protocol Support"
msgstr ""
#: ../Doc/extending/newtypes.rst:418
#: extending/newtypes.rst:418
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:422
#: extending/newtypes.rst:422
msgid ""
"A number of these abstract interfaces were defined early in the development "
"of the Python implementation. In particular, the number, mapping, and "
@ -431,7 +431,7 @@ msgid ""
"slot, but a slot may still be unfilled.) ::"
msgstr ""
#: ../Doc/extending/newtypes.rst:437
#: extending/newtypes.rst:437
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 "
@ -442,13 +442,13 @@ msgid ""
"distribution. ::"
msgstr ""
#: ../Doc/extending/newtypes.rst:446
#: extending/newtypes.rst:446
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 ""
#: ../Doc/extending/newtypes.rst:459
#: extending/newtypes.rst:459
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, "
@ -456,7 +456,7 @@ msgid ""
"computation is successful, as seen above."
msgstr ""
#: ../Doc/extending/newtypes.rst:468
#: extending/newtypes.rst:468
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 "
@ -464,23 +464,23 @@ msgid ""
"handler is invoked."
msgstr ""
#: ../Doc/extending/newtypes.rst:472
#: extending/newtypes.rst:472
msgid "This function takes three arguments:"
msgstr ""
#: ../Doc/extending/newtypes.rst:474
#: extending/newtypes.rst:474
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 ""
#: ../Doc/extending/newtypes.rst:477
#: extending/newtypes.rst:477
msgid ""
"*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:480
#: extending/newtypes.rst:480
msgid ""
"*kwds* is a dictionary of keyword arguments that were passed. If this is non-"
"``NULL`` and you support keyword arguments, use :c:func:"
@ -489,11 +489,11 @@ msgid ""
"`TypeError` with a message saying that keyword arguments are not supported."
msgstr ""
#: ../Doc/extending/newtypes.rst:486
#: extending/newtypes.rst:486
msgid "Here is a toy ``tp_call`` implementation::"
msgstr ""
#: ../Doc/extending/newtypes.rst:512
#: extending/newtypes.rst:512
msgid ""
"These functions provide support for the iterator protocol. Both handlers "
"take exactly one parameter, the instance for which they are being called, "
@ -504,21 +504,21 @@ msgid ""
"__next__` method."
msgstr ""
#: ../Doc/extending/newtypes.rst:519
#: extending/newtypes.rst:519
msgid ""
"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:523
#: extending/newtypes.rst:523
msgid ""
"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:526
#: extending/newtypes.rst:526
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."
@ -526,7 +526,7 @@ msgid ""
"therefore implement the :c:member:`~PyTypeObject.tp_iternext` handler."
msgstr ""
#: ../Doc/extending/newtypes.rst:531
#: extending/newtypes.rst:531
msgid ""
"Any :term:`iterator` object should implement both :c:member:`~PyTypeObject."
"tp_iter` and :c:member:`~PyTypeObject.tp_iternext`. An iterator's :c:member:"
@ -541,28 +541,28 @@ msgid ""
"``NULL``."
msgstr ""
#: ../Doc/extending/newtypes.rst:547
#: extending/newtypes.rst:547
msgid "Weak Reference Support"
msgstr ""
#: ../Doc/extending/newtypes.rst:549
#: extending/newtypes.rst:549
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 "
"overhead on performance-critical objects (such as numbers)."
msgstr ""
#: ../Doc/extending/newtypes.rst:554
#: extending/newtypes.rst:554
msgid "Documentation for the :mod:`weakref` module."
msgstr ""
#: ../Doc/extending/newtypes.rst:556
#: extending/newtypes.rst:556
msgid ""
"For an object to be weakly referencable, the extension type must do two "
"things:"
msgstr ""
#: ../Doc/extending/newtypes.rst:558
#: extending/newtypes.rst:558
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 "
@ -570,35 +570,35 @@ msgid ""
"tp_alloc`)."
msgstr ""
#: ../Doc/extending/newtypes.rst:563
#: extending/newtypes.rst:563
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 "
"interpreter knows how to access and modify that field."
msgstr ""
#: ../Doc/extending/newtypes.rst:567
#: extending/newtypes.rst:567
msgid ""
"Concretely, here is how a trivial object structure would be augmented with "
"the required field::"
msgstr ""
#: ../Doc/extending/newtypes.rst:575
#: extending/newtypes.rst:575
msgid "And the corresponding member in the statically-declared type object::"
msgstr ""
#: ../Doc/extending/newtypes.rst:583
#: extending/newtypes.rst:583
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:599
#: extending/newtypes.rst:599
msgid "More Suggestions"
msgstr ""
#: ../Doc/extending/newtypes.rst:601
#: extending/newtypes.rst:601
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` "
@ -607,26 +607,26 @@ msgid ""
"function you want to implement."
msgstr ""
#: ../Doc/extending/newtypes.rst:607
#: extending/newtypes.rst:607
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 "
"sample of its use might be something like the following::"
msgstr ""
#: ../Doc/extending/newtypes.rst:618
#: extending/newtypes.rst:618
msgid "Download CPython source releases."
msgstr ""
#: ../Doc/extending/newtypes.rst:618
#: extending/newtypes.rst:618
msgid "https://www.python.org/downloads/source/"
msgstr ""
#: ../Doc/extending/newtypes.rst:620
#: extending/newtypes.rst:620
msgid ""
"The CPython project on GitHub, where the CPython source code is developed."
msgstr ""
#: ../Doc/extending/newtypes.rst:621
#: extending/newtypes.rst:621
msgid "https://github.com/python/cpython"
msgstr ""

View file

@ -14,11 +14,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../Doc/extending/newtypes_tutorial.rst:7
#: extending/newtypes_tutorial.rst:7
msgid "Defining Extension Types: Tutorial"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:14
#: 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` "
@ -27,11 +27,11 @@ msgid ""
"can get started. This document is a gentle introduction to the topic."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:24
#: extending/newtypes_tutorial.rst:24
msgid "The Basics"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:26
#: 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. "
@ -43,20 +43,20 @@ msgid ""
"functions are called \"type methods\"."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:35
#: 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
#: 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
#: 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 "
@ -64,36 +64,36 @@ msgid ""
"`PyType_FromSpec` function, which isn't covered in this tutorial."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:50
#: 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
#: 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
#: 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
#: 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
#: extending/newtypes_tutorial.rst:61
msgid "The first bit is::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:67
#: 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 "
@ -103,31 +103,31 @@ msgid ""
"abstract away the layout and to enable additional fields in debug builds."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:75
#: 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
#: 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
#: extending/newtypes_tutorial.rst:87
msgid "The second bit is the definition of the type object. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:100
#: extending/newtypes_tutorial.rst:100
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:104
#: extending/newtypes_tutorial.rst:104
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 +135,23 @@ msgid ""
"to not specify them explicitly unless you need them."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:109
#: extending/newtypes_tutorial.rst:109
msgid "We're going to pick it apart, one field at a time::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:113
#: extending/newtypes_tutorial.rst:113
msgid ""
"This line is mandatory boilerplate to initialize the ``ob_base`` field "
"mentioned above. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:118
#: extending/newtypes_tutorial.rst:118
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:128
#: extending/newtypes_tutorial.rst:128
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 +160,14 @@ msgid ""
"type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:137
#: extending/newtypes_tutorial.rst:137
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:143
#: extending/newtypes_tutorial.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 "
@ -181,23 +181,23 @@ msgid ""
"your base type, and therefore increasing its size."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:153
#: extending/newtypes_tutorial.rst:153
msgid "We set the class flags to :const:`Py_TPFLAGS_DEFAULT`. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:157
#: extending/newtypes_tutorial.rst:157
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:161
#: extending/newtypes_tutorial.rst:161
msgid ""
"We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:165
#: extending/newtypes_tutorial.rst:165
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 +206,53 @@ msgid ""
"`PyType_GenericNew`. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:172
#: extending/newtypes_tutorial.rst:172
msgid ""
"Everything else in the file should be familiar, except for some code in :c:"
"func:`PyInit_custom`::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:178
#: extending/newtypes_tutorial.rst:178
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:189
#: extending/newtypes_tutorial.rst:189
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:197
#: extending/newtypes_tutorial.rst:197
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:206
#: extending/newtypes_tutorial.rst:206
msgid "in a file called :file:`setup.py`; then typing"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:212
#: extending/newtypes_tutorial.rst:212
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:216
#: extending/newtypes_tutorial.rst:216
msgid "That wasn't so hard, was it?"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:218
#: extending/newtypes_tutorial.rst:218
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:222
#: extending/newtypes_tutorial.rst:222
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 +262,32 @@ msgid ""
"packages/>`_."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:230
#: extending/newtypes_tutorial.rst:230
msgid "Adding data and methods to the Basic example"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:232
#: extending/newtypes_tutorial.rst:232
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:239
#: extending/newtypes_tutorial.rst:239
msgid "This version of the module has a number of changes."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:241
#: extending/newtypes_tutorial.rst:241
msgid "We've added an extra include::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:245
#: extending/newtypes_tutorial.rst:245
msgid ""
"This include provides declarations that we use to handle attributes, as "
"described a bit later."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:248
#: extending/newtypes_tutorial.rst:248
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 +295,21 @@ msgid ""
"integer."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:252
#: extending/newtypes_tutorial.rst:252
msgid "The object structure is updated accordingly::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:261
#: extending/newtypes_tutorial.rst:261
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:272
#: extending/newtypes_tutorial.rst:272
msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:276
#: extending/newtypes_tutorial.rst:276
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 +320,7 @@ msgid ""
"instance of a subclass."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:285
#: extending/newtypes_tutorial.rst:285
msgid ""
"The explicit cast to ``destructor`` above is needed because we defined "
"``Custom_dealloc`` to take a ``CustomObject *`` argument, but the "
@ -329,17 +329,17 @@ msgid ""
"oriented polymorphism, in C!"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:291
#: extending/newtypes_tutorial.rst:291
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:315
#: extending/newtypes_tutorial.rst:315
msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:319
#: extending/newtypes_tutorial.rst:319
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 +350,7 @@ msgid ""
"attributes to non-``NULL`` default values."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:327
#: extending/newtypes_tutorial.rst:327
msgid ""
"``tp_new`` is passed the type being instantiated (not necessarily "
"``CustomType``, if a subclass is instantiated) and any arguments passed when "
@ -360,25 +360,25 @@ msgid ""
"k.a. ``tp_init`` in C or ``__init__`` in Python) methods."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:335
#: extending/newtypes_tutorial.rst:335
msgid ""
"``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do "
"it itself."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:338
#: extending/newtypes_tutorial.rst:338
msgid ""
"The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` "
"slot to allocate memory::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:343
#: extending/newtypes_tutorial.rst:343
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:347
#: extending/newtypes_tutorial.rst:347
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 +386,7 @@ msgid ""
"allocation strategy."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:353
#: extending/newtypes_tutorial.rst:353
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 +399,17 @@ msgid ""
"subclasses without getting a :exc:`TypeError`.)"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:363
#: extending/newtypes_tutorial.rst:363
msgid ""
"We also define an initialization function which accepts arguments to provide "
"initial values for our instance::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:392
#: extending/newtypes_tutorial.rst:392
msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:396
#: extending/newtypes_tutorial.rst:396
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 +417,7 @@ msgid ""
"return either ``0`` on success or ``-1`` on error."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:401
#: extending/newtypes_tutorial.rst:401
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 +428,7 @@ msgid ""
"``first`` member like this::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:415
#: extending/newtypes_tutorial.rst:415
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 +438,49 @@ msgid ""
"and modifies our object."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:422
#: extending/newtypes_tutorial.rst:422
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:426
#: extending/newtypes_tutorial.rst:426
msgid "when we absolutely know that the reference count is greater than 1;"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:428
#: extending/newtypes_tutorial.rst:428
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:431
#: extending/newtypes_tutorial.rst:431
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:434
#: extending/newtypes_tutorial.rst:434
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:447
#: extending/newtypes_tutorial.rst:447
msgid ""
"and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:451
#: extending/newtypes_tutorial.rst:451
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:455
#: extending/newtypes_tutorial.rst:455
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 +491,13 @@ msgid ""
"deleted."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:462
#: extending/newtypes_tutorial.rst:462
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:479
#: extending/newtypes_tutorial.rst:479
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 +507,7 @@ msgid ""
"method is equivalent to the Python method:"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:491
#: extending/newtypes_tutorial.rst:491
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 +516,23 @@ msgid ""
"We'll see how to do that in the next section."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:497
#: extending/newtypes_tutorial.rst:497
msgid ""
"Now that we've defined the method, we need to create an array of method "
"definitions::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:507
#: extending/newtypes_tutorial.rst:507
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:510
#: extending/newtypes_tutorial.rst:510
msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:514
#: extending/newtypes_tutorial.rst:514
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 +540,22 @@ msgid ""
"to add the :const:`Py_TPFLAGS_BASETYPE` to our class flag definition::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:521
#: extending/newtypes_tutorial.rst:521
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:525
#: extending/newtypes_tutorial.rst:525
msgid "Finally, we update our :file:`setup.py` file to build the new module:"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:538
#: extending/newtypes_tutorial.rst:538
msgid "Providing finer control over data attributes"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:540
#: extending/newtypes_tutorial.rst:540
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 +564,14 @@ msgid ""
"make sure that these attributes always contain strings."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:549
#: extending/newtypes_tutorial.rst:549
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:580
#: extending/newtypes_tutorial.rst:580
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 +581,7 @@ msgid ""
"data in the closure.)"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:586
#: extending/newtypes_tutorial.rst:586
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 +589,32 @@ msgid ""
"or if its new value is not a string."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:591
#: extending/newtypes_tutorial.rst:591
msgid "We create an array of :c:type:`PyGetSetDef` structures::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:601
#: extending/newtypes_tutorial.rst:601
msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:605
#: extending/newtypes_tutorial.rst:605
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:608
#: extending/newtypes_tutorial.rst:608
msgid "We also remove the member definitions for these attributes::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:616
#: extending/newtypes_tutorial.rst:616
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:645
#: extending/newtypes_tutorial.rst:645
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 +624,25 @@ msgid ""
"possibility that the initialization of these members failed in ``tp_new``."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:652
#: extending/newtypes_tutorial.rst:652
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:658
#: extending/newtypes_tutorial.rst:658
msgid "Supporting cyclic garbage collection"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:660
#: extending/newtypes_tutorial.rst:660
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 ""
#: ../Doc/extending/newtypes_tutorial.rst:670
#: extending/newtypes_tutorial.rst:670
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 +650,7 @@ msgid ""
"out that the list is garbage and free it."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:675
#: extending/newtypes_tutorial.rst:675
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 +659,7 @@ msgid ""
"reasons, :class:`Custom` objects can participate in cycles:"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:689
#: extending/newtypes_tutorial.rst:689
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 +667,13 @@ msgid ""
"slots:"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:696
#: extending/newtypes_tutorial.rst:696
msgid ""
"First, the traversal method lets the cyclic GC know about subobjects that "
"could participate in cycles::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:716
#: extending/newtypes_tutorial.rst:716
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 +682,26 @@ msgid ""
"be returned if it is non-zero."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:722
#: extending/newtypes_tutorial.rst:722
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:735
#: extending/newtypes_tutorial.rst:735
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:738
#: extending/newtypes_tutorial.rst:738
msgid ""
"Second, we need to provide a method for clearing any subobjects that can "
"participate in cycles::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:749
#: extending/newtypes_tutorial.rst:749
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 +711,18 @@ msgid ""
"again (*especially* if there is a reference cycle)."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:757
#: extending/newtypes_tutorial.rst:757
msgid "You could emulate :c:func:`Py_CLEAR` by writing::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:764
#: extending/newtypes_tutorial.rst:764
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:768
#: extending/newtypes_tutorial.rst:768
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 +732,12 @@ msgid ""
"`PyObject_GC_UnTrack` and ``Custom_clear``::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:783
#: extending/newtypes_tutorial.rst:783
msgid ""
"Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:787
#: extending/newtypes_tutorial.rst:787
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 +745,11 @@ msgid ""
"automatically provided."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:793
#: extending/newtypes_tutorial.rst:793
msgid "Subclassing other types"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:795
#: extending/newtypes_tutorial.rst:795
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 +757,7 @@ msgid ""
"share these :c:type:`PyTypeObject` structures between extension modules."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:800
#: extending/newtypes_tutorial.rst:800
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 +765,34 @@ msgid ""
"that increases an internal counter:"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:820
#: extending/newtypes_tutorial.rst:820
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:828
#: extending/newtypes_tutorial.rst:828
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:832
#: extending/newtypes_tutorial.rst:832
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:844
#: extending/newtypes_tutorial.rst:844
msgid ""
"We see above how to call through to the :attr:`__init__` method of the base "
"type."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:847
#: extending/newtypes_tutorial.rst:847
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 +801,7 @@ msgid ""
"the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:853
#: extending/newtypes_tutorial.rst:853
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 +810,7 @@ msgid ""
"function::"
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:881
#: extending/newtypes_tutorial.rst:881
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 +819,29 @@ msgid ""
"from the base type will be inherited."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:887
#: extending/newtypes_tutorial.rst:887
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:892
#: extending/newtypes_tutorial.rst:892
msgid "Footnotes"
msgstr "Notes"
#: ../Doc/extending/newtypes_tutorial.rst:893
#: extending/newtypes_tutorial.rst:893
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:896
#: extending/newtypes_tutorial.rst:896
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:899
#: extending/newtypes_tutorial.rst:899
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 +851,7 @@ msgid ""
"objects."
msgstr ""
#: ../Doc/extending/newtypes_tutorial.rst:905
#: extending/newtypes_tutorial.rst:905
msgid ""
"Also, even with our attributes restricted to strings instances, the user "
"could pass arbitrary :class:`str` subclasses and therefore still create "

View file

@ -14,11 +14,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../Doc/extending/windows.rst:8
#: extending/windows.rst:8
msgid "Building C and C++ Extensions on Windows"
msgstr "Construire des extensions C et C++ sur Windows"
#: ../Doc/extending/windows.rst:10
#: extending/windows.rst:10
msgid ""
"This chapter briefly explains how to create a Windows extension module for "
"Python using Microsoft Visual C++, and follows with more detailed background "
@ -34,7 +34,7 @@ msgstr ""
"que pour le développeur Unix souhaitant produire des logiciels pouvant être "
"construits sur Unix et Windows."
#: ../Doc/extending/windows.rst:17
#: extending/windows.rst:17
msgid ""
"Module authors are encouraged to use the distutils approach for building "
"extension modules, instead of the one described in this section. You will "
@ -46,7 +46,7 @@ msgstr ""
"section. Vous aurez toujours besoin du compilateur C utilisé pour construire "
"Python ; typiquement Microsoft Visual C++."
#: ../Doc/extending/windows.rst:24
#: extending/windows.rst:24
msgid ""
"This chapter mentions a number of filenames that include an encoded Python "
"version number. These filenames are represented with the version number "
@ -62,11 +62,11 @@ msgstr ""
"Python avec laquelle vous travaillez. Par exemple, si vous utilisez Python "
"2.2.1, ``XY`` correspond à ``22``."
#: ../Doc/extending/windows.rst:34
#: extending/windows.rst:34
msgid "A Cookbook Approach"
msgstr "Une approche \"recette de cuisine\""
#: ../Doc/extending/windows.rst:36
#: extending/windows.rst:36
msgid ""
"There are two approaches to building extension modules on Windows, just as "
"there are on Unix: use the :mod:`distutils` package to control the build "
@ -88,11 +88,11 @@ msgstr ""
"`winsound <PCbuild/winsound.vcxproj>` pour le module de la bibliothèque "
"standard."
#: ../Doc/extending/windows.rst:48
#: extending/windows.rst:48
msgid "Differences Between Unix and Windows"
msgstr "Différences entre Unix et Windows"
#: ../Doc/extending/windows.rst:53
#: extending/windows.rst:53
msgid ""
"Unix and Windows use completely different paradigms for run-time loading of "
"code. Before you try to build a module that can be dynamically loaded, be "
@ -103,7 +103,7 @@ msgstr ""
"module qui puisse être chargé dynamiquement, soyez conscient du mode de "
"fonctionnement du système."
#: ../Doc/extending/windows.rst:57
#: extending/windows.rst:57
msgid ""
"In Unix, a shared object (:file:`.so`) file contains code to be used by the "
"program, and also the names of functions and data that it expects to find in "
@ -120,7 +120,7 @@ msgstr ""
"programme où sont désormais placées les fonctions et données dans la "
"mémoire. C'est tout simplement une opération de liaison."
#: ../Doc/extending/windows.rst:64
#: extending/windows.rst:64
msgid ""
"In Windows, a dynamic-link library (:file:`.dll`) file has no dangling "
"references. Instead, an access to functions or data goes through a lookup "
@ -137,7 +137,7 @@ msgstr ""
"cette table est modifiée à l'exécution pour pointer vers les fonctions et "
"données."
#: ../Doc/extending/windows.rst:70
#: extending/windows.rst:70
msgid ""
"In Unix, there is only one type of library file (:file:`.a`) which contains "
"code from several object files (:file:`.o`). During the link step to create "
@ -153,7 +153,7 @@ msgstr ""
"lieur le cherchera dans les fichiers objet dans les bibliothèques ; s'il le "
"trouve, il inclura tout le code provenant de ce fichier objet."
#: ../Doc/extending/windows.rst:76
#: extending/windows.rst:76
msgid ""
"In Windows, there are two types of library, a static library and an import "
"library (both called :file:`.lib`). A static library is like a Unix :file:`."
@ -179,7 +179,7 @@ msgstr ""
"devra être utilisée pour toutes les futures DLL dépendantes aux symboles "
"provenant de l'application ou de la DLL."
#: ../Doc/extending/windows.rst:86
#: extending/windows.rst:86
msgid ""
"Suppose you are building two dynamic-load modules, B and C, which should "
"share another block of code A. On Unix, you would *not* pass :file:`A.a` to "
@ -198,7 +198,7 @@ msgstr ""
"lib` ne contient pas de code ; il contient uniquement des informations qui "
"seront utilisées lors de l'exécution pour accéder au code de A."
#: ../Doc/extending/windows.rst:94
#: extending/windows.rst:94
msgid ""
"In Windows, using an import library is sort of like using ``import spam``; "
"it gives you access to spam's names, but does not create a separate copy. "
@ -210,11 +210,11 @@ msgstr ""
"de copie séparée. Sur Unix, se lier à une bibliothèque est plus comme ``from "
"spam import *`` ; cela crée une copie séparée."
#: ../Doc/extending/windows.rst:103
#: extending/windows.rst:103
msgid "Using DLLs in Practice"
msgstr "Utiliser les DLL en pratique"
#: ../Doc/extending/windows.rst:108
#: extending/windows.rst:108
msgid ""
"Windows Python is built in Microsoft Visual C++; using other compilers may "
"or may not work (though Borland seems to). The rest of this section is MSVC+"
@ -224,7 +224,7 @@ msgstr ""
"d'autres compilateurs pourrait fonctionner, ou pas (cependant Borland a "
"l'air de fonctionner). Le reste de cette section est spécifique à MSVC++."
#: ../Doc/extending/windows.rst:112
#: extending/windows.rst:112
msgid ""
"When creating DLLs in Windows, you must pass :file:`pythonXY.lib` to the "
"linker. To build two DLLs, spam and ni (which uses C functions found in "
@ -234,7 +234,7 @@ msgstr ""
"`pythonXY.lib` au lieur. Pour construire deux DLL, spam et ni (qui utilisent "
"des fonctions C trouvées dans spam), vous pouvez utiliser ces commandes ::"
#: ../Doc/extending/windows.rst:119
#: extending/windows.rst:119
msgid ""
"The first command created three files: :file:`spam.obj`, :file:`spam.dll` "
"and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python "
@ -246,7 +246,7 @@ msgstr ""
"Python (telles que :c:func:`PyArg_ParseTuple`), mais il sait comment trouver "
"le code Python grâce à :file:`pythonXY.lib`."
#: ../Doc/extending/windows.rst:124
#: extending/windows.rst:124
msgid ""
"The second command created :file:`ni.dll` (and :file:`.obj` and :file:`."
"lib`), which knows how to find the necessary functions from spam, and also "
@ -256,7 +256,7 @@ msgstr ""
"qui sait comment trouver les fonctions nécessaires dans spam, ainsi qu'à "
"partir de l'exécutable Python."
#: ../Doc/extending/windows.rst:128
#: extending/windows.rst:128
msgid ""
"Not every identifier is exported to the lookup table. If you want any other "
"modules (including Python) to be able to see your identifiers, you have to "
@ -269,7 +269,7 @@ msgstr ""
"``void _declspec(dllexport) initspam(void)`` ou ``PyObject "
"_declspec(dllexport) *NiGetSpamData(void)``."
#: ../Doc/extending/windows.rst:133
#: extending/windows.rst:133
msgid ""
"Developer Studio will throw in a lot of import libraries that you do not "
"really need, adding about 100K to your executable. To get rid of them, use "