Make Merge a3488e5902f5c26e5cc289aec2518e7b5058e5d1 (#729)
* make merge * Update distributing/index.po * Update extending/extending.po * Apply suggestions from code review * powrap
This commit is contained in:
parent ecdbeec7ee
commit 294e8b93c0
68 changed files with 3640 additions and 3581 deletions
| | @ -5,7 +5,7 @@ msgid "" | |||
msgstr "" | ||||
"Project-Id-Version: Python 3.6\n" | ||||
"Report-Msgid-Bugs-To: \n" | ||||
"POT-Creation-Date: 2017-05-27 19:40+0200\n" | ||||
"POT-Creation-Date: 2019-05-23 16:48+0200\n" | ||||
"PO-Revision-Date: 2018-10-04 16:18+0200\n" | ||||
"Last-Translator: Julien Palard <julien@palard.fr>\n" | ||||
"Language-Team: FRENCH <traductions@lists.afpy.org>\n" | ||||
| | @ -114,7 +114,7 @@ msgstr "" | |||
"sans avoir à interagir avec directement. C'est utile, par exemple, pour " | ||||
"effectuer une opération sur un fichier. ::" | ||||
| ||||
#: ../Doc/extending/embedding.rst:77 | ||||
#: ../Doc/extending/embedding.rst:78 | ||||
msgid "" | ||||
"The :c:func:`Py_SetProgramName` function should be called before :c:func:" | ||||
"`Py_Initialize` to inform the interpreter about paths to Python run-time " | ||||
| | @ -140,11 +140,11 @@ msgstr "" | |||
"`PyRun_SimplFile`, qui vous économise le travail d'allouer de la mémoire et " | ||||
"de charger le contenu du fichier." | ||||
| ||||
#: ../Doc/extending/embedding.rst:92 | ||||
#: ../Doc/extending/embedding.rst:93 | ||||
msgid "Beyond Very High Level Embedding: An overview" | ||||
msgstr "Au delà de l'intégration de haut niveau: survol" | ||||
| ||||
#: ../Doc/extending/embedding.rst:94 | ||||
#: ../Doc/extending/embedding.rst:95 | ||||
msgid "" | ||||
"The high level interface gives you the ability to execute arbitrary pieces " | ||||
"of Python code from your application, but exchanging data values is quite " | ||||
| | @ -158,7 +158,7 @@ msgstr "" | |||
"appels de niveau plus bas. Il vous en coûtera plus de lignes de C à écrire, " | ||||
"mais vous pourrez presque tout faire." | ||||
| ||||
#: ../Doc/extending/embedding.rst:99 | ||||
#: ../Doc/extending/embedding.rst:100 | ||||
msgid "" | ||||
"It should be noted that extending Python and embedding Python is quite the " | ||||
"same activity, despite the different intent. Most topics discussed in the " | ||||
| | @ -170,27 +170,27 @@ msgstr "" | |||
"dans les chapitres précédents sont toujours valides. Pour le prouver, " | ||||
"regardez ce qu'un code d'extension de Python vers C fait réellement :" | ||||
| ||||
#: ../Doc/extending/embedding.rst:104 | ||||
#: ../Doc/extending/embedding.rst:105 | ||||
msgid "Convert data values from Python to C," | ||||
msgstr "Convertir des valeurs de Python vers le C," | ||||
| ||||
#: ../Doc/extending/embedding.rst:106 | ||||
#: ../Doc/extending/embedding.rst:107 | ||||
msgid "Perform a function call to a C routine using the converted values, and" | ||||
msgstr "Appeler une fonction C en utilisant les valeurs converties, et" | ||||
| ||||
#: ../Doc/extending/embedding.rst:108 | ||||
#: ../Doc/extending/embedding.rst:109 | ||||
msgid "Convert the data values from the call from C to Python." | ||||
msgstr "Convertir les résultats de l'appel à la fonction C pour Python." | ||||
| ||||
#: ../Doc/extending/embedding.rst:110 | ||||
#: ../Doc/extending/embedding.rst:111 | ||||
msgid "When embedding Python, the interface code does:" | ||||
msgstr "Lors de l'intégration de Python, le code de l'interface fait :" | ||||
| ||||
#: ../Doc/extending/embedding.rst:112 | ||||
#: ../Doc/extending/embedding.rst:113 | ||||
msgid "Convert data values from C to Python," | ||||
msgstr "Convertir les valeurs depuis le C vers Python," | ||||
| ||||
#: ../Doc/extending/embedding.rst:114 | ||||
#: ../Doc/extending/embedding.rst:115 | ||||
msgid "" | ||||
"Perform a function call to a Python interface routine using the converted " | ||||
"values, and" | ||||
| | @ -198,11 +198,11 @@ msgstr "" | |||
"Effectuer un appel de fonction de l'interface Python en utilisant les " | ||||
"valeurs converties, et" | ||||
| ||||
#: ../Doc/extending/embedding.rst:117 | ||||
#: ../Doc/extending/embedding.rst:118 | ||||
msgid "Convert the data values from the call from Python to C." | ||||
msgstr "Convertir les valeurs de l'appel Python pour le C." | ||||
| ||||
#: ../Doc/extending/embedding.rst:119 | ||||
#: ../Doc/extending/embedding.rst:120 | ||||
msgid "" | ||||
"As you can see, the data conversion steps are simply swapped to accommodate " | ||||
"the different direction of the cross-language transfer. The only difference " | ||||
| | @ -215,7 +215,7 @@ msgstr "" | |||
"données. Lors de l'extension, vous appelez une fonction C, lors de " | ||||
"l'intégration vous appelez une fonction Python." | ||||
| ||||
#: ../Doc/extending/embedding.rst:124 | ||||
#: ../Doc/extending/embedding.rst:125 | ||||
msgid "" | ||||
"This chapter will not discuss how to convert data from Python to C and vice " | ||||
"versa. Also, proper use of references and dealing with errors is assumed to " | ||||
| | @ -228,11 +228,11 @@ msgstr "" | |||
"l'extension de l'interpréteur, vous pouvez vous référer aux chapitres " | ||||
"précédents." | ||||
| ||||
#: ../Doc/extending/embedding.rst:133 | ||||
#: ../Doc/extending/embedding.rst:134 | ||||
msgid "Pure Embedding" | ||||
msgstr "Intégration pure" | ||||
| ||||
#: ../Doc/extending/embedding.rst:135 | ||||
#: ../Doc/extending/embedding.rst:136 | ||||
msgid "" | ||||
"The first program aims to execute a function in a Python script. Like in the " | ||||
"section about the very high level interface, the Python interpreter does not " | ||||
| | @ -244,11 +244,11 @@ msgstr "" | |||
"l'interpréteur n'interagit pas directement avec l'application (mais le fera " | ||||
"dans la section suivante)." | ||||
| ||||
#: ../Doc/extending/embedding.rst:140 | ||||
#: ../Doc/extending/embedding.rst:141 | ||||
msgid "The code to run a function defined in a Python script is:" | ||||
msgstr "Le code pour appeler une fonction définie dans un script Python est :" | ||||
| ||||
#: ../Doc/extending/embedding.rst:145 | ||||
#: ../Doc/extending/embedding.rst:146 | ||||
msgid "" | ||||
"This code loads a Python script using ``argv[1]``, and calls the function " | ||||
"named in ``argv[2]``. Its integer arguments are the other values of the " | ||||
| | @ -262,11 +262,11 @@ msgstr "" | |||
"programme (appelons l'exécutable :program:`call`), et l'appelez pour " | ||||
"exécuter un script Python, tel que :" | ||||
| ||||
#: ../Doc/extending/embedding.rst:160 | ||||
#: ../Doc/extending/embedding.rst:161 | ||||
msgid "then the result should be:" | ||||
msgstr "alors, le résultat sera:" | ||||
| ||||
#: ../Doc/extending/embedding.rst:168 | ||||
#: ../Doc/extending/embedding.rst:169 | ||||
msgid "" | ||||
"Although the program is quite large for its functionality, most of the code " | ||||
"is for data conversion between Python and C, and for error reporting. The " | ||||
| | @ -277,7 +277,7 @@ msgstr "" | |||
"rapporter les erreurs. La partie intéressante, qui concerne l'intégration de " | ||||
"Python débute par : ::" | ||||
| ||||
#: ../Doc/extending/embedding.rst:177 | ||||
#: ../Doc/extending/embedding.rst:178 | ||||
msgid "" | ||||
"After initializing the interpreter, the script is loaded using :c:func:" | ||||
"`PyImport_Import`. This routine needs a Python string as its argument, " | ||||
| | @ -289,7 +289,7 @@ msgstr "" | |||
"argument, elle même construite en utilisant la fonction de conversion :c:" | ||||
"func:`PyUnicode_FromString`." | ||||
| ||||
#: ../Doc/extending/embedding.rst:190 | ||||
#: ../Doc/extending/embedding.rst:191 | ||||
msgid "" | ||||
"Once the script is loaded, the name we're looking for is retrieved using :c:" | ||||
"func:`PyObject_GetAttrString`. If the name exists, and the object returned " | ||||
| | @ -303,7 +303,7 @@ msgstr "" | |||
"programme continue, classiquement, par la construction de n-uplet " | ||||
"d'arguments. L'appel à la fonction Python est alors effectué avec : ::" | ||||
| ||||
#: ../Doc/extending/embedding.rst:198 | ||||
#: ../Doc/extending/embedding.rst:199 | ||||
msgid "" | ||||
"Upon return of the function, ``pValue`` is either *NULL* or it contains a " | ||||
"reference to the return value of the function. Be sure to release the " | ||||
| | @ -313,11 +313,11 @@ msgstr "" | |||
"référence sur la valeur donnée par la fonction. Assurez-vous de libérer la " | ||||
"référence après avoir utilisé la valeur." | ||||
| ||||
#: ../Doc/extending/embedding.rst:206 | ||||
#: ../Doc/extending/embedding.rst:207 | ||||
msgid "Extending Embedded Python" | ||||
msgstr "Étendre un Python intégré" | ||||
| ||||
#: ../Doc/extending/embedding.rst:208 | ||||
#: ../Doc/extending/embedding.rst:209 | ||||
msgid "" | ||||
"Until now, the embedded Python interpreter had no access to functionality " | ||||
"from the application itself. The Python API allows this by extending the " | ||||
| | @ -338,7 +338,7 @@ msgstr "" | |||
"à Python, tout comme vous écririez une extension Python normale. Par " | ||||
"exemple : ::" | ||||
| ||||
#: ../Doc/extending/embedding.rst:245 | ||||
#: ../Doc/extending/embedding.rst:246 | ||||
msgid "" | ||||
"Insert the above code just above the :c:func:`main` function. Also, insert " | ||||
"the following two statements before the call to :c:func:`Py_Initialize`::" | ||||
| | @ -347,7 +347,7 @@ msgstr "" | |||
"aussi les deux instructions suivantes avant l'appel à :c:func:" | ||||
"`Py_Initialize` ::" | ||||
| ||||
#: ../Doc/extending/embedding.rst:251 | ||||
#: ../Doc/extending/embedding.rst:252 | ||||
msgid "" | ||||
"These two lines initialize the ``numargs`` variable, and make the :func:`emb." | ||||
"numargs` function accessible to the embedded Python interpreter. With these " | ||||
| | @ -357,7 +357,7 @@ msgstr "" | |||
"func:`emb.numargs` accessible à l'interpréteur intégré. Avec ces ajouts, le " | ||||
"script Python petit maintenant faire des choses comme" | ||||
| ||||
#: ../Doc/extending/embedding.rst:260 | ||||
#: ../Doc/extending/embedding.rst:261 | ||||
msgid "" | ||||
"In a real application, the methods will expose an API of the application to " | ||||
"Python." | ||||
| | @ -365,11 +365,11 @@ msgstr "" | |||
"Dans un cas réel, les méthodes exposeraient une API de l'application a " | ||||
"Python." | ||||
| ||||
#: ../Doc/extending/embedding.rst:270 | ||||
#: ../Doc/extending/embedding.rst:271 | ||||
msgid "Embedding Python in C++" | ||||
msgstr "Intégrer Python dans du C++" | ||||
| ||||
#: ../Doc/extending/embedding.rst:272 | ||||
#: ../Doc/extending/embedding.rst:273 | ||||
msgid "" | ||||
"It is also possible to embed Python in a C++ program; precisely how this is " | ||||
"done will depend on the details of the C++ system used; in general you will " | ||||
| | @ -383,11 +383,11 @@ msgstr "" | |||
"compilateur C++ pour compiler et lier votre programme. Il n'y a pas besoin " | ||||
"de recompiler Python en utilisant C++." | ||||
| ||||
#: ../Doc/extending/embedding.rst:281 | ||||
#: ../Doc/extending/embedding.rst:282 | ||||
msgid "Compiling and Linking under Unix-like systems" | ||||
msgstr "Compiler et Lier en environnement Unix ou similaire" | ||||
| ||||
#: ../Doc/extending/embedding.rst:283 | ||||
#: ../Doc/extending/embedding.rst:284 | ||||
msgid "" | ||||
"It is not necessarily trivial to find the right flags to pass to your " | ||||
"compiler (and linker) in order to embed the Python interpreter into your " | ||||
| | @ -399,7 +399,7 @@ msgstr "" | |||
"Python ayant besoin de charger des extensions sous forme de bibliothèques " | ||||
"dynamiques en C (des :file:`.so`) pour se lier avec." | ||||
| ||||
#: ../Doc/extending/embedding.rst:289 | ||||
#: ../Doc/extending/embedding.rst:290 | ||||
msgid "" | ||||
"To find out the required compiler and linker flags, you can execute the :" | ||||
"file:`python{X.Y}-config` script which is generated as part of the " | ||||
| | @ -412,7 +412,7 @@ msgstr "" | |||
"(un script :file:`python3-config` peut aussi être disponible). Ce script a " | ||||
"quelques options, celles-ci vous seront utiles :" | ||||
| ||||
#: ../Doc/extending/embedding.rst:295 | ||||
#: ../Doc/extending/embedding.rst:296 | ||||
msgid "" | ||||
"``pythonX.Y-config --cflags`` will give you the recommended flags when " | ||||
"compiling:" | ||||
| | @ -420,7 +420,7 @@ msgstr "" | |||
"``pythonX.Y-config --cflags`` vous donnera les options recommandées pour " | ||||
"compiler:" | ||||
| ||||
#: ../Doc/extending/embedding.rst:303 | ||||
#: ../Doc/extending/embedding.rst:304 | ||||
msgid "" | ||||
"``pythonX.Y-config --ldflags`` will give you the recommended flags when " | ||||
"linking:" | ||||
| | @ -428,7 +428,7 @@ msgstr "" | |||
"``pythonX.Y-config --ldflags`` vous donnera les drapeaux recommandés lors de " | ||||
"l'édition de lien:" | ||||
| ||||
#: ../Doc/extending/embedding.rst:312 | ||||
#: ../Doc/extending/embedding.rst:313 | ||||
msgid "" | ||||
"To avoid confusion between several Python installations (and especially " | ||||
"between the system Python and your own compiled Python), it is recommended " | ||||
| | @ -440,7 +440,7 @@ msgstr "" | |||
"recommandé d'utiliser un chemin absolu vers :file:`python{X.Y}-config`, " | ||||
"comme dans l'exemple précédent." | ||||
| ||||
#: ../Doc/extending/embedding.rst:317 | ||||
#: ../Doc/extending/embedding.rst:318 | ||||
msgid "" | ||||
"If this procedure doesn't work for you (it is not guaranteed to work for all " | ||||
"Unix-like platforms; however, we welcome :ref:`bug reports <reporting-" | ||||
| | | |||
File diff suppressed because it is too large Load diff
| | @ -5,7 +5,7 @@ msgid "" | |||
msgstr "" | ||||
"Project-Id-Version: Python 3.6\n" | ||||
"Report-Msgid-Bugs-To: \n" | ||||
"POT-Creation-Date: 2018-05-02 00:10+0200\n" | ||||
"POT-Creation-Date: 2019-05-23 16:48+0200\n" | ||||
"PO-Revision-Date: 2018-06-17 10:15+0200\n" | ||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||||
"Language-Team: FRENCH <traductions@lists.afpy.org>\n" | ||||
| | @ -120,14 +120,14 @@ msgstr "" | |||
msgid "The second bit is the definition of the type object. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:99 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:100 | ||||
msgid "" | ||||
"We recommend using C99-style designated initializers as above, to avoid " | ||||
"listing all the :c:type:`PyTypeObject` fields that you don't care about and " | ||||
"also to avoid caring about the fields' declaration order." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:103 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:104 | ||||
msgid "" | ||||
"The actual definition of :c:type:`PyTypeObject` in :file:`object.h` has many " | ||||
"more :ref:`fields <type-structs>` than the definition above. The remaining " | ||||
| | @ -135,23 +135,23 @@ msgid "" | |||
"to not specify them explicitly unless you need them." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:108 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:109 | ||||
msgid "We're going to pick it apart, one field at a time::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:112 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:113 | ||||
msgid "" | ||||
"This line is mandatory boilerplate to initialize the ``ob_base`` field " | ||||
"mentioned above. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:117 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:118 | ||||
msgid "" | ||||
"The name of our type. This will appear in the default textual " | ||||
"representation of our objects and in some error messages, for example:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:127 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:128 | ||||
msgid "" | ||||
"Note that the name is a dotted name that includes both the module name and " | ||||
"the name of the type within the module. The module in this case is :mod:" | ||||
| | @ -160,14 +160,14 @@ msgid "" | |||
"type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:136 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:137 | ||||
msgid "" | ||||
"This is so that Python knows how much memory to allocate when creating new :" | ||||
"class:`Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is only " | ||||
"used for variable-sized objects and should otherwise be zero." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:142 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:143 | ||||
msgid "" | ||||
"If you want your type to be subclassable from Python, and your type has the " | ||||
"same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " | ||||
| | @ -181,23 +181,23 @@ msgid "" | |||
"your base type, and therefore increasing its size." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:152 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:153 | ||||
msgid "We set the class flags to :const:`Py_TPFLAGS_DEFAULT`. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:156 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:157 | ||||
msgid "" | ||||
"All types should include this constant in their flags. It enables all of " | ||||
"the members defined until at least Python 3.3. If you need further members, " | ||||
"you will need to OR the corresponding flags." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:160 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:161 | ||||
msgid "" | ||||
"We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:164 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:165 | ||||
msgid "" | ||||
"To enable object creation, we have to provide a :c:member:`~PyTypeObject." | ||||
"tp_new` handler. This is the equivalent of the Python method :meth:" | ||||
| | @ -206,53 +206,53 @@ msgid "" | |||
"`PyType_GenericNew`. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:171 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:172 | ||||
msgid "" | ||||
"Everything else in the file should be familiar, except for some code in :c:" | ||||
"func:`PyInit_custom`::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:177 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:178 | ||||
msgid "" | ||||
"This initializes the :class:`Custom` type, filling in a number of members to " | ||||
"the appropriate default values, including :attr:`ob_type` that we initially " | ||||
"set to *NULL*. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:183 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:184 | ||||
msgid "" | ||||
"This adds the type to the module dictionary. This allows us to create :" | ||||
"class:`Custom` instances by calling the :class:`Custom` class:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:191 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:192 | ||||
msgid "" | ||||
"That's it! All that remains is to build it; put the above code in a file " | ||||
"called :file:`custom.c` and:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:200 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:201 | ||||
msgid "in a file called :file:`setup.py`; then typing" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:206 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:207 | ||||
msgid "" | ||||
"at a shell should produce a file :file:`custom.so` in a subdirectory; move " | ||||
"to that directory and fire up Python --- you should be able to ``import " | ||||
"custom`` and play around with Custom objects." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:210 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:211 | ||||
msgid "That wasn't so hard, was it?" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:212 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:213 | ||||
msgid "" | ||||
"Of course, the current Custom type is pretty uninteresting. It has no data " | ||||
"and doesn't do anything. It can't even be subclassed." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:216 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:217 | ||||
msgid "" | ||||
"While this documentation showcases the standard :mod:`distutils` module for " | ||||
"building C extensions, it is recommended in real-world use cases to use the " | ||||
| | @ -262,32 +262,32 @@ msgid "" | |||
"packages/>`_." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:224 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:225 | ||||
msgid "Adding data and methods to the Basic example" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:226 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:227 | ||||
msgid "" | ||||
"Let's extend the basic example to add some data and methods. Let's also " | ||||
"make the type usable as a base class. We'll create a new module, :mod:" | ||||
"`custom2` that adds these capabilities:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:233 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:234 | ||||
msgid "This version of the module has a number of changes." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:235 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:236 | ||||
msgid "We've added an extra include::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:239 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:240 | ||||
msgid "" | ||||
"This include provides declarations that we use to handle attributes, as " | ||||
"described a bit later." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:242 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:243 | ||||
msgid "" | ||||
"The :class:`Custom` type now has three data attributes in its C struct, " | ||||
"*first*, *last*, and *number*. The *first* and *last* variables are Python " | ||||
| | @ -295,21 +295,21 @@ msgid "" | |||
"integer." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:246 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:247 | ||||
msgid "The object structure is updated accordingly::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:255 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:256 | ||||
msgid "" | ||||
"Because we now have data to manage, we have to be more careful about object " | ||||
"allocation and deallocation. At a minimum, we need a deallocation method::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:266 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:267 | ||||
msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:270 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:271 | ||||
msgid "" | ||||
"This method first clears the reference counts of the two Python attributes. :" | ||||
"c:func:`Py_XDECREF` correctly handles the case where its argument is *NULL* " | ||||
| | @ -320,7 +320,7 @@ msgid "" | |||
"subclass." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:279 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:280 | ||||
msgid "" | ||||
"The explicit cast to ``destructor`` above is needed because we defined " | ||||
"``Custom_dealloc`` to take a ``CustomObject *`` argument, but the " | ||||
| | @ -329,17 +329,17 @@ msgid "" | |||
"oriented polymorphism, in C!" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:285 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:286 | ||||
msgid "" | ||||
"We want to make sure that the first and last names are initialized to empty " | ||||
"strings, so we provide a ``tp_new`` implementation::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:309 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:310 | ||||
msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:313 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:314 | ||||
msgid "" | ||||
"The ``tp_new`` handler is responsible for creating (as opposed to " | ||||
"initializing) objects of the type. It is exposed in Python as the :meth:" | ||||
| | @ -350,7 +350,7 @@ msgid "" | |||
"attributes to non-*NULL* default values." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:321 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:322 | ||||
msgid "" | ||||
"``tp_new`` is passed the type being instantiated (not necessarily " | ||||
"``CustomType``, if a subclass is instantiated) and any arguments passed when " | ||||
| | @ -360,25 +360,25 @@ msgid "" | |||
"k.a. ``tp_init`` in C or ``__init__`` in Python) methods." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:329 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:330 | ||||
msgid "" | ||||
"``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do " | ||||
"it itself." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:332 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:333 | ||||
msgid "" | ||||
"The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` " | ||||
"slot to allocate memory::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:337 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:338 | ||||
msgid "" | ||||
"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject." | ||||
"tp_alloc` result against *NULL* before proceeding." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:341 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:342 | ||||
msgid "" | ||||
"We didn't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. " | ||||
"Rather :c:func:`PyType_Ready` fills it for us by inheriting it from our base " | ||||
| | @ -386,7 +386,7 @@ msgid "" | |||
"allocation strategy." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:347 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:348 | ||||
msgid "" | ||||
"If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one " | ||||
"that calls a base type's :c:member:`~PyTypeObject.tp_new` or :meth:" | ||||
| | @ -399,17 +399,17 @@ msgid "" | |||
"subclasses without getting a :exc:`TypeError`.)" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:357 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:358 | ||||
msgid "" | ||||
"We also define an initialization function which accepts arguments to provide " | ||||
"initial values for our instance::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:386 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:387 | ||||
msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:390 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:391 | ||||
msgid "" | ||||
"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:" | ||||
"`__init__` method. It is used to initialize an object after it's created. " | ||||
| | @ -417,7 +417,7 @@ msgid "" | |||
"return either ``0`` on success or ``-1`` on error." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:395 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:396 | ||||
msgid "" | ||||
"Unlike the ``tp_new`` handler, there is no guarantee that ``tp_init`` is " | ||||
"called at all (for example, the :mod:`pickle` module by default doesn't " | ||||
| | @ -428,7 +428,7 @@ msgid "" | |||
"``first`` member like this::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:409 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:410 | ||||
msgid "" | ||||
"But this would be risky. Our type doesn't restrict the type of the " | ||||
"``first`` member, so it could be any kind of object. It could have a " | ||||
| | @ -438,49 +438,49 @@ msgid "" | |||
"and modifies our object." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:416 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:417 | ||||
msgid "" | ||||
"To be paranoid and protect ourselves against this possibility, we almost " | ||||
"always reassign members before decrementing their reference counts. When " | ||||
"don't we have to do this?" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:420 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:421 | ||||
msgid "when we absolutely know that the reference count is greater than 1;" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:422 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:423 | ||||
msgid "" | ||||
"when we know that deallocation of the object [#]_ will neither release the :" | ||||
"term:`GIL` nor cause any calls back into our type's code;" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:425 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:426 | ||||
msgid "" | ||||
"when decrementing a reference count in a :c:member:`~PyTypeObject." | ||||
"tp_dealloc` handler on a type which doesn't support cyclic garbage " | ||||
"collection [#]_." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:428 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:429 | ||||
msgid "" | ||||
"We want to expose our instance variables as attributes. There are a number " | ||||
"of ways to do that. The simplest way is to define member definitions::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:441 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:442 | ||||
msgid "" | ||||
"and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:445 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:446 | ||||
msgid "" | ||||
"Each member definition has a member name, type, offset, access flags and " | ||||
"documentation string. See the :ref:`Generic-Attribute-Management` section " | ||||
"below for details." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:449 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:450 | ||||
msgid "" | ||||
"A disadvantage of this approach is that it doesn't provide a way to restrict " | ||||
"the types of objects that can be assigned to the Python attributes. We " | ||||
| | @ -491,13 +491,13 @@ msgid "" | |||
"deleted." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:456 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:457 | ||||
msgid "" | ||||
"We define a single method, :meth:`Custom.name()`, that outputs the objects " | ||||
"name as the concatenation of the first and last names. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:473 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:474 | ||||
msgid "" | ||||
"The method is implemented as a C function that takes a :class:`Custom` (or :" | ||||
"class:`Custom` subclass) instance as the first argument. Methods always " | ||||
| | @ -507,7 +507,7 @@ msgid "" | |||
"method is equivalent to the Python method:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:485 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:486 | ||||
msgid "" | ||||
"Note that we have to check for the possibility that our :attr:`first` and :" | ||||
"attr:`last` members are *NULL*. This is because they can be deleted, in " | ||||
| | @ -516,23 +516,23 @@ msgid "" | |||
"We'll see how to do that in the next section." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:491 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:492 | ||||
msgid "" | ||||
"Now that we've defined the method, we need to create an array of method " | ||||
"definitions::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:501 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:502 | ||||
msgid "" | ||||
"(note that we used the :const:`METH_NOARGS` flag to indicate that the method " | ||||
"is expecting no arguments other than *self*)" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:504 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:505 | ||||
msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:508 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:509 | ||||
msgid "" | ||||
"Finally, we'll make our type usable as a base class for subclassing. We've " | ||||
"written our methods carefully so far so that they don't make any assumptions " | ||||
| | @ -540,22 +540,22 @@ msgid "" | |||
"to add the :const:`Py_TPFLAGS_BASETYPE` to our class flag definition::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:515 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:516 | ||||
msgid "" | ||||
"We rename :c:func:`PyInit_custom` to :c:func:`PyInit_custom2`, update the " | ||||
"module name in the :c:type:`PyModuleDef` struct, and update the full class " | ||||
"name in the :c:type:`PyTypeObject` struct." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:519 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:520 | ||||
msgid "Finally, we update our :file:`setup.py` file to build the new module:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:532 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:533 | ||||
msgid "Providing finer control over data attributes" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:534 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:535 | ||||
msgid "" | ||||
"In this section, we'll provide finer control over how the :attr:`first` and :" | ||||
"attr:`last` attributes are set in the :class:`Custom` example. In the " | ||||
| | @ -564,14 +564,14 @@ msgid "" | |||
"make sure that these attributes always contain strings." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:543 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:544 | ||||
msgid "" | ||||
"To provide greater control, over the :attr:`first` and :attr:`last` " | ||||
"attributes, we'll use custom getter and setter functions. Here are the " | ||||
"functions for getting and setting the :attr:`first` attribute::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:574 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:575 | ||||
msgid "" | ||||
"The getter function is passed a :class:`Custom` object and a \"closure\", " | ||||
"which is a void pointer. In this case, the closure is ignored. (The " | ||||
| | @ -581,7 +581,7 @@ msgid "" | |||
"data in the closure.)" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:580 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:581 | ||||
msgid "" | ||||
"The setter function is passed the :class:`Custom` object, the new value, and " | ||||
"the closure. The new value may be *NULL*, in which case the attribute is " | ||||
| | @ -589,32 +589,32 @@ msgid "" | |||
"or if its new value is not a string." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:585 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:586 | ||||
msgid "We create an array of :c:type:`PyGetSetDef` structures::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:595 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:596 | ||||
msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:599 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:600 | ||||
msgid "" | ||||
"The last item in a :c:type:`PyGetSetDef` structure is the \"closure\" " | ||||
"mentioned above. In this case, we aren't using a closure, so we just pass " | ||||
"*NULL*." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:602 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:603 | ||||
msgid "We also remove the member definitions for these attributes::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:610 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:611 | ||||
msgid "" | ||||
"We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " | ||||
"allow strings [#]_ to be passed::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:639 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:640 | ||||
msgid "" | ||||
"With these changes, we can assure that the ``first`` and ``last`` members " | ||||
"are never *NULL* so we can remove checks for *NULL* values in almost all " | ||||
| | @ -624,25 +624,25 @@ msgid "" | |||
"possibility that the initialization of these members failed in ``tp_new``." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:646 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:647 | ||||
msgid "" | ||||
"We also rename the module initialization function and module name in the " | ||||
"initialization function, as we did before, and we add an extra definition to " | ||||
"the :file:`setup.py` file." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:652 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:653 | ||||
msgid "Supporting cyclic garbage collection" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:654 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:655 | ||||
msgid "" | ||||
"Python has a :term:`cyclic garbage collector (GC) <garbage collection>` that " | ||||
"can identify unneeded objects even when their reference counts are not zero. " | ||||
"This can happen when objects are involved in cycles. For example, consider:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:664 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:665 | ||||
msgid "" | ||||
"In this example, we create a list that contains itself. When we delete it, " | ||||
"it still has a reference from itself. Its reference count doesn't drop to " | ||||
| | @ -650,7 +650,7 @@ msgid "" | |||
"out that the list is garbage and free it." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:669 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:670 | ||||
msgid "" | ||||
"In the second version of the :class:`Custom` example, we allowed any kind of " | ||||
"object to be stored in the :attr:`first` or :attr:`last` attributes [#]_. " | ||||
| | @ -659,7 +659,7 @@ msgid "" | |||
"reasons, :class:`Custom` objects can participate in cycles:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:683 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:684 | ||||
msgid "" | ||||
"To allow a :class:`Custom` instance participating in a reference cycle to be " | ||||
"properly detected and collected by the cyclic GC, our :class:`Custom` type " | ||||
| | @ -667,13 +667,13 @@ msgid "" | |||
"slots:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:690 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:691 | ||||
msgid "" | ||||
"First, the traversal method lets the cyclic GC know about subobjects that " | ||||
"could participate in cycles::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:710 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:711 | ||||
msgid "" | ||||
"For each subobject that can participate in cycles, we need to call the :c:" | ||||
"func:`visit` function, which is passed to the traversal method. The :c:func:" | ||||
| | @ -682,26 +682,26 @@ msgid "" | |||
"be returned if it is non-zero." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:716 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:717 | ||||
msgid "" | ||||
"Python provides a :c:func:`Py_VISIT` macro that automates calling visit " | ||||
"functions. With :c:func:`Py_VISIT`, we can minimize the amount of " | ||||
"boilerplate in ``Custom_traverse``::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:729 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:730 | ||||
msgid "" | ||||
"The :c:member:`~PyTypeObject.tp_traverse` implementation must name its " | ||||
"arguments exactly *visit* and *arg* in order to use :c:func:`Py_VISIT`." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:732 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:733 | ||||
msgid "" | ||||
"Second, we need to provide a method for clearing any subobjects that can " | ||||
"participate in cycles::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:743 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:744 | ||||
msgid "" | ||||
"Notice the use of the :c:func:`Py_CLEAR` macro. It is the recommended and " | ||||
"safe way to clear data attributes of arbitrary types while decrementing " | ||||
| | @ -711,18 +711,18 @@ msgid "" | |||
"again (*especially* if there is a reference cycle)." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:751 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:752 | ||||
msgid "You could emulate :c:func:`Py_CLEAR` by writing::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:758 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:759 | ||||
msgid "" | ||||
"Nevertheless, it is much easier and less error-prone to always use :c:func:" | ||||
"`Py_CLEAR` when deleting an attribute. Don't try to micro-optimize at the " | ||||
"expense of robustness!" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:762 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:763 | ||||
msgid "" | ||||
"The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " | ||||
"attributes. It means the circular GC can be triggered inside the function. " | ||||
| | @ -732,12 +732,12 @@ msgid "" | |||
"`PyObject_GC_UnTrack` and ``Custom_clear``::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:777 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:778 | ||||
msgid "" | ||||
"Finally, we add the :const:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:781 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:782 | ||||
msgid "" | ||||
"That's pretty much it. If we had written custom :c:member:`~PyTypeObject." | ||||
"tp_alloc` or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify " | ||||
| | @ -745,11 +745,11 @@ msgid "" | |||
"automatically provided." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:787 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:788 | ||||
msgid "Subclassing other types" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:789 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:790 | ||||
msgid "" | ||||
"It is possible to create new extension types that are derived from existing " | ||||
"types. It is easiest to inherit from the built in types, since an extension " | ||||
| | @ -757,7 +757,7 @@ msgid "" | |||
"share these :c:type:`PyTypeObject` structures between extension modules." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:794 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:795 | ||||
msgid "" | ||||
"In this example we will create a :class:`SubList` type that inherits from " | ||||
"the built-in :class:`list` type. The new type will be completely compatible " | ||||
| | @ -765,34 +765,34 @@ msgid "" | |||
"that increases an internal counter:" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:814 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:815 | ||||
msgid "" | ||||
"As you can see, the source code closely resembles the :class:`Custom` " | ||||
"examples in previous sections. We will break down the main differences " | ||||
"between them. ::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:822 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:823 | ||||
msgid "" | ||||
"The primary difference for derived type objects is that the base type's " | ||||
"object structure must be the first value. The base type will already " | ||||
"include the :c:func:`PyObject_HEAD` at the beginning of its structure." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:826 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:827 | ||||
msgid "" | ||||
"When a Python object is a :class:`SubList` instance, its ``PyObject *`` " | ||||
"pointer can be safely cast to both ``PyListObject *`` and ``SubListObject " | ||||
"*``::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:838 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:839 | ||||
msgid "" | ||||
"We see above how to call through to the :attr:`__init__` method of the base " | ||||
"type." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:841 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:842 | ||||
msgid "" | ||||
"This pattern is important when writing a type with custom :c:member:" | ||||
"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " | ||||
| | @ -801,7 +801,7 @@ msgid "" | |||
"the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:847 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:848 | ||||
msgid "" | ||||
"The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." | ||||
"tp_base` specifying the type's concrete base class. Due to cross-platform " | ||||
| | @ -810,7 +810,7 @@ msgid "" | |||
"function::" | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:870 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:871 | ||||
msgid "" | ||||
"Before calling :c:func:`PyType_Ready`, the type structure must have the :c:" | ||||
"member:`~PyTypeObject.tp_base` slot filled in. When we are deriving an " | ||||
| | @ -819,29 +819,29 @@ msgid "" | |||
"from the base type will be inherited." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:876 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:877 | ||||
msgid "" | ||||
"After that, calling :c:func:`PyType_Ready` and adding the type object to the " | ||||
"module is the same as with the basic :class:`Custom` examples." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:881 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:882 | ||||
msgid "Footnotes" | ||||
msgstr "Notes" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:882 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:883 | ||||
msgid "" | ||||
"This is true when we know that the object is a basic type, like a string or " | ||||
"a float." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:885 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:886 | ||||
msgid "" | ||||
"We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " | ||||
"this example, because our type doesn't support garbage collection." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:888 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:889 | ||||
msgid "" | ||||
"We now know that the first and last members are strings, so perhaps we could " | ||||
"be less careful about decrementing their reference counts, however, we " | ||||
| | @ -851,7 +851,7 @@ msgid "" | |||
"objects." | ||||
msgstr "" | ||||
| ||||
#: ../Doc/extending/newtypes_tutorial.rst:894 | ||||
#: ../Doc/extending/newtypes_tutorial.rst:895 | ||||
msgid "" | ||||
"Also, even with our attributes restricted to strings instances, the user " | ||||
"could pass arbitrary :class:`str` subclasses and therefore still create " | ||||
| | | |||
Loading…
Add table
Add a link
Reference in a new issue