66# Translators:
77# tomo, 2021
88# Arihiro TAKASE, 2023
9+ # QQ, 2024
910#
1011#, fuzzy
1112msgid ""
1213msgstr ""
1314"Project-Id-Version : Python 3.13\n "
1415"Report-Msgid-Bugs-To : \n "
15- "POT-Creation-Date : 2024-06-20 06:40 +0000\n "
16+ "POT-Creation-Date : 2024-06-28 14:15 +0000\n "
1617"PO-Revision-Date : 2021-06-28 00:52+0000\n "
17- "Last-Translator : Arihiro TAKASE, 2023 \n "
18+ "Last-Translator : QQ, 2024 \n "
1819"Language-Team : Japanese (https://app.transifex.com/python-doc/teams/5390/ "
1920"ja/)\n "
2021"MIME-Version : 1.0\n "
@@ -56,6 +57,14 @@ msgid ""
5657"an object, a method called, or it is multiplied by another object. These C "
5758"functions are called \" type methods\" ."
5859msgstr ""
60+ ":term:`CPython` ランタイムは Python の全てのオブジェクトを、 Python の全ての"
61+ "オブジェクトの \" 基底型 (base type)\" である :c:expr:`PyObject*` 型の変数と見"
62+ "なします。 :c:type:`PyObject` 構造体自身は :term:`参照カウント <reference "
63+ "count>` と、オブジェクトの \" 型オブジェクト\" へのポインタのみを持ちます。こ"
64+ "こには動作が定義されています; 型オブジェクトは、例えば、ある属性があるオブ"
65+ "ジェクトから検索されたり、メソッドが呼ばれたり、他のオブジェクトによって操作"
66+ "されたりしたときに、どの (C) 関数がインタープリターから呼ばれるのかを決定しま"
67+ "す。これらの C 関数は \" 型メソッド (type method)\" と呼ばれます。"
5968
6069#: ../../extending/newtypes_tutorial.rst:35
6170msgid ""
@@ -71,6 +80,9 @@ msgid ""
7180"but complete, module that defines a new type named :class:`!Custom` inside a "
7281"C extension module :mod:`!custom`:"
7382msgstr ""
83+ "この手のことは例を見たほうが早いでしょうから、以下に C 拡張モジュール :mod:`!"
84+ "custom` にある :class:`!Custom` という名前の新しい型を定義する、最小限ながら"
85+ "完全なモジュールをあげておきます:"
7486
7587#: ../../extending/newtypes_tutorial.rst:43
7688msgid ""
@@ -97,19 +109,27 @@ msgid ""
97109"What a :class:`!Custom` **object** contains: this is the ``CustomObject`` "
98110"struct, which is allocated once for each :class:`!Custom` instance."
99111msgstr ""
112+ ":class:`!Custom` **オブジェクト** が何を含んでいるか: これが "
113+ "``CustomObject`` 構造体で、 :class:`!Custom` インスタンスごとに1回だけメモリ"
114+ "確保が行われます。"
100115
101116#: ../../extending/newtypes_tutorial.rst:55
102117msgid ""
103118"How the :class:`!Custom` **type** behaves: this is the ``CustomType`` "
104119"struct, which defines a set of flags and function pointers that the "
105120"interpreter inspects when specific operations are requested."
106121msgstr ""
122+ ":class:`!Custom` **型** がどのように振る舞うか: これが ``CustomType`` 構造体"
123+ "で、フラグと関数ポインタの集まりを定義しています。特定の操作が要求されたとき"
124+ "に、この関数ポインタをインタープリターが見に行きます。"
107125
108126#: ../../extending/newtypes_tutorial.rst:58
109127msgid ""
110128"How to initialize the :mod:`!custom` module: this is the ``PyInit_custom`` "
111129"function and the associated ``custommodule`` struct."
112130msgstr ""
131+ ":mod:`!custom` モジュールをどう初期化するか: これが ``PyInit_custom`` 関数と"
132+ "それに関係する ``custommodule`` 構造体です。"
113133
114134#: ../../extending/newtypes_tutorial.rst:61
115135msgid "The first bit is::"
@@ -125,6 +145,13 @@ msgid ""
125145"abstract away the layout and to enable additional fields in :ref:`debug "
126146"builds <debug-build>`."
127147msgstr ""
148+ "これが Custom オブジェクトの内容です。 ``PyObject_HEAD`` はそれぞれのオブジェ"
149+ "クト構造体の先頭に必須なもので、 :c:type:`PyObject` 型の ``ob_base`` という名"
150+ "前のフィールドを定義します。 :c:type:`PyObject` 型には (それぞれ :c:macro:"
151+ "`Py_TYPE` マクロおよび :c:macro:`Py_REFCNT` マクロからアクセスできる) 型オブ"
152+ "ジェクトへのポインタと参照カウントが格納されています。このマクロが用意されて"
153+ "いる理由は、構造体のレイアウトを抽象化し、デバッグビルドでフィールドを追加で"
154+ "きるようにするためです。"
128155
129156#: ../../extending/newtypes_tutorial.rst:76
130157msgid ""
@@ -200,13 +227,22 @@ msgid ""
200227"`!custom.Custom`. Using the real dotted import path is important to make "
201228"your type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::"
202229msgstr ""
230+ "型の名前が、モジュール名とモジュールにおける型の名前の両方をドットでつないだ"
231+ "名前になっていることに注意してください。この場合は、モジュールは :mod:`!"
232+ "custom` で型は :class:`!Custom` なので、型の名前を :class:`!custom.Custom` に"
233+ "設定しました。実際のドット付きのインポートパスを使うのは、 :mod:`pydoc` モ"
234+ "ジュールや :mod:`pickle` モジュールと互換性を持たせるために重要なのです。"
203235
204236#: ../../extending/newtypes_tutorial.rst:138
205237msgid ""
206238"This is so that Python knows how much memory to allocate when creating new :"
207239"class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is only "
208240"used for variable-sized objects and should otherwise be zero."
209241msgstr ""
242+ "これは、新しい :class:`!Custom` インスタンスを作るときに Python が割り当てる"
243+ "べきメモリがどのくらいなのかを知るためのものです。 :c:member:`~PyTypeObject."
244+ "tp_itemsize` は可変サイズのオブジェクトでのみ使うものなので、サイズが可変でな"
245+ "いオブジェクトでは 0 にすべきです。"
210246
211247#: ../../extending/newtypes_tutorial.rst:144
212248msgid ""
@@ -221,10 +257,19 @@ msgid ""
221257"type will be :class:`object`, or else you will be adding data members to "
222258"your base type, and therefore increasing its size."
223259msgstr ""
260+ "型を Python でサブクラス化可能にしたい場合、その型が基底の型と同じ :c:member:"
261+ "`~PyTypeObject.tp_basicsize` をもっていると、多重継承のときに問題が生じること"
262+ "があります。その型の Python サブクラスは、 :attr:`~class.__bases__` リストの"
263+ "最初に型がくるようにしなければなりません。さもないと、エラーの発生なしに、型"
264+ "の :meth:`~object.__new__` メソッドを呼び出すことができなくなります。つねに型"
265+ "の :c:member:`~PyTypeObject.tp_basicsize` をその基底型よりも大きくしておくこ"
266+ "とで、この問題を回避することができます。ほとんどの場合、型は :class:`object` "
267+ "か、そうでなければ基底タイプにデータ用のメンバを追加したものでしょうから、大"
268+ "きさはつねに増加するためこの条件は満たされています。"
224269
225270#: ../../extending/newtypes_tutorial.rst:154
226271msgid "We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::"
227- msgstr ""
272+ msgstr ":c:macro:`Py_TPFLAGS_DEFAULT` にクラスフラグを設定します。 :: "
228273
229274#: ../../extending/newtypes_tutorial.rst:158
230275msgid ""
@@ -249,46 +294,65 @@ msgid ""
249294"the default implementation provided by the API function :c:func:"
250295"`PyType_GenericNew`. ::"
251296msgstr ""
297+ "オブジェクトが生成できるように、 :c:member:`~PyTypeObject.tp_new` ハンドラを"
298+ "提供する必要があります。これは Python のメソッド :meth:`~object.__new__` と同"
299+ "等のものですが、明示的に与える必要があります。今の場合では、 API 関数の :c:"
300+ "func:`PyType_GenericNew` として提供されるデフォルトの実装をそのまま使えま"
301+ "す。 ::"
252302
253303#: ../../extending/newtypes_tutorial.rst:173
254304msgid ""
255305"Everything else in the file should be familiar, except for some code in :c:"
256306"func:`!PyInit_custom`::"
257307msgstr ""
308+ "ファイルの残りの部分はきっと馴染みやすいものだと思いますが、 :c:func:`!"
309+ "PyInit_custom` の一部のコードはそうではないでしょう::"
258310
259311#: ../../extending/newtypes_tutorial.rst:179
260312msgid ""
261313"This initializes the :class:`!Custom` type, filling in a number of members "
262314"to the appropriate default values, including :c:member:`~PyObject.ob_type` "
263315"that we initially set to ``NULL``. ::"
264316msgstr ""
317+ "これは、 ``NULL`` に初期化された :c:member:`~PyObject.ob_type` も含めて、いく"
318+ "つかのメンバーを適切なデフォルト値で埋めて、 :class:`!Custom` 型を初期化しま"
319+ "す。 ::"
265320
266321#: ../../extending/newtypes_tutorial.rst:188
267322msgid ""
268323"This adds the type to the module dictionary. This allows us to create :"
269324"class:`!Custom` instances by calling the :class:`!Custom` class:"
270325msgstr ""
326+ "これは型をモジュールの辞書に追加します。こうすることで :class:`!Custom` クラ"
327+ "スの呼び出しで :class:`!Custom` インスタンスが作成できるようになります:"
271328
272329#: ../../extending/newtypes_tutorial.rst:196
273330msgid ""
274331"That's it! All that remains is to build it; put the above code in a file "
275332"called :file:`custom.c`,"
276333msgstr ""
334+ "以上です!残りの作業はビルドだけです; :file:`custom.c` という名前のファイルに"
335+ "ここまでのコードを書き込み、"
277336
278337#: ../../extending/newtypes_tutorial.rst:201
279338msgid "in a file called :file:`pyproject.toml`, and"
280- msgstr ""
339+ msgstr ":file:`pyproject.toml` というファイルにこれを書き込み、 "
281340
282341#: ../../extending/newtypes_tutorial.rst:208
283342msgid "in a file called :file:`setup.py`; then typing"
284- msgstr "そして、シェルから以下のように入力します"
343+ msgstr ""
344+ "そして :file:`setup.py` というファイルにこのように書き込み、そして、以下のよ"
345+ "うに"
285346
286347#: ../../extending/newtypes_tutorial.rst:214
287348msgid ""
288349"in a shell should produce a file :file:`custom.so` in a subdirectory and "
289350"install it; now fire up Python --- you should be able to ``import custom`` "
290351"and play around with ``Custom`` objects."
291352msgstr ""
353+ "シェルに入力します。これにより、サブディレクトリに :file:`custom.so` が生成さ"
354+ "れ、インストールされます。これで、 Python を立ち上げて、 ``import custom`` す"
355+ "ると ``Custom`` オブジェクトで遊べるようになっているはずです。"
292356
293357#: ../../extending/newtypes_tutorial.rst:218
294358msgid "That wasn't so hard, was it?"
@@ -312,10 +376,13 @@ msgid ""
312376"make the type usable as a base class. We'll create a new module, :mod:`!"
313377"custom2` that adds these capabilities:"
314378msgstr ""
379+ "この基本のサンプルにデータとメソッドを追加してみましょう。ついでに、この型を"
380+ "基底クラスとしても利用できるようにします。ここでは新しいモジュール :mod:`!"
381+ "custom2` をつくり、これらの機能を追加します:"
315382
316383#: ../../extending/newtypes_tutorial.rst:234
317384msgid "This version of the module has a number of changes."
318- msgstr "このバージョンでは 、いくつもの変更をおこないます。"
385+ msgstr "モジュールのこのバージョンでは 、いくつもの変更をおこないます。"
319386
320387#: ../../extending/newtypes_tutorial.rst:236
321388msgid ""
@@ -324,6 +391,10 @@ msgid ""
324391"strings containing first and last names. The *number* attribute is a C "
325392"integer."
326393msgstr ""
394+ ":class:`!Custom` 型は そのC構造体に 3つのデータ属性 *first* 、 *last* 、およ"
395+ "び *number* をもつようになりました。 *first* と *last* 属性はファーストネーム"
396+ "とラストネームを格納した Python 文字列で、 *number* 属性は C言語での整数の値"
397+ "です。"
327398
328399#: ../../extending/newtypes_tutorial.rst:240
329400msgid "The object structure is updated accordingly::"
@@ -352,6 +423,13 @@ msgid ""
352423"object's type might not be :class:`!CustomType`, because the object may be "
353424"an instance of a subclass."
354425msgstr ""
426+ "このメソッドは、まず二つのPython 属性の参照カウントをクリアします。 :c:func:"
427+ "`Py_XDECREF` は引数が ``NULL`` のケースを正しく扱えます (これは、``tp_new`` "
428+ "が途中で失敗した場合に起こりえます) 。このメソッドは、つぎにオブジェクトの型 "
429+ "(``Py_TYPE(self)`` で算出します) のメンバ :c:member:`~PyTypeObject.tp_free` "
430+ "を呼び出し、オブジェクトのメモリを開放します。オブジェクトの型が :class:`!"
431+ "CustomType` であるとは限らない点に注意してください。なぜなら、オブジェクトは"
432+ "サブクラスのインスタンスかもしれないからです。"
355433
356434#: ../../extending/newtypes_tutorial.rst:273
357435msgid ""
@@ -365,7 +443,7 @@ msgstr ""
365443"``Custom_dealloc`` が ``CustomObject *`` 引数をとると定義しましたが、 "
366444"``tp_dealloc`` 関数のポインタは ``PyObject *`` 引数を受け取ることになっている"
367445"からです。もし明示的に型変換をしなければ、コンパイラが警告を発するでしょう。"
368- "これは、Cにおけるオブジェクト指向のポリモーフィズムです !"
446+ "これは、 C におけるオブジェクト指向のポリモーフィズムです !"
369447
370448#: ../../extending/newtypes_tutorial.rst:279
371449msgid ""
@@ -423,6 +501,9 @@ msgid ""
423501"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject."
424502"tp_alloc` result against ``NULL`` before proceeding."
425503msgstr ""
504+ "メモリ割り当ては失敗するかもしれないので、先に進む前に :c:member:"
505+ "`~PyTypeObject.tp_alloc` の結果が ``NULL`` でないかチェックしなければなりませ"
506+ "ん。"
426507
427508#: ../../extending/newtypes_tutorial.rst:335
428509msgid ""
@@ -444,6 +525,15 @@ msgid ""
444525"correctly. (Specifically, you may not be able to create instances of such "
445526"subclasses without getting a :exc:`TypeError`.)"
446527msgstr ""
528+ "もし協力的な :c:member:`~PyTypeObject.tp_new` (基底タイプの :c:member:"
529+ "`~PyTypeObject.tp_new` または :meth:`~object.__new__` を呼んでいるもの) を作"
530+ "りたいのならば、実行時のメソッド解決順序をつかってどのメソッドを呼びだすかを"
531+ "決定しようとしては *いけません* 。常に呼び出す型を静的に決めておき、直接そ"
532+ "の :c:member:`~PyTypeObject.tp_new` を呼び出すか、あるいは ``type->tp_base-"
533+ ">tp_new`` を経由してください。こうしないと、あなたが作成したタイプの Python "
534+ "サブクラスが他の Python で定義されたクラスも継承している場合にうまく動かない"
535+ "場合があります。 (とりわけ、そのようなサブクラスのインスタンスを :exc:"
536+ "`TypeError` を出さずに作ることが不可能になります。)"
447537
448538#: ../../extending/newtypes_tutorial.rst:351
449539msgid ""
0 commit comments