python-docs-fr/faq/extending.po

540 lines
24 KiB
Plaintext
Raw Normal View History

2018-07-04 09:06:45 +00:00
# Copyright (C) 2001-2018, Python Software Foundation
2018-07-04 09:08:42 +00:00
# For licence information, see README file.
2016-10-30 09:46:26 +00:00
#
msgid ""
msgstr ""
2019-12-05 22:15:54 +00:00
"Project-Id-Version: Python 3\n"
2016-10-30 09:46:26 +00:00
"Report-Msgid-Bugs-To: \n"
2020-09-11 07:11:46 +00:00
"POT-Creation-Date: 2020-08-24 09:01+0200\n"
"PO-Revision-Date: 2020-03-03 19:27+0100\n"
2020-05-24 14:31:50 +00:00
"Last-Translator: ZepmanBC <zepman@gmail.com>\n"
2018-07-04 09:14:25 +00:00
"Language-Team: FRENCH <traductions@lists.afpy.org>\n"
2017-05-23 22:40:56 +00:00
"Language: fr\n"
2016-10-30 09:46:26 +00:00
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3\n"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:3
2016-10-30 09:46:26 +00:00
msgid "Extending/Embedding FAQ"
msgstr "FAQ extension/intégration"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:6
2018-06-10 09:32:30 +00:00
msgid "Contents"
msgstr "Sommaire"
2018-06-10 09:32:30 +00:00
#: faq/extending.rst:16
2016-10-30 09:46:26 +00:00
msgid "Can I create my own functions in C?"
msgstr "Puis-je créer mes propres fonctions en C ?"
#: faq/extending.rst:18
2016-10-30 09:46:26 +00:00
msgid ""
"Yes, you can create built-in modules containing functions, variables, "
"exceptions and even new types in C. This is explained in the document :ref:"
"`extending-index`."
msgstr ""
"Oui, vous pouvez créer des modules intégrés contenant des fonctions, des "
"variables, des exceptions et même de nouveaux types en C. Ceci est expliqué "
"dans le document :ref:`extending-index`."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:22
2016-10-30 09:46:26 +00:00
msgid "Most intermediate or advanced Python books will also cover this topic."
msgstr ""
"La plupart des livres Python intermédiaires ou avancés couvrent également ce "
"sujet."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:26
2016-10-30 09:46:26 +00:00
msgid "Can I create my own functions in C++?"
msgstr "Puis-je créer mes propres fonctions en C++ ?"
#: faq/extending.rst:28
2016-10-30 09:46:26 +00:00
msgid ""
"Yes, using the C compatibility features found in C++. Place ``extern \"C"
"\" { ... }`` around the Python include files and put ``extern \"C\"`` before "
"each function that is going to be called by the Python interpreter. Global "
"or static C++ objects with constructors are probably not a good idea."
msgstr ""
"Oui, en utilisant les fonctionnalités de compatibilité C existantes en C++. "
"Placez ``extern \"C\" { ... }`` autour des fichiers Python inclus et mettez "
"``extern \"C\"`` avant chaque fonction qui va être appelée par "
"l'interpréteur Python. Les objets C++ globaux ou statiques avec les "
"constructeurs ne sont probablement pas une bonne idée."
#: faq/extending.rst:37
2016-10-30 09:46:26 +00:00
msgid "Writing C is hard; are there any alternatives?"
msgstr "Écrire directement en C est difficile ; existe-t-il des alternatives ?"
#: faq/extending.rst:39
2016-10-30 09:46:26 +00:00
msgid ""
"There are a number of alternatives to writing your own C extensions, "
"depending on what you're trying to do."
msgstr ""
"Il y a un certain nombre de solutions existantes qui vous permettent "
"d'écrire vos propres extensions C, selon ce que vous essayez de faire."
#: faq/extending.rst:44
2016-10-30 09:46:26 +00:00
msgid ""
"`Cython <http://cython.org>`_ and its relative `Pyrex <https://www.cosc."
"canterbury.ac.nz/greg.ewing/python/Pyrex/>`_ are compilers that accept a "
"slightly modified form of Python and generate the corresponding C code. "
"Cython and Pyrex make it possible to write an extension without having to "
"learn Python's C API."
msgstr ""
"`Cython <http://cython.org>`_ et son cousin `Pyrex <https://www.cosc."
"canterbury.ac.nz/greg.ewing/python/Pyrex/>`_ sont des compilateurs qui "
"acceptent une forme légèrement modifiée de Python et produisent du code C "
"correspondant. Cython et Pyrex permettent d'écrire une extension sans avoir "
"à connaître l'API C de Python."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:50
2016-10-30 09:46:26 +00:00
msgid ""
"If you need to interface to some C or C++ library for which no Python "
"extension currently exists, you can try wrapping the library's data types "
"and functions with a tool such as `SWIG <http://www.swig.org>`_. `SIP "
"<https://riverbankcomputing.com/software/sip/intro>`__, `CXX <http://cxx."
"sourceforge.net/>`_ `Boost <http://www.boost.org/libs/python/doc/index."
2018-01-04 14:57:05 +00:00
"html>`_, or `Weave <https://github.com/scipy/weave>`_ are also alternatives "
"for wrapping C++ libraries."
2016-10-30 09:46:26 +00:00
msgstr ""
"Si vous avez besoin d'accéder à l'interface d'une bibliothèque C ou C++ pour "
"laquelle aucune extension Python n'existe à ce jour, vous pouvez essayer "
"d'encapsuler les types de données et fonctions de la bibliothèque avec un "
"outil tel que `SWIG <http://www.swig.org>`_. `SIP <https://"
"riverbankcomputing.com/software/sip/intro>`__, `CXX <http://cxx.sourceforge."
"net/>`_, `Boost <http://www.boost.org/libs/python/doc/index.html>`_ ou "
"`Weave <https://github.com/scipy/weave>`_ sont également des alternatives "
"pour encapsuler des bibliothèques C++."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:61
2016-10-30 09:46:26 +00:00
msgid "How can I execute arbitrary Python statements from C?"
msgstr ""
"Comment puis-je exécuter des instructions quelconques Python à partir de C ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:63
2016-10-30 09:46:26 +00:00
msgid ""
"The highest-level function to do this is :c:func:`PyRun_SimpleString` which "
"takes a single string argument to be executed in the context of the module "
2018-03-23 08:57:03 +00:00
"``__main__`` and returns ``0`` for success and ``-1`` when an exception "
2018-11-29 15:13:39 +00:00
"occurred (including :exc:`SyntaxError`). If you want more control, use :c:"
"func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in "
"``Python/pythonrun.c``."
2016-10-30 09:46:26 +00:00
msgstr ""
"La fonction de plus haut niveau pour ce faire est :c:func:"
"`PyRun_SimpleStringString` qui prend une chaîne pour seul argument afin de "
"l'exécuter dans le contexte du module ``__main__`` et renvoie ``0`` en cas "
"de succès et ``-1`` quand une exception se produit (incluant :exc:"
"`SyntaxError`). Pour une meilleure maîtrise, utilisez :c:func:"
"`PyRun_String` ; voir le code source pour :c:func:`PyRun_SimpleString` dans "
"``Python/pythonrun.c``."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:72
2016-10-30 09:46:26 +00:00
msgid "How can I evaluate an arbitrary Python expression from C?"
msgstr ""
"Comment puis-je évaluer une expression quelconque de Python à partir de C ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:74
2016-10-30 09:46:26 +00:00
msgid ""
"Call the function :c:func:`PyRun_String` from the previous question with the "
"start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it "
"and returns its value."
msgstr ""
"Appelez la fonction :c:func:`PyRun_String` de la question précédente avec le "
"symbole de départ :c:data:`Py_eval_input` ; il analyse une expression, "
"l'évalue et renvoie sa valeur."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:80
2016-10-30 09:46:26 +00:00
msgid "How do I extract C values from a Python object?"
msgstr "Comment puis-je extraire des donnés en C d'un objet Python ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:82
2016-10-30 09:46:26 +00:00
msgid ""
"That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` "
"returns its length and :c:func:`PyTuple_GetItem` returns the item at a "
"specified index. Lists have similar functions, :c:func:`PyListSize` and :c:"
"func:`PyList_GetItem`."
msgstr ""
"Cela dépend du type d'objet. Si c'est un tuple, :c:func:`PyTuple_Size` "
"renvoie sa longueur et :c:func:`PyTuple_GetItem` renvoie l'élément à l'index "
"spécifié. Les listes ont des fonctions similaires, :c:func:`PyListSize` et :"
"c:func:`PyList_GetItem`."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:87
2016-10-30 09:46:26 +00:00
msgid ""
"For bytes, :c:func:`PyBytes_Size` returns its length and :c:func:"
"`PyBytes_AsStringAndSize` provides a pointer to its value and its length. "
"Note that Python bytes objects may contain null bytes so C's :c:func:"
"`strlen` should not be used."
msgstr ""
"Pour les bytes, :c:func:`PyBytes_Size` renvoie sa longueur et :c:func:"
"`PyBytes_AsStringAndSize` fournit un pointeur vers sa valeur et sa longueur. "
"Notez que les objets bytes en Python peuvent contenir des valeurs nulles, "
"c'est pourquoi il ne faut pas utiliser la fonction C :c:func:`strlen`."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:92
2016-10-30 09:46:26 +00:00
msgid ""
"To test the type of an object, first make sure it isn't ``NULL``, and then "
2016-10-30 09:46:26 +00:00
"use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:"
"`PyList_Check`, etc."
msgstr ""
"Pour tester le type d'un objet, assurez-vous d'abord qu'il ne soit pas "
"``NULL``, puis utilisez :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:"
"func:`PyList_Check`, etc."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:95
2016-10-30 09:46:26 +00:00
msgid ""
"There is also a high-level API to Python objects which is provided by the so-"
"called 'abstract' interface -- read ``Include/abstract.h`` for further "
"details. It allows interfacing with any kind of Python sequence using calls "
"like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc. as well "
"as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et "
"al.) and mappings in the PyMapping APIs."
msgstr ""
"Il y a aussi une API de haut niveau pour les objets Python qui est fournie "
"par l'interface dite « abstraite » — voir ``Include/abstract.h`` pour plus "
"de détails. Elle permet l'interfaçage avec tout type de séquence Python en "
"utilisant des appels tels que :c:func:`PySequence_Length`, :c:func:"
"`PySequence_GetItem`, etc. ainsi que de nombreux autres protocoles utiles "
"tels que les nombres (:c:func:`PyNumber_Index` et autres) et les "
"correspondances dans les APIs PyMapping."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:104
2016-10-30 09:46:26 +00:00
msgid "How do I use Py_BuildValue() to create a tuple of arbitrary length?"
msgstr ""
"Comment utiliser Py_BuildValue() pour créer un tuple de longueur définie ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:106
2016-10-30 09:46:26 +00:00
msgid "You can't. Use :c:func:`PyTuple_Pack` instead."
msgstr "Vous ne pouvez pas. Utilisez :c:func:`PyTuple_Pack` à la place."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:110
2016-10-30 09:46:26 +00:00
msgid "How do I call an object's method from C?"
msgstr "Comment puis-je appeler la méthode d'un objet à partir de C ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:112
2016-10-30 09:46:26 +00:00
msgid ""
"The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary "
"method of an object. The parameters are the object, the name of the method "
"to call, a format string like that used with :c:func:`Py_BuildValue`, and "
"the argument values::"
msgstr ""
"La fonction :c:func:`PyObject_CallMethod` peut être utilisée pour appeler la "
"méthode d'un objet. Les paramètres sont l'objet, le nom de la méthode à "
"appeler, une chaîne de caractères comme celle utilisée pour :c:func:"
"`Py_BuildValue` et les valeurs des arguments ::"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:121
2016-10-30 09:46:26 +00:00
msgid ""
"This works for any object that has methods -- whether built-in or user-"
"defined. You are responsible for eventually :c:func:`Py_DECREF`\\ 'ing the "
"return value."
msgstr ""
"Cela fonctionne pour tous les objets qui ont des méthodes — qu'elles soient "
"intégrées ou définies par l'utilisateur. Vous êtes responsable de « :c:func:"
"`Py_DECREF`\\ *er* » la valeur de retour à la fin."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:124
2016-10-30 09:46:26 +00:00
msgid ""
"To call, e.g., a file object's \"seek\" method with arguments 10, 0 "
"(assuming the file object pointer is \"f\")::"
msgstr ""
"Pour appeler, p. ex., la méthode *seek* d'un objet *file* avec les arguments "
"10, 0 (en supposant que le pointeur de l'objet fichier est *f*) ::"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:135
2016-10-30 09:46:26 +00:00
msgid ""
"Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the "
"argument list, to call a function without arguments, pass \"()\" for the "
"format, and to call a function with one argument, surround the argument in "
"parentheses, e.g. \"(i)\"."
msgstr ""
"Notez que :c:func:`PyObject_CallObject` veut *toujours* un tuple comme liste "
"d'arguments. Aussi, pour appeler une fonction sans arguments, utilisez "
"\"()\" pour être conforme au type et, pour appeler une fonction avec un "
"paramètre, entourez-le de parenthèses, p. ex. \"(i)\"."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:142
2016-10-30 09:46:26 +00:00
msgid ""
"How do I catch the output from PyErr_Print() (or anything that prints to "
"stdout/stderr)?"
msgstr ""
"Comment puis-je récupérer la sortie de ``PyErr_Print()`` (ou tout ce qui "
"s'affiche sur *stdout*/*stderr*) ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:144
2016-10-30 09:46:26 +00:00
msgid ""
"In Python code, define an object that supports the ``write()`` method. "
"Assign this object to :data:`sys.stdout` and :data:`sys.stderr`. Call "
"print_error, or just allow the standard traceback mechanism to work. Then, "
"the output will go wherever your ``write()`` method sends it."
msgstr ""
"Dans le code Python, définissez un objet qui possède la méthode ``write()``. "
"Affectez cet objet à :data:`sys.stdout` et :data:`sys.stderr`. Appelez "
"*print_error* ou faites simplement en sorte que le mécanisme standard de "
"remontée des erreurs fonctionne. Ensuite, la sortie sera dirigée vers "
"l'endroit où votre méthode ``write()`` écrit."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:149
2016-10-30 09:46:26 +00:00
msgid "The easiest way to do this is to use the :class:`io.StringIO` class:"
msgstr ""
"La façon la plus simple consiste à utiliser la classe :class:`io.StringIO` :"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:161
2016-10-30 09:46:26 +00:00
msgid "A custom object to do the same would look like this:"
msgstr ""
"Le code d'un objet à la fonctionnalité similaire ressemblerait à ceci :"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:182
2016-10-30 09:46:26 +00:00
msgid "How do I access a module written in Python from C?"
msgstr "Comment accéder à un module écrit en Python à partir de C ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:184
2016-10-30 09:46:26 +00:00
msgid "You can get a pointer to the module object as follows::"
msgstr "Vous pouvez obtenir un pointeur sur l'objet module comme suit ::"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:188
2016-10-30 09:46:26 +00:00
msgid ""
"If the module hasn't been imported yet (i.e. it is not yet present in :data:"
"`sys.modules`), this initializes the module; otherwise it simply returns the "
"value of ``sys.modules[\"<modulename>\"]``. Note that it doesn't enter the "
"module into any namespace -- it only ensures it has been initialized and is "
"stored in :data:`sys.modules`."
msgstr ""
"Si le module n'a pas encore été importé (c.-à-d. qu'il n'est pas encore "
"présent dans :data:`sys.modules`), cela initialise le module ; sinon il "
"renvoie simplement la valeur de ``sys.modules[\"<modulename>\"]``. Notez "
"qu'il n'inscrit le module dans aucun espace de nommage — il s'assure "
"seulement qu'il a été initialisé et qu'il est stocké dans :data:`sys."
"modules`."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:194
2016-10-30 09:46:26 +00:00
msgid ""
"You can then access the module's attributes (i.e. any name defined in the "
"module) as follows::"
msgstr ""
"Vous pouvez alors accéder aux attributs du module (c.-à-d. à tout nom défini "
"dans le module) comme suit ::"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:199
2016-10-30 09:46:26 +00:00
msgid ""
"Calling :c:func:`PyObject_SetAttrString` to assign to variables in the "
"module also works."
msgstr ""
"Appeler :c:func:`PyObject_SetAttrString` pour assigner des valeurs aux "
"variables du module fonctionne également."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:204
2016-10-30 09:46:26 +00:00
msgid "How do I interface to C++ objects from Python?"
msgstr "Comment s'interfacer avec les objets C++ depuis Python ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:206
2016-10-30 09:46:26 +00:00
msgid ""
"Depending on your requirements, there are many approaches. To do this "
"manually, begin by reading :ref:`the \"Extending and Embedding\" document "
"<extending-index>`. Realize that for the Python run-time system, there "
"isn't a whole lot of difference between C and C++ -- so the strategy of "
"building a new Python type around a C structure (pointer) type will also "
"work for C++ objects."
msgstr ""
"Selon vos besoins, de nombreuses approches sont possibles. Pour le faire "
"manuellement, commencez par lire :ref:`le document \"Extension et intégration"
"\" <extending-index>`. Sachez que pour le système d'exécution Python, il n'y "
"a pas beaucoup de différence entre C et C++ — donc la méthode pour "
"construire un nouveau type Python à partir d'une structure C (pointeur) "
"fonctionne également avec des objets en C++."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:212
2016-10-30 09:46:26 +00:00
msgid "For C++ libraries, see :ref:`c-wrapper-software`."
msgstr "Pour les bibliothèques C++, voir :ref:`c-wrapper-software`."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:216
2016-10-30 09:46:26 +00:00
msgid "I added a module using the Setup file and the make fails; why?"
msgstr ""
"J'ai ajouté un module en utilisant le fichier *Setup* et la compilation "
"échoue ; pourquoi ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:218
2016-10-30 09:46:26 +00:00
msgid ""
"Setup must end in a newline, if there is no newline there, the build process "
"fails. (Fixing this requires some ugly shell script hackery, and this bug "
"is so minor that it doesn't seem worth the effort.)"
msgstr ""
"Le fichier *Setup* doit se terminer par une ligne vide, s'il n'y a pas de "
"ligne vide, le processus de compilation échoue (ce problème peut se régler "
"en bidouillant un script shell, et ce bogue est si mineur qu'il ne mérite "
"pas qu'on s'y attarde)."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:224
2016-10-30 09:46:26 +00:00
msgid "How do I debug an extension?"
msgstr "Comment déboguer une extension ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:226
2016-10-30 09:46:26 +00:00
msgid ""
"When using GDB with dynamically loaded extensions, you can't set a "
"breakpoint in your extension until your extension is loaded."
msgstr ""
"Lorsque vous utilisez GDB avec des extensions chargées dynamiquement, vous "
"ne pouvez pas placer de point d'arrêt dans votre extension tant que celle-ci "
"n'est pas chargée."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:229
2016-10-30 09:46:26 +00:00
msgid "In your ``.gdbinit`` file (or interactively), add the command:"
msgstr ""
"Dans votre fichier ``.gdbinit`` (ou manuellement), ajoutez la commande :"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:235
2016-10-30 09:46:26 +00:00
msgid "Then, when you run GDB:"
msgstr "Ensuite, lorsque vous exécutez GDB :"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:247
2016-10-30 09:46:26 +00:00
msgid ""
"I want to compile a Python module on my Linux system, but some files are "
"missing. Why?"
msgstr ""
"Je veux compiler un module Python sur mon système Linux, mais il manque "
"certains fichiers. Pourquoi ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:249
2016-10-30 09:46:26 +00:00
msgid ""
"Most packaged versions of Python don't include the :file:`/usr/lib/python2."
"{x}/config/` directory, which contains various files required for compiling "
"Python extensions."
msgstr ""
"La plupart des versions pré-compilées de Python n'incluent pas le "
"répertoire :file:`/usr/lib/python2.{x}/config/`, qui contient les différents "
"fichiers nécessaires à la compilation des extensions Python."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:253
2016-10-30 09:46:26 +00:00
msgid "For Red Hat, install the python-devel RPM to get the necessary files."
msgstr ""
"Pour Red Hat, installez le RPM *python-devel* pour obtenir les fichiers "
"nécessaires."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:255
2016-10-30 09:46:26 +00:00
msgid "For Debian, run ``apt-get install python-dev``."
msgstr "Pour Debian, exécutez ``apt-get install python-dev``."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:259
2016-10-30 09:46:26 +00:00
msgid "How do I tell \"incomplete input\" from \"invalid input\"?"
msgstr ""
"Comment distinguer une « entrée incomplète » (*incomplete input*) d'une "
 entrée invalide » (*invalid input*) ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:261
2016-10-30 09:46:26 +00:00
msgid ""
"Sometimes you want to emulate the Python interactive interpreter's behavior, "
"where it gives you a continuation prompt when the input is incomplete (e.g. "
"you typed the start of an \"if\" statement or you didn't close your "
"parentheses or triple string quotes), but it gives you a syntax error "
"message immediately when the input is invalid."
msgstr ""
"Parfois vous souhaitez émuler le comportement de l'interpréteur interactif "
"Python, quand il vous donne une invite de continuation lorsque l'entrée est "
"incomplète (par exemple, vous avez tapé le début d'une instruction \"if\" ou "
"vous n'avez pas fermé vos parenthèses ou triple guillemets) mais il vous "
"renvoie immédiatement une erreur syntaxique quand la saisie est incorrecte."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:267
2016-10-30 09:46:26 +00:00
msgid ""
"In Python you can use the :mod:`codeop` module, which approximates the "
"parser's behavior sufficiently. IDLE uses this, for example."
msgstr ""
"En Python, vous pouvez utiliser le module :mod:`codeop`, qui se rapproche "
"assez du comportement de l'analyseur. Par exemple, IDLE l'utilise."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:270
2016-10-30 09:46:26 +00:00
msgid ""
"The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` "
"(perhaps in a separate thread) and let the Python interpreter handle the "
"input for you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` "
"to point at your custom input function. See ``Modules/readline.c`` and "
"``Parser/myreadline.c`` for more hints."
msgstr ""
"La façon la plus simple de le faire en C est d'appeler :c:func:"
"`PyRun_InteractiveLoop` (peut-être dans un autre fil d'exécution) et laisser "
"l'interpréteur Python gérer l'entrée pour vous. Vous pouvez également "
"définir :c:func:`PyOS_ReadlineFunctionPointer` pour pointer vers votre "
"fonction d'entrée personnalisée. Voir ``Modules/readline.c`` et ``Parser/"
"myreadline.c`` pour plus de conseils."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:276
2016-10-30 09:46:26 +00:00
msgid ""
"However sometimes you have to run the embedded Python interpreter in the "
"same thread as your rest application and you can't allow the :c:func:"
"`PyRun_InteractiveLoop` to stop while waiting for user input. The one "
"solution then is to call :c:func:`PyParser_ParseString` and test for ``e."
2018-12-24 13:20:55 +00:00
"error`` equal to ``E_EOF``, which means the input is incomplete. Here's a "
2016-10-30 09:46:26 +00:00
"sample code fragment, untested, inspired by code from Alex Farber::"
msgstr ""
"Cependant, vous devez parfois exécuter l'interpréteur Python intégré dans le "
"même fil dexécution que le reste de votre application et vous ne pouvez pas "
"laisser :c:func:`PyRun_InteractiveLoop` attendre les entrées utilisateur. La "
"seule solution est alors d'appeler :c:func:`PyParser_ParseString` et de "
"tester si ``e.error`` égale ``E_EOF``, ce qui signifie que l'entrée est "
"incomplète. Voici un exemple de code, non testé, inspiré d'un code écrit par "
"Alex Farber ::"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:310
2016-10-30 09:46:26 +00:00
msgid ""
"Another solution is trying to compile the received string with :c:func:"
"`Py_CompileString`. If it compiles without errors, try to execute the "
"returned code object by calling :c:func:`PyEval_EvalCode`. Otherwise save "
"the input for later. If the compilation fails, find out if it's an error or "
"just more input is required - by extracting the message string from the "
"exception tuple and comparing it to the string \"unexpected EOF while parsing"
"\". Here is a complete example using the GNU readline library (you may want "
"to ignore **SIGINT** while calling readline())::"
msgstr ""
"Une autre solution est d'essayer de compiler la chaîne reçue avec :c:func:"
"`Py_CompileString`. Si cela se compile sans erreur, essayez d'exécuter "
"l'objet code renvoyé en appelant :c:func:`PyEval_EvalCode`. Sinon, "
"enregistrez l'entrée pour plus tard. Si la compilation échoue, vérifiez s'il "
"s'agit d'une erreur ou s'il faut juste plus de données — en extrayant la "
"chaîne de message du tuple d'exception et en la comparant à la chaîne *"
"\"unexpected EOF while parsing\"*. Voici un exemple complet d'utilisation de "
"la bibliothèque *readline* de GNU (il vous est possible d'ignorer **SIGINT** "
"lors de l'appel à ``readline()``) ::"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:432
2016-10-30 09:46:26 +00:00
msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?"
msgstr ""
"Comment puis-je trouver les symboles g++ indéfinis ``__builtin_new`` ou "
"``__pure_virtual`` ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:434
2016-10-30 09:46:26 +00:00
msgid ""
"To dynamically load g++ extension modules, you must recompile Python, relink "
"it using g++ (change LINKCC in the Python Modules Makefile), and link your "
"extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``)."
msgstr ""
"Pour charger dynamiquement les modules d'extension g++, vous devez "
"recompiler Python, effectuer l'édition de liens en utilisant g++ (modifiez "
"*LINKCC* dans le *Python Modules Makefile*), et effectuer l'édition de liens "
"de votre module d'extension avec g++ (par exemple, ``g++ -shared -o mymodule."
"so mymodule.o``)."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:440
2016-10-30 09:46:26 +00:00
msgid ""
"Can I create an object class with some methods implemented in C and others "
"in Python (e.g. through inheritance)?"
msgstr ""
"Puis-je créer une classe d'objets avec certaines méthodes implémentées en C "
"et d'autres en Python (p. ex. en utilisant l'héritage) ?"
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:442
2016-10-30 09:46:26 +00:00
msgid ""
"Yes, you can inherit from built-in classes such as :class:`int`, :class:"
"`list`, :class:`dict`, etc."
msgstr ""
"Oui, vous pouvez hériter de classes intégrées telles que :class:`int`, :"
"class:`list`, :class:`dict`, etc."
2016-10-30 09:46:26 +00:00
#: faq/extending.rst:445
2016-10-30 09:46:26 +00:00
msgid ""
"The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index."
"html) provides a way of doing this from C++ (i.e. you can inherit from an "
"extension class written in C++ using the BPL)."
msgstr ""
"La bibliothèque *Boost Python Library* (BPL, http://www.boost.org/libs/"
"python/doc/index.html) fournit un moyen de le faire depuis C++ (c.-à-d. que "
"vous pouvez hériter d'une classe d'extension écrite en C++ en utilisant BPL)."