python-docs-fr/library/ctypes.po
2020-04-27 23:12:22 +02:00

2862 lines
109 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (C) 2001-2018, Python Software Foundation
# For licence information, see README file.
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.6\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-23 16:48+0200\n"
"PO-Revision-Date: 2018-07-29 19:07+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: FRENCH <traductions@lists.afpy.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../Doc/library/ctypes.rst:2
msgid ":mod:`ctypes` --- A foreign function library for Python"
msgstr ":mod:`ctypes` — Bibliothèque Python d'appels à des fonctions externes"
#: ../Doc/library/ctypes.rst:11
msgid ""
":mod:`ctypes` is a foreign function library for Python. It provides C "
"compatible data types, and allows calling functions in DLLs or shared "
"libraries. It can be used to wrap these libraries in pure Python."
msgstr ""
":mod:`ctypes` est une bibliothèque d'appel à des fonctions externes en "
"python. Elle fournit des types de données compatibles avec le langage C et "
"permet d'appeler des fonctions depuis des DLL ou des bibliothèques "
"partagées, rendant ainsi possible l'interfaçage de ces bibliothèques avec du "
"pur code Python."
#: ../Doc/library/ctypes.rst:19
msgid "ctypes tutorial"
msgstr "Didacticiel de *ctypes*"
#: ../Doc/library/ctypes.rst:21
msgid ""
"Note: The code samples in this tutorial use :mod:`doctest` to make sure that "
"they actually work. Since some code samples behave differently under Linux, "
"Windows, or Mac OS X, they contain doctest directives in comments."
msgstr ""
"Remarque : Les exemples de code de ce didacticiel utilisent :mod:`doctest` "
"pour s'assurer de leur propre bon fonctionnement. Vu que certains de ces "
"exemples ont un comportement différent en Linux, Windows ou Mac OS X, ils "
"contiennent des directives *doctest* dans les commentaires."
#: ../Doc/library/ctypes.rst:25
msgid ""
"Note: Some code samples reference the ctypes :class:`c_int` type. On "
"platforms where ``sizeof(long) == sizeof(int)`` it is an alias to :class:"
"`c_long`. So, you should not be confused if :class:`c_long` is printed if "
"you would expect :class:`c_int` --- they are actually the same type."
msgstr ""
"Remarque : Le type :class:`c_int` du module apparaît dans certains de ces "
"exemples. Sur les plates-formes où ``sizeof(long) == sizeof(int)``, ce type "
"est un alias de :class:`c_long`. Ne soyez donc pas surpris si :class:"
"`c_long` s'affiche là où vous vous attendiez à :class:`c_int` — il s'agit "
"bien du même type."
#: ../Doc/library/ctypes.rst:33
msgid "Loading dynamic link libraries"
msgstr "Chargement des DLL"
#: ../Doc/library/ctypes.rst:35
msgid ""
":mod:`ctypes` exports the *cdll*, and on Windows *windll* and *oledll* "
"objects, for loading dynamic link libraries."
msgstr ""
":mod:`ctypes` fournit l'objet *cdll* pour charger des bibliothèques à liens "
"dynamiques (et les objets *windll* et *oledll* en Windows)."
#: ../Doc/library/ctypes.rst:38
msgid ""
"You load libraries by accessing them as attributes of these objects. *cdll* "
"loads libraries which export functions using the standard ``cdecl`` calling "
"convention, while *windll* libraries call functions using the ``stdcall`` "
"calling convention. *oledll* also uses the ``stdcall`` calling convention, "
"and assumes the functions return a Windows :c:type:`HRESULT` error code. The "
"error code is used to automatically raise an :class:`OSError` exception when "
"the function call fails."
msgstr ""
"Une bibliothèque se charge en y accédant comme un attribut de ces objets. "
"*cdll* charge les bibliothèques qui exportent des fonctions utilisant la "
"convention d'appel standard ``cdecl``, alors que les bibliothèques qui se "
"chargent avec *windll* utilisent la convention d'appel ``stdcall``. *oledll* "
"utilise elle aussi la convention ``stdcall`` et suppose que les fonctions "
"renvoient un code d'erreur :c:type:`HRESULT` de Windows. Ce code d'erreur "
"est utilisé pour lever automatiquement une :class:`OSError` quand l'appel de "
"la fonction échoue."
#: ../Doc/library/ctypes.rst:46
msgid ""
"Windows errors used to raise :exc:`WindowsError`, which is now an alias of :"
"exc:`OSError`."
msgstr ""
"En Windows, les erreurs levaient auparavant une :exc:`WindowsError`, qui est "
"maintenant un alias de :exc:`OSError`."
#: ../Doc/library/ctypes.rst:51
msgid ""
"Here are some examples for Windows. Note that ``msvcrt`` is the MS standard "
"C library containing most standard C functions, and uses the cdecl calling "
"convention::"
msgstr ""
"Voici quelques exemples Windows. ``msvcrt`` est la bibliothèque standard C "
"de Microsoft qui contient la plupart des fonctions standards C. Elle suit la "
"convention d'appel *cdecl* ::"
#: ../Doc/library/ctypes.rst:63
msgid "Windows appends the usual ``.dll`` file suffix automatically."
msgstr "Windows ajoute le suffixe habituel ``.dll`` automatiquement."
#: ../Doc/library/ctypes.rst:66
msgid ""
"Accessing the standard C library through ``cdll.msvcrt`` will use an "
"outdated version of the library that may be incompatible with the one being "
"used by Python. Where possible, use native Python functionality, or else "
"import and use the ``msvcrt`` module."
msgstr ""
"Accéder à la bibliothèque standard C par ``cdll.msvcrt`` utilise une version "
"obsolète de la bibliothèque qui peut avoir des problèmes de compatibilité "
"avec celle que Python utilise. Si possible, mieux vaut utiliser la "
"fonctionnalité native de Python, ou bien importer et utiliser le module "
"``msvcrt``."
#: ../Doc/library/ctypes.rst:71
msgid ""
"On Linux, it is required to specify the filename *including* the extension "
"to load a library, so attribute access can not be used to load libraries. "
"Either the :meth:`LoadLibrary` method of the dll loaders should be used, or "
"you should load the library by creating an instance of CDLL by calling the "
"constructor::"
msgstr ""
"Pour charger une bibliothèque en Linux, il faut passer le nom du fichier "
"*avec* son extension. Il est donc impossible de charger une bibliothèque en "
"accédant à un attribut. Il faut utiliser la méthode :meth:`LoadLibrary` des "
"chargeurs de DLL, ou bien charger la bibliothèque en créant une instance de "
"*CDLL* en appelant son constructeur ::"
#: ../Doc/library/ctypes.rst:89
msgid "Accessing functions from loaded dlls"
msgstr "Accès aux fonctions des DLL chargées"
#: ../Doc/library/ctypes.rst:91
msgid "Functions are accessed as attributes of dll objects::"
msgstr "Les fonctions sont alors des attributs des objets DLL ::"
#: ../Doc/library/ctypes.rst:106
msgid ""
"Note that win32 system dlls like ``kernel32`` and ``user32`` often export "
"ANSI as well as UNICODE versions of a function. The UNICODE version is "
"exported with an ``W`` appended to the name, while the ANSI version is "
"exported with an ``A`` appended to the name. The win32 ``GetModuleHandle`` "
"function, which returns a *module handle* for a given module name, has the "
"following C prototype, and a macro is used to expose one of them as "
"``GetModuleHandle`` depending on whether UNICODE is defined or not::"
msgstr ""
"Les DLL des systèmes *win32* comme ``kernel32`` et ``user32`` exportent "
"souvent une version ANSI et une version UNICODE d'une fonction. La version "
"UNICODE est exportée avec un ``W`` à la fin, et la version ANSI avec un "
"``A``. La fonction *win32* ``GetModuleHandle``, qui renvoie un *gestionnaire "
"de module* à partir de son nom, a le prototype C suivant (c'est une macro "
"qui décide d'exporter l'une ou l'autre à travers ``GetModuleHandle``, selon "
"qu'UNICODE est définie ou non) ::"
#: ../Doc/library/ctypes.rst:119
msgid ""
"*windll* does not try to select one of them by magic, you must access the "
"version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW`` "
"explicitly, and then call it with bytes or string objects respectively."
msgstr ""
"*windll* n'en choisit pas une par magie, il faut accéder à la bonne en "
"écrivant explicitement ``GetModuleHandleA`` ou ``GetModuleHandleW`` et en "
"les appelant ensuite avec des objets octets ou avec des chaînes de "
"caractères, respectivement."
#: ../Doc/library/ctypes.rst:123
msgid ""
"Sometimes, dlls export functions with names which aren't valid Python "
"identifiers, like ``\"??2@YAPAXI@Z\"``. In this case you have to use :func:"
"`getattr` to retrieve the function::"
msgstr ""
"Les DLL exportent parfois des fonctions dont les noms ne sont pas des "
"identifiants Python valides, comme ``\"??2@YAPAXI@Z\"``. Dans ce cas, il "
"faut utiliser :func:`getattr` pour accéder à la fonction ::"
#: ../Doc/library/ctypes.rst:131
msgid ""
"On Windows, some dlls export functions not by name but by ordinal. These "
"functions can be accessed by indexing the dll object with the ordinal "
"number::"
msgstr ""
"Sous Windows, certaines DLL exportent des fonctions à travers un indice "
"plutôt qu'à travers un nom. On accède à une fonction en indiçant l'objet DLL "
"avec son index ::"
#: ../Doc/library/ctypes.rst:148
msgid "Calling functions"
msgstr "Appel de fonctions"
#: ../Doc/library/ctypes.rst:150
msgid ""
"You can call these functions like any other Python callable. This example "
"uses the ``time()`` function, which returns system time in seconds since the "
"Unix epoch, and the ``GetModuleHandleA()`` function, which returns a win32 "
"module handle."
msgstr ""
"Ces fonctions s'appellent comme n'importe quel appelable Python. Cet exemple "
"utilise la fonction ``time()``, qui renvoie le temps en secondes du système "
"depuis l'*epoch* Unix, et la fonction ``GetModuleHandleA()``, qui renvoie un "
"gestionnaire de module *win32*."
#: ../Doc/library/ctypes.rst:155
msgid ""
"This example calls both functions with a NULL pointer (``None`` should be "
"used as the NULL pointer)::"
msgstr ""
#: ../Doc/library/ctypes.rst:166
msgid ""
":mod:`ctypes` may raise a :exc:`ValueError` after calling the function, if "
"it detects that an invalid number of arguments were passed. This behavior "
"should not be relied upon. It is deprecated in 3.6.2, and will be removed "
"in 3.7."
msgstr ""
#: ../Doc/library/ctypes.rst:171
msgid ""
":exc:`ValueError` is raised when you call an ``stdcall`` function with the "
"``cdecl`` calling convention, or vice versa::"
msgstr ""
"Une :exc:`ValueError` est levée quand on appelle une fonction ``stdcall`` "
"avec la convention d'appel ``cdecl`` et vice-versa ::"
#: ../Doc/library/ctypes.rst:186
msgid ""
"To find out the correct calling convention you have to look into the C "
"header file or the documentation for the function you want to call."
msgstr ""
"Pour déterminer la convention d'appel, il faut consulter l'en-tête C ou la "
"documentation de la fonction à appeler."
#: ../Doc/library/ctypes.rst:189
msgid ""
"On Windows, :mod:`ctypes` uses win32 structured exception handling to "
"prevent crashes from general protection faults when functions are called "
"with invalid argument values::"
msgstr ""
"En Windows, :mod:`ctypes` tire profit de la gestion structurée des "
"exceptions (*structured exception handling*) *win32* pour empêcher les "
"plantages dus à des interruptions, afin de préserver la protection globale "
"(*general protection faults*) du système, lorsque des fonctions sont "
"appelées avec un nombre incorrect d'arguments ::"
#: ../Doc/library/ctypes.rst:199
msgid ""
"There are, however, enough ways to crash Python with :mod:`ctypes`, so you "
"should be careful anyway. The :mod:`faulthandler` module can be helpful in "
"debugging crashes (e.g. from segmentation faults produced by erroneous C "
"library calls)."
msgstr ""
"Cependant, il y a suffisamment de façons de faire planter Python avec :mod:"
"`ctypes`, donc il faut être prudent dans tous les cas. Le module :mod:"
"`faulthandler` est pratique pour déboguer les plantages (p. ex. dus à des "
"erreurs de segmentation produites par des appels erronés à la bibliothèque "
"C)."
#: ../Doc/library/ctypes.rst:204
msgid ""
"``None``, integers, bytes objects and (unicode) strings are the only native "
"Python objects that can directly be used as parameters in these function "
"calls. ``None`` is passed as a C ``NULL`` pointer, bytes objects and strings "
"are passed as pointer to the memory block that contains their data (:c:type:"
"`char *` or :c:type:`wchar_t *`). Python integers are passed as the "
"platforms default C :c:type:`int` type, their value is masked to fit into "
"the C type."
msgstr ""
"``None``, les entiers, les objets octets et les chaînes de caractères "
"(Unicode) sont les seuls types natifs de Python qui peuvent être directement "
"passés en paramètres de ces appels de fonctions. ``None`` est passé comme le "
"pointeur C ``NULL``, les objets octets et les chaînes de caractères sont "
"passés comme un pointeur sur le bloc mémoire qui contient la donnée (:c:type:"
"`char *` ou :c:type:`wchar_t *`). Les entiers Python sont passés comme le "
"type C :c:type:`int` par défaut de la plate-forme, un masque étant appliqué "
"pour qu'ils tiennent dans le type C."
#: ../Doc/library/ctypes.rst:211
msgid ""
"Before we move on calling functions with other parameter types, we have to "
"learn more about :mod:`ctypes` data types."
msgstr ""
"Avant de poursuivre sur l'appel de fonctions avec d'autres types de "
"paramètres, apprenons-en un peu plus sur les types de données de :mod:"
"`ctypes`."
#: ../Doc/library/ctypes.rst:218 ../Doc/library/ctypes.rst:2066
msgid "Fundamental data types"
msgstr "Types de données fondamentaux"
#: ../Doc/library/ctypes.rst:220
msgid ":mod:`ctypes` defines a number of primitive C compatible data types:"
msgstr ""
":mod:`ctypes` définit plusieurs types de donnée de base compatibles avec le "
"C :"
#: ../Doc/library/ctypes.rst:223
msgid "ctypes type"
msgstr "Types de *ctypes*"
#: ../Doc/library/ctypes.rst:223
msgid "C type"
msgstr "Type C"
#: ../Doc/library/ctypes.rst:223
msgid "Python type"
msgstr "Type Python"
#: ../Doc/library/ctypes.rst:225
msgid ":class:`c_bool`"
msgstr ":class:`c_bool`"
#: ../Doc/library/ctypes.rst:225
msgid ":c:type:`_Bool`"
msgstr ":c:type:`_Bool`"
#: ../Doc/library/ctypes.rst:225
msgid "bool (1)"
msgstr "*bool* (1)"
#: ../Doc/library/ctypes.rst:227
msgid ":class:`c_char`"
msgstr ":class:`c_char`"
#: ../Doc/library/ctypes.rst:227 ../Doc/library/ctypes.rst:231
msgid ":c:type:`char`"
msgstr ":c:type:`char`"
#: ../Doc/library/ctypes.rst:227
msgid "1-character bytes object"
msgstr "objet octet (*bytes*) de 1 caractère"
#: ../Doc/library/ctypes.rst:229
msgid ":class:`c_wchar`"
msgstr ":class:`c_wchar`"
#: ../Doc/library/ctypes.rst:229
msgid ":c:type:`wchar_t`"
msgstr ":c:type:`wchar_t`"
#: ../Doc/library/ctypes.rst:229
msgid "1-character string"
msgstr "chaîne de caractères (*string*) de longueur 1"
#: ../Doc/library/ctypes.rst:231
msgid ":class:`c_byte`"
msgstr ":class:`c_byte`"
#: ../Doc/library/ctypes.rst:231 ../Doc/library/ctypes.rst:233
#: ../Doc/library/ctypes.rst:235 ../Doc/library/ctypes.rst:237
#: ../Doc/library/ctypes.rst:239 ../Doc/library/ctypes.rst:241
#: ../Doc/library/ctypes.rst:243 ../Doc/library/ctypes.rst:245
#: ../Doc/library/ctypes.rst:247 ../Doc/library/ctypes.rst:249
#: ../Doc/library/ctypes.rst:252 ../Doc/library/ctypes.rst:254
msgid "int"
msgstr "*int*"
#: ../Doc/library/ctypes.rst:233
msgid ":class:`c_ubyte`"
msgstr ":class:`c_ubyte`"
#: ../Doc/library/ctypes.rst:233
msgid ":c:type:`unsigned char`"
msgstr ":c:type:`unsigned char`"
#: ../Doc/library/ctypes.rst:235
msgid ":class:`c_short`"
msgstr ":class:`c_short`"
#: ../Doc/library/ctypes.rst:235
msgid ":c:type:`short`"
msgstr ":c:type:`short`"
#: ../Doc/library/ctypes.rst:237
msgid ":class:`c_ushort`"
msgstr ":class:`c_ushort`"
#: ../Doc/library/ctypes.rst:237
msgid ":c:type:`unsigned short`"
msgstr ":c:type:`unsigned short`"
#: ../Doc/library/ctypes.rst:239
msgid ":class:`c_int`"
msgstr ":class:`c_int`"
#: ../Doc/library/ctypes.rst:239
msgid ":c:type:`int`"
msgstr ":c:type:`int`"
#: ../Doc/library/ctypes.rst:241
msgid ":class:`c_uint`"
msgstr ":class:`c_uint`"
#: ../Doc/library/ctypes.rst:241
msgid ":c:type:`unsigned int`"
msgstr ":c:type:`unsigned int`"
#: ../Doc/library/ctypes.rst:243
msgid ":class:`c_long`"
msgstr ":class:`c_long`"
#: ../Doc/library/ctypes.rst:243
msgid ":c:type:`long`"
msgstr ":c:type:`long`"
#: ../Doc/library/ctypes.rst:245
msgid ":class:`c_ulong`"
msgstr ":class:`c_ulong`"
#: ../Doc/library/ctypes.rst:245
msgid ":c:type:`unsigned long`"
msgstr ":c:type:`unsigned long`"
#: ../Doc/library/ctypes.rst:247
msgid ":class:`c_longlong`"
msgstr ":class:`c_longlong`"
#: ../Doc/library/ctypes.rst:247
msgid ":c:type:`__int64` or :c:type:`long long`"
msgstr ":c:type:`__int64` ou :c:type:`long long`"
#: ../Doc/library/ctypes.rst:249
msgid ":class:`c_ulonglong`"
msgstr ":class:`c_ulonglong`"
#: ../Doc/library/ctypes.rst:249
msgid ":c:type:`unsigned __int64` or :c:type:`unsigned long long`"
msgstr ":c:type:`unsigned __int64` ou :c:type:`unsigned long long`"
#: ../Doc/library/ctypes.rst:252
msgid ":class:`c_size_t`"
msgstr ":class:`c_size_t`"
#: ../Doc/library/ctypes.rst:252
msgid ":c:type:`size_t`"
msgstr ":c:type:`size_t`"
#: ../Doc/library/ctypes.rst:254
msgid ":class:`c_ssize_t`"
msgstr ":class:`c_ssize_t`"
#: ../Doc/library/ctypes.rst:254
msgid ":c:type:`ssize_t` or :c:type:`Py_ssize_t`"
msgstr ":c:type:`ssize_t` ou :c:type:`Py_ssize_t`"
#: ../Doc/library/ctypes.rst:257
msgid ":class:`c_float`"
msgstr ":class:`c_float`"
#: ../Doc/library/ctypes.rst:257
msgid ":c:type:`float`"
msgstr ":c:type:`float`"
#: ../Doc/library/ctypes.rst:257 ../Doc/library/ctypes.rst:259
#: ../Doc/library/ctypes.rst:261
msgid "float"
msgstr "*float*"
#: ../Doc/library/ctypes.rst:259
msgid ":class:`c_double`"
msgstr ":class:`c_double`"
#: ../Doc/library/ctypes.rst:259
msgid ":c:type:`double`"
msgstr ":c:type:`double`"
#: ../Doc/library/ctypes.rst:261
msgid ":class:`c_longdouble`"
msgstr ":class:`c_longdouble`"
#: ../Doc/library/ctypes.rst:261
msgid ":c:type:`long double`"
msgstr ":c:type:`long double`"
#: ../Doc/library/ctypes.rst:263
msgid ":class:`c_char_p`"
msgstr ":class:`c_char_p`"
#: ../Doc/library/ctypes.rst:263
msgid ":c:type:`char *` (NUL terminated)"
msgstr ":c:type:`char *` (terminé par NUL)"
#: ../Doc/library/ctypes.rst:263
msgid "bytes object or ``None``"
msgstr "objet octet (*bytes*) ou ``None``"
#: ../Doc/library/ctypes.rst:265
msgid ":class:`c_wchar_p`"
msgstr ":class:`c_wchar_p`"
#: ../Doc/library/ctypes.rst:265
msgid ":c:type:`wchar_t *` (NUL terminated)"
msgstr ":c:type:`wchar_t *` (terminé par NUL)"
#: ../Doc/library/ctypes.rst:265
msgid "string or ``None``"
msgstr "chaîne de caractères (*string*) ou ``None``"
#: ../Doc/library/ctypes.rst:267
msgid ":class:`c_void_p`"
msgstr ":class:`c_void_p`"
#: ../Doc/library/ctypes.rst:267
msgid ":c:type:`void *`"
msgstr ":c:type:`void *`"
#: ../Doc/library/ctypes.rst:267
msgid "int or ``None``"
msgstr "*int* ou ``None``"
#: ../Doc/library/ctypes.rst:271
msgid "The constructor accepts any object with a truth value."
msgstr "Le constructeur accepte n'importe quel objet convertible en booléen."
#: ../Doc/library/ctypes.rst:273
msgid ""
"All these types can be created by calling them with an optional initializer "
"of the correct type and value::"
msgstr ""
"Il est possible de créer chacun de ces types en les appelant avec une valeur "
"d'initialisation du bon type et avec une valeur cohérente ::"
#: ../Doc/library/ctypes.rst:284
msgid ""
"Since these types are mutable, their value can also be changed afterwards::"
msgstr ""
"Ces types étant des muables, leur valeur peut aussi être modifiée après "
"coup ::"
#: ../Doc/library/ctypes.rst:296
msgid ""
"Assigning a new value to instances of the pointer types :class:`c_char_p`, :"
"class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they "
"point to, *not the contents* of the memory block (of course not, because "
"Python bytes objects are immutable)::"
msgstr ""
"Affecter une nouvelle valeur à une instance de type pointeur — :class:"
"`c_char_p`, :class:`c_wchar_p` et :class:`c_void_p` — change *la zone "
"mémoire* sur laquelle elle pointe, et non *le contenu* de ce bloc mémoire "
"(c'est logique parce que les objets octets sont immuables en Python) ::"
#: ../Doc/library/ctypes.rst:316
msgid ""
"You should be careful, however, not to pass them to functions expecting "
"pointers to mutable memory. If you need mutable memory blocks, ctypes has a :"
"func:`create_string_buffer` function which creates these in various ways. "
"The current memory block contents can be accessed (or changed) with the "
"``raw`` property; if you want to access it as NUL terminated string, use the "
"``value`` property::"
msgstr ""
"Cependant, prenez garde à ne pas en passer à des fonctions qui prennent en "
"paramètre des pointeurs sur de la mémoire modifiable. S'il vous faut de la "
"mémoire modifiable, *ctypes* fournit la fonction :func:"
"`create_string_buffer` qui en crée de plusieurs façons. L'attribut ``raw`` "
"permet d'accéder à (ou de modifier) un bloc mémoire ; l'attribut ``value`` "
"permet d'y accéder comme à une chaîne de caractères terminée par NUL ::"
#: ../Doc/library/ctypes.rst:340
msgid ""
"The :func:`create_string_buffer` function replaces the :func:`c_buffer` "
"function (which is still available as an alias), as well as the :func:"
"`c_string` function from earlier ctypes releases. To create a mutable "
"memory block containing unicode characters of the C type :c:type:`wchar_t` "
"use the :func:`create_unicode_buffer` function."
msgstr ""
"La fonction :func:`create_string_buffer` remplace les fonctions :func:"
"`c_buffer` (qui en reste un alias) et :func:`c_string` des versions "
"antérieures de *ctypes*. La fonction :func:`create_unicode_buffer` crée un "
"bloc mémoire modifiable contenant des caractères Unicode du type C :c:type:"
"`wchar_t`."
#: ../Doc/library/ctypes.rst:350
msgid "Calling functions, continued"
msgstr "Appel de fonctions, suite"
#: ../Doc/library/ctypes.rst:352
msgid ""
"Note that printf prints to the real standard output channel, *not* to :data:"
"`sys.stdout`, so these examples will only work at the console prompt, not "
"from within *IDLE* or *PythonWin*::"
msgstr ""
"*printf* utilise la vraie sortie standard, et non :data:`sys.stdout` ; les "
"exemples suivants ne fonctionnent donc que dans une invite de commande et "
"non depuis *IDLE* or *PythonWin* ::"
#: ../Doc/library/ctypes.rst:372
msgid ""
"As has been mentioned before, all Python types except integers, strings, and "
"bytes objects have to be wrapped in their corresponding :mod:`ctypes` type, "
"so that they can be converted to the required C data type::"
msgstr ""
"Comme mentionné plus haut, tous les types Python (les entiers, les chaînes "
"de caractères et les objets octet exceptés) doivent être encapsulés dans "
"leur type :mod:`ctypes` correspondant pour pouvoir être convertis dans le "
"type C requis ::"
#: ../Doc/library/ctypes.rst:385
msgid "Calling functions with your own custom data types"
msgstr "Appel de fonctions avec des types de données personnalisés"
#: ../Doc/library/ctypes.rst:387
msgid ""
"You can also customize :mod:`ctypes` argument conversion to allow instances "
"of your own classes be used as function arguments. :mod:`ctypes` looks for "
"an :attr:`_as_parameter_` attribute and uses this as the function argument. "
"Of course, it must be one of integer, string, or bytes::"
msgstr ""
"Il est possible de personnaliser la conversion des arguments effectuée par :"
"mod:`ctypes` pour permettre de passer en argument des instances de vos "
"propres classes. :mod:`ctypes` recherche un attribut :attr:`_as_parameter_` "
"et le prend comme argument à la fonction. Bien entendu, cet attribut doit "
"être un entier, une chaîne de caractères ou des octets ::"
#: ../Doc/library/ctypes.rst:402
msgid ""
"If you don't want to store the instance's data in the :attr:`_as_parameter_` "
"instance variable, you could define a :class:`property` which makes the "
"attribute available on request."
msgstr ""
"Si vous ne souhaitez pas stocker les données de l'instance dans la variable :"
"attr:`_as_parameter_` de l'instance, vous pouvez toujours définir une :class:"
"`propriété <property>` qui rend cet attribut disponible sur demande."
#: ../Doc/library/ctypes.rst:410
msgid "Specifying the required argument types (function prototypes)"
msgstr "Définition du type des arguments nécessaires (prototypes de fonction)"
#: ../Doc/library/ctypes.rst:412
msgid ""
"It is possible to specify the required argument types of functions exported "
"from DLLs by setting the :attr:`argtypes` attribute."
msgstr ""
"Il est possible de définir le type des arguments demandés par une fonction "
"exportée depuis une DLL en définissant son attribut :attr:`argtypes`."
#: ../Doc/library/ctypes.rst:415
msgid ""
":attr:`argtypes` must be a sequence of C data types (the ``printf`` function "
"is probably not a good example here, because it takes a variable number and "
"different types of parameters depending on the format string, on the other "
"hand this is quite handy to experiment with this feature)::"
msgstr ""
":attr:`argtypes` doit être une séquence de types de données C (la fonction "
"``printf`` n'est probablement pas le meilleur exemple pour l'illustrer, car "
"elle accepte un nombre variable d'arguments de types eux aussi variables, "
"selon la chaîne de formatage ; cela dit, elle se révèle pratique pour tester "
"cette fonctionnalité) ::"
#: ../Doc/library/ctypes.rst:426
msgid ""
"Specifying a format protects against incompatible argument types (just as a "
"prototype for a C function), and tries to convert the arguments to valid "
"types::"
msgstr ""
"Définir un format empêche de passer des arguments de type incompatible "
"(comme le fait le prototype d'une fonction C) et tente de convertir les "
"arguments en des types valides ::"
#: ../Doc/library/ctypes.rst:438
msgid ""
"If you have defined your own classes which you pass to function calls, you "
"have to implement a :meth:`from_param` class method for them to be able to "
"use them in the :attr:`argtypes` sequence. The :meth:`from_param` class "
"method receives the Python object passed to the function call, it should do "
"a typecheck or whatever is needed to make sure this object is acceptable, "
"and then return the object itself, its :attr:`_as_parameter_` attribute, or "
"whatever you want to pass as the C function argument in this case. Again, "
"the result should be an integer, string, bytes, a :mod:`ctypes` instance, or "
"an object with an :attr:`_as_parameter_` attribute."
msgstr ""
"Pour appeler une fonction avec votre propre classe définie dans la séquence :"
"attr:`argtypes`, il est nécessaire d'implémenter une méthode de classe :meth:"
"`from_param`. La méthode de classe :meth:`from_param` récupère l'objet "
"Python passé à la fonction et doit faire une vérification de type ou tout ce "
"qui est nécessaire pour s'assurer que l'objet est valide, puis renvoie "
"l'objet lui-même, son attribut :attr:`_as_parameter_`, ou tout ce que vous "
"voulez passer comme argument fonction C dans ce cas. Encore une fois, il "
"convient que le résultat soit un entier, une chaîne, des octets, une "
"instance :mod:`ctypes` ou un objet avec un attribut :attr:`_as_parameter_`."
#: ../Doc/library/ctypes.rst:452
msgid "Return types"
msgstr "Types de sortie"
#: ../Doc/library/ctypes.rst:454
msgid ""
"By default functions are assumed to return the C :c:type:`int` type. Other "
"return types can be specified by setting the :attr:`restype` attribute of "
"the function object."
msgstr ""
"Le module suppose que toutes les fonctions renvoient par défaut un :c:type:"
"`int` C. Pour préciser un autre type de sortie, il faut définir l'attribut :"
"attr:`restype` de l'objet encapsulant la fonction."
#: ../Doc/library/ctypes.rst:458
msgid ""
"Here is a more advanced example, it uses the ``strchr`` function, which "
"expects a string pointer and a char, and returns a pointer to a string::"
msgstr ""
"Voici un exemple plus poussé. Celui-ci utilise la fonction ``strchr``, qui "
"prend en paramètres un pointeur vers une chaîne et un caractère. Elle "
"renvoie un pointeur sur une chaîne de caractères ::"
#: ../Doc/library/ctypes.rst:471
msgid ""
"If you want to avoid the ``ord(\"x\")`` calls above, you can set the :attr:"
"`argtypes` attribute, and the second argument will be converted from a "
"single character Python bytes object into a C char::"
msgstr ""
"Pour économiser l'appel ``ord(\"x\")``, il est possible de définir "
"l'attribut :attr:`argtypes` ; le second argument, un objet octet à un seul "
"caractère, sera automatiquement converti en un caractère C ::"
#: ../Doc/library/ctypes.rst:489
msgid ""
"You can also use a callable Python object (a function or a class for "
"example) as the :attr:`restype` attribute, if the foreign function returns "
"an integer. The callable will be called with the *integer* the C function "
"returns, and the result of this call will be used as the result of your "
"function call. This is useful to check for error return values and "
"automatically raise an exception::"
msgstr ""
"Si la fonction à interfacer renvoie un entier, l'attribut :attr:`restype` "
"peut aussi être un appelable (une fonction ou une classe par exemple). Dans "
"ce cas, l'appelable sera appelé avec l'entier renvoyé par la fonction et le "
"résultat de cet appel sera le résultat final de l'appel à la fonction. C'est "
"pratique pour vérifier les codes d'erreurs des valeurs de retour et lever "
"automatiquement des exceptions ::"
#: ../Doc/library/ctypes.rst:512
msgid ""
"``WinError`` is a function which will call Windows ``FormatMessage()`` api "
"to get the string representation of an error code, and *returns* an "
"exception. ``WinError`` takes an optional error code parameter, if no one is "
"used, it calls :func:`GetLastError` to retrieve it."
msgstr ""
"``WinError`` appelle l'API Windows ``FormatMessage()`` pour obtenir une "
"représentation de la chaîne de caractères qui correspond au code d'erreur, "
"et *renvoie* une exception. ``WinError`` prend en paramètre — optionnel — le "
"code d'erreur. Si celui-ci n'est pas passé, elle appelle :func:"
"`GetLastError` pour le récupérer."
#: ../Doc/library/ctypes.rst:517
msgid ""
"Please note that a much more powerful error checking mechanism is available "
"through the :attr:`errcheck` attribute; see the reference manual for details."
msgstr ""
"Notez cependant que l'attribut :attr:`errcheck` permet de vérifier bien plus "
"efficacement les erreurs ; référez-vous au manuel de référence pour plus de "
"précisions."
#: ../Doc/library/ctypes.rst:524
msgid "Passing pointers (or: passing parameters by reference)"
msgstr "Passage de pointeurs (passage de paramètres par référence)"
#: ../Doc/library/ctypes.rst:526
msgid ""
"Sometimes a C api function expects a *pointer* to a data type as parameter, "
"probably to write into the corresponding location, or if the data is too "
"large to be passed by value. This is also known as *passing parameters by "
"reference*."
msgstr ""
"Il arrive qu'une fonction C du code à interfacer requière un *pointeur* vers "
"un certain type de donnée en paramètre, typiquement pour écrire à l'endroit "
"correspondant ou si la donnée est trop grande pour pouvoir être passée par "
"valeur. Ce mécanisme est appelé *passage de paramètres par référence*."
#: ../Doc/library/ctypes.rst:530
msgid ""
":mod:`ctypes` exports the :func:`byref` function which is used to pass "
"parameters by reference. The same effect can be achieved with the :func:"
"`pointer` function, although :func:`pointer` does a lot more work since it "
"constructs a real pointer object, so it is faster to use :func:`byref` if "
"you don't need the pointer object in Python itself::"
msgstr ""
":mod:`ctypes` contient la fonction :func:`byref` qui permet de passer des "
"paramètres par référence. La fonction :func:`pointer` a la même utilité, "
"mais fait plus de travail car :func:`pointer` construit un véritable objet "
"pointeur. Ainsi, si vous n'avez pas besoin de cet objet dans votre code "
"Python, utiliser :func:`byref` est plus performant ::"
#: ../Doc/library/ctypes.rst:552
msgid "Structures and unions"
msgstr "Structures et unions"
#: ../Doc/library/ctypes.rst:554
msgid ""
"Structures and unions must derive from the :class:`Structure` and :class:"
"`Union` base classes which are defined in the :mod:`ctypes` module. Each "
"subclass must define a :attr:`_fields_` attribute. :attr:`_fields_` must be "
"a list of *2-tuples*, containing a *field name* and a *field type*."
msgstr ""
"Les structures et les unions doivent hériter des classes de base :class:"
"`Structure` et :class:`Union` définies dans le module :mod:`ctypes`. Chaque "
"sous-classe doit définir un attribut :attr:`_fields_`. :attr:`_fields_` doit "
"être une liste de *paires*, contenant un *nom de champ* et un *type de "
"champ*."
#: ../Doc/library/ctypes.rst:559
msgid ""
"The field type must be a :mod:`ctypes` type like :class:`c_int`, or any "
"other derived :mod:`ctypes` type: structure, union, array, pointer."
msgstr ""
"Le type de champ doit être un type :mod:`ctypes` comme :class:`c_int` ou un "
"type :mod:`ctypes` dérivé : structure, union, tableau ou pointeur."
#: ../Doc/library/ctypes.rst:562
msgid ""
"Here is a simple example of a POINT structure, which contains two integers "
"named *x* and *y*, and also shows how to initialize a structure in the "
"constructor::"
msgstr ""
"Voici un exemple simple : une structure POINT qui contient deux entiers *x* "
"et *y* et qui montre également comment instancier une structure avec le "
"constructeur ::"
#: ../Doc/library/ctypes.rst:582
msgid ""
"You can, however, build much more complicated structures. A structure can "
"itself contain other structures by using a structure as a field type."
msgstr ""
"Il est bien entendu possible de créer des structures plus complexes. Une "
"structure peut elle-même contenir d'autres structures en prenant une "
"structure comme type de champ."
#: ../Doc/library/ctypes.rst:585
msgid ""
"Here is a RECT structure which contains two POINTs named *upperleft* and "
"*lowerright*::"
msgstr ""
"Voici une structure RECT qui contient deux POINTs *upperleft* et "
"*lowerright* ::"
#: ../Doc/library/ctypes.rst:599
msgid ""
"Nested structures can also be initialized in the constructor in several "
"ways::"
msgstr ""
"Une structure encapsulée peut être instanciée par un constructeur de "
"plusieurs façons ::"
#: ../Doc/library/ctypes.rst:604
msgid ""
"Field :term:`descriptor`\\s can be retrieved from the *class*, they are "
"useful for debugging because they can provide useful information::"
msgstr ""
"Il est possible de récupérer les :term:`descripteurs <descriptor>` des "
"champs depuis la *classe*. Ils sont importants pour déboguer car ils "
"contiennent des informations utiles ::"
#: ../Doc/library/ctypes.rst:618
msgid ""
":mod:`ctypes` does not support passing unions or structures with bit-fields "
"to functions by value. While this may work on 32-bit x86, it's not "
"guaranteed by the library to work in the general case. Unions and "
"structures with bit-fields should always be passed to functions by pointer."
msgstr ""
":mod:`ctypes` ne prend pas en charge le passage par valeur des unions ou des "
"structures avec des champs de bits. Bien que cela puisse fonctionner sur des "
"architectures 32 bits avec un jeu d'instructions x86, ce n'est pas garanti "
"par la bibliothèque en général. Les unions et les structures avec des champs "
"de bits doivent toujours être passées par pointeur."
#: ../Doc/library/ctypes.rst:624
msgid "Structure/union alignment and byte order"
msgstr "Alignement et boutisme des structures et des unions"
#: ../Doc/library/ctypes.rst:626
msgid ""
"By default, Structure and Union fields are aligned in the same way the C "
"compiler does it. It is possible to override this behavior be specifying a :"
"attr:`_pack_` class attribute in the subclass definition. This must be set "
"to a positive integer and specifies the maximum alignment for the fields. "
"This is what ``#pragma pack(n)`` also does in MSVC."
msgstr ""
#: ../Doc/library/ctypes.rst:632
msgid ""
":mod:`ctypes` uses the native byte order for Structures and Unions. To "
"build structures with non-native byte order, you can use one of the :class:"
"`BigEndianStructure`, :class:`LittleEndianStructure`, :class:"
"`BigEndianUnion`, and :class:`LittleEndianUnion` base classes. These "
"classes cannot contain pointer fields."
msgstr ""
":mod:`ctypes` suit le boutisme natif pour les *Structure* et les *Union*. "
"Pour construire des structures avec un boutisme différent, utilisez les "
"classes de base :class:`BigEndianStructure`, :class:"
"`LittleEndianStructure`, :class:`BigEndianUnion` ou :class:"
"`LittleEndianUnion`. Ces classes ne peuvent pas avoir de champ pointeur."
#: ../Doc/library/ctypes.rst:642
msgid "Bit fields in structures and unions"
msgstr "Champs de bits dans les structures et les unions"
#: ../Doc/library/ctypes.rst:644
msgid ""
"It is possible to create structures and unions containing bit fields. Bit "
"fields are only possible for integer fields, the bit width is specified as "
"the third item in the :attr:`_fields_` tuples::"
msgstr ""
"Il est possible de créer des structures et des unions contenant des champs "
"de bits. Seuls les entiers peuvent être des champs de bits, le nombre de "
"bits est défini dans le troisième champ du n-uplet :attr:`_fields_` ::"
#: ../Doc/library/ctypes.rst:662
msgid "Arrays"
msgstr "Tableaux"
#: ../Doc/library/ctypes.rst:664
msgid ""
"Arrays are sequences, containing a fixed number of instances of the same "
"type."
msgstr ""
"Les tableaux sont des séquences qui contiennent un nombre fixe d'instances "
"du même type."
#: ../Doc/library/ctypes.rst:666
msgid ""
"The recommended way to create array types is by multiplying a data type with "
"a positive integer::"
msgstr ""
"La meilleure façon de créer des tableaux consiste à multiplier le type de "
"donnée par un entier positif ::"
#: ../Doc/library/ctypes.rst:671
msgid ""
"Here is an example of a somewhat artificial data type, a structure "
"containing 4 POINTs among other stuff::"
msgstr ""
"Voici un exemple — un peu artificiel — d'une structure contenant, entre "
"autres, 4 POINTs ::"
#: ../Doc/library/ctypes.rst:687
msgid "Instances are created in the usual way, by calling the class::"
msgstr "Comme d'habitude, on crée les instances en appelant la classe ::"
#: ../Doc/library/ctypes.rst:693
msgid ""
"The above code print a series of ``0 0`` lines, because the array contents "
"is initialized to zeros."
msgstr ""
"Le code précédent affiche une suite de ``0 0`` car le contenu du tableau est "
"initialisé avec des zéros."
#: ../Doc/library/ctypes.rst:696
msgid "Initializers of the correct type can also be specified::"
msgstr "Des valeurs d'initialisation du bon type peuvent être passées ::"
#: ../Doc/library/ctypes.rst:712
msgid "Pointers"
msgstr "Pointeurs"
#: ../Doc/library/ctypes.rst:714
msgid ""
"Pointer instances are created by calling the :func:`pointer` function on a :"
"mod:`ctypes` type::"
msgstr ""
"On crée une instance de pointeur en appelant la fonction :func:`pointer` sur "
"un type :mod:`ctypes` ::"
#: ../Doc/library/ctypes.rst:722
msgid ""
"Pointer instances have a :attr:`~_Pointer.contents` attribute which returns "
"the object to which the pointer points, the ``i`` object above::"
msgstr ""
"Les instances de pointeurs ont un attribut :attr:`~_Pointer.contents` qui "
"renvoie l'objet pointé (l'objet ``i`` ci-dessus) ::"
#: ../Doc/library/ctypes.rst:729
msgid ""
"Note that :mod:`ctypes` does not have OOR (original object return), it "
"constructs a new, equivalent object each time you retrieve an attribute::"
msgstr ""
"Attention, :mod:`ctypes` ne fait pas de ROI (retour de l'objet initial). Il "
"crée un nouvel objet à chaque fois qu'on accède à un attribut ::"
#: ../Doc/library/ctypes.rst:738
msgid ""
"Assigning another :class:`c_int` instance to the pointer's contents "
"attribute would cause the pointer to point to the memory location where this "
"is stored::"
msgstr ""
"Affecter une autre instance de :class:`c_int` à l'attribut *contents* du "
"pointeur fait pointer le pointeur vers l'adresse mémoire de cette nouvelle "
"instance ::"
#: ../Doc/library/ctypes.rst:750
msgid "Pointer instances can also be indexed with integers::"
msgstr "Il est possible d'indexer les pointeurs par des entiers ::"
#: ../Doc/library/ctypes.rst:756
msgid "Assigning to an integer index changes the pointed to value::"
msgstr "Affecter à travers un indice change la valeur pointée ::"
#: ../Doc/library/ctypes.rst:765
msgid ""
"It is also possible to use indexes different from 0, but you must know what "
"you're doing, just as in C: You can access or change arbitrary memory "
"locations. Generally you only use this feature if you receive a pointer from "
"a C function, and you *know* that the pointer actually points to an array "
"instead of a single item."
msgstr ""
"Si vous êtes sûr de vous, vous pouvez utiliser d'autres valeurs que 0, comme "
"en C : il est ainsi possible de modifier une zone mémoire de votre choix. De "
"manière générale cette fonctionnalité ne s'utilise que sur un pointeur "
"renvoyé par une fonction C, pointeur que vous *savez* pointer vers un "
"tableau et non sur un seul élément."
#: ../Doc/library/ctypes.rst:771
msgid ""
"Behind the scenes, the :func:`pointer` function does more than simply create "
"pointer instances, it has to create pointer *types* first. This is done with "
"the :func:`POINTER` function, which accepts any :mod:`ctypes` type, and "
"returns a new type::"
msgstr ""
"Sous le capot, la fonction :func:`pointer` fait plus que simplement créer "
"une instance de pointeur ; elle doit d'abord créer un type « pointeur "
"sur… ». Cela s'effectue avec la fonction :func:`POINTER`, qui prend en "
"paramètre n'importe quel type :mod:`ctypes` et renvoie un nouveau type ::"
#: ../Doc/library/ctypes.rst:787
msgid ""
"Calling the pointer type without an argument creates a ``NULL`` pointer. "
"``NULL`` pointers have a ``False`` boolean value::"
msgstr ""
"Appeler le pointeur sur type sans arguments crée un pointeur ``NULL``. Les "
"pointeurs ``NULL`` s'évaluent à ``False`` ::"
#: ../Doc/library/ctypes.rst:795
msgid ""
":mod:`ctypes` checks for ``NULL`` when dereferencing pointers (but "
"dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::"
msgstr ""
":mod:`ctypes` vérifie que le pointeur n'est pas ``NULL`` quand il en "
"déréférence un (mais déréférencer des pointeurs non ``NULL`` invalides fait "
"planter Python) ::"
#: ../Doc/library/ctypes.rst:814
msgid "Type conversions"
msgstr "Conversions de type"
#: ../Doc/library/ctypes.rst:816
msgid ""
"Usually, ctypes does strict type checking. This means, if you have "
"``POINTER(c_int)`` in the :attr:`argtypes` list of a function or as the type "
"of a member field in a structure definition, only instances of exactly the "
"same type are accepted. There are some exceptions to this rule, where "
"ctypes accepts other objects. For example, you can pass compatible array "
"instances instead of pointer types. So, for ``POINTER(c_int)``, ctypes "
"accepts an array of c_int::"
msgstr ""
"En général, *ctypes* respecte un typage fort. Cela signifie que si un "
"``POINTER(c_int)`` est présent dans la liste des :attr:`argtypes` d'une "
"fonction ou est le type d'un attribut membre dans une définition de "
"structure, seules des instances de ce type seront valides. Cette règle "
"comporte quelques exceptions pour lesquelles *ctypes* accepte d'autres "
"objets. Par exemple il est possible de passer des instances de tableau à "
"place de pointeurs, s'ils sont compatibles. Dans le cas de "
"``POINTER(c_int)``, *ctypes* accepte des tableaux de *c_int* ::"
#: ../Doc/library/ctypes.rst:837
msgid ""
"In addition, if a function argument is explicitly declared to be a pointer "
"type (such as ``POINTER(c_int)``) in :attr:`argtypes`, an object of the "
"pointed type (``c_int`` in this case) can be passed to the function. ctypes "
"will apply the required :func:`byref` conversion in this case automatically."
msgstr ""
"De plus, si un paramètre de fonction est déclaré explicitement de type "
"pointeur (comme ``POINTER(c_int)``) dans les :attr:`argtypes`, il est aussi "
"possible de passer un objet du type pointé — ici, ``c_int`` — à la fonction. "
"*ctypes* appelle alors automatiquement la fonction de conversion :func:"
"`byref`."
#: ../Doc/library/ctypes.rst:842
msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::"
msgstr ""
"Pour mettre un champ de type *POINTER* à ``NULL``, il faut lui affecter "
"``None`` ::"
#: ../Doc/library/ctypes.rst:849
msgid ""
"Sometimes you have instances of incompatible types. In C, you can cast one "
"type into another type. :mod:`ctypes` provides a :func:`cast` function "
"which can be used in the same way. The ``Bar`` structure defined above "
"accepts ``POINTER(c_int)`` pointers or :class:`c_int` arrays for its "
"``values`` field, but not instances of other types::"
msgstr ""
"Parfois il faut gérer des incompatibilités entre les types. En C, il est "
"possible de convertir un type en un autre. :mod:`ctypes` fournit la "
"fonction :func:`cast` qui permet la même chose. La structure ``Bar`` ci-"
"dessus accepte des pointeurs ``POINTER(c_int)`` ou des tableaux de :class:"
"`c_int` comme valeur pour le champ ``values``, mais pas des instances "
"d'autres types ::"
#: ../Doc/library/ctypes.rst:861
msgid "For these cases, the :func:`cast` function is handy."
msgstr "C'est là que la fonction :func:`cast` intervient."
#: ../Doc/library/ctypes.rst:863
msgid ""
"The :func:`cast` function can be used to cast a ctypes instance into a "
"pointer to a different ctypes data type. :func:`cast` takes two parameters, "
"a ctypes object that is or can be converted to a pointer of some kind, and a "
"ctypes pointer type. It returns an instance of the second argument, which "
"references the same memory block as the first argument::"
msgstr ""
"La fonction :func:`cast` permet de convertir une instance de *ctypes* en un "
"pointeur vers un type de données *ctypes* différent. :func:`cast` prend deux "
"paramètres : un objet *ctypes* qui est, ou qui peut être converti en, un "
"certain pointeur et un type pointeur de *ctypes*. Elle renvoie une instance "
"du second argument, qui pointe sur le même bloc mémoire que le premier "
"argument ::"
#: ../Doc/library/ctypes.rst:874
msgid ""
"So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` "
"the structure::"
msgstr ""
"Ainsi, la fonction :func:`cast` permet de remplir le champ ``values`` de la "
"structure ``Bar`` ::"
#: ../Doc/library/ctypes.rst:887
msgid "Incomplete Types"
msgstr "Types incomplets"
#: ../Doc/library/ctypes.rst:889
msgid ""
"*Incomplete Types* are structures, unions or arrays whose members are not "
"yet specified. In C, they are specified by forward declarations, which are "
"defined later::"
msgstr ""
"Un *type incomplet* est une structure, une union ou un tableau dont les "
"membres ne sont pas encore définis. C'est l'équivalent d'une déclaration "
"avancée en C, où la définition est fournie plus tard ::"
#: ../Doc/library/ctypes.rst:900
msgid ""
"The straightforward translation into ctypes code would be this, but it does "
"not work::"
msgstr ""
"Une traduction naïve, mais invalide, en code *ctypes* ressemblerait à ça ::"
#: ../Doc/library/ctypes.rst:913
msgid ""
"because the new ``class cell`` is not available in the class statement "
"itself. In :mod:`ctypes`, we can define the ``cell`` class and set the :attr:"
"`_fields_` attribute later, after the class statement::"
msgstr ""
"Cela ne fonctionne pas parce que la nouvelle ``class cell`` n'est pas "
"accessible dans la définition de la classe elle-même. Dans le module :mod:"
"`ctypes`, on définit la classe ``cell`` et on définira les :attr:`_fields_` "
"plus tard, après avoir défini la classe ::"
#: ../Doc/library/ctypes.rst:925
msgid ""
"Lets try it. We create two instances of ``cell``, and let them point to each "
"other, and finally follow the pointer chain a few times::"
msgstr ""
#: ../Doc/library/ctypes.rst:946
msgid "Callback functions"
msgstr "Fonctions de rappel"
#: ../Doc/library/ctypes.rst:948
msgid ""
":mod:`ctypes` allows creating C callable function pointers from Python "
"callables. These are sometimes called *callback functions*."
msgstr ""
":mod:`ctypes` permet de créer des pointeurs de fonctions appelables par des "
"appelables Python. On les appelle parfois *fonctions de rappel*."
#: ../Doc/library/ctypes.rst:951
msgid ""
"First, you must create a class for the callback function. The class knows "
"the calling convention, the return type, and the number and types of "
"arguments this function will receive."
msgstr ""
"Tout d'abord, il faut créer une classe pour la fonction de rappel. La classe "
"connaît la convention d'appel, le type de retour ainsi que le nombre et le "
"type de paramètres que la fonction accepte."
#: ../Doc/library/ctypes.rst:955
msgid ""
"The :func:`CFUNCTYPE` factory function creates types for callback functions "
"using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` "
"factory function creates types for callback functions using the ``stdcall`` "
"calling convention."
msgstr ""
"La fabrique :func:`CFUNCTYPE` crée un type pour les fonctions de rappel qui "
"suivent la convention d'appel ``cdecl``. En Windows, c'est la fabrique :func:"
"`WINFUNCTYPE` qui crée un type pour les fonctions de rappel qui suivent la "
"convention d'appel ``stdcall``."
#: ../Doc/library/ctypes.rst:960
msgid ""
"Both of these factory functions are called with the result type as first "
"argument, and the callback functions expected argument types as the "
"remaining arguments."
msgstr ""
"Le premier paramètre de ces deux fonctions est le type de retour, et les "
"suivants sont les types des arguments qu'attend la fonction de rappel."
#: ../Doc/library/ctypes.rst:964
msgid ""
"I will present an example here which uses the standard C library's :c:func:"
"`qsort` function, that is used to sort items with the help of a callback "
"function. :c:func:`qsort` will be used to sort an array of integers::"
msgstr ""
"Intéressons-nous à un exemple tiré de la bibliothèque standard C : la "
"fonction :c:func:`qsort`. Celle-ci permet de classer des éléments par "
"l'emploi d'une fonction de rappel. Nous allons utiliser :c:func:`qsort` pour "
"ordonner un tableau d'entiers ::"
#: ../Doc/library/ctypes.rst:974
msgid ""
":func:`qsort` must be called with a pointer to the data to sort, the number "
"of items in the data array, the size of one item, and a pointer to the "
"comparison function, the callback. The callback will then be called with two "
"pointers to items, and it must return a negative integer if the first item "
"is smaller than the second, a zero if they are equal, and a positive integer "
"otherwise."
msgstr ""
":func:`qsort` doit être appelée avec un pointeur vers la donnée à ordonner, "
"le nombre d'éléments dans la donnée, la taille d'un élément et un pointeur "
"vers le comparateur, c-à-d la fonction de rappel. Cette fonction sera "
"invoquée avec deux pointeurs sur deux éléments et doit renvoyer un entier "
"négatif si le premier élément est plus petit que le second, zéro s'ils sont "
"égaux et un entier positif sinon."
#: ../Doc/library/ctypes.rst:980
msgid ""
"So our callback function receives pointers to integers, and must return an "
"integer. First we create the ``type`` for the callback function::"
msgstr ""
"Ainsi notre fonction de rappel reçoit des pointeurs vers des entiers et doit "
"renvoyer un entier. Créons d'abord le ``type`` pour la fonction de rappel ::"
#: ../Doc/library/ctypes.rst:986
msgid ""
"To get started, here is a simple callback that shows the values it gets "
"passed::"
msgstr ""
"Pour commencer, voici une fonction de rappel simple qui affiche les valeurs "
"qu'on lui passe ::"
#: ../Doc/library/ctypes.rst:996
msgid "The result::"
msgstr "Résultat ::"
#: ../Doc/library/ctypes.rst:1006
msgid "Now we can actually compare the two items and return a useful result::"
msgstr ""
"À présent, comparons pour de vrai les deux entiers et renvoyons un résultat "
"utile ::"
#: ../Doc/library/ctypes.rst:1021
msgid "As we can easily check, our array is sorted now::"
msgstr ""
"Et comme il est facile de le voir, notre tableau est désormais classé ::"
#: ../Doc/library/ctypes.rst:1028
msgid ""
"The function factories can be used as decorator factories, so we may as well "
"write::"
msgstr ""
"Ces fonctions peuvent aussi être utilisées comme des décorateurs ; il est "
"donc possible d'écrire ::"
#: ../Doc/library/ctypes.rst:1046
msgid ""
"Make sure you keep references to :func:`CFUNCTYPE` objects as long as they "
"are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be "
"garbage collected, crashing your program when a callback is made."
msgstr ""
"Prenez garde à bien conserver une référence à un objet :func:`CFUNCTYPE` "
"tant que celui-ci est utilisé par le code C. :mod:`ctypes` ne le fait pas "
"tout seul et, si vous ne le faites pas, le ramasse-miette pourrait les "
"libérer, ce qui fera planter votre programme quand un appel sera fait."
#: ../Doc/library/ctypes.rst:1050
msgid ""
"Also, note that if the callback function is called in a thread created "
"outside of Python's control (e.g. by the foreign code that calls the "
"callback), ctypes creates a new dummy Python thread on every invocation. "
"This behavior is correct for most purposes, but it means that values stored "
"with :class:`threading.local` will *not* survive across different callbacks, "
"even when those calls are made from the same C thread."
msgstr ""
"Notez aussi que si la fonction de rappel est appelée dans un fil d'exécution "
"créé hors de Python (p. ex. par du code externe qui appelle la fonction de "
"rappel), *ctypes* crée un nouveau fil Python « creux » à chaque fois. Ce "
"comportement est acceptable pour la plupart des cas d'utilisation, mais cela "
"implique que les valeurs stockées avec :class:`threading.local` ne seront "
"*pas* persistantes d'un appel à l'autre, même si les appels proviennent du "
"même fil d'exécution C."
#: ../Doc/library/ctypes.rst:1060
msgid "Accessing values exported from dlls"
msgstr "Accès aux variables exportées depuis une DLL"
#: ../Doc/library/ctypes.rst:1062
msgid ""
"Some shared libraries not only export functions, they also export variables. "
"An example in the Python library itself is the :c:data:`Py_OptimizeFlag`, an "
"integer set to 0, 1, or 2, depending on the :option:`-O` or :option:`-OO` "
"flag given on startup."
msgstr ""
"Certaines bibliothèques ne se contentent pas d'exporter des fonctions, elles "
"exportent aussi des variables. Par exemple, la bibliothèque Python exporte :"
"c:data:`Py_OptimizeFlag`, un entier valant 0, 1, ou 2 selon que l'option :"
"option:`-O` ou :option:`-OO` soit donnée au démarrage."
#: ../Doc/library/ctypes.rst:1067
msgid ""
":mod:`ctypes` can access values like this with the :meth:`in_dll` class "
"methods of the type. *pythonapi* is a predefined symbol giving access to "
"the Python C api::"
msgstr ""
":mod:`ctypes` peut accéder à ce type de valeurs avec les méthodes de classe :"
"meth:`in_dll` du type considéré. *pythonapi* est un symbole prédéfini qui "
"donne accès à l'API C Python ::"
#: ../Doc/library/ctypes.rst:1076
msgid ""
"If the interpreter would have been started with :option:`-O`, the sample "
"would have printed ``c_long(1)``, or ``c_long(2)`` if :option:`-OO` would "
"have been specified."
msgstr ""
"Si l'interpréteur est lancé avec :option:`-O`, l'exemple affiche "
"``c_long(1)`` et ``c_long(2)`` avec :option:`-OO`."
#: ../Doc/library/ctypes.rst:1080
msgid ""
"An extended example which also demonstrates the use of pointers accesses "
"the :c:data:`PyImport_FrozenModules` pointer exported by Python."
msgstr ""
"Le pointeur :c:data:`PyImport_FrozenModules` exposé par Python est un autre "
"exemple complet de l'utilisation de pointeurs."
#: ../Doc/library/ctypes.rst:1083
msgid "Quoting the docs for that value:"
msgstr "Citons la documentation :"
#: ../Doc/library/ctypes.rst:1085
msgid ""
"This pointer is initialized to point to an array of :c:type:`struct _frozen` "
"records, terminated by one whose members are all *NULL* or zero. When a "
"frozen module is imported, it is searched in this table. Third-party code "
"could play tricks with this to provide a dynamically created collection of "
"frozen modules."
msgstr ""
#: ../Doc/library/ctypes.rst:1090
msgid ""
"So manipulating this pointer could even prove useful. To restrict the "
"example size, we show only how this table can be read with :mod:`ctypes`::"
msgstr ""
"Donc manipuler ce pointeur peut même se révéler utile. Pour limiter la "
"taille de l'exemple, nous nous bornons à montrer comment lire ce tableau "
"avec :mod:`ctypes` ::"
#: ../Doc/library/ctypes.rst:1102
msgid ""
"We have defined the :c:type:`struct _frozen` data type, so we can get the "
"pointer to the table::"
msgstr ""
"Le type de donnée :c:type:`struct _frozen` ayant été défini, nous pouvons "
"récupérer le pointeur vers le tableau ::"
#: ../Doc/library/ctypes.rst:1109
msgid ""
"Since ``table`` is a ``pointer`` to the array of ``struct_frozen`` records, "
"we can iterate over it, but we just have to make sure that our loop "
"terminates, because pointers have no size. Sooner or later it would probably "
"crash with an access violation or whatever, so it's better to break out of "
"the loop when we hit the NULL entry::"
msgstr ""
#: ../Doc/library/ctypes.rst:1127
msgid ""
"The fact that standard Python has a frozen module and a frozen package "
"(indicated by the negative size member) is not well known, it is only used "
"for testing. Try it out with ``import __hello__`` for example."
msgstr ""
#: ../Doc/library/ctypes.rst:1135
msgid "Surprises"
msgstr "Pièges"
#: ../Doc/library/ctypes.rst:1137
msgid ""
"There are some edges in :mod:`ctypes` where you might expect something other "
"than what actually happens."
msgstr ""
"Il y a quelques cas tordus dans :mod:`ctypes` où on peut s'attendre à un "
"résultat différent de la réalité."
#: ../Doc/library/ctypes.rst:1140
msgid "Consider the following example::"
msgstr "Examinons l'exemple suivant ::"
#: ../Doc/library/ctypes.rst:1160
msgid ""
"Hm. We certainly expected the last statement to print ``3 4 1 2``. What "
"happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::"
msgstr ""
"Diantre. On s'attendait certainement à ce que le dernier résultat affiche "
"``3 4 1 2``. Que s'est-il passé ? Les étapes de la ligne ``rc.a, rc.b = rc."
"b, rc.a`` ci-dessus sont les suivantes ::"
#: ../Doc/library/ctypes.rst:1168
msgid ""
"Note that ``temp0`` and ``temp1`` are objects still using the internal "
"buffer of the ``rc`` object above. So executing ``rc.a = temp0`` copies the "
"buffer contents of ``temp0`` into ``rc`` 's buffer. This, in turn, changes "
"the contents of ``temp1``. So, the last assignment ``rc.b = temp1``, doesn't "
"have the expected effect."
msgstr ""
"Les objets ``temp0`` et ``temp1`` utilisent encore le tampon interne de "
"l'objet ``rc`` ci-dessus. Donc exécuter ``rc.a = temp0`` copie le contenu du "
"tampon de ``temp0`` dans celui de ``rc``. Ce qui, par ricochet, modifie le "
"contenu de ``temp1``. Et donc, la dernière affectation, ``rc.b = temp1``, "
"n'a pas l'effet escompté."
#: ../Doc/library/ctypes.rst:1174
msgid ""
"Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays "
"doesn't *copy* the sub-object, instead it retrieves a wrapper object "
"accessing the root-object's underlying buffer."
msgstr ""
"Gardez en tête qu'accéder au sous-objet depuis une *Structure*, une *Union* "
"ou un *Array* ne copie *pas* le sous-objet, mais crée un objet interface qui "
"accède au tampon sous-jacent de l'objet initial."
#: ../Doc/library/ctypes.rst:1178
msgid ""
"Another example that may behave different from what one would expect is "
"this::"
msgstr ""
#: ../Doc/library/ctypes.rst:1188
msgid ""
"Why is it printing ``False``? ctypes instances are objects containing a "
"memory block plus some :term:`descriptor`\\s accessing the contents of the "
"memory. Storing a Python object in the memory block does not store the "
"object itself, instead the ``contents`` of the object is stored. Accessing "
"the contents again constructs a new Python object each time!"
msgstr ""
"Pourquoi cela affiche-t'il ``False`` ? Les instances *ctypes* sont des "
"objets qui contiennent un bloc mémoire et des :term:`descriptor` qui donnent "
"accès au contenu du ce bloc. Stocker un objet Python dans le bloc mémoire ne "
"stocke pas l'objet même ; seuls ses ``contents`` le sont. Accéder au "
"``contents`` crée un nouvel objet Python à chaque fois !"
#: ../Doc/library/ctypes.rst:1198
msgid "Variable-sized data types"
msgstr "Types de données à taille flottante"
#: ../Doc/library/ctypes.rst:1200
msgid ""
":mod:`ctypes` provides some support for variable-sized arrays and structures."
msgstr ""
":mod:`ctypes` assure la prise en charge des tableaux et des structures à "
"taille flottante."
#: ../Doc/library/ctypes.rst:1202
msgid ""
"The :func:`resize` function can be used to resize the memory buffer of an "
"existing ctypes object. The function takes the object as first argument, "
"and the requested size in bytes as the second argument. The memory block "
"cannot be made smaller than the natural memory block specified by the "
"objects type, a :exc:`ValueError` is raised if this is tried::"
msgstr ""
"La fonction :func:`resize` permet de redimensionner la taille du tampon "
"mémoire d'un objet *ctypes* existant. Cette fonction prend l'objet comme "
"premier argument et la taille en octets désirée comme second. La taille du "
"tampon mémoire ne peut pas être inférieure à celle occupée par un objet "
"unitaire du type considéré. Une :exc:`ValueError` est levée si c'est le "
"cas ::"
#: ../Doc/library/ctypes.rst:1222
msgid ""
"This is nice and fine, but how would one access the additional elements "
"contained in this array? Since the type still only knows about 4 elements, "
"we get errors accessing other elements::"
msgstr ""
"Cela dit, comment accéder aux éléments supplémentaires contenus dans le "
"tableau ? Vu que le type ne connaît que 4 éléments, on obtient une erreur si "
"l'on accède aux suivants ::"
#: ../Doc/library/ctypes.rst:1234
msgid ""
"Another way to use variable-sized data types with :mod:`ctypes` is to use "
"the dynamic nature of Python, and (re-)define the data type after the "
"required size is already known, on a case by case basis."
msgstr ""
"Une autre approche pour utiliser des types de donnée à taille flottante "
"avec :mod:`ctypes` consiste à tirer profit de la nature intrinsèquement "
"dynamique de Python et de (re)définir le type de donnée une fois que la "
"taille demandée est connue, au cas-par-cas."
#: ../Doc/library/ctypes.rst:1242
msgid "ctypes reference"
msgstr "Référence du module"
#: ../Doc/library/ctypes.rst:1248
msgid "Finding shared libraries"
msgstr "Recherche de bibliothèques partagées"
#: ../Doc/library/ctypes.rst:1250
msgid ""
"When programming in a compiled language, shared libraries are accessed when "
"compiling/linking a program, and when the program is run."
msgstr ""
#: ../Doc/library/ctypes.rst:1253
msgid ""
"The purpose of the :func:`find_library` function is to locate a library in a "
"way similar to what the compiler or runtime loader does (on platforms with "
"several versions of a shared library the most recent should be loaded), "
"while the ctypes library loaders act like when a program is run, and call "
"the runtime loader directly."
msgstr ""
#: ../Doc/library/ctypes.rst:1259
msgid ""
"The :mod:`ctypes.util` module provides a function which can help to "
"determine the library to load."
msgstr ""
#: ../Doc/library/ctypes.rst:1267
msgid ""
"Try to find a library and return a pathname. *name* is the library name "
"without any prefix like *lib*, suffix like ``.so``, ``.dylib`` or version "
"number (this is the form used for the posix linker option :option:`!-l`). "
"If no library can be found, returns ``None``."
msgstr ""
#: ../Doc/library/ctypes.rst:1272 ../Doc/library/ctypes.rst:1860
msgid "The exact functionality is system dependent."
msgstr ""
#: ../Doc/library/ctypes.rst:1274
msgid ""
"On Linux, :func:`find_library` tries to run external programs (``/sbin/"
"ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library file. It "
"returns the filename of the library file."
msgstr ""
#: ../Doc/library/ctypes.rst:1278
msgid ""
"On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used "
"when searching for libraries, if a library cannot be found by any other "
"means."
msgstr ""
#: ../Doc/library/ctypes.rst:1282
msgid "Here are some examples::"
msgstr ""
#: ../Doc/library/ctypes.rst:1293
msgid ""
"On OS X, :func:`find_library` tries several predefined naming schemes and "
"paths to locate the library, and returns a full pathname if successful::"
msgstr ""
#: ../Doc/library/ctypes.rst:1307
msgid ""
"On Windows, :func:`find_library` searches along the system search path, and "
"returns the full pathname, but since there is no predefined naming scheme a "
"call like ``find_library(\"c\")`` will fail and return ``None``."
msgstr ""
#: ../Doc/library/ctypes.rst:1311
msgid ""
"If wrapping a shared library with :mod:`ctypes`, it *may* be better to "
"determine the shared library name at development time, and hardcode that "
"into the wrapper module instead of using :func:`find_library` to locate the "
"library at runtime."
msgstr ""
#: ../Doc/library/ctypes.rst:1319
msgid "Loading shared libraries"
msgstr "Chargement des bibliothèques partagées"
#: ../Doc/library/ctypes.rst:1321
msgid ""
"There are several ways to load shared libraries into the Python process. "
"One way is to instantiate one of the following classes:"
msgstr ""
#: ../Doc/library/ctypes.rst:1327
msgid ""
"Instances of this class represent loaded shared libraries. Functions in "
"these libraries use the standard C calling convention, and are assumed to "
"return :c:type:`int`."
msgstr ""
#: ../Doc/library/ctypes.rst:1334
msgid ""
"Windows only: Instances of this class represent loaded shared libraries, "
"functions in these libraries use the ``stdcall`` calling convention, and are "
"assumed to return the windows specific :class:`HRESULT` code. :class:"
"`HRESULT` values contain information specifying whether the function call "
"failed or succeeded, together with additional error code. If the return "
"value signals a failure, an :class:`OSError` is automatically raised."
msgstr ""
#: ../Doc/library/ctypes.rst:1341
msgid ":exc:`WindowsError` used to be raised."
msgstr ":exc:`WindowsError` était levée auparavant."
#: ../Doc/library/ctypes.rst:1347
msgid ""
"Windows only: Instances of this class represent loaded shared libraries, "
"functions in these libraries use the ``stdcall`` calling convention, and are "
"assumed to return :c:type:`int` by default."
msgstr ""
#: ../Doc/library/ctypes.rst:1351
msgid ""
"On Windows CE only the standard calling convention is used, for convenience "
"the :class:`WinDLL` and :class:`OleDLL` use the standard calling convention "
"on this platform."
msgstr ""
#: ../Doc/library/ctypes.rst:1355
msgid ""
"The Python :term:`global interpreter lock` is released before calling any "
"function exported by these libraries, and reacquired afterwards."
msgstr ""
#: ../Doc/library/ctypes.rst:1361
msgid ""
"Instances of this class behave like :class:`CDLL` instances, except that the "
"Python GIL is *not* released during the function call, and after the "
"function execution the Python error flag is checked. If the error flag is "
"set, a Python exception is raised."
msgstr ""
#: ../Doc/library/ctypes.rst:1366
msgid "Thus, this is only useful to call Python C api functions directly."
msgstr ""
#: ../Doc/library/ctypes.rst:1368
msgid ""
"All these classes can be instantiated by calling them with at least one "
"argument, the pathname of the shared library. If you have an existing "
"handle to an already loaded shared library, it can be passed as the "
"``handle`` named parameter, otherwise the underlying platforms ``dlopen`` or "
"``LoadLibrary`` function is used to load the library into the process, and "
"to get a handle to it."
msgstr ""
#: ../Doc/library/ctypes.rst:1375
msgid ""
"The *mode* parameter can be used to specify how the library is loaded. For "
"details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is "
"ignored. On posix systems, RTLD_NOW is always added, and is not "
"configurable."
msgstr ""
#: ../Doc/library/ctypes.rst:1380
msgid ""
"The *use_errno* parameter, when set to true, enables a ctypes mechanism that "
"allows accessing the system :data:`errno` error number in a safe way. :mod:"
"`ctypes` maintains a thread-local copy of the systems :data:`errno` "
"variable; if you call foreign functions created with ``use_errno=True`` then "
"the :data:`errno` value before the function call is swapped with the ctypes "
"private copy, the same happens immediately after the function call."
msgstr ""
#: ../Doc/library/ctypes.rst:1387
msgid ""
"The function :func:`ctypes.get_errno` returns the value of the ctypes "
"private copy, and the function :func:`ctypes.set_errno` changes the ctypes "
"private copy to a new value and returns the former value."
msgstr ""
#: ../Doc/library/ctypes.rst:1391
msgid ""
"The *use_last_error* parameter, when set to true, enables the same mechanism "
"for the Windows error code which is managed by the :func:`GetLastError` and :"
"func:`SetLastError` Windows API functions; :func:`ctypes.get_last_error` "
"and :func:`ctypes.set_last_error` are used to request and change the ctypes "
"private copy of the windows error code."
msgstr ""
#: ../Doc/library/ctypes.rst:1400
msgid ""
"Flag to use as *mode* parameter. On platforms where this flag is not "
"available, it is defined as the integer zero."
msgstr ""
#: ../Doc/library/ctypes.rst:1407
msgid ""
"Flag to use as *mode* parameter. On platforms where this is not available, "
"it is the same as *RTLD_GLOBAL*."
msgstr ""
#: ../Doc/library/ctypes.rst:1414
msgid ""
"The default mode which is used to load shared libraries. On OSX 10.3, this "
"is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*."
msgstr ""
#: ../Doc/library/ctypes.rst:1417
msgid ""
"Instances of these classes have no public methods. Functions exported by "
"the shared library can be accessed as attributes or by index. Please note "
"that accessing the function through an attribute caches the result and "
"therefore accessing it repeatedly returns the same object each time. On the "
"other hand, accessing it through an index returns a new object each time::"
msgstr ""
#: ../Doc/library/ctypes.rst:1430
msgid ""
"The following public attributes are available, their name starts with an "
"underscore to not clash with exported function names:"
msgstr ""
#: ../Doc/library/ctypes.rst:1436
msgid "The system handle used to access the library."
msgstr ""
#: ../Doc/library/ctypes.rst:1441
msgid "The name of the library passed in the constructor."
msgstr ""
#: ../Doc/library/ctypes.rst:1443
msgid ""
"Shared libraries can also be loaded by using one of the prefabricated "
"objects, which are instances of the :class:`LibraryLoader` class, either by "
"calling the :meth:`LoadLibrary` method, or by retrieving the library as "
"attribute of the loader instance."
msgstr ""
#: ../Doc/library/ctypes.rst:1451
msgid ""
"Class which loads shared libraries. *dlltype* should be one of the :class:"
"`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types."
msgstr ""
#: ../Doc/library/ctypes.rst:1454
msgid ""
":meth:`__getattr__` has special behavior: It allows loading a shared library "
"by accessing it as attribute of a library loader instance. The result is "
"cached, so repeated attribute accesses return the same library each time."
msgstr ""
#: ../Doc/library/ctypes.rst:1460
msgid ""
"Load a shared library into the process and return it. This method always "
"returns a new instance of the library."
msgstr ""
#: ../Doc/library/ctypes.rst:1464
msgid "These prefabricated library loaders are available:"
msgstr ""
#: ../Doc/library/ctypes.rst:1469
msgid "Creates :class:`CDLL` instances."
msgstr ""
#: ../Doc/library/ctypes.rst:1475
msgid "Windows only: Creates :class:`WinDLL` instances."
msgstr ""
#: ../Doc/library/ctypes.rst:1481
msgid "Windows only: Creates :class:`OleDLL` instances."
msgstr ""
#: ../Doc/library/ctypes.rst:1487
msgid "Creates :class:`PyDLL` instances."
msgstr ""
#: ../Doc/library/ctypes.rst:1490
msgid ""
"For accessing the C Python api directly, a ready-to-use Python shared "
"library object is available:"
msgstr ""
#: ../Doc/library/ctypes.rst:1496
msgid ""
"An instance of :class:`PyDLL` that exposes Python C API functions as "
"attributes. Note that all these functions are assumed to return C :c:type:"
"`int`, which is of course not always the truth, so you have to assign the "
"correct :attr:`restype` attribute to use these functions."
msgstr ""
#: ../Doc/library/ctypes.rst:1505
msgid "Foreign functions"
msgstr "Fonctions externes"
#: ../Doc/library/ctypes.rst:1507
msgid ""
"As explained in the previous section, foreign functions can be accessed as "
"attributes of loaded shared libraries. The function objects created in this "
"way by default accept any number of arguments, accept any ctypes data "
"instances as arguments, and return the default result type specified by the "
"library loader. They are instances of a private class:"
msgstr ""
#: ../Doc/library/ctypes.rst:1516
msgid "Base class for C callable foreign functions."
msgstr ""
#: ../Doc/library/ctypes.rst:1518
msgid ""
"Instances of foreign functions are also C compatible data types; they "
"represent C function pointers."
msgstr ""
#: ../Doc/library/ctypes.rst:1521
msgid ""
"This behavior can be customized by assigning to special attributes of the "
"foreign function object."
msgstr ""
#: ../Doc/library/ctypes.rst:1526
msgid ""
"Assign a ctypes type to specify the result type of the foreign function. Use "
"``None`` for :c:type:`void`, a function not returning anything."
msgstr ""
#: ../Doc/library/ctypes.rst:1529
msgid ""
"It is possible to assign a callable Python object that is not a ctypes type, "
"in this case the function is assumed to return a C :c:type:`int`, and the "
"callable will be called with this integer, allowing further processing or "
"error checking. Using this is deprecated, for more flexible post processing "
"or error checking use a ctypes data type as :attr:`restype` and assign a "
"callable to the :attr:`errcheck` attribute."
msgstr ""
#: ../Doc/library/ctypes.rst:1538
msgid ""
"Assign a tuple of ctypes types to specify the argument types that the "
"function accepts. Functions using the ``stdcall`` calling convention can "
"only be called with the same number of arguments as the length of this "
"tuple; functions using the C calling convention accept additional, "
"unspecified arguments as well."
msgstr ""
#: ../Doc/library/ctypes.rst:1544
msgid ""
"When a foreign function is called, each actual argument is passed to the :"
"meth:`from_param` class method of the items in the :attr:`argtypes` tuple, "
"this method allows adapting the actual argument to an object that the "
"foreign function accepts. For example, a :class:`c_char_p` item in the :"
"attr:`argtypes` tuple will convert a string passed as argument into a bytes "
"object using ctypes conversion rules."
msgstr ""
#: ../Doc/library/ctypes.rst:1551
msgid ""
"New: It is now possible to put items in argtypes which are not ctypes types, "
"but each item must have a :meth:`from_param` method which returns a value "
"usable as argument (integer, string, ctypes instance). This allows defining "
"adapters that can adapt custom objects as function parameters."
msgstr ""
#: ../Doc/library/ctypes.rst:1558
msgid ""
"Assign a Python function or another callable to this attribute. The callable "
"will be called with three or more arguments:"
msgstr ""
#: ../Doc/library/ctypes.rst:1565
msgid ""
"*result* is what the foreign function returns, as specified by the :attr:"
"`restype` attribute."
msgstr ""
#: ../Doc/library/ctypes.rst:1568
msgid ""
"*func* is the foreign function object itself, this allows reusing the same "
"callable object to check or post process the results of several functions."
msgstr ""
#: ../Doc/library/ctypes.rst:1572
msgid ""
"*arguments* is a tuple containing the parameters originally passed to the "
"function call, this allows specializing the behavior on the arguments used."
msgstr ""
#: ../Doc/library/ctypes.rst:1576
msgid ""
"The object that this function returns will be returned from the foreign "
"function call, but it can also check the result value and raise an exception "
"if the foreign function call failed."
msgstr ""
#: ../Doc/library/ctypes.rst:1583
msgid ""
"This exception is raised when a foreign function call cannot convert one of "
"the passed arguments."
msgstr ""
#: ../Doc/library/ctypes.rst:1590
msgid "Function prototypes"
msgstr "Prototypes de fonction"
#: ../Doc/library/ctypes.rst:1592
msgid ""
"Foreign functions can also be created by instantiating function prototypes. "
"Function prototypes are similar to function prototypes in C; they describe a "
"function (return type, argument types, calling convention) without defining "
"an implementation. The factory functions must be called with the desired "
"result type and the argument types of the function, and can be used as "
"decorator factories, and as such, be applied to functions through the "
"``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples."
msgstr ""
#: ../Doc/library/ctypes.rst:1603
msgid ""
"The returned function prototype creates functions that use the standard C "
"calling convention. The function will release the GIL during the call. If "
"*use_errno* is set to true, the ctypes private copy of the system :data:"
"`errno` variable is exchanged with the real :data:`errno` value before and "
"after the call; *use_last_error* does the same for the Windows error code."
msgstr ""
#: ../Doc/library/ctypes.rst:1613
msgid ""
"Windows only: The returned function prototype creates functions that use the "
"``stdcall`` calling convention, except on Windows CE where :func:"
"`WINFUNCTYPE` is the same as :func:`CFUNCTYPE`. The function will release "
"the GIL during the call. *use_errno* and *use_last_error* have the same "
"meaning as above."
msgstr ""
#: ../Doc/library/ctypes.rst:1622
msgid ""
"The returned function prototype creates functions that use the Python "
"calling convention. The function will *not* release the GIL during the call."
msgstr ""
#: ../Doc/library/ctypes.rst:1625
msgid ""
"Function prototypes created by these factory functions can be instantiated "
"in different ways, depending on the type and number of the parameters in the "
"call:"
msgstr ""
#: ../Doc/library/ctypes.rst:1633
msgid ""
"Returns a foreign function at the specified address which must be an integer."
msgstr ""
#: ../Doc/library/ctypes.rst:1640
msgid ""
"Create a C callable function (a callback function) from a Python *callable*."
msgstr ""
#: ../Doc/library/ctypes.rst:1647
msgid ""
"Returns a foreign function exported by a shared library. *func_spec* must be "
"a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of the "
"exported function as string, or the ordinal of the exported function as "
"small integer. The second item is the shared library instance."
msgstr ""
#: ../Doc/library/ctypes.rst:1657
msgid ""
"Returns a foreign function that will call a COM method. *vtbl_index* is the "
"index into the virtual function table, a small non-negative integer. *name* "
"is name of the COM method. *iid* is an optional pointer to the interface "
"identifier which is used in extended error reporting."
msgstr ""
#: ../Doc/library/ctypes.rst:1662
msgid ""
"COM methods use a special calling convention: They require a pointer to the "
"COM interface as first argument, in addition to those parameters that are "
"specified in the :attr:`argtypes` tuple."
msgstr ""
#: ../Doc/library/ctypes.rst:1666
msgid ""
"The optional *paramflags* parameter creates foreign function wrappers with "
"much more functionality than the features described above."
msgstr ""
#: ../Doc/library/ctypes.rst:1669
msgid "*paramflags* must be a tuple of the same length as :attr:`argtypes`."
msgstr ""
#: ../Doc/library/ctypes.rst:1671
msgid ""
"Each item in this tuple contains further information about a parameter, it "
"must be a tuple containing one, two, or three items."
msgstr ""
#: ../Doc/library/ctypes.rst:1674
msgid ""
"The first item is an integer containing a combination of direction flags for "
"the parameter:"
msgstr ""
#: ../Doc/library/ctypes.rst:1678
msgid "1"
msgstr "1"
#: ../Doc/library/ctypes.rst:1678
msgid "Specifies an input parameter to the function."
msgstr ""
#: ../Doc/library/ctypes.rst:1681
msgid "2"
msgstr "2"
#: ../Doc/library/ctypes.rst:1681
msgid "Output parameter. The foreign function fills in a value."
msgstr ""
#: ../Doc/library/ctypes.rst:1684
msgid "4"
msgstr "4"
#: ../Doc/library/ctypes.rst:1684
msgid "Input parameter which defaults to the integer zero."
msgstr ""
#: ../Doc/library/ctypes.rst:1686
msgid ""
"The optional second item is the parameter name as string. If this is "
"specified, the foreign function can be called with named parameters."
msgstr ""
#: ../Doc/library/ctypes.rst:1689
msgid "The optional third item is the default value for this parameter."
msgstr ""
#: ../Doc/library/ctypes.rst:1691
msgid ""
"This example demonstrates how to wrap the Windows ``MessageBoxW`` function "
"so that it supports default parameters and named arguments. The C "
"declaration from the windows header file is this::"
msgstr ""
#: ../Doc/library/ctypes.rst:1702 ../Doc/library/ctypes.rst:1725
msgid "Here is the wrapping with :mod:`ctypes`::"
msgstr ""
#: ../Doc/library/ctypes.rst:1710
msgid "The ``MessageBox`` foreign function can now be called in these ways::"
msgstr ""
#: ../Doc/library/ctypes.rst:1716
msgid ""
"A second example demonstrates output parameters. The win32 "
"``GetWindowRect`` function retrieves the dimensions of a specified window by "
"copying them into ``RECT`` structure that the caller has to supply. Here is "
"the C declaration::"
msgstr ""
#: ../Doc/library/ctypes.rst:1734
msgid ""
"Functions with output parameters will automatically return the output "
"parameter value if there is a single one, or a tuple containing the output "
"parameter values when there are more than one, so the GetWindowRect function "
"now returns a RECT instance, when called."
msgstr ""
#: ../Doc/library/ctypes.rst:1739
msgid ""
"Output parameters can be combined with the :attr:`errcheck` protocol to do "
"further output processing and error checking. The win32 ``GetWindowRect`` "
"api function returns a ``BOOL`` to signal success or failure, so this "
"function could do the error checking, and raises an exception when the api "
"call failed::"
msgstr ""
#: ../Doc/library/ctypes.rst:1752
msgid ""
"If the :attr:`errcheck` function returns the argument tuple it receives "
"unchanged, :mod:`ctypes` continues the normal processing it does on the "
"output parameters. If you want to return a tuple of window coordinates "
"instead of a ``RECT`` instance, you can retrieve the fields in the function "
"and return them instead, the normal processing will no longer take place::"
msgstr ""
#: ../Doc/library/ctypes.rst:1771
msgid "Utility functions"
msgstr "Fonctions utilitaires"
#: ../Doc/library/ctypes.rst:1775
msgid ""
"Returns the address of the memory buffer as integer. *obj* must be an "
"instance of a ctypes type."
msgstr ""
#: ../Doc/library/ctypes.rst:1781
msgid ""
"Returns the alignment requirements of a ctypes type. *obj_or_type* must be a "
"ctypes type or instance."
msgstr ""
#: ../Doc/library/ctypes.rst:1787
msgid ""
"Returns a light-weight pointer to *obj*, which must be an instance of a "
"ctypes type. *offset* defaults to zero, and must be an integer that will be "
"added to the internal pointer value."
msgstr ""
#: ../Doc/library/ctypes.rst:1791
msgid "``byref(obj, offset)`` corresponds to this C code::"
msgstr ""
#: ../Doc/library/ctypes.rst:1795
msgid ""
"The returned object can only be used as a foreign function call parameter. "
"It behaves similar to ``pointer(obj)``, but the construction is a lot faster."
msgstr ""
#: ../Doc/library/ctypes.rst:1801
msgid ""
"This function is similar to the cast operator in C. It returns a new "
"instance of *type* which points to the same memory block as *obj*. *type* "
"must be a pointer type, and *obj* must be an object that can be interpreted "
"as a pointer."
msgstr ""
#: ../Doc/library/ctypes.rst:1809
msgid ""
"This function creates a mutable character buffer. The returned object is a "
"ctypes array of :class:`c_char`."
msgstr ""
#: ../Doc/library/ctypes.rst:1812
msgid ""
"*init_or_size* must be an integer which specifies the size of the array, or "
"a bytes object which will be used to initialize the array items."
msgstr ""
#: ../Doc/library/ctypes.rst:1815
msgid ""
"If a bytes object is specified as first argument, the buffer is made one "
"item larger than its length so that the last element in the array is a NUL "
"termination character. An integer can be passed as second argument which "
"allows specifying the size of the array if the length of the bytes should "
"not be used."
msgstr ""
#: ../Doc/library/ctypes.rst:1824
msgid ""
"This function creates a mutable unicode character buffer. The returned "
"object is a ctypes array of :class:`c_wchar`."
msgstr ""
#: ../Doc/library/ctypes.rst:1827
msgid ""
"*init_or_size* must be an integer which specifies the size of the array, or "
"a string which will be used to initialize the array items."
msgstr ""
#: ../Doc/library/ctypes.rst:1830
msgid ""
"If a string is specified as first argument, the buffer is made one item "
"larger than the length of the string so that the last element in the array "
"is a NUL termination character. An integer can be passed as second argument "
"which allows specifying the size of the array if the length of the string "
"should not be used."
msgstr ""
#: ../Doc/library/ctypes.rst:1840
msgid ""
"Windows only: This function is a hook which allows implementing in-process "
"COM servers with ctypes. It is called from the DllCanUnloadNow function "
"that the _ctypes extension dll exports."
msgstr ""
#: ../Doc/library/ctypes.rst:1847
msgid ""
"Windows only: This function is a hook which allows implementing in-process "
"COM servers with ctypes. It is called from the DllGetClassObject function "
"that the ``_ctypes`` extension dll exports."
msgstr ""
#: ../Doc/library/ctypes.rst:1855
msgid ""
"Try to find a library and return a pathname. *name* is the library name "
"without any prefix like ``lib``, suffix like ``.so``, ``.dylib`` or version "
"number (this is the form used for the posix linker option :option:`!-l`). "
"If no library can be found, returns ``None``."
msgstr ""
#: ../Doc/library/ctypes.rst:1866
msgid ""
"Windows only: return the filename of the VC runtime library used by Python, "
"and by the extension modules. If the name of the library cannot be "
"determined, ``None`` is returned."
msgstr ""
#: ../Doc/library/ctypes.rst:1870
msgid ""
"If you need to free memory, for example, allocated by an extension module "
"with a call to the ``free(void *)``, it is important that you use the "
"function in the same library that allocated the memory."
msgstr ""
#: ../Doc/library/ctypes.rst:1877
msgid ""
"Windows only: Returns a textual description of the error code *code*. If no "
"error code is specified, the last error code is used by calling the Windows "
"api function GetLastError."
msgstr ""
#: ../Doc/library/ctypes.rst:1884
msgid ""
"Windows only: Returns the last error code set by Windows in the calling "
"thread. This function calls the Windows `GetLastError()` function directly, "
"it does not return the ctypes-private copy of the error code."
msgstr ""
#: ../Doc/library/ctypes.rst:1890
msgid ""
"Returns the current value of the ctypes-private copy of the system :data:"
"`errno` variable in the calling thread."
msgstr ""
#: ../Doc/library/ctypes.rst:1895
msgid ""
"Windows only: returns the current value of the ctypes-private copy of the "
"system :data:`LastError` variable in the calling thread."
msgstr ""
#: ../Doc/library/ctypes.rst:1900
msgid ""
"Same as the standard C memmove library function: copies *count* bytes from "
"*src* to *dst*. *dst* and *src* must be integers or ctypes instances that "
"can be converted to pointers."
msgstr ""
#: ../Doc/library/ctypes.rst:1907
msgid ""
"Same as the standard C memset library function: fills the memory block at "
"address *dst* with *count* bytes of value *c*. *dst* must be an integer "
"specifying an address, or a ctypes instance."
msgstr ""
#: ../Doc/library/ctypes.rst:1914
msgid ""
"This factory function creates and returns a new ctypes pointer type. Pointer "
"types are cached and reused internally, so calling this function repeatedly "
"is cheap. *type* must be a ctypes type."
msgstr ""
#: ../Doc/library/ctypes.rst:1921
msgid ""
"This function creates a new pointer instance, pointing to *obj*. The "
"returned object is of the type ``POINTER(type(obj))``."
msgstr ""
#: ../Doc/library/ctypes.rst:1924
msgid ""
"Note: If you just want to pass a pointer to an object to a foreign function "
"call, you should use ``byref(obj)`` which is much faster."
msgstr ""
#: ../Doc/library/ctypes.rst:1930
msgid ""
"This function resizes the internal memory buffer of *obj*, which must be an "
"instance of a ctypes type. It is not possible to make the buffer smaller "
"than the native size of the objects type, as given by ``sizeof(type(obj))``, "
"but it is possible to enlarge the buffer."
msgstr ""
#: ../Doc/library/ctypes.rst:1938
msgid ""
"Set the current value of the ctypes-private copy of the system :data:`errno` "
"variable in the calling thread to *value* and return the previous value."
msgstr ""
#: ../Doc/library/ctypes.rst:1945
msgid ""
"Windows only: set the current value of the ctypes-private copy of the "
"system :data:`LastError` variable in the calling thread to *value* and "
"return the previous value."
msgstr ""
#: ../Doc/library/ctypes.rst:1953
msgid ""
"Returns the size in bytes of a ctypes type or instance memory buffer. Does "
"the same as the C ``sizeof`` operator."
msgstr ""
#: ../Doc/library/ctypes.rst:1959
msgid ""
"This function returns the C string starting at memory address *address* as a "
"bytes object. If size is specified, it is used as size, otherwise the string "
"is assumed to be zero-terminated."
msgstr ""
#: ../Doc/library/ctypes.rst:1966
msgid ""
"Windows only: this function is probably the worst-named thing in ctypes. It "
"creates an instance of OSError. If *code* is not specified, "
"``GetLastError`` is called to determine the error code. If *descr* is not "
"specified, :func:`FormatError` is called to get a textual description of the "
"error."
msgstr ""
#: ../Doc/library/ctypes.rst:1972
msgid "An instance of :exc:`WindowsError` used to be created."
msgstr ""
#: ../Doc/library/ctypes.rst:1978
msgid ""
"This function returns the wide character string starting at memory address "
"*address* as a string. If *size* is specified, it is used as the number of "
"characters of the string, otherwise the string is assumed to be zero-"
"terminated."
msgstr ""
#: ../Doc/library/ctypes.rst:1987
msgid "Data types"
msgstr "Types de données"
#: ../Doc/library/ctypes.rst:1992
msgid ""
"This non-public class is the common base class of all ctypes data types. "
"Among other things, all ctypes type instances contain a memory block that "
"hold C compatible data; the address of the memory block is returned by the :"
"func:`addressof` helper function. Another instance variable is exposed as :"
"attr:`_objects`; this contains other Python objects that need to be kept "
"alive in case the memory block contains pointers."
msgstr ""
#: ../Doc/library/ctypes.rst:1999
msgid ""
"Common methods of ctypes data types, these are all class methods (to be "
"exact, they are methods of the :term:`metaclass`):"
msgstr ""
#: ../Doc/library/ctypes.rst:2004
msgid ""
"This method returns a ctypes instance that shares the buffer of the *source* "
"object. The *source* object must support the writeable buffer interface. "
"The optional *offset* parameter specifies an offset into the source buffer "
"in bytes; the default is zero. If the source buffer is not large enough a :"
"exc:`ValueError` is raised."
msgstr ""
#: ../Doc/library/ctypes.rst:2013
msgid ""
"This method creates a ctypes instance, copying the buffer from the *source* "
"object buffer which must be readable. The optional *offset* parameter "
"specifies an offset into the source buffer in bytes; the default is zero. "
"If the source buffer is not large enough a :exc:`ValueError` is raised."
msgstr ""
#: ../Doc/library/ctypes.rst:2021
msgid ""
"This method returns a ctypes type instance using the memory specified by "
"*address* which must be an integer."
msgstr ""
#: ../Doc/library/ctypes.rst:2026
msgid ""
"This method adapts *obj* to a ctypes type. It is called with the actual "
"object used in a foreign function call when the type is present in the "
"foreign function's :attr:`argtypes` tuple; it must return an object that can "
"be used as a function call parameter."
msgstr ""
#: ../Doc/library/ctypes.rst:2031
msgid ""
"All ctypes data types have a default implementation of this classmethod that "
"normally returns *obj* if that is an instance of the type. Some types "
"accept other objects as well."
msgstr ""
#: ../Doc/library/ctypes.rst:2037
msgid ""
"This method returns a ctypes type instance exported by a shared library. "
"*name* is the name of the symbol that exports the data, *library* is the "
"loaded shared library."
msgstr ""
#: ../Doc/library/ctypes.rst:2041
msgid "Common instance variables of ctypes data types:"
msgstr ""
#: ../Doc/library/ctypes.rst:2045
msgid ""
"Sometimes ctypes data instances do not own the memory block they contain, "
"instead they share part of the memory block of a base object. The :attr:"
"`_b_base_` read-only member is the root ctypes object that owns the memory "
"block."
msgstr ""
#: ../Doc/library/ctypes.rst:2052
msgid ""
"This read-only variable is true when the ctypes data instance has allocated "
"the memory block itself, false otherwise."
msgstr ""
#: ../Doc/library/ctypes.rst:2057
msgid ""
"This member is either ``None`` or a dictionary containing Python objects "
"that need to be kept alive so that the memory block contents is kept valid. "
"This object is only exposed for debugging; never modify the contents of this "
"dictionary."
msgstr ""
#: ../Doc/library/ctypes.rst:2070
msgid ""
"This non-public class is the base class of all fundamental ctypes data "
"types. It is mentioned here because it contains the common attributes of the "
"fundamental ctypes data types. :class:`_SimpleCData` is a subclass of :"
"class:`_CData`, so it inherits their methods and attributes. ctypes data "
"types that are not and do not contain pointers can now be pickled."
msgstr ""
#: ../Doc/library/ctypes.rst:2076
msgid "Instances have a single attribute:"
msgstr ""
#: ../Doc/library/ctypes.rst:2080
msgid ""
"This attribute contains the actual value of the instance. For integer and "
"pointer types, it is an integer, for character types, it is a single "
"character bytes object or string, for character pointer types it is a Python "
"bytes object or string."
msgstr ""
#: ../Doc/library/ctypes.rst:2085
msgid ""
"When the ``value`` attribute is retrieved from a ctypes instance, usually a "
"new object is returned each time. :mod:`ctypes` does *not* implement "
"original object return, always a new object is constructed. The same is "
"true for all other ctypes object instances."
msgstr ""
#: ../Doc/library/ctypes.rst:2091
msgid ""
"Fundamental data types, when returned as foreign function call results, or, "
"for example, by retrieving structure field members or array items, are "
"transparently converted to native Python types. In other words, if a "
"foreign function has a :attr:`restype` of :class:`c_char_p`, you will always "
"receive a Python bytes object, *not* a :class:`c_char_p` instance."
msgstr ""
#: ../Doc/library/ctypes.rst:2099
msgid ""
"Subclasses of fundamental data types do *not* inherit this behavior. So, if "
"a foreign functions :attr:`restype` is a subclass of :class:`c_void_p`, you "
"will receive an instance of this subclass from the function call. Of course, "
"you can get the value of the pointer by accessing the ``value`` attribute."
msgstr ""
#: ../Doc/library/ctypes.rst:2104
msgid "These are the fundamental ctypes data types:"
msgstr ""
#: ../Doc/library/ctypes.rst:2108
msgid ""
"Represents the C :c:type:`signed char` datatype, and interprets the value as "
"small integer. The constructor accepts an optional integer initializer; no "
"overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2115
msgid ""
"Represents the C :c:type:`char` datatype, and interprets the value as a "
"single character. The constructor accepts an optional string initializer, "
"the length of the string must be exactly one character."
msgstr ""
#: ../Doc/library/ctypes.rst:2122
msgid ""
"Represents the C :c:type:`char *` datatype when it points to a zero-"
"terminated string. For a general character pointer that may also point to "
"binary data, ``POINTER(c_char)`` must be used. The constructor accepts an "
"integer address, or a bytes object."
msgstr ""
#: ../Doc/library/ctypes.rst:2130
msgid ""
"Represents the C :c:type:`double` datatype. The constructor accepts an "
"optional float initializer."
msgstr ""
#: ../Doc/library/ctypes.rst:2136
msgid ""
"Represents the C :c:type:`long double` datatype. The constructor accepts an "
"optional float initializer. On platforms where ``sizeof(long double) == "
"sizeof(double)`` it is an alias to :class:`c_double`."
msgstr ""
#: ../Doc/library/ctypes.rst:2142
msgid ""
"Represents the C :c:type:`float` datatype. The constructor accepts an "
"optional float initializer."
msgstr ""
#: ../Doc/library/ctypes.rst:2148
msgid ""
"Represents the C :c:type:`signed int` datatype. The constructor accepts an "
"optional integer initializer; no overflow checking is done. On platforms "
"where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`."
msgstr ""
#: ../Doc/library/ctypes.rst:2155
msgid ""
"Represents the C 8-bit :c:type:`signed int` datatype. Usually an alias for :"
"class:`c_byte`."
msgstr ""
#: ../Doc/library/ctypes.rst:2161
msgid ""
"Represents the C 16-bit :c:type:`signed int` datatype. Usually an alias "
"for :class:`c_short`."
msgstr ""
#: ../Doc/library/ctypes.rst:2167
msgid ""
"Represents the C 32-bit :c:type:`signed int` datatype. Usually an alias "
"for :class:`c_int`."
msgstr ""
#: ../Doc/library/ctypes.rst:2173
msgid ""
"Represents the C 64-bit :c:type:`signed int` datatype. Usually an alias "
"for :class:`c_longlong`."
msgstr ""
#: ../Doc/library/ctypes.rst:2179
msgid ""
"Represents the C :c:type:`signed long` datatype. The constructor accepts an "
"optional integer initializer; no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2185
msgid ""
"Represents the C :c:type:`signed long long` datatype. The constructor "
"accepts an optional integer initializer; no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2191
msgid ""
"Represents the C :c:type:`signed short` datatype. The constructor accepts "
"an optional integer initializer; no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2197
msgid "Represents the C :c:type:`size_t` datatype."
msgstr ""
#: ../Doc/library/ctypes.rst:2202
msgid "Represents the C :c:type:`ssize_t` datatype."
msgstr ""
#: ../Doc/library/ctypes.rst:2209
msgid ""
"Represents the C :c:type:`unsigned char` datatype, it interprets the value "
"as small integer. The constructor accepts an optional integer initializer; "
"no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2216
msgid ""
"Represents the C :c:type:`unsigned int` datatype. The constructor accepts "
"an optional integer initializer; no overflow checking is done. On platforms "
"where ``sizeof(int) == sizeof(long)`` it is an alias for :class:`c_ulong`."
msgstr ""
#: ../Doc/library/ctypes.rst:2223
msgid ""
"Represents the C 8-bit :c:type:`unsigned int` datatype. Usually an alias "
"for :class:`c_ubyte`."
msgstr ""
#: ../Doc/library/ctypes.rst:2229
msgid ""
"Represents the C 16-bit :c:type:`unsigned int` datatype. Usually an alias "
"for :class:`c_ushort`."
msgstr ""
#: ../Doc/library/ctypes.rst:2235
msgid ""
"Represents the C 32-bit :c:type:`unsigned int` datatype. Usually an alias "
"for :class:`c_uint`."
msgstr ""
#: ../Doc/library/ctypes.rst:2241
msgid ""
"Represents the C 64-bit :c:type:`unsigned int` datatype. Usually an alias "
"for :class:`c_ulonglong`."
msgstr ""
#: ../Doc/library/ctypes.rst:2247
msgid ""
"Represents the C :c:type:`unsigned long` datatype. The constructor accepts "
"an optional integer initializer; no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2253
msgid ""
"Represents the C :c:type:`unsigned long long` datatype. The constructor "
"accepts an optional integer initializer; no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2259
msgid ""
"Represents the C :c:type:`unsigned short` datatype. The constructor accepts "
"an optional integer initializer; no overflow checking is done."
msgstr ""
#: ../Doc/library/ctypes.rst:2265
msgid ""
"Represents the C :c:type:`void *` type. The value is represented as "
"integer. The constructor accepts an optional integer initializer."
msgstr ""
#: ../Doc/library/ctypes.rst:2271
msgid ""
"Represents the C :c:type:`wchar_t` datatype, and interprets the value as a "
"single character unicode string. The constructor accepts an optional string "
"initializer, the length of the string must be exactly one character."
msgstr ""
#: ../Doc/library/ctypes.rst:2278
msgid ""
"Represents the C :c:type:`wchar_t *` datatype, which must be a pointer to a "
"zero-terminated wide character string. The constructor accepts an integer "
"address, or a string."
msgstr ""
#: ../Doc/library/ctypes.rst:2285
msgid ""
"Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` "
"from C99). Its value can be ``True`` or ``False``, and the constructor "
"accepts any object that has a truth value."
msgstr ""
#: ../Doc/library/ctypes.rst:2292
msgid ""
"Windows only: Represents a :c:type:`HRESULT` value, which contains success "
"or error information for a function or method call."
msgstr ""
#: ../Doc/library/ctypes.rst:2298
msgid ""
"Represents the C :c:type:`PyObject *` datatype. Calling this without an "
"argument creates a ``NULL`` :c:type:`PyObject *` pointer."
msgstr ""
#: ../Doc/library/ctypes.rst:2301
msgid ""
"The :mod:`ctypes.wintypes` module provides quite some other Windows specific "
"data types, for example :c:type:`HWND`, :c:type:`WPARAM`, or :c:type:"
"`DWORD`. Some useful structures like :c:type:`MSG` or :c:type:`RECT` are "
"also defined."
msgstr ""
#: ../Doc/library/ctypes.rst:2309
msgid "Structured data types"
msgstr "Types de donnée dérivés de Structure"
#: ../Doc/library/ctypes.rst:2314
msgid "Abstract base class for unions in native byte order."
msgstr ""
#: ../Doc/library/ctypes.rst:2319
msgid "Abstract base class for structures in *big endian* byte order."
msgstr ""
#: ../Doc/library/ctypes.rst:2324
msgid "Abstract base class for structures in *little endian* byte order."
msgstr ""
#: ../Doc/library/ctypes.rst:2326
msgid ""
"Structures with non-native byte order cannot contain pointer type fields, or "
"any other data types containing pointer type fields."
msgstr ""
#: ../Doc/library/ctypes.rst:2332
msgid "Abstract base class for structures in *native* byte order."
msgstr ""
#: ../Doc/library/ctypes.rst:2334
msgid ""
"Concrete structure and union types must be created by subclassing one of "
"these types, and at least define a :attr:`_fields_` class variable. :mod:"
"`ctypes` will create :term:`descriptor`\\s which allow reading and writing "
"the fields by direct attribute accesses. These are the"
msgstr ""
#: ../Doc/library/ctypes.rst:2342
msgid ""
"A sequence defining the structure fields. The items must be 2-tuples or 3-"
"tuples. The first item is the name of the field, the second item specifies "
"the type of the field; it can be any ctypes data type."
msgstr ""
#: ../Doc/library/ctypes.rst:2346
msgid ""
"For integer type fields like :class:`c_int`, a third optional item can be "
"given. It must be a small positive integer defining the bit width of the "
"field."
msgstr ""
#: ../Doc/library/ctypes.rst:2350
msgid ""
"Field names must be unique within one structure or union. This is not "
"checked, only one field can be accessed when names are repeated."
msgstr ""
#: ../Doc/library/ctypes.rst:2353
msgid ""
"It is possible to define the :attr:`_fields_` class variable *after* the "
"class statement that defines the Structure subclass, this allows creating "
"data types that directly or indirectly reference themselves::"
msgstr ""
#: ../Doc/library/ctypes.rst:2363
msgid ""
"The :attr:`_fields_` class variable must, however, be defined before the "
"type is first used (an instance is created, :func:`sizeof` is called on it, "
"and so on). Later assignments to the :attr:`_fields_` class variable will "
"raise an AttributeError."
msgstr ""
#: ../Doc/library/ctypes.rst:2368
msgid ""
"It is possible to define sub-subclasses of structure types, they inherit the "
"fields of the base class plus the :attr:`_fields_` defined in the sub-"
"subclass, if any."
msgstr ""
#: ../Doc/library/ctypes.rst:2375
msgid ""
"An optional small integer that allows overriding the alignment of structure "
"fields in the instance. :attr:`_pack_` must already be defined when :attr:"
"`_fields_` is assigned, otherwise it will have no effect."
msgstr ""
#: ../Doc/library/ctypes.rst:2382
msgid ""
"An optional sequence that lists the names of unnamed (anonymous) fields. :"
"attr:`_anonymous_` must be already defined when :attr:`_fields_` is "
"assigned, otherwise it will have no effect."
msgstr ""
#: ../Doc/library/ctypes.rst:2386
msgid ""
"The fields listed in this variable must be structure or union type fields. :"
"mod:`ctypes` will create descriptors in the structure type that allows "
"accessing the nested fields directly, without the need to create the "
"structure or union field."
msgstr ""
#: ../Doc/library/ctypes.rst:2391
msgid "Here is an example type (Windows)::"
msgstr ""
#: ../Doc/library/ctypes.rst:2404
msgid ""
"The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field "
"specifies which one of the union fields is valid. Since the ``u`` field is "
"defined as anonymous field, it is now possible to access the members "
"directly off the TYPEDESC instance. ``td.lptdesc`` and ``td.u.lptdesc`` are "
"equivalent, but the former is faster since it does not need to create a "
"temporary union instance::"
msgstr ""
#: ../Doc/library/ctypes.rst:2416
msgid ""
"It is possible to define sub-subclasses of structures, they inherit the "
"fields of the base class. If the subclass definition has a separate :attr:"
"`_fields_` variable, the fields specified in this are appended to the fields "
"of the base class."
msgstr ""
#: ../Doc/library/ctypes.rst:2421
msgid ""
"Structure and union constructors accept both positional and keyword "
"arguments. Positional arguments are used to initialize member fields in the "
"same order as they are appear in :attr:`_fields_`. Keyword arguments in the "
"constructor are interpreted as attribute assignments, so they will "
"initialize :attr:`_fields_` with the same name, or create new attributes for "
"names not present in :attr:`_fields_`."
msgstr ""
#: ../Doc/library/ctypes.rst:2432
msgid "Arrays and pointers"
msgstr "Tableaux et pointeurs"
#: ../Doc/library/ctypes.rst:2436
msgid "Abstract base class for arrays."
msgstr "Classe de base abstraite pour les *arrays*."
#: ../Doc/library/ctypes.rst:2438
msgid ""
"The recommended way to create concrete array types is by multiplying any :"
"mod:`ctypes` data type with a positive integer. Alternatively, you can "
"subclass this type and define :attr:`_length_` and :attr:`_type_` class "
"variables. Array elements can be read and written using standard subscript "
"and slice accesses; for slice reads, the resulting object is *not* itself "
"an :class:`Array`."
msgstr ""
#: ../Doc/library/ctypes.rst:2448
msgid ""
"A positive integer specifying the number of elements in the array. Out-of-"
"range subscripts result in an :exc:`IndexError`. Will be returned by :func:"
"`len`."
msgstr ""
#: ../Doc/library/ctypes.rst:2455
msgid "Specifies the type of each element in the array."
msgstr "Spécifie le type de chaque élément de l'*array*."
#: ../Doc/library/ctypes.rst:2458
msgid ""
"Array subclass constructors accept positional arguments, used to initialize "
"the elements in order."
msgstr ""
#: ../Doc/library/ctypes.rst:2464
msgid "Private, abstract base class for pointers."
msgstr ""
#: ../Doc/library/ctypes.rst:2466
msgid ""
"Concrete pointer types are created by calling :func:`POINTER` with the type "
"that will be pointed to; this is done automatically by :func:`pointer`."
msgstr ""
#: ../Doc/library/ctypes.rst:2470
msgid ""
"If a pointer points to an array, its elements can be read and written using "
"standard subscript and slice accesses. Pointer objects have no size, so :"
"func:`len` will raise :exc:`TypeError`. Negative subscripts will read from "
"the memory *before* the pointer (as in C), and out-of-range subscripts will "
"probably crash with an access violation (if you're lucky)."
msgstr ""
#: ../Doc/library/ctypes.rst:2480
msgid "Specifies the type pointed to."
msgstr ""
#: ../Doc/library/ctypes.rst:2484
msgid ""
"Returns the object to which to pointer points. Assigning to this attribute "
"changes the pointer to point to the assigned object."
msgstr ""